forked from mkoloberdin/waze
/
roadmap_plugin.h
237 lines (177 loc) · 7.82 KB
/
roadmap_plugin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* roadmap_plugin.h - plugin interfaces
*
* LICENSE:
*
* Copyright 2005 Ehud Shabtai
*
* This file is part of RoadMap.
*
* RoadMap is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* RoadMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RoadMap; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef INCLUDE__ROADMAP_PLUGIN__H
#define INCLUDE__ROADMAP_PLUGIN__H
#include "roadmap_canvas.h"
#include "roadmap_screen.h"
#define INVALID_PLUGIN_ID -1
#define ROADMAP_PLUGIN_ID 0
#define PLUGIN_MAKE_LINE(plugin_id, line_id, cfcc, square, fips) \
{plugin_id, line_id, cfcc, square, fips}
#define PLUGIN_VALID(plugin) (plugin.plugin_id >= 0)
#define INVALIDATE_PLUGIN(plugin) (plugin.plugin_id = -1)
#define PLUGIN_STREET_ONLY 0x1
/* plugin types */
typedef struct {
int plugin_id;
int line_id;
int cfcc;
int square;
int fips;
} PluginLine;
typedef struct {
int plugin_id;
int square;
int street_id;
} PluginStreet;
typedef struct {
const char *address;
const char *street;
const char *street_t2s;
const char *city;
PluginStreet plugin_street;
const char *shield_text;
const char *shield_type;
} PluginStreetProperties;
#define PLUGIN_LINE_NULL {-1, -1, -1, -1, -1}
#define PLUGIN_STREET_NULL {-1, -1, -1}
struct RoadMapNeighbour_t;
int roadmap_plugin_same_line (const PluginLine *line1, const PluginLine *line2);
int roadmap_plugin_same_db_line (const PluginLine *line1,
const PluginLine *line2);
int roadmap_plugin_same_street (const PluginStreet *street1,
const PluginStreet *street2);
void roadmap_plugin_get_street (const PluginLine *line, PluginStreet *street);
void roadmap_plugin_line_from (const PluginLine *line, RoadMapPosition *pos);
void roadmap_plugin_line_to (const PluginLine *line, RoadMapPosition *pos);
void roadmap_plugin_get_line_points (const PluginLine *line,
RoadMapPosition *from_pos,
RoadMapPosition *to_pos,
int *first_shape,
int *last_shape,
RoadMapShapeItr *shape_itr);
int roadmap_plugin_get_id (const PluginLine *line);
int roadmap_plugin_get_square (const PluginLine *line);
int roadmap_plugin_get_fips (const PluginLine *line);
int roadmap_plugin_get_line_id (const PluginLine *line);
int roadmap_plugin_get_line_cfcc (const PluginLine *line);
int roadmap_plugin_get_street_id (const PluginStreet *street);
void roadmap_plugin_set_line (PluginLine *line,
int plugin_id,
int line_id,
int cfcc,
int square,
int fips);
void roadmap_plugin_set_street (PluginStreet *street,
int plugin_id,
int square,
int street_id);
int roadmap_plugin_activate_db (const PluginLine *line);
int roadmap_plugin_get_distance
(const RoadMapPosition *point,
const PluginLine *line,
struct RoadMapNeighbour_t *result);
/* hook functions definition */
typedef int (*plugin_override_line_hook) (int line, int cfcc, int fips);
typedef int (*plugin_override_pen_hook) (int line,
int cfcc,
int fips,
int pen_type,
RoadMapPen *override_pen);
typedef void (*plugin_screen_repaint_hook) (int max_pen);
typedef int (*plugin_activate_db_func) (const PluginLine *line);
typedef void (*plugin_line_pos_func)
(const PluginLine *line, RoadMapPosition *pos);
typedef int (*plugin_get_distance_func)
(const RoadMapPosition *point,
const PluginLine *line,
struct RoadMapNeighbour_t *result);
typedef void (*plugin_get_street_func)
(const PluginLine *line, PluginStreet *street);
typedef const char *(*plugin_street_full_name_func)
(const PluginLine *line);
typedef void (*plugin_street_properties_func)
(const PluginLine *line, PluginStreetProperties *props,
int type);
typedef int (*plugin_find_connected_lines_func)
(const RoadMapPosition *crossing,
PluginLine *plugin_lines,
int max);
typedef void (*plugin_adjust_layer_hook)
(int layer, int thickness, int pen_count);
typedef int (*plugin_get_closest_func)
(const RoadMapPosition *position,
int *categories, int categories_count, int max_shapes,
struct RoadMapNeighbour_t *neighbours, int count,
int max);
typedef int (*plugin_line_route_direction) (PluginLine *line, int who);
typedef void (*plugin_shutdown) (void);
typedef struct {
plugin_line_pos_func line_from;
plugin_line_pos_func line_to;
plugin_activate_db_func activate_db;
plugin_get_distance_func get_distance;
plugin_override_line_hook override_line;
plugin_override_pen_hook override_pen;
plugin_screen_repaint_hook screen_repaint;
plugin_get_street_func get_street;
plugin_street_full_name_func get_street_full_name;
plugin_street_properties_func get_street_properties;
plugin_find_connected_lines_func find_connected_lines;
plugin_adjust_layer_hook adjust_layer;
plugin_get_closest_func get_closest;
plugin_line_route_direction route_direction;
plugin_shutdown shutdown;
} RoadMapPluginHooks;
/* Interface functions */
int roadmap_plugin_register (RoadMapPluginHooks *hooks);
void roadmap_plugin_unregister (int plugin_id);
int roadmap_plugin_override_line (int line, int cfcc, int fips);
int roadmap_plugin_override_pen (int line,
int cfcc,
int fips,
int pen_type,
RoadMapPen *override_pen);
void roadmap_plugin_screen_repaint (int max_pen);
const char *roadmap_plugin_street_full_name (const PluginLine *line);
void roadmap_plugin_get_street_properties (const PluginLine *line,
PluginStreetProperties *props,
int type);
int roadmap_plugin_find_connected_lines (RoadMapPosition *crossing,
PluginLine *plugin_lines,
int max);
void roadmap_plugin_adjust_layer (int layer,
int thickness,
int pen_count);
int roadmap_plugin_get_closest
(const RoadMapPosition *position,
int *categories, int categories_count, int max_shapes,
struct RoadMapNeighbour_t *neighbours, int count,
int max);
int roadmap_plugin_get_direction (PluginLine *line, int who);
int roadmap_plugin_calc_length (const RoadMapPosition *position,
const PluginLine *line,
int *total_length);
void roadmap_plugin_shutdown (void);
#endif /* INCLUDE__ROADMAP_PLUGIN__H */