1
0
Fork 0

Misc api changes and tweaks.

This commit is contained in:
curt 1998-01-10 00:01:47 +00:00
parent ada64cecce
commit 3cead5c91d
2 changed files with 33 additions and 23 deletions

View file

@ -44,7 +44,7 @@
3 bits - to represent x (0 to 7) 3 bits - to represent x (0 to 7)
3 bits - to represent y (0 to 7) */ 3 bits - to represent y (0 to 7) */
static long gen_index(struct bucket *p) { long int gen_index(struct bucket *p) {
long index = 0; long index = 0;
index = ((p->lon + 180) << 14) + ((p->lat + 90) << 6) + (p->y << 3) + p->x; index = ((p->lon + 180) << 14) + ((p->lat + 90) << 6) + (p->y << 3) + p->x;
@ -55,7 +55,7 @@ static long gen_index(struct bucket *p) {
/* Parse a unique scenery tile index and find the lon, lat, x, and y */ /* Parse a unique scenery tile index and find the lon, lat, x, and y */
static void parse_index(long int index, struct bucket *p) { void parse_index(long int index, struct bucket *p) {
p->lon = index >> 14; p->lon = index >> 14;
index -= p->lon << 14; index -= p->lon << 14;
p->lon -= 180; p->lon -= 180;
@ -72,20 +72,19 @@ static void parse_index(long int index, struct bucket *p) {
/* Build a path name from an tile index */ /* Build a path name from an tile index */
void gen_path(long int index, char *path) { void gen_base_path(struct bucket *p, char *path) {
struct bucket p; long int index;
int top_lon, top_lat, main_lon, main_lat; int top_lon, top_lat, main_lon, main_lat;
char hem, pole; char hem, pole;
parse_index(index, &p); index = gen_index(p);
path[0] = '\0'; path[0] = '\0';
top_lon = p.lon / 10; top_lon = p->lon / 10;
main_lon = p.lon; main_lon = p->lon;
if ( (p.lon < 0) && (top_lon * 10 != p.lon) ) { if ( (p->lon < 0) && (top_lon * 10 != p->lon) ) {
top_lon -= 1; top_lon -= 1;
main_lon -= 1;
} }
top_lon *= 10; top_lon *= 10;
if ( top_lon >= 0 ) { if ( top_lon >= 0 ) {
@ -98,11 +97,10 @@ void gen_path(long int index, char *path) {
main_lon *= -1; main_lon *= -1;
} }
top_lat = p.lat / 10; top_lat = p->lat / 10;
main_lat = p.lat; main_lat = p->lat;
if ( (p.lat < 0) && (top_lat * 10 != p.lat) ) { if ( (p->lat < 0) && (top_lat * 10 != p->lat) ) {
top_lat -= 1; top_lat -= 1;
main_lat -= 1;
} }
top_lat *= 10; top_lat *= 10;
if ( top_lat >= 0 ) { if ( top_lat >= 0 ) {
@ -115,10 +113,9 @@ void gen_path(long int index, char *path) {
main_lat *= -1; main_lat *= -1;
} }
sprintf(path, "%c%03d%c%03d/%c%03d%c%03d/%ld.ter", sprintf(path, "%c%03d%c%03d/%c%03d%c%03d",
hem, top_lon, pole, top_lat, hem, top_lon, pole, top_lat,
hem, main_lon, pole, main_lat, hem, main_lon, pole, main_lat);
index);
} }
@ -268,9 +265,12 @@ int main() {
/* $Log$ /* $Log$
/* Revision 1.2 1998/01/08 02:22:28 curt /* Revision 1.3 1998/01/10 00:01:47 curt
/* Continue working on basic features. /* Misc api changes and tweaks.
/* /*
* Revision 1.2 1998/01/08 02:22:28 curt
* Continue working on basic features.
*
* Revision 1.1 1998/01/07 23:50:52 curt * Revision 1.1 1998/01/07 23:50:52 curt
* "area" renamed to "tile" * "area" renamed to "tile"
* *

View file

@ -24,6 +24,10 @@
**************************************************************************/ **************************************************************************/
#ifndef TILEUTILS_H
#define TILEUTILS_H
struct bucket { struct bucket {
int lon; /* longitude (-180 to 179) */ int lon; /* longitude (-180 to 179) */
int lat; /* latitude (-90 to 89) */ int lat; /* latitude (-90 to 89) */
@ -45,15 +49,15 @@ struct bucket {
3 bits - to represent x (0 to 7) 3 bits - to represent x (0 to 7)
3 bits - to represent y (0 to 7) */ 3 bits - to represent y (0 to 7) */
/* static long gen_index(struct bucket *p); */ long int gen_index(struct bucket *p);
/* Parse a unique scenery tile index and find the lon, lat, x, and y */ /* Parse a unique scenery tile index and find the lon, lat, x, and y */
/* static void parse_index(long int index, struct bucket *p); */ void parse_index(long int index, struct bucket *p);
/* Build a path name from an tile index */ /* Build a path name from an tile index */
void gen_path(long int index, char *path); void gen_base_path(struct bucket *p, char *path);
/* offset an bucket struct by the specified amounts in the X & Y direction */ /* offset an bucket struct by the specified amounts in the X & Y direction */
@ -69,10 +73,16 @@ void gen_idx_array(struct bucket *p1, long int *tiles,
int width, int height); int width, int height);
#endif /* TILEUTILS_H */
/* $Log$ /* $Log$
/* Revision 1.2 1998/01/08 02:22:28 curt /* Revision 1.3 1998/01/10 00:01:48 curt
/* Continue working on basic features. /* Misc api changes and tweaks.
/* /*
* Revision 1.2 1998/01/08 02:22:28 curt
* Continue working on basic features.
*
* Revision 1.1 1998/01/07 23:50:52 curt * Revision 1.1 1998/01/07 23:50:52 curt
* "area" renamed to "tile" * "area" renamed to "tile"
* *