/[zanavi_public1]/navit/navit/coord.h
ZANavi

Contents of /navit/navit/coord.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 28 - (hide annotations) (download)
Sun Jun 17 08:12:47 2012 UTC (11 years, 10 months ago) by zoff99
File MIME type: text/plain
File size: 4789 byte(s)
lots of new stuff and fixes
1 zoff99 2 /**
2     * Navit, a modular navigation system.
3     * Copyright (C) 2005-2008 Navit Team
4     *
5     * This program is free software; you can redistribute it and/or
6     * modify it under the terms of the GNU Library General Public License
7     * version 2 as published by the Free Software Foundation.
8     *
9     * This program is distributed in the hope that it will be useful,
10     * but WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     * GNU Library General Public License for more details.
13     *
14     * You should have received a copy of the GNU Library General Public
15     * License along with this program; if not, write to the
16     * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     * Boston, MA 02110-1301, USA.
18     */
19    
20     #ifndef NAVIT_COORD_H
21     #define NAVIT_COORD_H
22    
23    
24     #ifdef __cplusplus
25     extern "C" {
26     #endif
27     #include <stdio.h>
28     #include "config.h"
29     #include "projection.h"
30    
31     #define coord_is_equal(a,b) ((a).x==(b).x && (a).y==(b).y)
32    
33     /*! A integer mercator coordinate */
34     struct coord {
35     int x; /*!< X-Value */
36     int y; /*!< Y-Value */
37     };
38    
39     /*! A integer mercator coordinate carrying its projection */
40     struct pcoord {
41     enum projection pro;
42     int x; /*!< X-Value */
43     int y; /*!< Y-Value */
44     };
45    
46     struct coord_rect {
47     struct coord lu;
48     struct coord rl;
49     };
50    
51    
52     #ifdef AVOID_FLOAT
53     /**
54     * On platforms where we are trying to avoid floats, sometimes we can't.
55     * It is better on these platforms to use single precision floating points
56     * over double percision ones since performance is much better.
57     */
58     typedef float navit_float;
59     #define navit_sin(x) sinf(x)
60     #define navit_cos(x) cosf(x)
61     #define navit_tan(x) tanf(x)
62     #define navit_atan(x) atanf(x)
63     #define navit_acos(x) acosf(x)
64     #define navit_asin(x) asinf(x)
65     #define navit_sqrt(x) sqrtf(x)
66     #else
67     typedef double navit_float;
68     #define navit_sin(x) sin(x)
69     #define navit_cos(x) cos(x)
70     #define navit_tan(x) tan(x)
71     #define navit_atan(x) atan(x)
72     #define navit_acos(x) acos(x)
73     #define navit_asin(x) asin(x)
74     #define navit_sqrt(x) sqrt(x)
75     #endif
76    
77    
78     //! A double mercator coordinate
79     struct coord_d {
80     double x; /*!< X-Value */
81     double y; /*!< Y-Value */
82     };
83    
84     //! A WGS84 coordinate
85     struct coord_geo {
86     navit_float lng; /*!< Longitude */
87     navit_float lat; /*!< Latitude */
88     };
89    
90     //! A cartesian coordinate
91     struct coord_geo_cart {
92     navit_float x; /*!< X-Value */
93     navit_float y; /*!< Y-Value */
94     navit_float z; /*!< Z-Value */
95     };
96    
97     /**
98     * An enumeration of formats for printing geographic coordinates in.
99     *
100     */
101     enum coord_format
102     {
103     /**
104     * Degrees with decimal places.
105     * Ie 20.5000 N 110.5000 E
106     */
107     DEGREES_DECIMAL,
108    
109     /**
110     * Degrees and minutes.
111     * ie 20 30.00 N 110 30.00 E
112     */
113     DEGREES_MINUTES,
114     /**
115     * Degrees, minutes and seconds.
116     * ie 20 30 30.00 N 110 30 30 E
117     */
118     DEGREES_MINUTES_SECONDS
119     };
120    
121     enum projection;
122     struct attr;
123    
124     struct coord * coord_get(unsigned char **p);
125     struct coord * coord_new(int x, int y);
126     struct coord * coord_new_from_attrs(struct attr *parent, struct attr **attrs);
127     void coord_destroy(struct coord *c);
128     int coord_parse(const char *c_str, enum projection pro, struct coord *c_ret);
129     int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *c_ret);
130     void coord_print(enum projection pro, struct coord *c, FILE *out);
131     struct coord_rect * coord_rect_new(struct coord *lu, struct coord *rl);
132     void coord_rect_destroy(struct coord_rect *r);
133     int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2);
134     int coord_rect_contains(struct coord_rect *r, struct coord *c);
135     void coord_rect_extend(struct coord_rect *r, struct coord *c);
136     void coord_format(float lat,float lng, enum coord_format, char * buffer, int size);
137    
138     /* prototypes */
139     enum coord_format;
140     enum projection;
141     struct attr;
142     struct coord;
143     struct coord_rect;
144     struct pcoord;
145 zoff99 28
146     float sqrtf_fast2(float x2);
147     float sqrtf_fast(float number2);
148    
149 zoff99 2 struct coord *coord_get(unsigned char **p);
150     struct coord *coord_new(int x, int y);
151     struct coord *coord_new_from_attrs(struct attr *parent, struct attr **attrs);
152     void coord_destroy(struct coord *c);
153     struct coord_rect *coord_rect_new(struct coord *lu, struct coord *rl);
154     void coord_rect_destroy(struct coord_rect *r);
155     int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2);
156     int coord_rect_contains(struct coord_rect *r, struct coord *c);
157     void coord_rect_extend(struct coord_rect *r, struct coord *c);
158     int coord_parse(const char *c_str, enum projection pro, struct coord *c_ret);
159     int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *pc_ret);
160     void coord_print(enum projection pro, struct coord *c, FILE *out);
161     void coord_format(float lat, float lng, enum coord_format fmt, char *buffer, int size);
162     unsigned int coord_hash(const void *key);
163     int coord_equal(const void *a, const void *b);
164     /* end of prototypes */
165     #ifdef __cplusplus
166     }
167     #endif
168     #endif

   
Visit the ZANavi Wiki