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.
25 #include "projection.h"
27 #define coord_is_equal(a,b) ((a).x==(b).x && (a).y==(b).y)
29 /*! A integer mercator coordinate */
31 int x; /*!< X-Value */
32 int y; /*!< Y-Value */
35 /*! A integer mercator coordinate carrying its projection */
38 int x; /*!< X-Value */
39 int y; /*!< Y-Value */
50 * On platforms where we are trying to avoid floats, sometimes we can't.
51 * It is better on these platforms to use single precision floating points
52 * over double percision ones since performance is much better.
54 typedef float navit_float;
55 #define navit_sin(x) sinf(x)
56 #define navit_cos(x) cosf(x)
57 #define navit_tan(x) tanf(x)
58 #define navit_atan(x) atanf(x)
59 #define navit_acos(x) acosf(x)
60 #define navit_asin(x) asinf(x)
61 #define navit_sqrt(x) sqrtf(x)
63 typedef double navit_float;
64 #define navit_sin(x) sin(x)
65 #define navit_cos(x) cos(x)
66 #define navit_tan(x) tan(x)
67 #define navit_atan(x) atan(x)
68 #define navit_acos(x) acos(x)
69 #define navit_asin(x) asin(x)
70 #define navit_sqrt(x) sqrt(x)
74 //! A double mercator coordinate
76 double x; /*!< X-Value */
77 double y; /*!< Y-Value */
80 //! A WGS84 coordinate
82 navit_float lng; /*!< Longitude */
83 navit_float lat; /*!< Latitude */
86 //! A cartesian coordinate
87 struct coord_geo_cart {
88 navit_float x; /*!< X-Value */
89 navit_float y; /*!< Y-Value */
90 navit_float z; /*!< Z-Value */
94 * An enumeration of formats for printing geographic coordinates in.
100 * Degrees with decimal places.
101 * Ie 20.5000 N 110.5000 E
106 * Degrees and minutes.
107 * ie 20 30.00 N 110 30.00 E
111 * Degrees, minutes and seconds.
112 * ie 20 30 30.00 N 110 30 30 E
114 DEGREES_MINUTES_SECONDS
120 struct coord * coord_get(unsigned char **p);
121 struct coord * coord_new(int x, int y);
122 struct coord * coord_new_from_attrs(struct attr *parent, struct attr **attrs);
123 void coord_destroy(struct coord *c);
124 int coord_parse(const char *c_str, enum projection pro, struct coord *c_ret);
125 int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *c_ret);
126 void coord_print(enum projection pro, struct coord *c, FILE *out);
127 struct coord_rect * coord_rect_new(struct coord *lu, struct coord *rl);
128 void coord_rect_destroy(struct coord_rect *r);
129 int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2);
130 int coord_rect_contains(struct coord_rect *r, struct coord *c);
131 void coord_rect_extend(struct coord_rect *r, struct coord *c);
132 void coord_format(float lat,float lng, enum coord_format, char * buffer, int size);
142 struct coord *coord_get(unsigned char **p);
143 struct coord *coord_new(int x, int y);
144 struct coord *coord_new_from_attrs(struct attr *parent, struct attr **attrs);
145 void coord_destroy(struct coord *c);
146 struct coord_rect *coord_rect_new(struct coord *lu, struct coord *rl);
147 void coord_rect_destroy(struct coord_rect *r);
148 int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2);
149 int coord_rect_contains(struct coord_rect *r, struct coord *c);
150 void coord_rect_extend(struct coord_rect *r, struct coord *c);
151 int coord_parse(const char *c_str, enum projection pro, struct coord *c_ret);
152 int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *pc_ret);
153 void coord_print(enum projection pro, struct coord *c, FILE *out);
154 void coord_format(float lat, float lng, enum coord_format fmt, char *buffer, int size);
155 unsigned int coord_hash(const void *key);
156 int coord_equal(const void *a, const void *b);
157 /* end of prototypes */