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