2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
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.
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.
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.
29 #include "projection.h"
31 #define coord_is_equal(a,b) ((a).x==(b).x && (a).y==(b).y)
33 /*! A integer mercator coordinate */
35 int x; /*!< X-Value */
36 int y; /*!< Y-Value */
39 /*! A integer mercator coordinate carrying its projection */
42 int x; /*!< X-Value */
43 int y; /*!< Y-Value */
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.
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)
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)
78 //! A double mercator coordinate
80 double x; /*!< X-Value */
81 double y; /*!< Y-Value */
84 //! A WGS84 coordinate
86 navit_float lng; /*!< Longitude */
87 navit_float lat; /*!< Latitude */
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 */
98 * An enumeration of formats for printing geographic coordinates in.
104 * Degrees with decimal places.
105 * Ie 20.5000 N 110.5000 E
110 * Degrees and minutes.
111 * ie 20 30.00 N 110 30.00 E
115 * Degrees, minutes and seconds.
116 * ie 20 30 30.00 N 110 30 30 E
118 DEGREES_MINUTES_SECONDS
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);
145 struct coord *coord_get(unsigned char **p);
146 struct coord *coord_new(int x, int y);
147 struct coord *coord_new_from_attrs(struct attr *parent, struct attr **attrs);
148 void coord_destroy(struct coord *c);
149 struct coord_rect *coord_rect_new(struct coord *lu, struct coord *rl);
150 void coord_rect_destroy(struct coord_rect *r);
151 int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2);
152 int coord_rect_contains(struct coord_rect *r, struct coord *c);
153 void coord_rect_extend(struct coord_rect *r, struct coord *c);
154 int coord_parse(const char *c_str, enum projection pro, struct coord *c_ret);
155 int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *pc_ret);
156 void coord_print(enum projection pro, struct coord *c, FILE *out);
157 void coord_format(float lat, float lng, enum coord_format fmt, char *buffer, int size);
158 unsigned int coord_hash(const void *key);
159 int coord_equal(const void *a, const void *b);
160 /* end of prototypes */