navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
coord.h
Go to the documentation of this file.
1 
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 
34 struct coord {
35  int x;
36  int y;
37 };
38 
40 struct pcoord {
42  int x;
43  int y;
44 };
45 
46 struct coord_rect {
47  struct coord lu;
48  struct coord rl;
49 };
50 
51 
52 #ifdef AVOID_FLOAT
53 
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 
79 struct coord_d {
80  double x;
81  double y;
82 };
83 
85 struct coord_geo {
86  navit_float lng;
87  navit_float lat;
88 };
89 
92  navit_float x;
93  navit_float y;
94  navit_float z;
95 };
96 
102 {
108 
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 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:74
int size
Definition: garmin_img.c:131
enum projection pro
Definition: coord.h:41
void coord_rect_destroy(struct coord_rect *r)
Definition: coord.c:95
int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2)
Definition: coord.c:101
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
coord_format
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:165
Definition: coord.h:113
struct coord lu
Definition: coord.h:47
A cartesian coordinate.
Definition: coord.h:91
projection
Definition: projection.h:23
unsigned char key
Definition: tree.c:65
int coord_equal(const void *a, const void *b)
Definition: coord.c:393
Definition: attr.h:156
int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *c_ret)
Definition: coord.c:278
struct triple lng lat
Definition: garmin_img.c:498
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:386
int coord_rect_contains(struct coord_rect *r, struct coord *c)
Definition: coord.c:120
struct coord_rect * coord_rect_new(struct coord *lu, struct coord *rl)
Definition: coord.c:80
void coord_rect_extend(struct coord_rect *r, struct coord *c)
Definition: coord.c:136
void coord_print(enum projection pro, struct coord *c, FILE *out)
Definition: coord.c:290
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:51
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:62
int x
Definition: coord.h:35