]> git.mxchange.org Git - simgear.git/blob - Bucket/bucketutils.h
Portability updates contributed by Bernie Bright.
[simgear.git] / Bucket / bucketutils.h
1 // bucketutils.h -- support routines to handle fgBUCKET operations
2 //
3 // Written by Curtis Olson, started January 1998.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifndef _BUCKETUTILS_H
26 #define _BUCKETUTILS_H
27
28
29 #ifdef __cplusplus                                                          
30 extern "C" {                            
31 #endif                                   
32
33
34 typedef struct {
35     int lon;  // longitude (-180 to 179)
36     int lat;  // latitude (-90 to 89)
37     int x;    // x (0 to 7)
38     int y;    // y (0 to 7)
39 } fgBUCKET;
40
41
42 /* Generate the unique scenery tile index containing the specified
43    lon/lat parameters.
44
45    The index is constructed as follows:
46
47    9 bits - to represent 360 degrees of longitude (-180 to 179)
48    8 bits - to represent 180 degrees of latitude (-90 to 89)
49
50    Each 1 degree by 1 degree tile is further broken down into an 8x8
51    grid.  So we also need:
52
53    3 bits - to represent x (0 to 7)
54    3 bits - to represent y (0 to 7) */
55 long int fgBucketGenIndex( const fgBUCKET *p);
56
57
58 // Parse a unique scenery tile index and find the lon, lat, x, and y
59 void fgBucketParseIndex(long int index, fgBUCKET *p);
60
61
62 // Build a path name from an tile index
63 void fgBucketGenBasePath( const fgBUCKET *p, char *path);
64
65
66 // offset an bucket struct by the specified amounts in the X & Y direction
67 void fgBucketOffset(fgBUCKET *in, fgBUCKET *out, int x, int y);
68
69
70 // Given a lat/lon in degrees, find the "bucket" or tile that it falls
71 // within
72 void fgBucketFind(double lon, double lat, fgBUCKET *p);
73
74
75 // Given a lat/lon, fill in the local tile index array
76 void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
77
78
79 #ifdef __cplusplus
80 }
81 #endif
82
83
84 #endif // _BUCKETUTILS_H
85
86
87 // $Log$
88 // Revision 1.4  1998/12/09 18:48:09  curt
89 // Use C++ style comments.
90 //
91 // Revision 1.3  1998/12/07 21:08:03  curt
92 // Added a const in a couple places to get rid of annoying compiler warnings.
93 //
94 // Revision 1.2  1998/07/04 00:46:48  curt
95 // typedef'd struct fgBUCKET.
96 //
97 // Revision 1.1  1998/04/08 23:28:59  curt
98 // Adopted Gnu automake/autoconf system.
99 //
100 // Revision 1.2  1998/01/24 00:03:28  curt
101 // Initial revision.
102 //
103 // Revision 1.1  1998/01/23 20:06:52  curt
104 // tileutils.* renamed to bucketutils.*
105 //
106 // Revision 1.6  1998/01/22 02:59:42  curt
107 // Changed #ifdef FILE_H to #ifdef _FILE_H
108 //
109 // Revision 1.5  1998/01/14 02:19:05  curt
110 // Makde offset_bucket visible to outside.
111 //
112 // Revision 1.4  1998/01/13 00:23:12  curt
113 // Initial changes to support loading and management of scenery tiles.  Note,
114 // there's still a fair amount of work left to be done.
115 //
116 // Revision 1.3  1998/01/10 00:01:48  curt
117 // Misc api changes and tweaks.
118 //
119 // Revision 1.2  1998/01/08 02:22:28  curt
120 // Continue working on basic features.
121 //
122 // Revision 1.1  1998/01/07 23:50:52  curt
123 // "area" renamed to "tile"
124 //
125 // Revision 1.1  1998/01/07 23:23:40  curt
126 // Initial revision.
127 //
128
129
130