navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
Go to the documentation of this file.
20 #ifndef NAVIT_COORD_H
21 #define NAVIT_COORD_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 #include <stdio.h>
28 #include "config.h"
29 #include "projection.h"
31 #define coord_is_equal(a,b) ((a).x==(b).x && (a).y==(b).y)
34 struct coord {
35  int x;
36  int y;
37 };
40 struct pcoord {
42  int x;
43  int y;
44 };
46 struct coord_rect {
47  struct coord lu;
48  struct coord rl;
49 };
52 #ifdef AVOID_FLOAT
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
79 struct coord_d {
80  double x;
81  double y;
82 };
85 struct coord_geo {
86  navit_float lng;
87  navit_float lat;
88 };
92  navit_float x;
93  navit_float y;
94  navit_float z;
95 };
102 {
119 };
121 enum projection;
122 struct attr;
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);
138 /* prototypes */
139 enum coord_format;
140 enum projection;
141 struct attr;
142 struct coord;
143 struct coord_rect;
144 struct pcoord;
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 */
161 #ifdef __cplusplus
162 }
163 #endif
164 #endif
unsigned char p[5]
Definition: mg.h:48
navit_float z
Definition: coord.h:94
Definition: gpx2navit_txt.h:51
int y
Definition: coord.h:36
void coord_destroy(struct coord *c)
Definition: coord.c:70
int size
Definition: garmin_img.c:124
enum projection pro
Definition: coord.h:41
void coord_rect_destroy(struct coord_rect *r)
Definition: coord.c:88
int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2)
Definition: coord.c:92
int y
Definition: coord.h:43
struct coord * coord_get(unsigned char **p)
Definition: coord.c:43
navit_float lng
Definition: coord.h:86
navit_float x
Definition: coord.h:92
Definition: coord.h:101
int x
Definition: coord.h:42
navit_float y
Definition: coord.h:93
int coord_parse(const char *c_str, enum projection pro, struct coord *c_ret)
Definition: coord.c:151
Definition: coord.h:113
struct coord lu
Definition: coord.h:47
A cartesian coordinate.
Definition: coord.h:91
Definition: projection.h:23
unsigned char key
Definition: tree.c:98
int coord_equal(const void *a, const void *b)
Definition: coord.c:372
Definition: attr.h:156
int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *c_ret)
Definition: coord.c:262
struct triple lng lat
Definition: garmin_img.c:464
double x
Definition: coord.h:80
double navit_float
Definition: coord.h:67
navit_float lat
Definition: coord.h:87
Definition: maptool.h:168
unsigned int coord_hash(const void *key)
Definition: coord.c:367
int coord_rect_contains(struct coord_rect *r, struct coord *c)
Definition: coord.c:110
struct coord_rect * coord_rect_new(struct coord *lu, struct coord *rl)
Definition: coord.c:75
void coord_rect_extend(struct coord_rect *r, struct coord *c)
Definition: coord.c:124
void coord_print(enum projection pro, struct coord *c, FILE *out)
Definition: coord.c:272
struct coord rl
Definition: coord.h:48
Definition: coord.h:46
A double mercator coordinate.
Definition: coord.h:79
Definition: coord.h:34
Definition: coord.h:107
double y
Definition: coord.h:81
Definition: coord.h:40
struct coord * coord_new(int x, int y)
Definition: coord.c:50
A WGS84 coordinate.
Definition: coord.h:85
Definition: coord.h:118
struct coord * coord_new_from_attrs(struct attr *parent, struct attr **attrs)
Definition: coord.c:60
int x
Definition: coord.h:35