1
0
Fork 0

Use C++ style comments.

This commit is contained in:
curt 1998-12-09 18:48:08 +00:00
parent b3eacb19f6
commit 99f11a01fc
2 changed files with 174 additions and 173 deletions

View file

@ -1,27 +1,25 @@
/************************************************************************** // bucketutils.c -- support routines to handle fgBUCKET operations
* bucketutils.c -- support routines to handle fgBUCKET operations //
* // Written by Curtis Olson, started January 1998.
* Written by Curtis Olson, started January 1998. //
* // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com //
* // This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as
* modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the
* published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version.
* License, or (at your option) any later version. //
* // This program is distributed in the hope that it will be useful, but
* This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of
* WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details.
* General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
* // $Id$
* $Id$ // (Log is kept at end of this file)
* (Log is kept at end of this file)
**************************************************************************/
#include <math.h> #include <math.h>
@ -49,13 +47,13 @@ long int fgBucketGenIndex( const fgBUCKET *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;
/* printf(" generated index = %ld\n", index); */ // printf(" generated index = %ld\n", index);
return(index); return(index);
} }
/* 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
void fgBucketParseIndex(long int index, fgBUCKET *p) { void fgBucketParseIndex(long int index, fgBUCKET *p) {
p->lon = index >> 14; p->lon = index >> 14;
index -= p->lon << 14; index -= p->lon << 14;
@ -72,7 +70,7 @@ void fgBucketParseIndex(long int index, fgBUCKET *p) {
} }
/* Build a path name from an tile index */ // Build a path name from an tile index
void fgBucketGenBasePath( const fgBUCKET *p, char *path) { void fgBucketGenBasePath( const fgBUCKET *p, char *path) {
long int index; long int index;
int top_lon, top_lat, main_lon, main_lat; int top_lon, top_lat, main_lon, main_lat;
@ -120,7 +118,7 @@ void fgBucketGenBasePath( const fgBUCKET *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
void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) { void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) {
int diff, temp; int diff, temp;
int dist_lat; int dist_lat;
@ -130,9 +128,9 @@ void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) {
out->x = in->x; out->x = in->x;
out->y = in->y; out->y = in->y;
/* do X direction */ // do X direction
diff = out->x + x; diff = out->x + x;
/* printf(" reducing x (%d)\n", diff); */ // printf(" reducing x (%d)\n", diff);
if ( diff >= 0 ) { if ( diff >= 0 ) {
temp = diff / 8; temp = diff / 8;
} else if ( diff < -7 ) { } else if ( diff < -7 ) {
@ -143,9 +141,9 @@ void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) {
out->x = ((diff % 8) + 8) % 8; out->x = ((diff % 8) + 8) % 8;
out->lon = ( (out->lon + 180 + 360 + temp) % 360 ) - 180; out->lon = ( (out->lon + 180 + 360 + temp) % 360 ) - 180;
/* do Y direction */ // do Y direction
diff = out->y + y; diff = out->y + y;
/* printf(" reducing x (%d)\n", diff); */ // printf(" reducing x (%d)\n", diff);
if ( diff >= 0 ) { if ( diff >= 0 ) {
temp = diff / 8; temp = diff / 8;
} else if ( diff < -7 ) { } else if ( diff < -7 ) {
@ -158,7 +156,7 @@ void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) {
if ( out->lat >= 90 ) { if ( out->lat >= 90 ) {
dist_lat = out->lat - 90; dist_lat = out->lat - 90;
/* printf(" +lat = %d +y = %d\n", dist_lat, out->y); */ // printf(" +lat = %d +y = %d\n", dist_lat, out->y);
out->lat = 90 - (dist_lat + 1); out->lat = 90 - (dist_lat + 1);
out->lon = ( (out->lon + 180 + 180) % 360 ) - 180; out->lon = ( (out->lon + 180 + 180) % 360 ) - 180;
@ -167,7 +165,7 @@ void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) {
if ( out->lat < -90 ) { if ( out->lat < -90 ) {
dist_lat = -90 - out->lat; dist_lat = -90 - out->lat;
/* printf(" +lat = %d +y = %d\n", dist_lat, out->y); */ // printf(" +lat = %d +y = %d\n", dist_lat, out->y);
out->lat = -90 + (dist_lat - 1); out->lat = -90 + (dist_lat - 1);
out->lon = ( (out->lon + 180 + 180) % 360 ) - 180; out->lon = ( (out->lon + 180 + 180) % 360 ) - 180;
@ -176,37 +174,37 @@ void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y) {
} }
/* Given a lat/lon in degrees, find the "bucket" or tile that it falls // Given a lat/lon in degrees, find the "bucket" or tile that it falls
within */ // within
void fgBucketFind(double lon, double lat, fgBUCKET *p) { void fgBucketFind(double lon, double lat, fgBUCKET *p) {
double diff; double diff;
diff = lon - (double)(int)lon; diff = lon - (double)(int)lon;
/* printf("diff = %.2f\n", diff); */ // printf("diff = %.2f\n", diff);
if ( (lon >= 0) || (fabs(diff) < FG_EPSILON) ) { if ( (lon >= 0) || (fabs(diff) < FG_EPSILON) ) {
p->lon = (int)lon; p->lon = (int)lon;
} else { } else {
p->lon = (int)lon - 1; p->lon = (int)lon - 1;
} }
/* printf(" p->lon = %d\n", p->lon); */ // printf(" p->lon = %d\n", p->lon);
diff = lat - (double)(int)lat; diff = lat - (double)(int)lat;
/* printf("diff = %.2f\n", diff); */ // printf("diff = %.2f\n", diff);
if ( (lat >= 0) || (fabs(diff) < FG_EPSILON) ) { if ( (lat >= 0) || (fabs(diff) < FG_EPSILON) ) {
p->lat = (int)lat; p->lat = (int)lat;
} else { } else {
p->lat = (int)lat - 1; p->lat = (int)lat - 1;
} }
/* printf(" p->lat = %d\n", p->lat); */ // printf(" p->lat = %d\n", p->lat);
p->x = (int)((lon - p->lon) * 8); p->x = (int)((lon - p->lon) * 8);
p->y = (int)((lat - p->lat) * 8); p->y = (int)((lat - p->lat) * 8);
/* printf( "Bucket = lon,lat = %d,%d x,y index = %d,%d\n", // printf( "Bucket = lon,lat = %d,%d x,y index = %d,%d\n",
p->lon, p->lat, p->x, p->y); */ // p->lon, p->lat, p->x, p->y);
} }
/* Given a lat/lon, fill in the local tile index array */ // Given a lat/lon, fill in the local tile index array
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height) { void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height) {
fgBUCKET *p2; fgBUCKET *p2;
int dw, dh, i, j; int dw, dh, i, j;
@ -266,61 +264,63 @@ int main() {
} */ } */
/* $Log$ // $Log$
/* Revision 1.4 1998/12/07 21:08:01 curt // Revision 1.5 1998/12/09 18:48:08 curt
/* Added a const in a couple places to get rid of annoying compiler warnings. // Use C++ style comments.
/* //
* Revision 1.3 1998/07/04 00:46:47 curt // Revision 1.4 1998/12/07 21:08:01 curt
* typedef'd struct fgBUCKET. // Added a const in a couple places to get rid of annoying compiler warnings.
* //
* Revision 1.2 1998/04/25 22:06:22 curt // Revision 1.3 1998/07/04 00:46:47 curt
* Edited cvs log messages in source files ... bad bad bad! // typedef'd struct fgBUCKET.
* //
* Revision 1.1 1998/04/08 23:28:58 curt // Revision 1.2 1998/04/25 22:06:22 curt
* Adopted Gnu automake/autoconf system. // Edited cvs log messages in source files ... bad bad bad!
* //
* Revision 1.6 1998/02/09 15:07:51 curt // Revision 1.1 1998/04/08 23:28:58 curt
* Minor tweaks. // Adopted Gnu automake/autoconf system.
* //
* Revision 1.5 1998/01/29 00:51:38 curt // Revision 1.6 1998/02/09 15:07:51 curt
* First pass at tile cache, dynamic tile loading and tile unloading now works. // Minor tweaks.
* //
* Revision 1.4 1998/01/27 03:26:41 curt // Revision 1.5 1998/01/29 00:51:38 curt
* Playing with new fgPrintf command. // First pass at tile cache, dynamic tile loading and tile unloading now works.
* //
* Revision 1.3 1998/01/27 00:48:01 curt // Revision 1.4 1998/01/27 03:26:41 curt
* Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message // Playing with new fgPrintf command.
* system and commandline/config file processing code. //
* // Revision 1.3 1998/01/27 00:48:01 curt
* Revision 1.2 1998/01/24 00:03:28 curt // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
* Initial revision. // system and commandline/config file processing code.
* //
* Revision 1.1 1998/01/23 20:06:51 curt // Revision 1.2 1998/01/24 00:03:28 curt
* tileutils.* renamed to bucketutils.* // Initial revision.
* //
* Revision 1.6 1998/01/19 19:27:18 curt // Revision 1.1 1998/01/23 20:06:51 curt
* Merged in make system changes from Bob Kuehne <rpk@sgi.com> // tileutils.* renamed to bucketutils.*
* This should simplify things tremendously. //
* // Revision 1.6 1998/01/19 19:27:18 curt
* Revision 1.5 1998/01/14 02:19:04 curt // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
* Makde offset_bucket visible to outside. // This should simplify things tremendously.
* //
* Revision 1.4 1998/01/13 00:23:12 curt // Revision 1.5 1998/01/14 02:19:04 curt
* Initial changes to support loading and management of scenery tiles. Note, // Makde offset_bucket visible to outside.
* there's still a fair amount of work left to be done. //
* // Revision 1.4 1998/01/13 00:23:12 curt
* Revision 1.3 1998/01/10 00:01:47 curt // Initial changes to support loading and management of scenery tiles. Note,
* Misc api changes and tweaks. // there's still a fair amount of work left to be done.
* //
* 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.1 1998/01/07 23:50:52 curt // Revision 1.2 1998/01/08 02:22:28 curt
* "area" renamed to "tile" // Continue working on basic features.
* //
* Revision 1.1 1998/01/07 23:23:40 curt // Revision 1.1 1998/01/07 23:50:52 curt
* Initial revision. // "area" renamed to "tile"
* //
* */ // Revision 1.1 1998/01/07 23:23:40 curt
// Initial revision.
//

View file

@ -1,27 +1,25 @@
/************************************************************************** // bucketutils.h -- support routines to handle fgBUCKET operations
* bucketutils.h -- support routines to handle fgBUCKET operations //
* // Written by Curtis Olson, started January 1998.
* Written by Curtis Olson, started January 1998. //
* // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com //
* // This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as
* modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the
* published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version.
* License, or (at your option) any later version. //
* // This program is distributed in the hope that it will be useful, but
* This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of
* WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details.
* General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
* // $Id$
* $Id$ // (Log is kept at end of this file)
* (Log is kept at end of this file)
**************************************************************************/
#ifndef _BUCKETUTILS_H #ifndef _BUCKETUTILS_H
@ -34,10 +32,10 @@ extern "C" {
typedef struct { typedef struct {
int lon; /* longitude (-180 to 179) */ int lon; // longitude (-180 to 179)
int lat; /* latitude (-90 to 89) */ int lat; // latitude (-90 to 89)
int x; /* x (0 to 7) */ int x; // x (0 to 7)
int y; /* y (0 to 7) */ int y; // y (0 to 7)
} fgBUCKET; } fgBUCKET;
@ -57,24 +55,24 @@ typedef struct {
long int fgBucketGenIndex( const fgBUCKET *p); long int fgBucketGenIndex( const fgBUCKET *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
void fgBucketParseIndex(long int index, fgBUCKET *p); void fgBucketParseIndex(long int index, fgBUCKET *p);
/* Build a path name from an tile index */ // Build a path name from an tile index
void fgBucketGenBasePath( const fgBUCKET *p, char *path); void fgBucketGenBasePath( const fgBUCKET *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
void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y); void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y);
/* Given a lat/lon in degrees, find the "bucket" or tile that it falls // Given a lat/lon in degrees, find the "bucket" or tile that it falls
within */ // within
void fgBucketFind(double lon, double lat, fgBUCKET *p); void fgBucketFind(double lon, double lat, fgBUCKET *p);
/* Given a lat/lon, fill in the local tile index array */ // Given a lat/lon, fill in the local tile index array
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height); void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
@ -83,47 +81,50 @@ void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
#endif #endif
#endif /* _BUCKETUTILS_H */ #endif // _BUCKETUTILS_H
/* $Log$ // $Log$
/* Revision 1.3 1998/12/07 21:08:03 curt // Revision 1.4 1998/12/09 18:48:09 curt
/* Added a const in a couple places to get rid of annoying compiler warnings. // Use C++ style comments.
/* //
* Revision 1.2 1998/07/04 00:46:48 curt // Revision 1.3 1998/12/07 21:08:03 curt
* typedef'd struct fgBUCKET. // Added a const in a couple places to get rid of annoying compiler warnings.
* //
* Revision 1.1 1998/04/08 23:28:59 curt // Revision 1.2 1998/07/04 00:46:48 curt
* Adopted Gnu automake/autoconf system. // typedef'd struct fgBUCKET.
* //
* Revision 1.2 1998/01/24 00:03:28 curt // Revision 1.1 1998/04/08 23:28:59 curt
* Initial revision. // Adopted Gnu automake/autoconf system.
* //
* Revision 1.1 1998/01/23 20:06:52 curt // Revision 1.2 1998/01/24 00:03:28 curt
* tileutils.* renamed to bucketutils.* // Initial revision.
* //
* Revision 1.6 1998/01/22 02:59:42 curt // Revision 1.1 1998/01/23 20:06:52 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H // tileutils.* renamed to bucketutils.*
* //
* Revision 1.5 1998/01/14 02:19:05 curt // Revision 1.6 1998/01/22 02:59:42 curt
* Makde offset_bucket visible to outside. // Changed #ifdef FILE_H to #ifdef _FILE_H
* //
* Revision 1.4 1998/01/13 00:23:12 curt // Revision 1.5 1998/01/14 02:19:05 curt
* Initial changes to support loading and management of scenery tiles. Note, // Makde offset_bucket visible to outside.
* there's still a fair amount of work left to be done. //
* // Revision 1.4 1998/01/13 00:23:12 curt
* Revision 1.3 1998/01/10 00:01:48 curt // Initial changes to support loading and management of scenery tiles. Note,
* Misc api changes and tweaks. // there's still a fair amount of work left to be done.
* //
* 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.1 1998/01/07 23:50:52 curt // Revision 1.2 1998/01/08 02:22:28 curt
* "area" renamed to "tile" // Continue working on basic features.
* //
* Revision 1.1 1998/01/07 23:23:40 curt // Revision 1.1 1998/01/07 23:50:52 curt
* Initial revision. // "area" renamed to "tile"
* //
* */ // Revision 1.1 1998/01/07 23:23:40 curt
// Initial revision.
//