1 |
zoff99 |
2 |
/** |
2 |
zoff99 |
27 |
* ZANavi, Zoff Android Navigation system. |
3 |
zoff99 |
40 |
* Copyright (C) 2011-2014 Zoff <zoff@zoff.cc> |
4 |
zoff99 |
27 |
* |
5 |
|
|
* This program is free software; you can redistribute it and/or |
6 |
|
|
* modify it under the terms of the GNU General Public License |
7 |
|
|
* version 2 as published by the Free Software Foundation. |
8 |
|
|
* |
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 General Public License for more details. |
13 |
|
|
* |
14 |
|
|
* You should have received a copy of the GNU General Public License |
15 |
|
|
* 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. |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
/** |
21 |
zoff99 |
2 |
* Navit, a modular navigation system. |
22 |
|
|
* Copyright (C) 2005-2009 Navit Team |
23 |
|
|
* |
24 |
|
|
* This program is free software; you can redistribute it and/or |
25 |
|
|
* modify it under the terms of the GNU General Public License |
26 |
|
|
* version 2 as published by the Free Software Foundation. |
27 |
|
|
* |
28 |
|
|
* This program is distributed in the hope that it will be useful, |
29 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
30 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31 |
|
|
* GNU General Public License for more details. |
32 |
|
|
* |
33 |
|
|
* You should have received a copy of the GNU General Public License |
34 |
|
|
* along with this program; if not, write to the |
35 |
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
36 |
|
|
* Boston, MA 02110-1301, USA. |
37 |
|
|
*/ |
38 |
|
|
|
39 |
|
|
#define _USE_MATH_DEFINES 1 |
40 |
|
|
#include "config.h" |
41 |
|
|
#ifdef HAVE_UNISTD_H |
42 |
|
|
#include <unistd.h> |
43 |
|
|
#endif |
44 |
|
|
#include <stdio.h> |
45 |
|
|
#include <stdlib.h> |
46 |
|
|
#include <signal.h> |
47 |
|
|
#include <string.h> |
48 |
|
|
#include <fcntl.h> |
49 |
|
|
#include <glib.h> |
50 |
|
|
#include <math.h> |
51 |
|
|
#include <time.h> |
52 |
|
|
#include "debug.h" |
53 |
|
|
#include "navit.h" |
54 |
|
|
#include "callback.h" |
55 |
|
|
#include "gui.h" |
56 |
|
|
#include "item.h" |
57 |
|
|
#include "projection.h" |
58 |
|
|
#include "map.h" |
59 |
|
|
#include "mapset.h" |
60 |
|
|
#include "main.h" |
61 |
|
|
#include "coord.h" |
62 |
|
|
#include "point.h" |
63 |
|
|
#include "transform.h" |
64 |
|
|
#include "param.h" |
65 |
|
|
#include "menu.h" |
66 |
|
|
#include "graphics.h" |
67 |
|
|
#include "popup.h" |
68 |
|
|
#include "data_window.h" |
69 |
|
|
#include "route.h" |
70 |
|
|
#include "navigation.h" |
71 |
|
|
#include "speech.h" |
72 |
|
|
#include "track.h" |
73 |
|
|
#include "vehicle.h" |
74 |
|
|
#include "layout.h" |
75 |
|
|
#include "log.h" |
76 |
|
|
#include "attr.h" |
77 |
|
|
#include "event.h" |
78 |
|
|
#include "file.h" |
79 |
|
|
#include "profile.h" |
80 |
|
|
#include "command.h" |
81 |
|
|
#include "navit_nls.h" |
82 |
|
|
#include "map.h" |
83 |
|
|
#include "util.h" |
84 |
|
|
#include "messages.h" |
85 |
|
|
#include "vehicleprofile.h" |
86 |
|
|
#include "sunriset.h" |
87 |
|
|
#include "bookmarks.h" |
88 |
zoff99 |
27 |
#include "map.h" |
89 |
zoff99 |
2 |
#ifdef HAVE_API_WIN32_BASE |
90 |
|
|
#include <windows.h> |
91 |
|
|
#include "util.h" |
92 |
|
|
#endif |
93 |
|
|
#ifdef HAVE_API_WIN32_CE |
94 |
|
|
#include "libc.h" |
95 |
|
|
#endif |
96 |
|
|
|
97 |
zoff99 |
40 |
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
// #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1 |
110 |
|
|
|
111 |
|
|
|
112 |
|
|
// --------------- debug function calls ------------------ |
113 |
|
|
// --------------- debug function calls ------------------ |
114 |
|
|
#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
115 |
|
|
#undef return2 |
116 |
|
|
#define return2 dbg_func(0, global_func_indent_counter, "return(%d)\n", __LINE__);global_func_indent_counter--;return |
117 |
|
|
|
118 |
|
|
#define __F_START__ global_func_indent_counter++;dbg_func(0, global_func_indent_counter, "enter\n"); |
119 |
|
|
#define __F_END__ dbg_func(0, global_func_indent_counter, "leave\n");global_func_indent_counter--; |
120 |
|
|
#else |
121 |
|
|
#undef return2 |
122 |
|
|
#define return2 return |
123 |
|
|
|
124 |
|
|
#define __F_START__ |
125 |
|
|
#define __F_END__ |
126 |
|
|
#endif |
127 |
|
|
// --------------- debug function calls ------------------ |
128 |
|
|
// --------------- debug function calls ------------------ |
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
zoff99 |
2 |
/** |
136 |
|
|
* @defgroup navit the navit core instance. navit is the object containing nearly everything: A set of maps, one or more vehicle, a graphics object for rendering the map, a gui object for displaying the user interface, a route object, a navigation object and so on. Be warned that it is theoretically possible to have more than one navit object |
137 |
|
|
* @{ |
138 |
|
|
*/ |
139 |
|
|
|
140 |
|
|
struct gui *main_loop_gui; |
141 |
|
|
|
142 |
zoff99 |
27 |
struct attr_iter |
143 |
|
|
{ |
144 |
|
|
union |
145 |
|
|
{ |
146 |
zoff99 |
2 |
GList *list; |
147 |
|
|
struct mapset_handle *mapset_handle; |
148 |
|
|
} u; |
149 |
|
|
}; |
150 |
|
|
|
151 |
zoff99 |
29 |
static int dist_to_street = 100000; |
152 |
|
|
|
153 |
zoff99 |
2 |
static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv); |
154 |
|
|
static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt); |
155 |
|
|
static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init); |
156 |
|
|
static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir); |
157 |
|
|
static void navit_cmd_zoom_to_route(struct navit *this); |
158 |
|
|
static void navit_cmd_set_center_cursor(struct navit *this_); |
159 |
|
|
static void navit_cmd_announcer_toggle(struct navit *this_); |
160 |
|
|
static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv); |
161 |
|
|
|
162 |
zoff99 |
30 |
int allow_gui_internal = 0; // disable old GUI internal. it will not work anymore! |
163 |
zoff99 |
2 |
int routing_mode = 0; |
164 |
|
|
int MYSTERY_SPEED = 2; |
165 |
zoff99 |
14 |
int offline_search_filter_duplicates = 0; |
166 |
|
|
int offline_search_break_searching = 0; |
167 |
zoff99 |
27 |
char *navit_maps_dir; |
168 |
zoff99 |
34 |
char *navit_share_dir; |
169 |
|
|
char *navit_data_dir; |
170 |
zoff99 |
27 |
int cancel_drawing_global = 0; |
171 |
|
|
int global_speak_streetnames = 1; |
172 |
|
|
int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now |
173 |
|
|
int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB) |
174 |
|
|
int draw_polylines_fast = 0; // default: 0 |
175 |
|
|
int limit_order_corrected = 4; // remain at this order level for drawing streets etc. |
176 |
zoff99 |
28 |
int shift_order = 0; // shift order level (for displaying objects) by this values (should only be bigger than zero!!) |
177 |
zoff99 |
40 |
int global_search_street_size_factor = 1; // make search radius for streets bigger (not used on indexsearch) |
178 |
zoff99 |
28 |
int disable_map_drawing = 0; // dont draw the map and dont read data from file (hopefully saving resources) |
179 |
|
|
int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing |
180 |
zoff99 |
30 |
int global_stop_demo_vehicle = 0; // 0 -> demo vehicle can move, 1 -> demo vehicle stands still |
181 |
zoff99 |
31 |
int global_show_route_rectangles = 0; // 1 -> show route rectangles, 0 -> dont show route rectangles |
182 |
|
|
int global_traffic_light_delay = 0; // 0 -> dont account for traffic lights in route, >0 -> calc a delay for each traffic light |
183 |
zoff99 |
40 |
int global_clinedrawing_active = 0; // 0 -> java line drawing, 1 -> C line drawing |
184 |
zoff99 |
31 |
int global_draw_multipolygons = 1; // 0 -> dont draw lines and triangles from multipolygons, 1 -> draw them |
185 |
zoff99 |
34 |
int global_have_dpi_value = 240; |
186 |
|
|
float global_dpi_factor = 1.0f; |
187 |
|
|
int global_order_level_for_fast_draw = 13; |
188 |
|
|
int global_show_english_labels = 1; // 0 -> only "normal" names/labels shown on map |
189 |
|
|
// 1 -> show "normal, english" |
190 |
|
|
// 2 -> show only "english" labels |
191 |
zoff99 |
41 |
int global_routing_engine = 0; // 0 -> offline ZANavi, 1 -> online OSRM |
192 |
|
|
float global_overspill_factor = 1.0f; // overspill factor from Java code |
193 |
zoff99 |
40 |
int global_avoid_sharp_turns_flag = 0; // 0 -> normal routing, 1 -> try to avoid sharp turns / u-turns |
194 |
|
|
int global_avoid_sharp_turns_min_angle = 40; // at what angle is it a sharp turn? |
195 |
zoff99 |
41 |
int global_avoid_sharp_turns_min_penalty = 1000; // routing penalty for sharp turns (DEFAULT = 1000) |
196 |
zoff99 |
2 |
|
197 |
zoff99 |
40 |
int global_search_radius_for_housenumbers = 300; // search this far around street-coord to find potential housenumbers for this street |
198 |
|
|
int global_vehicle_profile = 0; // 0 -> car, 1 -> bicycle, 2 -> bicylce no one-ways |
199 |
|
|
int global_cycle_lanes_prio = 5; // how much prio weight will be subtracted from prio weight if a road has a cycle lane (painted white line for bicycles) |
200 |
|
|
int global_cycle_track_prio = 1; // unused for now!! |
201 |
|
|
|
202 |
|
|
double global_v_pos_lat = 0.0; // global vehicle position |
203 |
|
|
double global_v_pos_lng = 0.0; // global vehicle position |
204 |
|
|
double global_v_pos_dir = 0.0; // global vehicle direction |
205 |
|
|
|
206 |
zoff99 |
41 |
struct coord global_vehicle_pos_onscreen; |
207 |
|
|
struct coord_geo global_last_vehicle_pos_geo; |
208 |
|
|
double ggggg_lat = 0; |
209 |
|
|
double ggggg_lon = 0; |
210 |
|
|
|
211 |
|
|
|
212 |
zoff99 |
40 |
int global_demo_vehicle = 0; |
213 |
|
|
int global_demo_vehicle_short_switch = 0; |
214 |
|
|
long global_last_spoken = -1; |
215 |
|
|
long global_last_spoken_base = 0; |
216 |
zoff99 |
41 |
float global_road_speed_factor = 0.85f; |
217 |
zoff99 |
40 |
|
218 |
zoff99 |
47 |
float global_level0_announcement = 5.0f; |
219 |
|
|
float global_level1_announcement = 11.0f; |
220 |
|
|
float global_level2_announcement = 24.3f; |
221 |
zoff99 |
41 |
float global_levelx_announcement_factor = 6.0f / 4.0f; |
222 |
|
|
|
223 |
|
|
float global_b_level0_announcement = 4.8f; |
224 |
|
|
float global_b_level1_announcement = 11.1f; |
225 |
|
|
float global_b_level2_announcement = 21.1f; |
226 |
|
|
float global_b_levelx_announcement_factor = 6.0f / 4.0f; |
227 |
|
|
|
228 |
|
|
int global_driven_away_from_route = 0; |
229 |
|
|
|
230 |
|
|
int global_enhance_cycleway = 0; |
231 |
|
|
int global_tracking_show_real_gps_pos = 0; |
232 |
zoff99 |
46 |
int global_show_maps_debug_view = 0; |
233 |
zoff99 |
50 |
int global_cancel_preview_map_drawing = 0; |
234 |
zoff99 |
51 |
int global_night_mode = 0; |
235 |
|
|
int global_test_number = -1; |
236 |
zoff99 |
41 |
|
237 |
zoff99 |
40 |
GList *global_all_cbs = NULL; |
238 |
|
|
|
239 |
|
|
struct coord global_debug_route_seg_winner_start; |
240 |
|
|
struct coord global_debug_route_seg_winner_end; |
241 |
|
|
struct coord global_debug_seg_winner_start; |
242 |
|
|
struct coord global_debug_seg_winner_end; |
243 |
|
|
struct coord global_debug_route_seg_winner_p_start; |
244 |
|
|
struct coord global_debug_route_seg_winner_p_end; |
245 |
|
|
struct coord global_debug_seg_winner_p_start; |
246 |
|
|
struct coord global_debug_seg_route_start; |
247 |
|
|
struct coord global_debug_seg_route_end; |
248 |
|
|
struct coord global_debug_trlast_start; |
249 |
|
|
struct coord global_debug_trlast_end; |
250 |
|
|
|
251 |
|
|
struct coord *global_debug_coord_list; |
252 |
|
|
int global_debug_coord_list_items = 0; |
253 |
|
|
int global_has_gpsfix = 0; |
254 |
|
|
int global_pos_is_underground = 0; |
255 |
|
|
|
256 |
|
|
|
257 |
|
|
int global_sharp_turn_list_count = 0; |
258 |
|
|
struct global_sharp_turn *global_sharp_turn_list = NULL; |
259 |
|
|
|
260 |
|
|
int global_freetext_list_count = 0; |
261 |
|
|
struct global_freetext *global_freetext_list = NULL; |
262 |
|
|
|
263 |
|
|
|
264 |
zoff99 |
31 |
GHashTable *global_transform_hash = NULL; |
265 |
|
|
GHashTable *global_transform_hash2 = NULL; |
266 |
|
|
|
267 |
zoff99 |
28 |
long long draw_lines_count_2 = 0; |
268 |
|
|
long long draw_lines_count_3 = 0; |
269 |
|
|
long long draw_lines_count_4 = 0; |
270 |
zoff99 |
34 |
int poi_on_map_count = 0; |
271 |
|
|
int label_on_map_count = 0; |
272 |
|
|
int label_district_on_map_count = 0; |
273 |
|
|
int label_major_on_map_count = 0; |
274 |
|
|
int poi_icon_on_map_count = 0; |
275 |
zoff99 |
28 |
|
276 |
|
|
int mapdraw_time[11 + 5]; // time to draw map on screen (in 1/1000 of a second) [add 5, just in case we inc it 2 times at same time because of threads] |
277 |
|
|
int cur_mapdraw_time_index = 0; |
278 |
|
|
|
279 |
zoff99 |
30 |
int route_status_previous = 0; |
280 |
zoff99 |
31 |
long long global_route_memory_size = 0; |
281 |
zoff99 |
34 |
int global_old_vehicle_speed = -1; |
282 |
|
|
int global_old_vehicle_speed_for_autozoom = -1; |
283 |
zoff99 |
52 |
long global_scale = 100; |
284 |
zoff99 |
30 |
|
285 |
zoff99 |
27 |
void navit_add_mapset(struct navit *this_, struct mapset *ms) |
286 |
zoff99 |
2 |
{ |
287 |
|
|
this_->mapsets = g_list_append(this_->mapsets, ms); |
288 |
|
|
} |
289 |
|
|
|
290 |
|
|
struct mapset * |
291 |
|
|
navit_get_mapset(struct navit *this_) |
292 |
|
|
{ |
293 |
zoff99 |
27 |
if (this_->mapsets) |
294 |
|
|
{ |
295 |
zoff99 |
2 |
return this_->mapsets->data; |
296 |
|
|
} |
297 |
zoff99 |
27 |
else |
298 |
|
|
{ |
299 |
|
|
//DBG dbg(0,"No mapsets enabled! Is it on purpose? Navit can't draw a map. Please check your navit.xml\n"); |
300 |
|
|
} |
301 |
zoff99 |
2 |
return NULL; |
302 |
|
|
} |
303 |
|
|
|
304 |
|
|
struct tracking * |
305 |
|
|
navit_get_tracking(struct navit *this_) |
306 |
|
|
{ |
307 |
|
|
return this_->tracking; |
308 |
|
|
} |
309 |
|
|
|
310 |
|
|
/** |
311 |
|
|
* @brief Get the user data directory. |
312 |
|
|
* @param[in] create - create the directory if it does not exist |
313 |
|
|
* |
314 |
|
|
* @return char * to the data directory string. |
315 |
|
|
* |
316 |
|
|
* returns the directory used to store user data files (center.txt, |
317 |
|
|
* destination.txt, bookmark.txt, ...) |
318 |
|
|
* |
319 |
|
|
*/ |
320 |
|
|
char* |
321 |
zoff99 |
27 |
navit_get_user_data_directory(int create) |
322 |
|
|
{ |
323 |
zoff99 |
2 |
char *dir; |
324 |
zoff99 |
34 |
// dir = getenv("NAVIT_USER_DATADIR"); |
325 |
|
|
dir = navit_share_dir; |
326 |
zoff99 |
27 |
if (create && !file_exists(dir)) |
327 |
|
|
{ |
328 |
|
|
//DBG dbg(0, "creating dir %s\n", dir); |
329 |
|
|
if (file_mkdir(dir, 0)) |
330 |
|
|
{ |
331 |
|
|
//DBG dbg(0, "failed creating dir %s\n", dir); |
332 |
zoff99 |
2 |
return NULL; |
333 |
|
|
} |
334 |
|
|
} |
335 |
|
|
return dir; |
336 |
|
|
} /* end: navit_get_user_data_directory(gboolean create) */ |
337 |
|
|
|
338 |
zoff99 |
27 |
void navit_draw_async(struct navit *this_, int async) |
339 |
zoff99 |
2 |
{ |
340 |
zoff99 |
40 |
__F_START__ |
341 |
zoff99 |
30 |
|
342 |
zoff99 |
28 |
//dbg(0,"EEnter this_->blocked=%d\n",this_->blocked); |
343 |
zoff99 |
2 |
if (this_->blocked) |
344 |
|
|
{ |
345 |
|
|
this_->blocked |= 2; |
346 |
zoff99 |
28 |
//dbg(0,"set this_->blocked=%d\n",this_->blocked); |
347 |
zoff99 |
30 |
// dbg(0,"DO__DRAW:ndasync return 001\n"); |
348 |
zoff99 |
40 |
return2; |
349 |
zoff99 |
2 |
} |
350 |
zoff99 |
40 |
|
351 |
zoff99 |
2 |
transform_setup_source_rect(this_->trans); |
352 |
zoff99 |
28 |
//dbg(0,"call graphics_draw\n"); |
353 |
zoff99 |
30 |
|
354 |
|
|
// dbg(0,"DO__DRAW:gras_draw call\n"); |
355 |
zoff99 |
27 |
graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1); |
356 |
zoff99 |
30 |
// dbg(0,"DO__DRAW:ndasync leave\n"); |
357 |
zoff99 |
40 |
|
358 |
|
|
__F_END__ |
359 |
zoff99 |
2 |
} |
360 |
|
|
|
361 |
zoff99 |
27 |
void navit_draw(struct navit *this_) |
362 |
zoff99 |
2 |
{ |
363 |
zoff99 |
40 |
__F_START__ |
364 |
zoff99 |
28 |
|
365 |
|
|
//dbg(0,"EEnter this_->ready=%d\n",this_->ready); |
366 |
zoff99 |
2 |
if (this_->ready == 3) |
367 |
|
|
{ |
368 |
zoff99 |
40 |
// dbg(0,"navit_draw_async_001\n"); |
369 |
zoff99 |
30 |
// dbg(0,"DO__DRAW:navit_draw_async call\n"); |
370 |
zoff99 |
2 |
navit_draw_async(this_, 0); |
371 |
|
|
} |
372 |
zoff99 |
30 |
|
373 |
zoff99 |
40 |
__F_END__ |
374 |
zoff99 |
2 |
} |
375 |
|
|
|
376 |
zoff99 |
27 |
int navit_get_ready(struct navit *this_) |
377 |
zoff99 |
2 |
{ |
378 |
|
|
return this_->ready; |
379 |
|
|
} |
380 |
|
|
|
381 |
zoff99 |
30 |
// UNUSED ----- |
382 |
|
|
// UNUSED ----- |
383 |
zoff99 |
27 |
void navit_draw_displaylist(struct navit *this_) |
384 |
zoff99 |
2 |
{ |
385 |
|
|
if (this_->ready == 3) |
386 |
|
|
{ |
387 |
zoff99 |
27 |
// //DBG dbg(0,"call graphics_displaylist_draw 2") |
388 |
|
|
graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags | 1); |
389 |
zoff99 |
2 |
} |
390 |
|
|
} |
391 |
|
|
|
392 |
zoff99 |
27 |
static void navit_map_progress(struct navit *this_) |
393 |
zoff99 |
2 |
{ |
394 |
|
|
struct map *map; |
395 |
|
|
struct mapset *ms; |
396 |
|
|
struct mapset_handle *msh; |
397 |
|
|
struct attr attr; |
398 |
|
|
struct point p; |
399 |
|
|
if (this_->ready != 3) |
400 |
|
|
return; |
401 |
zoff99 |
27 |
p.x = 10; |
402 |
|
|
p.y = 32; |
403 |
zoff99 |
2 |
|
404 |
zoff99 |
27 |
ms = this_->mapsets->data; |
405 |
|
|
msh = mapset_open(ms); |
406 |
|
|
while (msh && (map = mapset_next(msh, 0))) |
407 |
|
|
{ |
408 |
|
|
if (map_get_attr(map, attr_progress, &attr, NULL)) |
409 |
|
|
{ |
410 |
|
|
char *str = g_strdup_printf("%s ", attr.u.str); |
411 |
zoff99 |
2 |
graphics_draw_mode(this_->gra, draw_mode_begin); |
412 |
|
|
graphics_draw_text_std(this_->gra, 16, str, &p); |
413 |
|
|
g_free(str); |
414 |
zoff99 |
27 |
p.y += 32; |
415 |
zoff99 |
2 |
graphics_draw_mode(this_->gra, draw_mode_end); |
416 |
|
|
} |
417 |
|
|
} |
418 |
|
|
mapset_close(msh); |
419 |
|
|
} |
420 |
|
|
|
421 |
zoff99 |
27 |
static void navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr) |
422 |
zoff99 |
2 |
{ |
423 |
zoff99 |
40 |
__F_START__ |
424 |
zoff99 |
28 |
|
425 |
zoff99 |
2 |
int updated; |
426 |
|
|
|
427 |
zoff99 |
27 |
if ((this_->route) && (this_->route->route_status_was_updated == 1)) |
428 |
zoff99 |
2 |
{ |
429 |
zoff99 |
27 |
this_->route->route_status_was_updated = 0; |
430 |
zoff99 |
2 |
// send route_status to java |
431 |
|
|
#ifdef HAVE_API_ANDROID |
432 |
|
|
android_return_generic_int(1, this_->route->route_status); |
433 |
|
|
#endif |
434 |
|
|
} |
435 |
|
|
|
436 |
|
|
if (attr->type != attr_route_status) |
437 |
|
|
{ |
438 |
zoff99 |
40 |
return2; |
439 |
zoff99 |
2 |
} |
440 |
zoff99 |
40 |
|
441 |
zoff99 |
27 |
updated = attr->u.num; |
442 |
zoff99 |
40 |
|
443 |
zoff99 |
2 |
if (this_->ready != 3) |
444 |
|
|
{ |
445 |
zoff99 |
40 |
return2; |
446 |
zoff99 |
2 |
} |
447 |
zoff99 |
40 |
|
448 |
zoff99 |
2 |
if (updated != route_status_path_done_new) |
449 |
|
|
{ |
450 |
zoff99 |
40 |
return2; |
451 |
zoff99 |
2 |
} |
452 |
zoff99 |
40 |
|
453 |
zoff99 |
2 |
if (this_->vehicle) |
454 |
|
|
{ |
455 |
|
|
if (this_->vehicle->follow_curr == 1) |
456 |
|
|
{ |
457 |
zoff99 |
27 |
////DBG dbg(0,"disabled -> we want redraw!!\n"); |
458 |
zoff99 |
40 |
// return2; |
459 |
zoff99 |
2 |
} |
460 |
zoff99 |
40 |
|
461 |
zoff99 |
2 |
if (this_->vehicle->follow_curr <= this_->vehicle->follow) |
462 |
|
|
{ |
463 |
zoff99 |
27 |
this_->vehicle->follow_curr = this_->vehicle->follow; |
464 |
zoff99 |
2 |
} |
465 |
|
|
} |
466 |
zoff99 |
40 |
|
467 |
|
|
// *++*-- DISABLED --*++* // navit_draw(this_); |
468 |
|
|
|
469 |
|
|
__F_END__ |
470 |
zoff99 |
2 |
} |
471 |
|
|
|
472 |
zoff99 |
27 |
void navit_handle_resize(struct navit *this_, int w, int h) |
473 |
zoff99 |
2 |
{ |
474 |
zoff99 |
40 |
__F_START__ |
475 |
zoff99 |
28 |
|
476 |
zoff99 |
2 |
struct map_selection sel; |
477 |
zoff99 |
40 |
|
478 |
zoff99 |
27 |
int callback = (this_->ready == 1); |
479 |
zoff99 |
28 |
this_->ready = this_->ready | 2; |
480 |
zoff99 |
40 |
|
481 |
zoff99 |
2 |
memset(&sel, 0, sizeof(sel)); |
482 |
zoff99 |
40 |
|
483 |
zoff99 |
27 |
this_->w = w; |
484 |
|
|
this_->h = h; |
485 |
|
|
sel.u.p_rect.rl.x = w; |
486 |
|
|
sel.u.p_rect.rl.y = h; |
487 |
zoff99 |
2 |
transform_set_screen_selection(this_->trans, &sel); |
488 |
|
|
graphics_init(this_->gra); |
489 |
|
|
graphics_set_rect(this_->gra, &sel.u.p_rect); |
490 |
zoff99 |
40 |
|
491 |
zoff99 |
27 |
if (callback) |
492 |
|
|
{ |
493 |
zoff99 |
40 |
// HINT: this triggers all the OSD drawing (next turn, ETA, etc.) |
494 |
zoff99 |
2 |
callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); |
495 |
zoff99 |
27 |
} |
496 |
zoff99 |
40 |
|
497 |
zoff99 |
2 |
if (this_->ready == 3) |
498 |
|
|
{ |
499 |
zoff99 |
40 |
// dbg(0,"navit_draw_async_007\n"); |
500 |
zoff99 |
28 |
navit_draw_async(this_, 0); |
501 |
zoff99 |
2 |
} |
502 |
zoff99 |
30 |
|
503 |
zoff99 |
40 |
__F_END__ |
504 |
zoff99 |
2 |
} |
505 |
|
|
|
506 |
zoff99 |
27 |
void navit_resize(void *data, int w, int h) |
507 |
zoff99 |
2 |
{ |
508 |
zoff99 |
27 |
struct navit *this = data; |
509 |
zoff99 |
2 |
if (!this->ignore_graphics_events) |
510 |
zoff99 |
27 |
{ |
511 |
|
|
//DBG dbg(0,"11\n"); |
512 |
zoff99 |
2 |
navit_handle_resize(this, w, h); |
513 |
zoff99 |
27 |
} |
514 |
zoff99 |
2 |
} |
515 |
|
|
|
516 |
zoff99 |
27 |
int navit_get_width(struct navit *this_) |
517 |
zoff99 |
2 |
{ |
518 |
|
|
return this_->w; |
519 |
|
|
} |
520 |
|
|
|
521 |
zoff99 |
27 |
int navit_get_height(struct navit *this_) |
522 |
zoff99 |
2 |
{ |
523 |
|
|
return this_->h; |
524 |
|
|
} |
525 |
|
|
|
526 |
zoff99 |
27 |
static void navit_popup(void *data) |
527 |
zoff99 |
2 |
{ |
528 |
zoff99 |
27 |
struct navit *this_ = data; |
529 |
zoff99 |
2 |
popup(this_, 1, &this_->pressed); |
530 |
zoff99 |
27 |
this_->button_timeout = NULL; |
531 |
|
|
this_->popped = 1; |
532 |
zoff99 |
2 |
} |
533 |
|
|
|
534 |
zoff99 |
27 |
int navit_ignore_button(struct navit *this_) |
535 |
zoff99 |
2 |
{ |
536 |
|
|
if (this_->ignore_button) |
537 |
|
|
return 1; |
538 |
zoff99 |
40 |
|
539 |
zoff99 |
27 |
this_->ignore_button = 1; |
540 |
zoff99 |
2 |
return 0; |
541 |
|
|
} |
542 |
|
|
|
543 |
zoff99 |
27 |
void navit_ignore_graphics_events(struct navit *this_, int ignore) |
544 |
zoff99 |
2 |
{ |
545 |
zoff99 |
27 |
this_->ignore_graphics_events = ignore; |
546 |
zoff99 |
2 |
} |
547 |
|
|
|
548 |
zoff99 |
28 |
void update_transformation(struct transformation *tr, struct point *old, struct point *new, struct point *rot) |
549 |
zoff99 |
2 |
{ |
550 |
zoff99 |
27 |
struct coord co, cn; |
551 |
|
|
struct coord c, *cp; |
552 |
zoff99 |
2 |
int yaw; |
553 |
zoff99 |
27 |
double angleo, anglen; |
554 |
zoff99 |
2 |
|
555 |
|
|
if (!transform_reverse(tr, old, &co)) |
556 |
|
|
return; |
557 |
zoff99 |
27 |
if (rot) |
558 |
|
|
{ |
559 |
|
|
angleo = atan2(old->y - rot->y, old->x - rot->x) * 180 / M_PI; |
560 |
|
|
anglen = atan2(new->y - rot->y, new->x - rot->x) * 180 / M_PI; |
561 |
|
|
yaw = transform_get_yaw(tr) + angleo - anglen; |
562 |
zoff99 |
2 |
transform_set_yaw(tr, yaw % 360); |
563 |
|
|
} |
564 |
|
|
if (!transform_reverse(tr, new, &cn)) |
565 |
|
|
return; |
566 |
zoff99 |
27 |
cp = transform_get_center(tr); |
567 |
|
|
c.x = cp->x + co.x - cn.x; |
568 |
|
|
c.y = cp->y + co.y - cn.y; |
569 |
|
|
// dbg(1, "from 0x%x,0x%x to 0x%x,0x%x\n", cp->x, cp->y, c.x, c.y); |
570 |
zoff99 |
2 |
transform_set_center(tr, &c); |
571 |
|
|
} |
572 |
|
|
|
573 |
zoff99 |
27 |
void navit_set_timeout(struct navit *this_) |
574 |
zoff99 |
2 |
{ |
575 |
zoff99 |
28 |
// --------- DISABLE ----------- |
576 |
|
|
return; |
577 |
|
|
// --------- DISABLE ----------- |
578 |
zoff99 |
2 |
} |
579 |
|
|
|
580 |
zoff99 |
27 |
int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback) |
581 |
zoff99 |
2 |
{ |
582 |
zoff99 |
27 |
int border = 16; |
583 |
zoff99 |
2 |
|
584 |
zoff99 |
27 |
// dbg(1, "enter %d %d (ignore %d)\n", pressed, button, this_->ignore_button); |
585 |
zoff99 |
2 |
callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p); |
586 |
zoff99 |
27 |
if (this_->ignore_button) |
587 |
|
|
{ |
588 |
|
|
this_->ignore_button = 0; |
589 |
zoff99 |
2 |
return 0; |
590 |
|
|
} |
591 |
zoff99 |
27 |
if (pressed) |
592 |
|
|
{ |
593 |
|
|
this_->pressed = *p; |
594 |
|
|
this_->last = *p; |
595 |
|
|
this_->zoomed = 0; |
596 |
|
|
if (button == 1) |
597 |
|
|
{ |
598 |
|
|
this_->button_pressed = 1; |
599 |
|
|
this_->moved = 0; |
600 |
|
|
this_->popped = 0; |
601 |
zoff99 |
28 |
// ---- DISBALED -------- |
602 |
|
|
/* |
603 |
zoff99 |
30 |
if (popup_callback) |
604 |
|
|
this_->button_timeout = event_add_timeout(500, 0, popup_callback); |
605 |
|
|
*/ |
606 |
zoff99 |
2 |
} |
607 |
|
|
if (button == 2) |
608 |
|
|
navit_set_center_screen(this_, p, 1); |
609 |
|
|
if (button == 3) |
610 |
|
|
popup(this_, button, p); |
611 |
zoff99 |
27 |
if (button == 4 && this_->use_mousewheel) |
612 |
|
|
{ |
613 |
zoff99 |
2 |
this_->zoomed = 1; |
614 |
|
|
navit_zoom_in(this_, 2, p); |
615 |
|
|
} |
616 |
zoff99 |
27 |
if (button == 5 && this_->use_mousewheel) |
617 |
|
|
{ |
618 |
zoff99 |
2 |
this_->zoomed = 1; |
619 |
|
|
navit_zoom_out(this_, 2, p); |
620 |
|
|
} |
621 |
zoff99 |
27 |
} |
622 |
|
|
else |
623 |
|
|
{ |
624 |
zoff99 |
2 |
|
625 |
zoff99 |
27 |
this_->button_pressed = 0; |
626 |
|
|
if (this_->button_timeout) |
627 |
|
|
{ |
628 |
zoff99 |
2 |
event_remove_timeout(this_->button_timeout); |
629 |
zoff99 |
27 |
this_->button_timeout = NULL; |
630 |
|
|
if (!this_->moved && !transform_within_border(this_->trans, p, border)) |
631 |
|
|
{ |
632 |
zoff99 |
2 |
navit_set_center_screen(this_, p, !this_->zoomed); |
633 |
|
|
} |
634 |
|
|
} |
635 |
zoff99 |
27 |
if (this_->motion_timeout) |
636 |
|
|
{ |
637 |
zoff99 |
2 |
event_remove_timeout(this_->motion_timeout); |
638 |
zoff99 |
27 |
this_->motion_timeout = NULL; |
639 |
zoff99 |
2 |
} |
640 |
zoff99 |
27 |
if (this_->moved) |
641 |
|
|
{ |
642 |
zoff99 |
2 |
struct point pr; |
643 |
zoff99 |
27 |
pr.x = this_->w / 2; |
644 |
|
|
pr.y = this_->h; |
645 |
zoff99 |
2 |
#if 0 |
646 |
|
|
update_transformation(this_->trans, &this_->pressed, p, &pr); |
647 |
|
|
#else |
648 |
|
|
update_transformation(this_->trans, &this_->pressed, p, NULL); |
649 |
|
|
#endif |
650 |
|
|
graphics_draw_drag(this_->gra, NULL); |
651 |
|
|
transform_copy(this_->trans, this_->trans_cursor); |
652 |
|
|
graphics_overlay_disable(this_->gra, 0); |
653 |
zoff99 |
27 |
if (!this_->zoomed) |
654 |
zoff99 |
40 |
{ |
655 |
zoff99 |
2 |
navit_set_timeout(this_); |
656 |
zoff99 |
40 |
} |
657 |
zoff99 |
2 |
navit_draw(this_); |
658 |
zoff99 |
27 |
} |
659 |
|
|
else |
660 |
zoff99 |
2 |
return 1; |
661 |
|
|
} |
662 |
|
|
return 0; |
663 |
|
|
} |
664 |
|
|
|
665 |
zoff99 |
27 |
static void navit_button(void *data, int pressed, int button, struct point *p) |
666 |
zoff99 |
2 |
{ |
667 |
zoff99 |
27 |
struct navit *this = data; |
668 |
|
|
// dbg(1, "enter %d %d ignore %d\n", pressed, button, this->ignore_graphics_events); |
669 |
|
|
if (!this->ignore_graphics_events) |
670 |
|
|
{ |
671 |
|
|
if (!this->popup_callback) |
672 |
zoff99 |
28 |
{ |
673 |
zoff99 |
27 |
this->popup_callback = callback_new_1(callback_cast(navit_popup), this); |
674 |
zoff99 |
30 |
callback_add_names(this->popup_callback, "navit_button", "navit_popup"); |
675 |
zoff99 |
28 |
} |
676 |
zoff99 |
2 |
navit_handle_button(this, pressed, button, p, this->popup_callback); |
677 |
|
|
} |
678 |
|
|
} |
679 |
|
|
|
680 |
zoff99 |
30 |
// UNUSED --- |
681 |
|
|
// UNUSED --- |
682 |
zoff99 |
27 |
static void navit_motion_timeout(struct navit *this_) |
683 |
zoff99 |
2 |
{ |
684 |
|
|
int dx, dy; |
685 |
|
|
|
686 |
zoff99 |
27 |
if (this_->drag_bitmap) |
687 |
|
|
{ |
688 |
zoff99 |
2 |
struct point point; |
689 |
zoff99 |
27 |
point.x = (this_->current.x - this_->pressed.x); |
690 |
|
|
point.y = (this_->current.y - this_->pressed.y); |
691 |
|
|
if (graphics_draw_drag(this_->gra, &point)) |
692 |
|
|
{ |
693 |
zoff99 |
2 |
graphics_overlay_disable(this_->gra, 1); |
694 |
|
|
graphics_draw_mode(this_->gra, draw_mode_end); |
695 |
zoff99 |
27 |
this_->moved = 1; |
696 |
|
|
this_->motion_timeout = NULL; |
697 |
zoff99 |
2 |
return; |
698 |
|
|
} |
699 |
zoff99 |
27 |
} |
700 |
|
|
dx = (this_->current.x - this_->last.x); |
701 |
|
|
dy = (this_->current.y - this_->last.y); |
702 |
|
|
if (dx || dy) |
703 |
|
|
{ |
704 |
zoff99 |
2 |
struct transformation *tr; |
705 |
|
|
struct point pr; |
706 |
zoff99 |
27 |
this_->last = this_->current; |
707 |
zoff99 |
2 |
graphics_overlay_disable(this_->gra, 1); |
708 |
zoff99 |
27 |
tr = transform_dup(this_->trans); |
709 |
|
|
pr.x = this_->w / 2; |
710 |
|
|
pr.y = this_->h; |
711 |
zoff99 |
2 |
#if 0 |
712 |
|
|
update_transformation(tr, &this_->pressed, &this_->current, &pr); |
713 |
|
|
#else |
714 |
|
|
update_transformation(tr, &this_->pressed, &this_->current, NULL); |
715 |
|
|
#endif |
716 |
|
|
#if 0 |
717 |
|
|
graphics_displaylist_move(this_->displaylist, dx, dy); |
718 |
|
|
#endif |
719 |
zoff99 |
30 |
graphics_draw_cancel(this_->gra, this_->displaylist); // --> calls "do_draw" normally |
720 |
zoff99 |
2 |
graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, this_->graphics_flags); |
721 |
zoff99 |
30 |
|
722 |
zoff99 |
2 |
transform_destroy(tr); |
723 |
zoff99 |
27 |
this_->moved = 1; |
724 |
zoff99 |
2 |
} |
725 |
zoff99 |
27 |
this_->motion_timeout = NULL; |
726 |
zoff99 |
2 |
return; |
727 |
|
|
} |
728 |
|
|
|
729 |
zoff99 |
27 |
void navit_handle_motion(struct navit *this_, struct point *p) |
730 |
zoff99 |
2 |
{ |
731 |
zoff99 |
40 |
__F_START__ |
732 |
|
|
|
733 |
zoff99 |
2 |
int dx, dy; |
734 |
|
|
|
735 |
zoff99 |
27 |
if (this_->button_pressed && !this_->popped) |
736 |
|
|
{ |
737 |
|
|
dx = (p->x - this_->pressed.x); |
738 |
|
|
dy = (p->y - this_->pressed.y); |
739 |
|
|
if (dx < -8 || dx > 8 || dy < -8 || dy > 8) |
740 |
|
|
{ |
741 |
|
|
this_->moved = 1; |
742 |
|
|
if (this_->button_timeout) |
743 |
|
|
{ |
744 |
zoff99 |
2 |
event_remove_timeout(this_->button_timeout); |
745 |
zoff99 |
27 |
this_->button_timeout = NULL; |
746 |
zoff99 |
2 |
} |
747 |
zoff99 |
27 |
this_->current = *p; |
748 |
zoff99 |
28 |
|
749 |
|
|
// -------- DISABLE ------- |
750 |
|
|
// -------- DISABLE ------- |
751 |
|
|
// -------- DISABLE ------- |
752 |
|
|
/* |
753 |
zoff99 |
30 |
if (!this_->motion_timeout_callback) |
754 |
|
|
this_->motion_timeout_callback = callback_new_1(callback_cast(navit_motion_timeout), this_); |
755 |
|
|
if (!this_->motion_timeout) |
756 |
|
|
this_->motion_timeout = event_add_timeout(100, 0, this_->motion_timeout_callback); |
757 |
|
|
*/ |
758 |
zoff99 |
28 |
// -------- DISABLE ------- |
759 |
|
|
// -------- DISABLE ------- |
760 |
|
|
// -------- DISABLE ------- |
761 |
zoff99 |
2 |
} |
762 |
|
|
} |
763 |
zoff99 |
40 |
|
764 |
|
|
__F_END__ |
765 |
zoff99 |
2 |
} |
766 |
|
|
|
767 |
zoff99 |
28 |
void navit_motion(void *data, struct point *p) |
768 |
zoff99 |
2 |
{ |
769 |
zoff99 |
27 |
struct navit *this = data; |
770 |
|
|
if (!this->ignore_graphics_events) |
771 |
zoff99 |
28 |
{ |
772 |
zoff99 |
2 |
navit_handle_motion(this, p); |
773 |
zoff99 |
28 |
} |
774 |
zoff99 |
2 |
} |
775 |
|
|
|
776 |
zoff99 |
40 |
void navit_predraw(struct navit *this_) |
777 |
zoff99 |
2 |
{ |
778 |
zoff99 |
40 |
__F_START__ |
779 |
|
|
|
780 |
zoff99 |
2 |
GList *l; |
781 |
|
|
struct navit_vehicle *nv; |
782 |
|
|
transform_copy(this_->trans, this_->trans_cursor); |
783 |
zoff99 |
27 |
l = this_->vehicles; |
784 |
zoff99 |
2 |
while (l) |
785 |
|
|
{ |
786 |
zoff99 |
27 |
nv = l->data; |
787 |
|
|
////DBG dbg(0,"* here *\n"); |
788 |
|
|
////DBG dbg(0,"vehicle_draw_004\n"); |
789 |
zoff99 |
2 |
navit_vehicle_draw(this_, nv, NULL); |
790 |
zoff99 |
27 |
l = g_list_next(l); |
791 |
zoff99 |
2 |
} |
792 |
zoff99 |
40 |
|
793 |
|
|
__F_END__ |
794 |
zoff99 |
2 |
} |
795 |
|
|
|
796 |
zoff99 |
27 |
static void navit_scale(struct navit *this_, long scale, struct point *p, int draw) |
797 |
zoff99 |
2 |
{ |
798 |
|
|
struct coord c1, c2, *center; |
799 |
|
|
|
800 |
|
|
if (scale < this_->zoom_min) |
801 |
|
|
{ |
802 |
zoff99 |
27 |
scale = this_->zoom_min; |
803 |
zoff99 |
2 |
} |
804 |
|
|
|
805 |
|
|
if (scale > this_->zoom_max) |
806 |
|
|
{ |
807 |
zoff99 |
27 |
scale = this_->zoom_max; |
808 |
zoff99 |
2 |
} |
809 |
|
|
|
810 |
zoff99 |
52 |
global_scale = scale; |
811 |
|
|
|
812 |
zoff99 |
2 |
// return scale value to android |
813 |
|
|
#ifdef HAVE_API_ANDROID |
814 |
|
|
android_return_generic_int(3, (int)scale); |
815 |
|
|
#endif |
816 |
|
|
|
817 |
zoff99 |
34 |
//dbg(0, "zoom to scale=%d", (int)scale); |
818 |
|
|
|
819 |
|
|
|
820 |
zoff99 |
2 |
if (p) |
821 |
|
|
{ |
822 |
|
|
transform_reverse(this_->trans, p, &c1); |
823 |
|
|
} |
824 |
|
|
|
825 |
|
|
transform_set_scale(this_->trans, scale); |
826 |
|
|
|
827 |
|
|
if (p) |
828 |
|
|
{ |
829 |
|
|
transform_reverse(this_->trans, p, &c2); |
830 |
|
|
center = transform_center(this_->trans); |
831 |
|
|
center->x += c1.x - c2.x; |
832 |
|
|
center->y += c1.y - c2.y; |
833 |
|
|
} |
834 |
|
|
|
835 |
zoff99 |
27 |
//DBG dbg(0,"aa331\n"); |
836 |
|
|
|
837 |
zoff99 |
2 |
if (draw) |
838 |
|
|
{ |
839 |
|
|
navit_draw(this_); |
840 |
|
|
} |
841 |
zoff99 |
27 |
|
842 |
|
|
//DBG dbg(0,"leave\n"); |
843 |
zoff99 |
2 |
} |
844 |
|
|
|
845 |
|
|
/** |
846 |
|
|
* @brief Automatically adjusts zoom level |
847 |
|
|
* |
848 |
|
|
* This function automatically adjusts the current |
849 |
|
|
* zoom level according to the current speed. |
850 |
|
|
* |
851 |
|
|
* @param this_ The navit struct |
852 |
|
|
* @param center The "immovable" point - i.e. the vehicles position if we're centering on the vehicle |
853 |
|
|
* @param speed The vehicles speed in meters per second |
854 |
|
|
* @param dir The direction into which the vehicle moves |
855 |
|
|
*/ |
856 |
zoff99 |
41 |
static long navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw, int *lold, int *lnew) |
857 |
zoff99 |
2 |
{ |
858 |
|
|
struct point pc; |
859 |
zoff99 |
41 |
int w, h; |
860 |
|
|
float distance; |
861 |
zoff99 |
34 |
long new_scale; |
862 |
zoff99 |
2 |
long scale; |
863 |
|
|
|
864 |
zoff99 |
27 |
if (!this_->autozoom_active) |
865 |
|
|
{ |
866 |
zoff99 |
34 |
return -1; |
867 |
zoff99 |
2 |
} |
868 |
|
|
|
869 |
zoff99 |
34 |
if (global_old_vehicle_speed < 1) |
870 |
|
|
{ |
871 |
|
|
return -1; |
872 |
|
|
} |
873 |
zoff99 |
2 |
|
874 |
zoff99 |
41 |
// --- no autozoom at slow speed --- |
875 |
|
|
//if (speed < 20) |
876 |
|
|
//{ |
877 |
|
|
// return -1; |
878 |
|
|
//} |
879 |
|
|
// --- no autozoom at slow speed --- |
880 |
zoff99 |
34 |
|
881 |
zoff99 |
41 |
|
882 |
|
|
|
883 |
zoff99 |
34 |
// this is kaputt!! |
884 |
|
|
#if 0 |
885 |
|
|
if (global_old_vehicle_speed_for_autozoom > 0) |
886 |
|
|
{ |
887 |
|
|
if (abs(global_old_vehicle_speed_for_autozoom - speed) < 10) |
888 |
|
|
{ |
889 |
|
|
// change in speed not significant |
890 |
|
|
return; |
891 |
|
|
} |
892 |
|
|
} |
893 |
|
|
global_old_vehicle_speed_for_autozoom = speed; |
894 |
|
|
#endif |
895 |
|
|
// this is kaputt!! |
896 |
|
|
|
897 |
zoff99 |
41 |
|
898 |
|
|
|
899 |
zoff99 |
34 |
// distance = speed * this_->autozoom_secs; |
900 |
|
|
if (speed > 109) |
901 |
|
|
{ |
902 |
zoff99 |
46 |
distance = (float)speed * 16.4f; |
903 |
zoff99 |
34 |
} |
904 |
zoff99 |
43 |
else if (speed > 75) |
905 |
|
|
{ |
906 |
zoff99 |
46 |
distance = (float)speed * 10.3f; |
907 |
zoff99 |
43 |
} |
908 |
zoff99 |
34 |
else |
909 |
|
|
{ |
910 |
zoff99 |
43 |
distance = (float)speed * 7.3f; |
911 |
zoff99 |
34 |
} |
912 |
|
|
|
913 |
zoff99 |
43 |
// dbg(0,"autozoom: dis1=%f\n", distance); |
914 |
|
|
|
915 |
zoff99 |
41 |
// if overspill > 1 ? |
916 |
|
|
if (global_overspill_factor > 1.0f) |
917 |
|
|
{ |
918 |
|
|
distance = distance * global_overspill_factor; |
919 |
|
|
} |
920 |
|
|
|
921 |
|
|
|
922 |
zoff99 |
34 |
// scale = this_->trans->scale * 16; |
923 |
|
|
scale = transform_get_scale(this_->trans); |
924 |
|
|
|
925 |
zoff99 |
2 |
transform_get_size(this_->trans, &w, &h); |
926 |
|
|
transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL); |
927 |
|
|
|
928 |
zoff99 |
43 |
#if 0 |
929 |
|
|
// dbg(0,"autozoom:ovrspll=%f\n", global_overspill_factor); |
930 |
|
|
dbg(0,"autozoom: dist=%f\n", distance); |
931 |
|
|
dbg(0,"autozoom: scale=%d\n", (int)scale); |
932 |
|
|
dbg(0,"autozoom:o speed=%d\n", speed); |
933 |
|
|
dbg(0,"autozoom:n speed=%d\n", global_old_vehicle_speed); |
934 |
|
|
#endif |
935 |
zoff99 |
34 |
|
936 |
zoff99 |
2 |
/* We make sure that the point we want to see is within a certain range |
937 |
|
|
* around the vehicle. The radius of this circle is the size of the |
938 |
|
|
* screen. This doesn't necessarily mean the point is visible because of |
939 |
|
|
* perspective etc. Quite rough, but should be enough. */ |
940 |
zoff99 |
27 |
|
941 |
|
|
if (w > h) |
942 |
|
|
{ |
943 |
zoff99 |
41 |
new_scale = (long)( (distance / (float)h) * 16); |
944 |
zoff99 |
2 |
} |
945 |
zoff99 |
27 |
else |
946 |
|
|
{ |
947 |
zoff99 |
41 |
new_scale = (long)( (distance / (float)w) * 16); |
948 |
zoff99 |
27 |
} |
949 |
zoff99 |
2 |
|
950 |
zoff99 |
34 |
if (new_scale < this_->autozoom_min) |
951 |
zoff99 |
27 |
{ |
952 |
zoff99 |
34 |
new_scale = this_->autozoom_min; |
953 |
zoff99 |
2 |
} |
954 |
zoff99 |
27 |
|
955 |
zoff99 |
43 |
#if 0 |
956 |
|
|
dbg(0,"autozoom:w n.scale=%d o.scale=%d\n", (int)new_scale, (int)scale); |
957 |
|
|
#endif |
958 |
zoff99 |
34 |
|
959 |
|
|
//if (abs(new_scale - scale) < 2) |
960 |
|
|
//{ |
961 |
|
|
// return; // Smoothing |
962 |
|
|
//} |
963 |
|
|
|
964 |
|
|
if (new_scale > scale) |
965 |
zoff99 |
27 |
{ |
966 |
zoff99 |
40 |
// zoom out |
967 |
zoff99 |
34 |
if (new_scale > (scale + 20)) |
968 |
|
|
{ |
969 |
|
|
scale = scale + 10; |
970 |
|
|
} |
971 |
|
|
else if (new_scale > (scale + 5)) |
972 |
|
|
{ |
973 |
|
|
scale = scale + 4; |
974 |
|
|
} |
975 |
|
|
else |
976 |
|
|
{ |
977 |
zoff99 |
41 |
scale = scale + 1; |
978 |
zoff99 |
34 |
} |
979 |
zoff99 |
27 |
} |
980 |
zoff99 |
34 |
else if (new_scale < scale) |
981 |
zoff99 |
27 |
{ |
982 |
zoff99 |
40 |
// zoom in |
983 |
zoff99 |
41 |
if ((new_scale + 220500) < scale) // lower threshold |
984 |
zoff99 |
27 |
{ |
985 |
zoff99 |
41 |
scale = (int)((float)scale * 0.85f); |
986 |
|
|
// dbg(0,"autozoom:step 8\n"); |
987 |
zoff99 |
40 |
} |
988 |
zoff99 |
41 |
else if ((new_scale + 130500) < scale) // lower threshold |
989 |
zoff99 |
40 |
{ |
990 |
zoff99 |
41 |
scale = (int)((float)scale * 0.85f); |
991 |
|
|
// dbg(0,"autozoom:step 7\n"); |
992 |
zoff99 |
40 |
} |
993 |
zoff99 |
41 |
else if ((new_scale + 4000) < scale) // lower threshold |
994 |
zoff99 |
40 |
{ |
995 |
zoff99 |
41 |
scale = (int)((float)scale * 0.85f); |
996 |
|
|
// dbg(0,"autozoom:step 6\n"); |
997 |
zoff99 |
40 |
} |
998 |
zoff99 |
41 |
else if ((new_scale + 1850) < scale) // lower threshold |
999 |
zoff99 |
40 |
{ |
1000 |
zoff99 |
41 |
// scale = scale - 1000; |
1001 |
|
|
scale = (int)((float)scale * 0.85f); |
1002 |
|
|
// dbg(0,"autozoom:step 5\n"); |
1003 |
zoff99 |
2 |
} |
1004 |
zoff99 |
41 |
else if ((new_scale + 90) < scale) // lower threshold |
1005 |
zoff99 |
34 |
{ |
1006 |
zoff99 |
41 |
// scale = scale - 200; |
1007 |
|
|
scale = (int)((float)scale * 0.85f); |
1008 |
|
|
// dbg(0,"autozoom:step 4\n"); |
1009 |
zoff99 |
34 |
} |
1010 |
zoff99 |
41 |
else if ((new_scale + 25) < scale) // lower threshold |
1011 |
|
|
{ |
1012 |
|
|
scale = scale - 8; |
1013 |
|
|
// dbg(0,"autozoom:step 3\n"); |
1014 |
|
|
} |
1015 |
|
|
else if ((new_scale + 7) < scale) // lower threshold |
1016 |
|
|
{ |
1017 |
|
|
scale = scale - 2; |
1018 |
|
|
// dbg(0,"autozoom:step 2\n"); |
1019 |
|
|
} |
1020 |
zoff99 |
34 |
else |
1021 |
|
|
{ |
1022 |
zoff99 |
41 |
scale = scale - 1; |
1023 |
|
|
// dbg(0,"autozoom:step 1\n"); |
1024 |
zoff99 |
34 |
} |
1025 |
zoff99 |
2 |
} |
1026 |
zoff99 |
34 |
else |
1027 |
|
|
{ |
1028 |
|
|
// no change |
1029 |
|
|
return -1; |
1030 |
|
|
} |
1031 |
|
|
|
1032 |
zoff99 |
41 |
// dbg(0,"autozoom:n scale=%d\n", (int)scale); |
1033 |
zoff99 |
34 |
|
1034 |
zoff99 |
41 |
// OLD zoom is applied here ------------------------- |
1035 |
|
|
struct coord c_left; |
1036 |
|
|
struct point p_left; |
1037 |
|
|
p_left.x = 0; |
1038 |
|
|
p_left.y = 200; |
1039 |
|
|
transform_reverse(this_->trans, &p_left, &c_left); |
1040 |
|
|
struct coord c_right; |
1041 |
|
|
struct point p_right; |
1042 |
|
|
p_right.x = 200; |
1043 |
|
|
p_right.y = 200; |
1044 |
|
|
transform_reverse(this_->trans, &p_right, &c_right); |
1045 |
|
|
// OLD zoom is applied here ------------------------- |
1046 |
|
|
|
1047 |
|
|
|
1048 |
zoff99 |
34 |
if (scale >= this_->autozoom_min) |
1049 |
|
|
{ |
1050 |
|
|
navit_scale(this_, (long) scale, &pc, 0); |
1051 |
|
|
} |
1052 |
|
|
else |
1053 |
|
|
{ |
1054 |
|
|
//if (scale != this_->autozoom_min) |
1055 |
|
|
//{ |
1056 |
|
|
navit_scale(this_, this_->autozoom_min, &pc, 0); |
1057 |
|
|
//} |
1058 |
|
|
} |
1059 |
|
|
|
1060 |
zoff99 |
41 |
// new zoom is applied here already ----------------- |
1061 |
|
|
struct point p_new_left; |
1062 |
|
|
transform(global_navit->trans, transform_get_projection(this_->trans), &c_left, &p_new_left, 1, 0, 0, NULL); |
1063 |
|
|
struct point p_new_right; |
1064 |
|
|
transform(global_navit->trans, transform_get_projection(this_->trans), &c_right, &p_new_right, 1, 0, 0, NULL); |
1065 |
|
|
|
1066 |
|
|
*lold = 200; |
1067 |
|
|
*lnew = abs(p_new_right.x - p_new_left.x); |
1068 |
|
|
// new zoom is applied here already ----------------- |
1069 |
|
|
|
1070 |
|
|
|
1071 |
zoff99 |
34 |
// return new scale value |
1072 |
|
|
return scale; |
1073 |
zoff99 |
2 |
} |
1074 |
|
|
|
1075 |
|
|
/** |
1076 |
|
|
* Change the current zoom level, zooming closer to the ground |
1077 |
|
|
* |
1078 |
|
|
* @param navit The navit instance |
1079 |
|
|
* @param factor The zoom factor, usually 2 |
1080 |
|
|
* @param p The invariant point (if set to NULL, default to center) |
1081 |
|
|
* @returns nothing |
1082 |
|
|
*/ |
1083 |
zoff99 |
27 |
void navit_zoom_in(struct navit *this_, int factor, struct point *p) |
1084 |
zoff99 |
2 |
{ |
1085 |
zoff99 |
27 |
long scale = transform_get_scale(this_->trans) / factor; |
1086 |
zoff99 |
2 |
if (scale < 1) |
1087 |
zoff99 |
34 |
{ |
1088 |
zoff99 |
27 |
scale = 1; |
1089 |
zoff99 |
34 |
} |
1090 |
zoff99 |
27 |
////DBG dbg(0,"zoom in -> scale=%d",scale); |
1091 |
zoff99 |
2 |
navit_scale(this_, scale, p, 1); |
1092 |
|
|
} |
1093 |
|
|
|
1094 |
|
|
/** |
1095 |
|
|
* Change the current zoom level |
1096 |
|
|
* |
1097 |
|
|
* @param navit The navit instance |
1098 |
|
|
* @param factor The zoom factor, usually 2 |
1099 |
|
|
* @param p The invariant point (if set to NULL, default to center) |
1100 |
|
|
* @returns nothing |
1101 |
|
|
*/ |
1102 |
zoff99 |
27 |
void navit_zoom_out(struct navit *this_, int factor, struct point *p) |
1103 |
zoff99 |
2 |
{ |
1104 |
zoff99 |
27 |
long scale = transform_get_scale(this_->trans) * factor; |
1105 |
|
|
////DBG dbg(0,"zoom out -> scale=%d",scale); |
1106 |
zoff99 |
2 |
navit_scale(this_, scale, p, 1); |
1107 |
|
|
} |
1108 |
|
|
|
1109 |
zoff99 |
27 |
int navit_get_cur_pnt(struct navit *this_, struct point *p) |
1110 |
zoff99 |
2 |
{ |
1111 |
|
|
return navit_get_cursor_pnt(this_, p, 0, NULL); |
1112 |
|
|
} |
1113 |
|
|
|
1114 |
zoff99 |
27 |
void navit_zoom_in_cursor(struct navit *this_, int factor) |
1115 |
zoff99 |
2 |
{ |
1116 |
|
|
struct point p; |
1117 |
zoff99 |
27 |
if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) |
1118 |
|
|
{ |
1119 |
zoff99 |
2 |
navit_zoom_in(this_, factor, &p); |
1120 |
zoff99 |
27 |
this_->vehicle->follow_curr = this_->vehicle->follow; |
1121 |
|
|
} |
1122 |
|
|
else |
1123 |
zoff99 |
34 |
{ |
1124 |
zoff99 |
2 |
navit_zoom_in(this_, factor, NULL); |
1125 |
zoff99 |
34 |
} |
1126 |
zoff99 |
2 |
} |
1127 |
|
|
|
1128 |
zoff99 |
41 |
void navit_zoom_to_scale_no_draw(struct navit *this_, int new_scale) |
1129 |
|
|
{ |
1130 |
|
|
long scale = transform_get_scale(this_->trans); |
1131 |
|
|
long new_scale_long = new_scale; |
1132 |
|
|
|
1133 |
|
|
// only do something if scale changed! |
1134 |
|
|
if (scale != new_scale_long) |
1135 |
|
|
{ |
1136 |
|
|
navit_scale(this_, new_scale_long, NULL, 0); |
1137 |
|
|
} |
1138 |
|
|
} |
1139 |
|
|
|
1140 |
|
|
|
1141 |
zoff99 |
27 |
void navit_zoom_to_scale(struct navit *this_, int new_scale) |
1142 |
zoff99 |
2 |
{ |
1143 |
zoff99 |
27 |
long scale = transform_get_scale(this_->trans); |
1144 |
|
|
long new_scale_long = new_scale; |
1145 |
|
|
//DBG dbg(0,"zoom to scale -> old scale=%d",scale); |
1146 |
|
|
//DBG dbg(0,"zoom to scale -> want scale=%d",new_scale_long); |
1147 |
zoff99 |
2 |
|
1148 |
|
|
// only do something if scale changed! |
1149 |
|
|
if (scale != new_scale_long) |
1150 |
|
|
{ |
1151 |
|
|
navit_scale(this_, new_scale_long, NULL, 1); |
1152 |
|
|
} |
1153 |
|
|
} |
1154 |
|
|
|
1155 |
zoff99 |
28 |
void navit_zoom_to_scale_with_center_point(struct navit *this_, int new_scale, struct point *p) |
1156 |
|
|
{ |
1157 |
|
|
long scale = transform_get_scale(this_->trans); |
1158 |
|
|
long new_scale_long = new_scale; |
1159 |
|
|
|
1160 |
zoff99 |
34 |
//dbg(0, "zoom to scale -> old scale=%d", scale); |
1161 |
|
|
//dbg(0, "zoom to scale -> want scale=%d", new_scale_long); |
1162 |
|
|
|
1163 |
zoff99 |
28 |
// only do something if scale changed! |
1164 |
|
|
if (scale != new_scale_long) |
1165 |
|
|
{ |
1166 |
|
|
navit_scale(this_, new_scale_long, p, 1); |
1167 |
|
|
} |
1168 |
|
|
} |
1169 |
|
|
|
1170 |
zoff99 |
27 |
void navit_zoom_out_cursor(struct navit *this_, int factor) |
1171 |
zoff99 |
2 |
{ |
1172 |
|
|
struct point p; |
1173 |
zoff99 |
27 |
if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) |
1174 |
|
|
{ |
1175 |
zoff99 |
2 |
navit_zoom_out(this_, 2, &p); |
1176 |
zoff99 |
27 |
this_->vehicle->follow_curr = this_->vehicle->follow; |
1177 |
|
|
} |
1178 |
|
|
else |
1179 |
zoff99 |
34 |
{ |
1180 |
zoff99 |
2 |
navit_zoom_out(this_, 2, NULL); |
1181 |
zoff99 |
34 |
} |
1182 |
zoff99 |
2 |
} |
1183 |
|
|
|
1184 |
zoff99 |
27 |
static int navit_cmd_zoom_in(struct navit *this_) |
1185 |
zoff99 |
2 |
{ |
1186 |
|
|
navit_zoom_in_cursor(this_, 2); |
1187 |
|
|
return 0; |
1188 |
|
|
} |
1189 |
|
|
|
1190 |
zoff99 |
27 |
static int navit_cmd_zoom_out(struct navit *this_) |
1191 |
zoff99 |
2 |
{ |
1192 |
|
|
navit_zoom_out_cursor(this_, 2); |
1193 |
|
|
return 0; |
1194 |
|
|
} |
1195 |
|
|
|
1196 |
zoff99 |
27 |
static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1197 |
zoff99 |
2 |
{ |
1198 |
zoff99 |
27 |
if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1199 |
|
|
{ |
1200 |
zoff99 |
2 |
navit_say(this, in[0]->u.str); |
1201 |
zoff99 |
27 |
} |
1202 |
zoff99 |
2 |
} |
1203 |
|
|
|
1204 |
|
|
static GHashTable *cmd_int_var_hash = NULL; |
1205 |
|
|
static GHashTable *cmd_attr_var_hash = NULL; |
1206 |
|
|
|
1207 |
|
|
/** |
1208 |
|
|
* Store key value pair for the command system (for int typed values) |
1209 |
|
|
* |
1210 |
|
|
* @param navit The navit instance |
1211 |
|
|
* @param function unused (needed to match command function signiture) |
1212 |
|
|
* @param in input attributes in[0] is the key string, in[1] is the integer value to store |
1213 |
|
|
* @param out output attributes, unused |
1214 |
|
|
* @param valid unused |
1215 |
|
|
* @returns nothing |
1216 |
|
|
*/ |
1217 |
zoff99 |
27 |
static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1218 |
zoff99 |
2 |
{ |
1219 |
|
|
char*key; |
1220 |
|
|
struct attr*val; |
1221 |
zoff99 |
27 |
if (!cmd_int_var_hash) |
1222 |
|
|
{ |
1223 |
zoff99 |
2 |
cmd_int_var_hash = g_hash_table_new(g_str_hash, g_str_equal); |
1224 |
|
|
} |
1225 |
|
|
|
1226 |
zoff99 |
27 |
if ((in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) && (in && in[1] && ATTR_IS_NUMERIC(in[1]->type))) |
1227 |
|
|
{ |
1228 |
zoff99 |
2 |
val = g_new(struct attr,1); |
1229 |
zoff99 |
27 |
attr_dup_content(in[1], val); |
1230 |
zoff99 |
2 |
key = g_strdup(in[0]->u.str); |
1231 |
|
|
g_hash_table_insert(cmd_int_var_hash, key, val); |
1232 |
zoff99 |
27 |
} |
1233 |
zoff99 |
2 |
} |
1234 |
|
|
|
1235 |
|
|
/** |
1236 |
|
|
* Store key value pair for the command system (for attr typed values, can be used as opaque handles) |
1237 |
|
|
* |
1238 |
|
|
* @param navit The navit instance |
1239 |
|
|
* @param function unused (needed to match command function signiture) |
1240 |
|
|
* @param in input attributes in[0] is the key string, in[1] is the attr* value to store |
1241 |
|
|
* @param out output attributes, unused |
1242 |
|
|
* @param valid unused |
1243 |
|
|
* @returns nothing |
1244 |
|
|
*/ |
1245 |
|
|
//TODO free stored attributes on navit_destroy |
1246 |
zoff99 |
27 |
static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1247 |
zoff99 |
2 |
{ |
1248 |
|
|
char*key; |
1249 |
|
|
struct attr*val; |
1250 |
zoff99 |
27 |
if (!cmd_attr_var_hash) |
1251 |
|
|
{ |
1252 |
zoff99 |
2 |
cmd_attr_var_hash = g_hash_table_new(g_str_hash, g_str_equal); |
1253 |
|
|
} |
1254 |
|
|
|
1255 |
zoff99 |
27 |
if ((in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) && (in && in[1])) |
1256 |
|
|
{ |
1257 |
zoff99 |
2 |
val = attr_dup(in[1]); |
1258 |
|
|
//val = in[1]; |
1259 |
|
|
key = g_strdup(in[0]->u.str); |
1260 |
|
|
g_hash_table_insert(cmd_attr_var_hash, key, val); |
1261 |
zoff99 |
27 |
} |
1262 |
zoff99 |
2 |
} |
1263 |
|
|
|
1264 |
|
|
/** |
1265 |
|
|
* command to toggle the active state of a named layer of the current layout |
1266 |
|
|
* |
1267 |
|
|
* @param navit The navit instance |
1268 |
|
|
* @param function unused (needed to match command function signiture) |
1269 |
|
|
* @param in input attribute in[0] is the name of the layer |
1270 |
|
|
* @param out output unused |
1271 |
|
|
* @param valid unused |
1272 |
|
|
* @returns nothing |
1273 |
|
|
*/ |
1274 |
zoff99 |
27 |
static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1275 |
zoff99 |
2 |
{ |
1276 |
zoff99 |
27 |
if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1277 |
|
|
{ |
1278 |
|
|
if (this->layout_current && this->layout_current->layers) |
1279 |
|
|
{ |
1280 |
zoff99 |
2 |
GList* layers = this->layout_current->layers; |
1281 |
zoff99 |
27 |
while (layers) |
1282 |
|
|
{ |
1283 |
|
|
struct layer*l = layers->data; |
1284 |
|
|
if (l && !strcmp(l->name, in[0]->u.str)) |
1285 |
|
|
{ |
1286 |
zoff99 |
2 |
l->active ^= 1; |
1287 |
|
|
navit_draw(this); |
1288 |
|
|
return; |
1289 |
|
|
} |
1290 |
zoff99 |
27 |
layers = g_list_next(layers); |
1291 |
zoff99 |
2 |
} |
1292 |
|
|
} |
1293 |
zoff99 |
27 |
} |
1294 |
zoff99 |
2 |
} |
1295 |
|
|
|
1296 |
zoff99 |
40 |
|
1297 |
zoff99 |
41 |
void navit_enhance_cycleway(struct navit *this) |
1298 |
|
|
{ |
1299 |
|
|
GList *itms; |
1300 |
|
|
struct itemgra *itm; |
1301 |
|
|
struct element *e; |
1302 |
|
|
GList *es, *types; |
1303 |
|
|
int found = 0; |
1304 |
|
|
GList* layers = this->layout_current->layers; |
1305 |
|
|
|
1306 |
|
|
global_enhance_cycleway = 1; |
1307 |
|
|
|
1308 |
|
|
while (layers) |
1309 |
|
|
{ |
1310 |
|
|
|
1311 |
|
|
struct layer*l = layers->data; |
1312 |
|
|
if (l) |
1313 |
|
|
{ |
1314 |
|
|
|
1315 |
|
|
itms = l->itemgras; |
1316 |
|
|
while (itms) |
1317 |
|
|
{ |
1318 |
|
|
itm = itms->data; |
1319 |
|
|
found = 0; |
1320 |
|
|
|
1321 |
|
|
types = itm->type; |
1322 |
|
|
while (types) |
1323 |
|
|
{ |
1324 |
|
|
if (GPOINTER_TO_INT(types->data) == type_cycleway) |
1325 |
|
|
{ |
1326 |
|
|
found = 1; |
1327 |
|
|
} |
1328 |
|
|
types = g_list_next(types); |
1329 |
|
|
} |
1330 |
|
|
|
1331 |
|
|
if (found == 1) |
1332 |
|
|
{ |
1333 |
|
|
|
1334 |
|
|
dbg(0, "CYC:001:min=%d max=%d\n", itm->order.min, itm->order.max); |
1335 |
|
|
|
1336 |
|
|
if (itm->order.min == 14) |
1337 |
|
|
{ |
1338 |
|
|
itm->order.min = 10; |
1339 |
|
|
} |
1340 |
|
|
|
1341 |
|
|
es = itm->elements; |
1342 |
|
|
while (es) |
1343 |
|
|
{ |
1344 |
|
|
e = es->data; |
1345 |
|
|
|
1346 |
|
|
if (e->type == element_polyline) |
1347 |
|
|
{ |
1348 |
|
|
e->u.polyline.width = e->u.polyline.width * 2; |
1349 |
|
|
} |
1350 |
|
|
|
1351 |
|
|
es = g_list_next(es); |
1352 |
|
|
} |
1353 |
|
|
} |
1354 |
|
|
|
1355 |
|
|
itms = g_list_next(itms); |
1356 |
|
|
} |
1357 |
|
|
|
1358 |
|
|
} |
1359 |
|
|
layers = g_list_next(layers); |
1360 |
|
|
|
1361 |
|
|
} |
1362 |
|
|
|
1363 |
|
|
} |
1364 |
|
|
|
1365 |
|
|
|
1366 |
|
|
void navit_reset_cycleway(struct navit *this) |
1367 |
|
|
{ |
1368 |
|
|
GList *itms; |
1369 |
|
|
struct itemgra *itm; |
1370 |
|
|
struct element *e; |
1371 |
|
|
GList *es, *types; |
1372 |
|
|
int found = 0; |
1373 |
|
|
GList* layers = this->layout_current->layers; |
1374 |
|
|
|
1375 |
|
|
global_enhance_cycleway = 0; |
1376 |
|
|
|
1377 |
|
|
while (layers) |
1378 |
|
|
{ |
1379 |
|
|
|
1380 |
|
|
struct layer*l = layers->data; |
1381 |
|
|
if (l) |
1382 |
|
|
{ |
1383 |
|
|
|
1384 |
|
|
itms = l->itemgras; |
1385 |
|
|
while (itms) |
1386 |
|
|
{ |
1387 |
|
|
itm = itms->data; |
1388 |
|
|
found = 0; |
1389 |
|
|
|
1390 |
|
|
types = itm->type; |
1391 |
|
|
while (types) |
1392 |
|
|
{ |
1393 |
|
|
if (GPOINTER_TO_INT(types->data) == type_cycleway) |
1394 |
|
|
{ |
1395 |
|
|
found = 1; |
1396 |
|
|
} |
1397 |
|
|
types = g_list_next(types); |
1398 |
|
|
} |
1399 |
|
|
|
1400 |
|
|
if (found == 1) |
1401 |
|
|
{ |
1402 |
|
|
if (itm->order.min == 10) |
1403 |
|
|
{ |
1404 |
|
|
itm->order.min = 14; |
1405 |
|
|
} |
1406 |
|
|
|
1407 |
|
|
es = itm->elements; |
1408 |
|
|
while (es) |
1409 |
|
|
{ |
1410 |
|
|
e = es->data; |
1411 |
|
|
|
1412 |
|
|
if (e->type == element_polyline) |
1413 |
|
|
{ |
1414 |
|
|
e->u.polyline.width = e->u.polyline.width / 2; |
1415 |
|
|
} |
1416 |
|
|
|
1417 |
|
|
es = g_list_next(es); |
1418 |
|
|
} |
1419 |
|
|
} |
1420 |
|
|
|
1421 |
|
|
itms = g_list_next(itms); |
1422 |
|
|
} |
1423 |
|
|
|
1424 |
|
|
} |
1425 |
|
|
layers = g_list_next(layers); |
1426 |
|
|
|
1427 |
|
|
} |
1428 |
|
|
|
1429 |
|
|
} |
1430 |
|
|
|
1431 |
|
|
|
1432 |
zoff99 |
40 |
void navit_layer_toggle_active(struct navit *this, char *name, int draw) |
1433 |
|
|
{ |
1434 |
|
|
if (name) |
1435 |
|
|
{ |
1436 |
|
|
if (this->layout_current && this->layout_current->layers) |
1437 |
|
|
{ |
1438 |
|
|
GList* layers = this->layout_current->layers; |
1439 |
|
|
while (layers) |
1440 |
|
|
{ |
1441 |
|
|
struct layer *l = layers->data; |
1442 |
|
|
if (l && !strcmp(l->name, name)) |
1443 |
|
|
{ |
1444 |
|
|
l->active ^= 1; |
1445 |
|
|
if (draw == 1) |
1446 |
|
|
{ |
1447 |
|
|
navit_draw(this); |
1448 |
|
|
} |
1449 |
|
|
return; |
1450 |
|
|
} |
1451 |
|
|
layers = g_list_next(layers); |
1452 |
|
|
} |
1453 |
|
|
} |
1454 |
|
|
} |
1455 |
|
|
} |
1456 |
|
|
|
1457 |
|
|
|
1458 |
|
|
|
1459 |
zoff99 |
2 |
/** |
1460 |
zoff99 |
28 |
* command to set the active state of a named layer of the current layout |
1461 |
|
|
* |
1462 |
|
|
* @param navit The navit instance |
1463 |
|
|
* @param name name of the layer |
1464 |
|
|
* @param active 0 -> inactive, 1 -> active |
1465 |
|
|
* @param draw 0 -> dont redraw, 1 -> redraw |
1466 |
|
|
* @returns nothing |
1467 |
|
|
*/ |
1468 |
|
|
void navit_layer_set_active(struct navit *this, char *name, int active, int draw) |
1469 |
|
|
{ |
1470 |
|
|
if (name) |
1471 |
|
|
{ |
1472 |
|
|
if (this->layout_current && this->layout_current->layers) |
1473 |
|
|
{ |
1474 |
|
|
GList* layers = this->layout_current->layers; |
1475 |
|
|
while (layers) |
1476 |
|
|
{ |
1477 |
|
|
struct layer *l = layers->data; |
1478 |
|
|
if (l && !strcmp(l->name, name)) |
1479 |
|
|
{ |
1480 |
|
|
l->active = active; |
1481 |
|
|
if (draw == 1) |
1482 |
|
|
{ |
1483 |
|
|
navit_draw(this); |
1484 |
|
|
} |
1485 |
|
|
return; |
1486 |
|
|
} |
1487 |
|
|
layers = g_list_next(layers); |
1488 |
|
|
} |
1489 |
|
|
} |
1490 |
|
|
} |
1491 |
|
|
} |
1492 |
|
|
|
1493 |
|
|
/** |
1494 |
zoff99 |
2 |
* adds an item with the current coordinate of the vehicle to a named map |
1495 |
|
|
* |
1496 |
|
|
* @param navit The navit instance |
1497 |
|
|
* @param function unused (needed to match command function signiture) |
1498 |
|
|
* @param in input attribute in[0] is the name of the map |
1499 |
|
|
* @param out output attribute, 0 on error or the id of the created item on success |
1500 |
|
|
* @param valid unused |
1501 |
|
|
* @returns nothing |
1502 |
|
|
*/ |
1503 |
zoff99 |
27 |
static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1504 |
zoff99 |
2 |
{ |
1505 |
|
|
struct attr **list = g_new0(struct attr *,2); |
1506 |
|
|
struct attr*val = g_new0(struct attr,1); |
1507 |
|
|
struct mapset* ms; |
1508 |
|
|
struct map_selection sel; |
1509 |
|
|
const int selection_range = 10; |
1510 |
|
|
enum item_type item_type; |
1511 |
|
|
struct item *it; |
1512 |
|
|
struct map* curr_map = NULL; |
1513 |
|
|
struct coord curr_coord; |
1514 |
|
|
struct map_rect *mr; |
1515 |
|
|
|
1516 |
zoff99 |
27 |
val->type = attr_type_item_begin; |
1517 |
|
|
val->u.item = NULL; //return invalid item on error |
1518 |
|
|
list[0] = val; |
1519 |
|
|
list[1] = NULL; |
1520 |
zoff99 |
2 |
*out = list; |
1521 |
zoff99 |
27 |
if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name |
1522 |
|
|
in[1] && ATTR_IS_STRING(in[1]->type) && in[1]->u.str //item type |
1523 |
|
|
) |
1524 |
|
|
{ |
1525 |
zoff99 |
2 |
|
1526 |
zoff99 |
27 |
if (!(ms = navit_get_mapset(this))) |
1527 |
|
|
{ |
1528 |
zoff99 |
2 |
return; |
1529 |
|
|
} |
1530 |
|
|
|
1531 |
zoff99 |
27 |
if ((item_type = item_from_name(in[1]->u.str)) == type_none) |
1532 |
|
|
{ |
1533 |
zoff99 |
2 |
return; |
1534 |
|
|
} |
1535 |
|
|
|
1536 |
|
|
curr_map = mapset_get_map_by_name(ms, in[0]->u.str); |
1537 |
|
|
|
1538 |
|
|
//no map with the given name found |
1539 |
zoff99 |
27 |
if (!curr_map) |
1540 |
|
|
{ |
1541 |
zoff99 |
2 |
return; |
1542 |
|
|
} |
1543 |
zoff99 |
27 |
|
1544 |
|
|
if (this->vehicle && this->vehicle->vehicle) |
1545 |
|
|
{ |
1546 |
zoff99 |
2 |
struct attr pos_attr; |
1547 |
zoff99 |
27 |
if (vehicle_get_attr(this->vehicle->vehicle, attr_position_coord_geo, &pos_attr, NULL)) |
1548 |
|
|
{ |
1549 |
zoff99 |
2 |
transform_from_geo(projection_mg, pos_attr.u.coord_geo, &curr_coord); |
1550 |
zoff99 |
27 |
} |
1551 |
|
|
else |
1552 |
|
|
{ |
1553 |
zoff99 |
2 |
return; |
1554 |
|
|
} |
1555 |
zoff99 |
27 |
} |
1556 |
|
|
else |
1557 |
|
|
{ |
1558 |
zoff99 |
2 |
return; |
1559 |
|
|
} |
1560 |
|
|
|
1561 |
zoff99 |
27 |
sel.next = NULL; |
1562 |
|
|
sel.order = 18; |
1563 |
|
|
sel.range.min = type_none; |
1564 |
|
|
sel.range.max = type_tec_common; |
1565 |
|
|
sel.u.c_rect.lu.x = curr_coord.x - selection_range; |
1566 |
|
|
sel.u.c_rect.lu.y = curr_coord.y + selection_range; |
1567 |
|
|
sel.u.c_rect.rl.x = curr_coord.x + selection_range; |
1568 |
|
|
sel.u.c_rect.rl.y = curr_coord.y - selection_range; |
1569 |
|
|
|
1570 |
zoff99 |
2 |
mr = map_rect_new(curr_map, &sel); |
1571 |
zoff99 |
27 |
if (mr) |
1572 |
|
|
{ |
1573 |
|
|
it = map_rect_create_item(mr, item_type); |
1574 |
|
|
item_coord_set(it, &curr_coord, 1, change_mode_modify); |
1575 |
|
|
val->u.item = it; |
1576 |
zoff99 |
2 |
} |
1577 |
|
|
map_rect_destroy(mr); |
1578 |
zoff99 |
27 |
} |
1579 |
zoff99 |
2 |
} |
1580 |
|
|
|
1581 |
|
|
/** |
1582 |
|
|
* sets an attribute (name value pair) of a map item specified by map name and item id |
1583 |
|
|
* |
1584 |
|
|
* @param navit The navit instance |
1585 |
|
|
* @param function unused (needed to match command function signiture) |
1586 |
|
|
* @param in input attribute in[0] - name of the map ; in[1] - item ; in[2] - attr name ; in[3] - attr value |
1587 |
|
|
* @param out output attribute, 0 on error, 1 on success |
1588 |
|
|
* @param valid unused |
1589 |
|
|
* @returns nothing |
1590 |
|
|
*/ |
1591 |
zoff99 |
27 |
static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1592 |
zoff99 |
2 |
{ |
1593 |
zoff99 |
27 |
if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name |
1594 |
|
|
in[1] && ATTR_IS_ITEM(in[1]->type) && //item |
1595 |
|
|
in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str |
1596 |
|
|
in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str |
1597 |
|
|
) |
1598 |
|
|
{ |
1599 |
zoff99 |
2 |
struct attr attr_to_set; |
1600 |
|
|
struct map* curr_map = NULL; |
1601 |
|
|
struct mapset *ms; |
1602 |
|
|
struct map_selection sel; |
1603 |
|
|
const int selection_range = 500; |
1604 |
|
|
struct coord curr_coord; |
1605 |
|
|
struct item *it; |
1606 |
zoff99 |
27 |
|
1607 |
|
|
if (ATTR_IS_STRING(attr_from_name(in[2]->u.str))) |
1608 |
|
|
{ |
1609 |
zoff99 |
2 |
attr_to_set.u.str = in[3]->u.str; |
1610 |
|
|
attr_to_set.type = attr_from_name(in[2]->u.str); |
1611 |
|
|
} |
1612 |
zoff99 |
27 |
else if (ATTR_IS_INT(attr_from_name(in[2]->u.str))) |
1613 |
|
|
{ |
1614 |
zoff99 |
2 |
attr_to_set.u.num = atoi(in[3]->u.str); |
1615 |
|
|
attr_to_set.type = attr_from_name(in[2]->u.str); |
1616 |
|
|
} |
1617 |
zoff99 |
27 |
else if (ATTR_IS_DOUBLE(attr_from_name(in[2]->u.str))) |
1618 |
|
|
{ |
1619 |
zoff99 |
2 |
double* val = g_new0(double,1); |
1620 |
|
|
*val = atof(in[3]->u.str); |
1621 |
|
|
attr_to_set.u.numd = val; |
1622 |
|
|
attr_to_set.type = attr_from_name(in[2]->u.str); |
1623 |
|
|
} |
1624 |
|
|
|
1625 |
|
|
ms = navit_get_mapset(this); |
1626 |
|
|
|
1627 |
|
|
curr_map = mapset_get_map_by_name(ms, in[0]->u.str); |
1628 |
|
|
|
1629 |
zoff99 |
27 |
if (!curr_map) |
1630 |
|
|
{ |
1631 |
zoff99 |
2 |
return; |
1632 |
|
|
} |
1633 |
zoff99 |
27 |
sel.next = NULL; |
1634 |
|
|
sel.order = 18; |
1635 |
|
|
sel.range.min = type_none; |
1636 |
|
|
sel.range.max = type_tec_common; |
1637 |
|
|
sel.u.c_rect.lu.x = curr_coord.x - selection_range; |
1638 |
|
|
sel.u.c_rect.lu.y = curr_coord.y + selection_range; |
1639 |
|
|
sel.u.c_rect.rl.x = curr_coord.x + selection_range; |
1640 |
|
|
sel.u.c_rect.rl.y = curr_coord.y - selection_range; |
1641 |
|
|
|
1642 |
zoff99 |
2 |
it = in[1]->u.item; |
1643 |
zoff99 |
27 |
if (it) |
1644 |
|
|
{ |
1645 |
zoff99 |
2 |
item_attr_set(it, &attr_to_set, change_mode_modify); |
1646 |
|
|
} |
1647 |
|
|
} |
1648 |
|
|
} |
1649 |
|
|
|
1650 |
|
|
/** |
1651 |
|
|
* Get attr variable given a key string for the command system (for opaque usage) |
1652 |
|
|
* |
1653 |
|
|
* @param navit The navit instance |
1654 |
|
|
* @param function unused (needed to match command function signiture) |
1655 |
|
|
* @param in input attribute in[0] is the key string |
1656 |
|
|
* @param out output attribute, the attr for the given key string if exists or NULL |
1657 |
|
|
* @param valid unused |
1658 |
|
|
* @returns nothing |
1659 |
|
|
*/ |
1660 |
zoff99 |
27 |
static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1661 |
zoff99 |
2 |
{ |
1662 |
|
|
struct attr **list = g_new0(struct attr *,2); |
1663 |
zoff99 |
27 |
if (!cmd_int_var_hash) |
1664 |
|
|
{ |
1665 |
zoff99 |
2 |
struct attr*val = g_new0(struct attr,1); |
1666 |
zoff99 |
27 |
val->type = attr_type_item_begin; |
1667 |
zoff99 |
2 |
val->u.item = NULL; |
1668 |
zoff99 |
27 |
list[0] = val; |
1669 |
zoff99 |
2 |
} |
1670 |
zoff99 |
27 |
if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1671 |
|
|
{ |
1672 |
zoff99 |
2 |
struct attr*ret = g_hash_table_lookup(cmd_attr_var_hash, in[0]->u.str); |
1673 |
zoff99 |
27 |
if (ret) |
1674 |
|
|
{ |
1675 |
zoff99 |
2 |
list[0] = attr_dup(ret); |
1676 |
|
|
} |
1677 |
zoff99 |
27 |
else |
1678 |
|
|
{ |
1679 |
zoff99 |
2 |
struct attr*val = g_new0(struct attr,1); |
1680 |
zoff99 |
27 |
val->type = attr_type_int_begin; |
1681 |
zoff99 |
2 |
val->u.item = NULL; |
1682 |
zoff99 |
27 |
list[0] = val; |
1683 |
zoff99 |
2 |
} |
1684 |
zoff99 |
27 |
} |
1685 |
zoff99 |
2 |
list[1] = NULL; |
1686 |
|
|
*out = list; |
1687 |
|
|
} |
1688 |
|
|
|
1689 |
|
|
/** |
1690 |
|
|
* Get value given a key string for the command system |
1691 |
|
|
* |
1692 |
|
|
* @param navit The navit instance |
1693 |
|
|
* @param function unused (needed to match command function signiture) |
1694 |
|
|
* @param in input attribute in[0] is the key string |
1695 |
|
|
* @param out output attribute, the value for the given key string if exists or 0 |
1696 |
|
|
* @param valid unused |
1697 |
|
|
* @returns nothing |
1698 |
|
|
*/ |
1699 |
zoff99 |
27 |
static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1700 |
zoff99 |
2 |
{ |
1701 |
|
|
struct attr **list = g_new0(struct attr *,2); |
1702 |
zoff99 |
27 |
if (!cmd_int_var_hash) |
1703 |
|
|
{ |
1704 |
zoff99 |
2 |
struct attr*val = g_new0(struct attr,1); |
1705 |
zoff99 |
27 |
val->type = attr_type_int_begin; |
1706 |
|
|
val->u.num = 0; |
1707 |
|
|
list[0] = val; |
1708 |
zoff99 |
2 |
} |
1709 |
zoff99 |
27 |
if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1710 |
|
|
{ |
1711 |
zoff99 |
2 |
struct attr*ret = g_hash_table_lookup(cmd_int_var_hash, in[0]->u.str); |
1712 |
zoff99 |
27 |
if (ret) |
1713 |
|
|
{ |
1714 |
zoff99 |
2 |
list[0] = ret; |
1715 |
|
|
} |
1716 |
zoff99 |
27 |
else |
1717 |
|
|
{ |
1718 |
zoff99 |
2 |
struct attr*val = g_new0(struct attr,1); |
1719 |
zoff99 |
27 |
val->type = attr_type_int_begin; |
1720 |
|
|
val->u.num = 0; |
1721 |
|
|
list[0] = val; |
1722 |
zoff99 |
2 |
} |
1723 |
zoff99 |
27 |
} |
1724 |
zoff99 |
2 |
list[1] = NULL; |
1725 |
|
|
*out = list; |
1726 |
|
|
} |
1727 |
|
|
|
1728 |
|
|
GList *cmd_int_var_stack = NULL; |
1729 |
|
|
|
1730 |
|
|
/** |
1731 |
|
|
* Push an integer to the stack for the command system |
1732 |
|
|
* |
1733 |
|
|
* @param navit The navit instance |
1734 |
|
|
* @param function unused (needed to match command function signiture) |
1735 |
|
|
* @param in input attribute in[0] is the integer attibute to push |
1736 |
|
|
* @param out output attributes, unused |
1737 |
|
|
* @param valid unused |
1738 |
|
|
* @returns nothing |
1739 |
|
|
*/ |
1740 |
zoff99 |
27 |
static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1741 |
zoff99 |
2 |
{ |
1742 |
zoff99 |
27 |
if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type)) |
1743 |
|
|
{ |
1744 |
zoff99 |
2 |
struct attr*val = g_new(struct attr,1); |
1745 |
zoff99 |
27 |
attr_dup_content(in[0], val); |
1746 |
zoff99 |
2 |
cmd_int_var_stack = g_list_prepend(cmd_int_var_stack, val); |
1747 |
|
|
} |
1748 |
|
|
} |
1749 |
|
|
|
1750 |
|
|
/** |
1751 |
|
|
* Pop an integer from the command system's integer stack |
1752 |
|
|
* |
1753 |
|
|
* @param navit The navit instance |
1754 |
|
|
* @param function unused (needed to match command function signiture) |
1755 |
|
|
* @param in input attributes unused |
1756 |
|
|
* @param out output attribute, the value popped if stack isn't empty or 0 |
1757 |
|
|
* @param valid unused |
1758 |
|
|
* @returns nothing |
1759 |
|
|
*/ |
1760 |
zoff99 |
27 |
static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1761 |
zoff99 |
2 |
{ |
1762 |
|
|
struct attr **list = g_new0(struct attr *,2); |
1763 |
zoff99 |
27 |
if (!cmd_int_var_stack) |
1764 |
|
|
{ |
1765 |
zoff99 |
2 |
struct attr*val = g_new0(struct attr,1); |
1766 |
|
|
val->type = attr_type_int_begin; |
1767 |
zoff99 |
27 |
val->u.num = 0; |
1768 |
|
|
list[0] = val; |
1769 |
zoff99 |
2 |
} |
1770 |
zoff99 |
27 |
else |
1771 |
|
|
{ |
1772 |
zoff99 |
2 |
list[0] = cmd_int_var_stack->data; |
1773 |
zoff99 |
27 |
cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack); |
1774 |
zoff99 |
2 |
} |
1775 |
|
|
list[1] = NULL; |
1776 |
|
|
*out = list; |
1777 |
|
|
} |
1778 |
|
|
|
1779 |
|
|
/** |
1780 |
|
|
* Get current size of command system's integer stack |
1781 |
|
|
* |
1782 |
|
|
* @param navit The navit instance |
1783 |
|
|
* @param function unused (needed to match command function signiture) |
1784 |
|
|
* @param in input attributes unused |
1785 |
|
|
* @param out output attribute, the size of stack |
1786 |
|
|
* @param valid unused |
1787 |
|
|
* @returns nothing |
1788 |
|
|
*/ |
1789 |
zoff99 |
27 |
static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1790 |
zoff99 |
2 |
{ |
1791 |
|
|
struct attr **list; |
1792 |
zoff99 |
27 |
struct attr *attr = g_new0(struct attr ,1); |
1793 |
|
|
attr->type = attr_type_int_begin; |
1794 |
|
|
if (!cmd_int_var_stack) |
1795 |
|
|
{ |
1796 |
|
|
attr->u.num = 0; |
1797 |
zoff99 |
2 |
} |
1798 |
zoff99 |
27 |
else |
1799 |
|
|
{ |
1800 |
|
|
attr->u.num = g_list_length(cmd_int_var_stack); |
1801 |
|
|
}list = g_new0(struct attr *,2); |
1802 |
zoff99 |
2 |
list[0] = attr; |
1803 |
|
|
list[1] = NULL; |
1804 |
|
|
*out = list; |
1805 |
zoff99 |
27 |
cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack); |
1806 |
zoff99 |
2 |
} |
1807 |
|
|
|
1808 |
zoff99 |
27 |
static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1809 |
zoff99 |
2 |
{ |
1810 |
|
|
struct pcoord pc; |
1811 |
zoff99 |
27 |
char *description = NULL; |
1812 |
zoff99 |
2 |
if (!in) |
1813 |
|
|
return; |
1814 |
|
|
if (!in[0]) |
1815 |
|
|
return; |
1816 |
|
|
pc.pro = transform_get_projection(this->trans); |
1817 |
zoff99 |
27 |
if (ATTR_IS_COORD(in[0]->type)) |
1818 |
|
|
{ |
1819 |
|
|
pc.x = in[0]->u.coord->x; |
1820 |
|
|
pc.y = in[0]->u.coord->y; |
1821 |
zoff99 |
2 |
in++; |
1822 |
zoff99 |
27 |
} |
1823 |
|
|
else if (ATTR_IS_PCOORD(in[0]->type)) |
1824 |
|
|
{ |
1825 |
|
|
pc = *in[0]->u.pcoord; |
1826 |
zoff99 |
2 |
in++; |
1827 |
zoff99 |
27 |
} |
1828 |
|
|
else if (in[1] && in[2] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type) && ATTR_IS_INT(in[2]->type)) |
1829 |
|
|
{ |
1830 |
|
|
pc.pro = in[0]->u.num; |
1831 |
|
|
pc.x = in[1]->u.num; |
1832 |
|
|
pc.y = in[2]->u.num; |
1833 |
|
|
in += 3; |
1834 |
|
|
} |
1835 |
|
|
else if (in[1] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type)) |
1836 |
|
|
{ |
1837 |
|
|
pc.x = in[0]->u.num; |
1838 |
|
|
pc.y = in[1]->u.num; |
1839 |
|
|
in += 2; |
1840 |
|
|
} |
1841 |
|
|
else |
1842 |
|
|
{ |
1843 |
zoff99 |
2 |
return; |
1844 |
zoff99 |
27 |
} |
1845 |
zoff99 |
2 |
if (in[0] && ATTR_IS_STRING(in[0]->type)) |
1846 |
zoff99 |
27 |
{ |
1847 |
|
|
description = in[0]->u.str; |
1848 |
|
|
} |
1849 |
zoff99 |
2 |
navit_set_destination(this, &pc, description, 1); |
1850 |
|
|
} |
1851 |
|
|
|
1852 |
zoff99 |
27 |
static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1853 |
zoff99 |
2 |
{ |
1854 |
|
|
struct attr attr; |
1855 |
zoff99 |
27 |
attr.type = attr_type_string_begin; |
1856 |
|
|
attr.u.str = "Fix me"; |
1857 |
|
|
if (out) |
1858 |
|
|
{ |
1859 |
|
|
*out = attr_generic_add_attr(*out, &attr); |
1860 |
zoff99 |
2 |
} |
1861 |
|
|
} |
1862 |
|
|
|
1863 |
|
|
/** |
1864 |
|
|
* Join several string attributes into one |
1865 |
|
|
* |
1866 |
|
|
* @param navit The navit instance |
1867 |
|
|
* @param function unused (needed to match command function signiture) |
1868 |
|
|
* @param in input attributes in[0] - separator, in[1..] - attributes to join |
1869 |
|
|
* @param out output attribute joined attribute as string |
1870 |
|
|
* @param valid unused |
1871 |
|
|
* @returns nothing |
1872 |
|
|
*/ |
1873 |
zoff99 |
27 |
static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1874 |
zoff99 |
2 |
{ |
1875 |
|
|
struct attr attr; |
1876 |
|
|
gchar *ret, *sep; |
1877 |
|
|
int i; |
1878 |
zoff99 |
27 |
attr.type = attr_type_string_begin; |
1879 |
|
|
attr.u.str = NULL; |
1880 |
|
|
if (in[0] && in[1]) |
1881 |
|
|
{ |
1882 |
|
|
sep = attr_to_text(in[0], NULL, 1); |
1883 |
|
|
ret = attr_to_text(in[1], NULL, 1); |
1884 |
|
|
for (i = 2; in[i]; i++) |
1885 |
|
|
{ |
1886 |
|
|
gchar *in_i = attr_to_text(in[i], NULL, 1); |
1887 |
|
|
gchar *r = g_strjoin(sep, ret, in_i, NULL); |
1888 |
zoff99 |
2 |
g_free(in_i); |
1889 |
|
|
g_free(ret); |
1890 |
zoff99 |
27 |
ret = r; |
1891 |
zoff99 |
2 |
} |
1892 |
|
|
g_free(sep); |
1893 |
zoff99 |
27 |
attr.u.str = ret; |
1894 |
|
|
if (out) |
1895 |
|
|
{ |
1896 |
|
|
*out = attr_generic_add_attr(*out, &attr); |
1897 |
zoff99 |
2 |
} |
1898 |
|
|
g_free(ret); |
1899 |
|
|
} |
1900 |
|
|
} |
1901 |
|
|
|
1902 |
|
|
/** |
1903 |
|
|
* Call external program |
1904 |
|
|
* |
1905 |
|
|
* @param navit The navit instance |
1906 |
|
|
* @param function unused (needed to match command function signiture) |
1907 |
|
|
* @param in input attributes in[0] - name of executable, in[1..] - parameters |
1908 |
|
|
* @param out output attribute unused |
1909 |
|
|
* @param valid unused |
1910 |
|
|
* @returns nothing |
1911 |
|
|
*/ |
1912 |
zoff99 |
27 |
static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1913 |
zoff99 |
2 |
{ |
1914 |
zoff99 |
27 |
int i, j, nparms, nvalid; |
1915 |
|
|
const char ** argv = NULL; |
1916 |
zoff99 |
2 |
struct spawn_process_info *pi; |
1917 |
|
|
|
1918 |
zoff99 |
27 |
nparms = 0; |
1919 |
|
|
nvalid = 0; |
1920 |
|
|
if (in) |
1921 |
|
|
{ |
1922 |
|
|
while (in[nparms]) |
1923 |
|
|
{ |
1924 |
|
|
if (in[nparms]->type != attr_none) |
1925 |
zoff99 |
2 |
nvalid++; |
1926 |
|
|
nparms++; |
1927 |
|
|
} |
1928 |
|
|
} |
1929 |
zoff99 |
27 |
|
1930 |
|
|
if (nvalid > 0) |
1931 |
|
|
{ |
1932 |
zoff99 |
2 |
argv=g_new(char*,nvalid+1); |
1933 |
zoff99 |
27 |
for (i = 0, j = 0; in[i]; i++) |
1934 |
|
|
{ |
1935 |
|
|
if (in[i]->type != attr_none) |
1936 |
|
|
{ |
1937 |
|
|
argv[j++] = attr_to_text(in[i], NULL, 1); |
1938 |
zoff99 |
2 |
} |
1939 |
zoff99 |
27 |
else |
1940 |
|
|
{ |
1941 |
|
|
//DBG dbg(0, "Parameter #%i is attr_none - skipping\n", i); |
1942 |
|
|
} |
1943 |
zoff99 |
2 |
} |
1944 |
zoff99 |
27 |
argv[j] = NULL; |
1945 |
|
|
pi = spawn_process(argv); |
1946 |
|
|
|
1947 |
zoff99 |
2 |
// spawn_process() testing suite - uncomment following code to test. |
1948 |
|
|
//sleep(3); |
1949 |
|
|
// example of non-blocking wait |
1950 |
zoff99 |
27 |
//int st=spawn_process_check_status(pi,0);//DBG dbg(0,"status %i\n",st); |
1951 |
zoff99 |
2 |
// example of blocking wait |
1952 |
zoff99 |
27 |
//st=spawn_process_check_status(pi,1);//DBG dbg(0,"status %i\n",st); |
1953 |
zoff99 |
2 |
// example of wait after process is finished and status is |
1954 |
|
|
// already tested |
1955 |
zoff99 |
27 |
//st=spawn_process_check_status(pi,1);//DBG dbg(0,"status %i\n",st); |
1956 |
zoff99 |
2 |
// example of wait after process is finished and status is |
1957 |
|
|
// already tested - unblocked |
1958 |
zoff99 |
27 |
//st=spawn_process_check_status(pi,0);//DBG dbg(0,"status %i\n",st); |
1959 |
|
|
|
1960 |
zoff99 |
2 |
// End testing suite |
1961 |
|
|
spawn_process_info_free(pi); |
1962 |
zoff99 |
27 |
for (i = 0; argv[i]; i++) |
1963 |
zoff99 |
2 |
g_free(argv[i]); |
1964 |
|
|
g_free(argv); |
1965 |
|
|
} |
1966 |
|
|
} |
1967 |
|
|
|
1968 |
zoff99 |
30 |
static struct command_table |
1969 |
|
|
commands[] = |
1970 |
|
|
{ { "zoom_in", command_cast(navit_cmd_zoom_in) }, { "zoom_out", command_cast(navit_cmd_zoom_out) }, { "zoom_to_route", command_cast(navit_cmd_zoom_to_route) }, { "say", command_cast(navit_cmd_say) }, { "set_center_cursor", command_cast(navit_cmd_set_center_cursor) }, { "set_destination", command_cast(navit_cmd_set_destination) }, { "announcer_toggle", command_cast(navit_cmd_announcer_toggle) }, { "fmt_coordinates", command_cast(navit_cmd_fmt_coordinates) }, { "set_int_var", command_cast(navit_cmd_set_int_var) }, { "get_int_var", command_cast(navit_cmd_get_int_var) }, { "push_int", command_cast(navit_cmd_push_int) }, { "pop_int", command_cast(navit_cmd_pop_int) }, { "int_stack_size", command_cast(navit_cmd_int_stack_size) }, { "toggle_layer", command_cast(navit_cmd_toggle_layer) }, { "strjoin", command_cast(navit_cmd_strjoin) }, { "spawn", command_cast(navit_cmd_spawn) }, { "map_add_curr_pos", command_cast(navit_cmd_map_add_curr_pos) }, { "map_item_set_attr", command_cast(navit_cmd_map_item_set_attr) }, { "set_attr_var", command_cast(navit_cmd_set_attr_var) }, { "get_attr_var", command_cast(navit_cmd_get_attr_var) }, }; |
1971 |
zoff99 |
2 |
|
1972 |
zoff99 |
27 |
void navit_command_add_table(struct navit*this_, struct command_table *commands, int count) |
1973 |
zoff99 |
2 |
{ |
1974 |
zoff99 |
27 |
command_add_table(this_->attr_cbl, commands, count, this_); |
1975 |
zoff99 |
2 |
} |
1976 |
|
|
|
1977 |
zoff99 |
40 |
|
1978 |
zoff99 |
2 |
struct navit * |
1979 |
|
|
navit_new(struct attr *parent, struct attr **attrs) |
1980 |
|
|
{ |
1981 |
|
|
struct navit *this_=g_new0(struct navit, 1); |
1982 |
|
|
struct pcoord center; |
1983 |
|
|
struct coord co; |
1984 |
|
|
struct coord_geo g; |
1985 |
zoff99 |
27 |
enum projection pro = projection_mg; |
1986 |
zoff99 |
2 |
int zoom = 256; |
1987 |
zoff99 |
27 |
g.lat = 53.13; |
1988 |
|
|
g.lng = 11.70; |
1989 |
zoff99 |
2 |
|
1990 |
zoff99 |
40 |
|
1991 |
|
|
global_demo_vehicle = 0; |
1992 |
|
|
global_demo_vehicle_short_switch = 0; |
1993 |
|
|
|
1994 |
|
|
|
1995 |
|
|
// set base for timestamps |
1996 |
|
|
struct timeval tv2; |
1997 |
|
|
if (gettimeofday(&tv2, NULL) == -1) |
1998 |
|
|
{ |
1999 |
|
|
global_last_spoken_base = 0; |
2000 |
|
|
} |
2001 |
|
|
else |
2002 |
|
|
{ |
2003 |
|
|
global_last_spoken_base = (long)tv2.tv_sec; |
2004 |
|
|
} |
2005 |
|
|
|
2006 |
|
|
global_debug_coord_list = g_new0(struct coord, (2 * (MAX_DEBUG_COORDS + 2))); |
2007 |
|
|
global_debug_coord_list_items = 0; |
2008 |
|
|
|
2009 |
|
|
global_debug_route_seg_winner_start.x = 0; |
2010 |
|
|
global_debug_route_seg_winner_start.y = 0; |
2011 |
|
|
global_debug_route_seg_winner_end.x = 0; |
2012 |
|
|
global_debug_route_seg_winner_end.y = 0; |
2013 |
|
|
|
2014 |
|
|
global_debug_seg_winner_start.x = 0; |
2015 |
|
|
global_debug_seg_winner_start.y = 0; |
2016 |
|
|
global_debug_seg_winner_end.x = 0; |
2017 |
|
|
global_debug_seg_winner_end.y = 0; |
2018 |
|
|
|
2019 |
|
|
global_debug_route_seg_winner_p_start.x = 0; |
2020 |
|
|
global_debug_route_seg_winner_p_start.y = 0; |
2021 |
|
|
|
2022 |
|
|
global_debug_seg_winner_p_start.x = 0; |
2023 |
|
|
global_debug_seg_winner_p_start.y = 0; |
2024 |
|
|
|
2025 |
|
|
global_debug_seg_route_start.x = 0; |
2026 |
|
|
global_debug_seg_route_start.y = 0; |
2027 |
|
|
|
2028 |
|
|
global_debug_seg_route_end.x = 0; |
2029 |
|
|
global_debug_seg_route_end.y = 0; |
2030 |
|
|
|
2031 |
|
|
|
2032 |
|
|
|
2033 |
zoff99 |
27 |
this_->self.type = attr_navit; |
2034 |
|
|
this_->self.u.navit = this_; |
2035 |
zoff99 |
40 |
this_->attr_cbl = callback_list_new("navit_new:this_->attr_cbl"); |
2036 |
zoff99 |
2 |
|
2037 |
zoff99 |
27 |
this_->orientation = -1; |
2038 |
|
|
this_->tracking_flag = 1; |
2039 |
|
|
this_->recentdest_count = 10; |
2040 |
|
|
this_->osd_configuration = -1; |
2041 |
zoff99 |
2 |
|
2042 |
|
|
// changed default to 1 |
2043 |
|
|
this_->center_timeout = 1; |
2044 |
|
|
this_->use_mousewheel = 1; |
2045 |
|
|
this_->autozoom_secs = 10; |
2046 |
zoff99 |
41 |
this_->autozoom_min = 5; |
2047 |
zoff99 |
2 |
this_->autozoom_active = 0; |
2048 |
|
|
this_->zoom_min = 1; |
2049 |
|
|
this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3; |
2050 |
|
|
this_->follow_cursor = 1; |
2051 |
|
|
this_->radius = 30; |
2052 |
|
|
this_->border = 16; |
2053 |
|
|
|
2054 |
zoff99 |
30 |
// dbg(0, "GGGGG:set global_navit\n"); |
2055 |
|
|
global_navit = this_; |
2056 |
|
|
|
2057 |
zoff99 |
2 |
this_->trans = transform_new(); |
2058 |
|
|
this_->trans_cursor = transform_new(); |
2059 |
|
|
transform_from_geo(pro, &g, &co); |
2060 |
zoff99 |
27 |
center.x = co.x; |
2061 |
|
|
center.y = co.y; |
2062 |
zoff99 |
2 |
center.pro = pro; |
2063 |
|
|
|
2064 |
zoff99 |
31 |
transform_init(); |
2065 |
|
|
|
2066 |
zoff99 |
27 |
//DBG dbg(0, "setting center from xmlfile [hardcoded]\n"); |
2067 |
zoff99 |
2 |
transform_setup(this_->trans, ¢er, zoom, (this_->orientation != -1) ? this_->orientation : 0); |
2068 |
|
|
|
2069 |
zoff99 |
31 |
// initialze trans_cursor here |
2070 |
zoff99 |
2 |
transform_copy(this_->trans, this_->trans_cursor); |
2071 |
zoff99 |
31 |
// initialze trans_cursor here |
2072 |
zoff99 |
2 |
|
2073 |
zoff99 |
31 |
|
2074 |
|
|
dbg(0, "ii 001\n"); |
2075 |
zoff99 |
27 |
this_->bookmarks = bookmarks_new(&this_->self, NULL, this_->trans); |
2076 |
zoff99 |
31 |
//this_->bookmarks = NULL; |
2077 |
|
|
dbg(0, "ii 002\n"); |
2078 |
zoff99 |
2 |
|
2079 |
zoff99 |
27 |
this_->prevTs = 0; |
2080 |
zoff99 |
2 |
|
2081 |
zoff99 |
27 |
for (; *attrs; attrs++) |
2082 |
|
|
{ |
2083 |
zoff99 |
2 |
navit_set_attr_do(this_, *attrs, 1); |
2084 |
|
|
} |
2085 |
zoff99 |
27 |
this_->displaylist = graphics_displaylist_new(); |
2086 |
|
|
command_add_table(this_->attr_cbl, commands, sizeof(commands) / sizeof(struct command_table), this_); |
2087 |
zoff99 |
2 |
|
2088 |
zoff99 |
31 |
dbg(0, "ii 009\n"); |
2089 |
|
|
|
2090 |
zoff99 |
27 |
// this_->messages = messagelist_new(attrs); |
2091 |
zoff99 |
2 |
|
2092 |
zoff99 |
31 |
dbg(0, "111111\n"); |
2093 |
zoff99 |
27 |
|
2094 |
zoff99 |
2 |
return this_; |
2095 |
|
|
} |
2096 |
|
|
|
2097 |
zoff99 |
27 |
static int navit_set_gui(struct navit *this_, struct gui *gui) |
2098 |
zoff99 |
2 |
{ |
2099 |
|
|
if (this_->gui) |
2100 |
|
|
return 0; |
2101 |
zoff99 |
40 |
|
2102 |
zoff99 |
27 |
this_->gui = gui; |
2103 |
zoff99 |
40 |
|
2104 |
zoff99 |
27 |
if (gui_has_main_loop(this_->gui)) |
2105 |
|
|
{ |
2106 |
|
|
if (!main_loop_gui) |
2107 |
|
|
{ |
2108 |
|
|
main_loop_gui = this_->gui; |
2109 |
|
|
} |
2110 |
|
|
else |
2111 |
|
|
{ |
2112 |
|
|
//DBG dbg(0, "gui with main loop already active, ignoring this instance"); |
2113 |
zoff99 |
2 |
return 0; |
2114 |
|
|
} |
2115 |
|
|
} |
2116 |
|
|
return 1; |
2117 |
|
|
} |
2118 |
|
|
|
2119 |
zoff99 |
27 |
void navit_add_message(struct navit *this_, char *message) |
2120 |
zoff99 |
2 |
{ |
2121 |
zoff99 |
27 |
// message_new(this_->messages, message); |
2122 |
zoff99 |
2 |
} |
2123 |
|
|
|
2124 |
zoff99 |
27 |
struct message *navit_get_messages(struct navit *this_) |
2125 |
zoff99 |
2 |
{ |
2126 |
zoff99 |
27 |
// return message_get(this_->messages); |
2127 |
zoff99 |
2 |
} |
2128 |
|
|
|
2129 |
zoff99 |
27 |
static int navit_set_graphics(struct navit *this_, struct graphics *gra) |
2130 |
zoff99 |
2 |
{ |
2131 |
|
|
if (this_->gra) |
2132 |
zoff99 |
40 |
{ |
2133 |
zoff99 |
2 |
return 0; |
2134 |
zoff99 |
40 |
} |
2135 |
|
|
|
2136 |
zoff99 |
27 |
this_->gra = gra; |
2137 |
zoff99 |
28 |
|
2138 |
|
|
/* |
2139 |
zoff99 |
30 |
this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_); |
2140 |
|
|
graphics_add_callback(gra, this_->resize_callback); |
2141 |
|
|
this_->button_callback = callback_new_attr_1(callback_cast(navit_button), attr_button, this_); |
2142 |
|
|
graphics_add_callback(gra, this_->button_callback); |
2143 |
|
|
this_->motion_callback = callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_); |
2144 |
|
|
graphics_add_callback(gra, this_->motion_callback); |
2145 |
|
|
*/ |
2146 |
zoff99 |
28 |
|
2147 |
|
|
// this draw the vehicle // very stupid |
2148 |
zoff99 |
27 |
this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_); |
2149 |
zoff99 |
30 |
callback_add_names(this_->predraw_callback, "navit_set_graphics", "navit_predraw"); |
2150 |
zoff99 |
2 |
graphics_add_callback(gra, this_->predraw_callback); |
2151 |
zoff99 |
28 |
|
2152 |
zoff99 |
2 |
return 1; |
2153 |
|
|
} |
2154 |
|
|
|
2155 |
|
|
struct graphics * |
2156 |
|
|
navit_get_graphics(struct navit *this_) |
2157 |
|
|
{ |
2158 |
|
|
return this_->gra; |
2159 |
|
|
} |
2160 |
|
|
|
2161 |
|
|
struct vehicleprofile * |
2162 |
|
|
navit_get_vehicleprofile(struct navit *this_) |
2163 |
|
|
{ |
2164 |
|
|
return this_->vehicleprofile; |
2165 |
|
|
} |
2166 |
|
|
|
2167 |
|
|
GList * |
2168 |
|
|
navit_get_vehicleprofiles(struct navit *this_) |
2169 |
|
|
{ |
2170 |
|
|
return this_->vehicleprofiles; |
2171 |
|
|
} |
2172 |
|
|
|
2173 |
zoff99 |
27 |
static void navit_projection_set(struct navit *this_, enum projection pro, int draw) |
2174 |
zoff99 |
2 |
{ |
2175 |
zoff99 |
40 |
|
2176 |
|
|
|
2177 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2178 |
zoff99 |
2 |
struct coord_geo g; |
2179 |
|
|
struct coord *c; |
2180 |
|
|
|
2181 |
zoff99 |
27 |
c = transform_center(this_->trans); |
2182 |
zoff99 |
2 |
transform_to_geo(transform_get_projection(this_->trans), c, &g); |
2183 |
|
|
transform_set_projection(this_->trans, pro); |
2184 |
|
|
transform_from_geo(pro, &g, c); |
2185 |
|
|
if (draw) |
2186 |
zoff99 |
28 |
{ |
2187 |
zoff99 |
2 |
navit_draw(this_); |
2188 |
zoff99 |
28 |
} |
2189 |
zoff99 |
2 |
} |
2190 |
|
|
|
2191 |
|
|
/** |
2192 |
|
|
* Start the route computing to a given set of coordinates |
2193 |
|
|
* |
2194 |
|
|
* @param navit The navit instance |
2195 |
|
|
* @param c The coordinate to start routing to |
2196 |
|
|
* @param description A label which allows the user to later identify this destination in the former destinations selection |
2197 |
|
|
* @returns nothing |
2198 |
|
|
*/ |
2199 |
zoff99 |
27 |
void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async) |
2200 |
zoff99 |
2 |
{ |
2201 |
zoff99 |
40 |
|
2202 |
|
|
|
2203 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2204 |
zoff99 |
2 |
char *destination_file; |
2205 |
zoff99 |
27 |
if (c) |
2206 |
|
|
{ |
2207 |
|
|
this_->destination = *c; |
2208 |
|
|
this_->destination_valid = 1; |
2209 |
|
|
//dbg(0, "navit->navit_set_destination %i\n", c->x); |
2210 |
|
|
//dbg(0, "navit->navit_set_destination %i\n", c->y); |
2211 |
|
|
} |
2212 |
|
|
else |
2213 |
|
|
{ |
2214 |
|
|
this_->destination_valid = 0; |
2215 |
|
|
} |
2216 |
|
|
//destination_file = bookmarks_get_destination_file(TRUE); |
2217 |
|
|
//bookmarks_append_coord(this_->bookmarks, destination_file, c, 1, "former_destination", description, NULL, this_->recentdest_count); |
2218 |
|
|
//g_free(destination_file); |
2219 |
|
|
callback_list_call_attr_0(this_->attr_cbl, attr_destination); |
2220 |
|
|
if (this_->route) |
2221 |
|
|
{ |
2222 |
|
|
//dbg(0, "navit->navit_set_destination 2: %i %i\n", c->x, c->y); |
2223 |
zoff99 |
2 |
|
2224 |
|
|
route_set_destination(this_->route, c, async); |
2225 |
|
|
if (this_->ready == 3) |
2226 |
zoff99 |
27 |
{ |
2227 |
zoff99 |
2 |
navit_draw(this_); |
2228 |
zoff99 |
27 |
} |
2229 |
zoff99 |
2 |
} |
2230 |
|
|
} |
2231 |
|
|
|
2232 |
|
|
/** |
2233 |
zoff99 |
27 |
* add a waypoint to an active route |
2234 |
|
|
* |
2235 |
|
|
* @param navit The navit instance |
2236 |
|
|
* @param c The coordinate of the waypoint |
2237 |
|
|
* @param description A dummy string |
2238 |
|
|
* @returns nothing |
2239 |
|
|
*/ |
2240 |
|
|
void navit_add_waypoint_to_route(struct navit *this_, struct pcoord *c, const char *description, int async) |
2241 |
|
|
{ |
2242 |
zoff99 |
40 |
|
2243 |
|
|
|
2244 |
zoff99 |
27 |
if (this_->destination_valid == 1) |
2245 |
|
|
{ |
2246 |
|
|
//int count = 0; |
2247 |
|
|
//count = g_list_length(this_->route->destinations); |
2248 |
|
|
//DBG dbg(0, "count=%d\n", count); |
2249 |
|
|
|
2250 |
|
|
//dbg(0, "navit->navit_add_waypoint_to_route 1: %i %i\n", c->x, c->y); |
2251 |
|
|
|
2252 |
|
|
route_add_destination(this_->route, c, async); |
2253 |
|
|
|
2254 |
|
|
this_->destination = *c; |
2255 |
|
|
this_->destination_valid = 1; |
2256 |
|
|
} |
2257 |
|
|
else |
2258 |
|
|
{ |
2259 |
|
|
//dbg(0, "navit->navit_add_waypoint_to_route 2: %i %i\n", c->x, c->y); |
2260 |
|
|
navit_set_destination(this_, c, description, async); |
2261 |
|
|
} |
2262 |
|
|
} |
2263 |
|
|
|
2264 |
|
|
/** |
2265 |
zoff99 |
2 |
* Start the route computing to a given set of coordinates including waypoints |
2266 |
|
|
* |
2267 |
|
|
* @param navit The navit instance |
2268 |
|
|
* @param c The coordinate to start routing to |
2269 |
|
|
* @param description A label which allows the user to later identify this destination in the former destinations selection |
2270 |
|
|
* @returns nothing |
2271 |
|
|
*/ |
2272 |
zoff99 |
27 |
void navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async) |
2273 |
zoff99 |
2 |
{ |
2274 |
zoff99 |
40 |
|
2275 |
|
|
|
2276 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2277 |
zoff99 |
2 |
char *destination_file; |
2278 |
zoff99 |
27 |
if (c && count) |
2279 |
|
|
{ |
2280 |
|
|
this_->destination = c[count - 1]; |
2281 |
|
|
this_->destination_valid = 1; |
2282 |
|
|
//dbg(0, "navit->navit_set_destinations 1: %i %i\n", c[count-1].x, c[count-1].y); |
2283 |
|
|
} |
2284 |
|
|
else |
2285 |
|
|
{ |
2286 |
|
|
this_->destination_valid = 0; |
2287 |
|
|
} |
2288 |
|
|
//destination_file = bookmarks_get_destination_file(TRUE); |
2289 |
|
|
//bookmarks_append_coord(this_->bookmarks, destination_file, c, count, "former_itinerary", description, NULL, this_->recentdest_count); |
2290 |
|
|
//g_free(destination_file); |
2291 |
zoff99 |
2 |
callback_list_call_attr_0(this_->attr_cbl, attr_destination); |
2292 |
zoff99 |
27 |
if (this_->route) |
2293 |
|
|
{ |
2294 |
zoff99 |
2 |
route_set_destinations(this_->route, c, count, async); |
2295 |
|
|
if (this_->ready == 3) |
2296 |
zoff99 |
27 |
{ |
2297 |
zoff99 |
2 |
navit_draw(this_); |
2298 |
zoff99 |
27 |
} |
2299 |
zoff99 |
2 |
} |
2300 |
|
|
} |
2301 |
|
|
|
2302 |
|
|
/** |
2303 |
|
|
* @brief Checks if a route is calculated |
2304 |
|
|
* |
2305 |
|
|
* This function checks if a route is calculated. |
2306 |
|
|
* |
2307 |
|
|
* @param this_ The navit struct whose route should be checked. |
2308 |
|
|
* @return True if the route is set, false otherwise. |
2309 |
|
|
*/ |
2310 |
zoff99 |
27 |
int navit_check_route(struct navit *this_) |
2311 |
zoff99 |
2 |
{ |
2312 |
zoff99 |
40 |
|
2313 |
|
|
|
2314 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2315 |
|
|
if (this_->route) |
2316 |
|
|
{ |
2317 |
zoff99 |
2 |
return route_get_path_set(this_->route); |
2318 |
|
|
} |
2319 |
|
|
|
2320 |
|
|
return 0; |
2321 |
|
|
} |
2322 |
|
|
|
2323 |
zoff99 |
27 |
static int navit_former_destinations_active(struct navit *this_) |
2324 |
zoff99 |
2 |
{ |
2325 |
zoff99 |
40 |
|
2326 |
|
|
|
2327 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2328 |
|
|
|
2329 |
|
|
return 0; |
2330 |
|
|
// disable this function!! |
2331 |
|
|
|
2332 |
|
|
|
2333 |
zoff99 |
2 |
char *destination_file = bookmarks_get_destination_file(FALSE); |
2334 |
|
|
FILE *f; |
2335 |
zoff99 |
27 |
int active = 0; |
2336 |
zoff99 |
2 |
char buffer[3]; |
2337 |
zoff99 |
27 |
f = fopen(destination_file, "r"); |
2338 |
|
|
if (f) |
2339 |
|
|
{ |
2340 |
|
|
if (!fseek(f, -2, SEEK_END) && fread(buffer, 2, 1, f) == 1 && (buffer[0] != '\n' || buffer[1] != '\n')) |
2341 |
|
|
{ |
2342 |
|
|
active = 1; |
2343 |
|
|
} |
2344 |
zoff99 |
2 |
fclose(f); |
2345 |
|
|
} |
2346 |
|
|
g_free(destination_file); |
2347 |
zoff99 |
27 |
|
2348 |
zoff99 |
2 |
return active; |
2349 |
|
|
} |
2350 |
|
|
|
2351 |
zoff99 |
27 |
static void navit_add_former_destinations_from_file(struct navit *this_) |
2352 |
zoff99 |
2 |
{ |
2353 |
zoff99 |
40 |
|
2354 |
|
|
|
2355 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2356 |
zoff99 |
2 |
char *destination_file = bookmarks_get_destination_file(FALSE); |
2357 |
|
|
struct attr *attrs[4]; |
2358 |
|
|
struct map_rect *mr; |
2359 |
|
|
struct item *item; |
2360 |
zoff99 |
27 |
int i, valid = 0, count = 0; |
2361 |
zoff99 |
2 |
struct coord c[16]; |
2362 |
|
|
struct pcoord pc[16]; |
2363 |
|
|
struct attr parent; |
2364 |
|
|
struct attr type; |
2365 |
|
|
struct attr data; |
2366 |
|
|
struct attr flags; |
2367 |
|
|
|
2368 |
zoff99 |
27 |
parent.type = attr_navit; |
2369 |
|
|
parent.u.navit = this_; |
2370 |
zoff99 |
2 |
|
2371 |
zoff99 |
27 |
type.type = attr_type; |
2372 |
|
|
type.u.str = "textfile"; |
2373 |
zoff99 |
2 |
|
2374 |
zoff99 |
27 |
data.type = attr_data; |
2375 |
|
|
data.u.str = destination_file; |
2376 |
zoff99 |
2 |
|
2377 |
zoff99 |
27 |
flags.type = attr_flags; |
2378 |
|
|
flags.u.num = 1; |
2379 |
zoff99 |
2 |
|
2380 |
zoff99 |
27 |
attrs[0] = &type; |
2381 |
|
|
attrs[1] = &data; |
2382 |
|
|
attrs[2] = &flags; |
2383 |
|
|
attrs[3] = NULL; |
2384 |
zoff99 |
2 |
|
2385 |
zoff99 |
27 |
this_->former_destination = map_new(&parent, attrs); |
2386 |
zoff99 |
2 |
g_free(destination_file); |
2387 |
|
|
if (!this_->route || !navit_former_destinations_active(this_)) |
2388 |
zoff99 |
27 |
return; |
2389 |
|
|
mr = map_rect_new(this_->former_destination, NULL); |
2390 |
|
|
while ((item = map_rect_get_item(mr))) |
2391 |
|
|
{ |
2392 |
|
|
if ((item->type == type_former_destination || item->type == type_former_itinerary || item->type == type_former_itinerary_part) && (count = item_coord_get(item, c, 16))) |
2393 |
|
|
valid = 1; |
2394 |
zoff99 |
2 |
} |
2395 |
|
|
map_rect_destroy(mr); |
2396 |
zoff99 |
27 |
if (valid && count > 0) |
2397 |
|
|
{ |
2398 |
|
|
for (i = 0; i < count; i++) |
2399 |
|
|
{ |
2400 |
|
|
pc[i].pro = map_projection(this_->former_destination); |
2401 |
|
|
pc[i].x = c[i].x; |
2402 |
|
|
pc[i].y = c[i].y; |
2403 |
zoff99 |
2 |
} |
2404 |
|
|
if (count == 1) |
2405 |
zoff99 |
27 |
{ |
2406 |
zoff99 |
2 |
route_set_destination(this_->route, &pc[0], 1); |
2407 |
zoff99 |
27 |
} |
2408 |
zoff99 |
2 |
else |
2409 |
zoff99 |
27 |
{ |
2410 |
zoff99 |
2 |
route_set_destinations(this_->route, pc, count, 1); |
2411 |
zoff99 |
27 |
} |
2412 |
|
|
this_->destination = pc[count - 1]; |
2413 |
|
|
this_->destination_valid = 1; |
2414 |
zoff99 |
2 |
} |
2415 |
|
|
} |
2416 |
|
|
|
2417 |
zoff99 |
27 |
void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...) |
2418 |
zoff99 |
2 |
{ |
2419 |
zoff99 |
40 |
|
2420 |
|
|
|
2421 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2422 |
zoff99 |
2 |
va_list ap; |
2423 |
zoff99 |
27 |
char *str1, *str2; |
2424 |
zoff99 |
2 |
va_start(ap, fmt); |
2425 |
zoff99 |
27 |
if (this_->textfile_debug_log && this_->vehicle) |
2426 |
|
|
{ |
2427 |
|
|
str1 = g_strdup_vprintf(fmt, ap); |
2428 |
|
|
str2 = g_strdup_printf("0x%x 0x%x%s%s\n", this_->vehicle->coord.x, this_->vehicle->coord.y, strlen(str1) ? " " : "", str1); |
2429 |
zoff99 |
2 |
log_write(this_->textfile_debug_log, str2, strlen(str2), 0); |
2430 |
|
|
g_free(str2); |
2431 |
|
|
g_free(str1); |
2432 |
|
|
} |
2433 |
zoff99 |
27 |
va_end(ap); |
2434 |
zoff99 |
2 |
} |
2435 |
|
|
|
2436 |
zoff99 |
27 |
void navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...) |
2437 |
zoff99 |
2 |
{ |
2438 |
zoff99 |
40 |
|
2439 |
|
|
|
2440 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2441 |
zoff99 |
2 |
va_list ap; |
2442 |
zoff99 |
27 |
char *str1, *str2; |
2443 |
zoff99 |
2 |
va_start(ap, fmt); |
2444 |
zoff99 |
27 |
if (this_->textfile_debug_log && this_->vehicle) |
2445 |
|
|
{ |
2446 |
|
|
str1 = g_strdup_vprintf(fmt, ap); |
2447 |
|
|
str2 = g_strdup_printf("0x%x 0x%x%s%s\n", pc->x, pc->y, strlen(str1) ? " " : "", str1); |
2448 |
zoff99 |
2 |
log_write(this_->textfile_debug_log, str2, strlen(str2), 0); |
2449 |
|
|
g_free(str2); |
2450 |
|
|
g_free(str1); |
2451 |
|
|
} |
2452 |
zoff99 |
27 |
va_end(ap); |
2453 |
zoff99 |
2 |
} |
2454 |
|
|
|
2455 |
zoff99 |
27 |
void navit_say(struct navit *this_, char *text) |
2456 |
zoff99 |
2 |
{ |
2457 |
zoff99 |
40 |
|
2458 |
|
|
|
2459 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2460 |
|
|
if (this_->speech) |
2461 |
|
|
{ |
2462 |
zoff99 |
40 |
//dbg(0,"say(1) s=%s\n", text); |
2463 |
zoff99 |
2 |
speech_say(this_->speech, text); |
2464 |
|
|
} |
2465 |
|
|
} |
2466 |
|
|
|
2467 |
|
|
/** |
2468 |
|
|
* @brief Toggles the navigation announcer for navit |
2469 |
|
|
* @param this_ The navit object |
2470 |
|
|
*/ |
2471 |
zoff99 |
27 |
static void navit_cmd_announcer_toggle(struct navit *this_) |
2472 |
zoff99 |
2 |
{ |
2473 |
zoff99 |
40 |
|
2474 |
|
|
|
2475 |
zoff99 |
27 |
struct attr attr, speechattr; |
2476 |
zoff99 |
2 |
|
2477 |
zoff99 |
27 |
// search for the speech attribute |
2478 |
|
|
if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) |
2479 |
|
|
return; |
2480 |
|
|
// find out if the corresponding attribute attr_active has been set |
2481 |
|
|
if (speech_get_attr(speechattr.u.speech, attr_active, &attr, NULL)) |
2482 |
|
|
{ |
2483 |
|
|
// flip it then... |
2484 |
|
|
attr.u.num = !attr.u.num; |
2485 |
|
|
} |
2486 |
|
|
else |
2487 |
|
|
{ |
2488 |
|
|
// otherwise disable it because voice is enabled by default |
2489 |
|
|
attr.type = attr_active; |
2490 |
|
|
attr.u.num = 0; |
2491 |
|
|
} |
2492 |
zoff99 |
2 |
|
2493 |
zoff99 |
27 |
// apply the new state |
2494 |
|
|
if (!speech_set_attr(speechattr.u.speech, &attr)) |
2495 |
|
|
return; |
2496 |
zoff99 |
2 |
|
2497 |
zoff99 |
27 |
// announce that the speech attribute has changed |
2498 |
|
|
callback_list_call_attr_0(this_->attr_cbl, attr_speech); |
2499 |
zoff99 |
2 |
} |
2500 |
|
|
|
2501 |
zoff99 |
27 |
void navit_cmd_announcer_on(struct navit *this_) |
2502 |
zoff99 |
2 |
{ |
2503 |
zoff99 |
40 |
|
2504 |
|
|
|
2505 |
zoff99 |
27 |
struct attr attr, speechattr; |
2506 |
zoff99 |
2 |
|
2507 |
zoff99 |
27 |
// search for the speech attribute |
2508 |
|
|
if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) |
2509 |
|
|
return; |
2510 |
zoff99 |
2 |
|
2511 |
|
|
attr.type = attr_active; |
2512 |
|
|
attr.u.num = 1; |
2513 |
|
|
|
2514 |
zoff99 |
27 |
// apply the new state |
2515 |
|
|
if (!speech_set_attr(speechattr.u.speech, &attr)) |
2516 |
|
|
return; |
2517 |
zoff99 |
2 |
|
2518 |
zoff99 |
27 |
// announce that the speech attribute has changed |
2519 |
|
|
callback_list_call_attr_0(this_->attr_cbl, attr_speech); |
2520 |
zoff99 |
2 |
} |
2521 |
|
|
|
2522 |
zoff99 |
27 |
void navit_cmd_announcer_off(struct navit *this_) |
2523 |
zoff99 |
2 |
{ |
2524 |
zoff99 |
40 |
|
2525 |
|
|
|
2526 |
zoff99 |
27 |
struct attr attr, speechattr; |
2527 |
zoff99 |
2 |
|
2528 |
zoff99 |
27 |
// search for the speech attribute |
2529 |
|
|
if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) |
2530 |
|
|
return; |
2531 |
zoff99 |
2 |
|
2532 |
|
|
attr.type = attr_active; |
2533 |
|
|
attr.u.num = 0; |
2534 |
|
|
|
2535 |
zoff99 |
27 |
// apply the new state |
2536 |
|
|
if (!speech_set_attr(speechattr.u.speech, &attr)) |
2537 |
|
|
return; |
2538 |
zoff99 |
2 |
|
2539 |
zoff99 |
27 |
// announce that the speech attribute has changed |
2540 |
|
|
callback_list_call_attr_0(this_->attr_cbl, attr_speech); |
2541 |
zoff99 |
2 |
} |
2542 |
|
|
|
2543 |
zoff99 |
27 |
void navit_speak(struct navit *this_) |
2544 |
zoff99 |
2 |
{ |
2545 |
zoff99 |
40 |
|
2546 |
|
|
|
2547 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2548 |
|
|
struct navigation *nav = this_->navigation; |
2549 |
|
|
struct map *map = NULL; |
2550 |
|
|
struct map_rect *mr = NULL; |
2551 |
zoff99 |
2 |
struct item *item; |
2552 |
|
|
struct attr attr; |
2553 |
|
|
|
2554 |
zoff99 |
27 |
if (!speech_get_attr(this_->speech, attr_active, &attr, NULL)) |
2555 |
zoff99 |
40 |
{ |
2556 |
zoff99 |
27 |
attr.u.num = 1; |
2557 |
zoff99 |
40 |
} |
2558 |
|
|
|
2559 |
zoff99 |
27 |
// dbg(1, "this_.speech->active %i\n", attr.u.num); |
2560 |
zoff99 |
40 |
|
2561 |
zoff99 |
41 |
dbg(0, "NAV_TURNAROUND:008:enter\n"); |
2562 |
|
|
|
2563 |
zoff99 |
27 |
if (!attr.u.num) |
2564 |
zoff99 |
40 |
{ |
2565 |
zoff99 |
27 |
return; |
2566 |
zoff99 |
40 |
} |
2567 |
zoff99 |
2 |
|
2568 |
|
|
if (nav) |
2569 |
zoff99 |
27 |
map = navigation_get_map(nav); |
2570 |
zoff99 |
40 |
|
2571 |
zoff99 |
2 |
if (map) |
2572 |
zoff99 |
27 |
mr = map_rect_new(map, NULL); |
2573 |
zoff99 |
40 |
|
2574 |
zoff99 |
27 |
if (mr) |
2575 |
|
|
{ |
2576 |
|
|
while ((item = map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none)) |
2577 |
zoff99 |
41 |
{ |
2578 |
|
|
dbg(0, "NAV_TURNAROUND:008a:%s\n", item_to_name(item->type)); |
2579 |
|
|
} |
2580 |
zoff99 |
40 |
|
2581 |
zoff99 |
41 |
dbg(0, "NAV_TURNAROUND:008b:item=%p\n", item); |
2582 |
|
|
|
2583 |
|
|
if (item && item_attr_get(item, attr_navigation_speech, &attr)) // this calls --> navigation_map_item_attr_get(...) --> show_next_maneuvers(...) |
2584 |
zoff99 |
27 |
{ |
2585 |
zoff99 |
40 |
//dbg(0,"say(2) s=X%sX\n", attr.u.str); |
2586 |
zoff99 |
41 |
|
2587 |
|
|
dbg(0, "NAV_TURNAROUND:009:%s\n", attr.u.str); |
2588 |
|
|
|
2589 |
zoff99 |
40 |
if (strlen(attr.u.str) > 0) |
2590 |
|
|
{ |
2591 |
|
|
speech_say(this_->speech, attr.u.str); |
2592 |
|
|
} |
2593 |
zoff99 |
27 |
//navit_add_message(this_, attr.u.str); |
2594 |
zoff99 |
40 |
// navit_textfile_debug_log(this_, "type=announcement label=\"%s\"", attr.u.str); |
2595 |
zoff99 |
2 |
} |
2596 |
|
|
map_rect_destroy(mr); |
2597 |
|
|
} |
2598 |
|
|
} |
2599 |
|
|
|
2600 |
zoff99 |
27 |
static void navit_window_roadbook_update(struct navit *this_) |
2601 |
zoff99 |
2 |
{ |
2602 |
zoff99 |
40 |
|
2603 |
|
|
|
2604 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
2605 |
|
|
struct navigation *nav = this_->navigation; |
2606 |
|
|
struct map *map = NULL; |
2607 |
|
|
struct map_rect *mr = NULL; |
2608 |
zoff99 |
2 |
struct item *item; |
2609 |
|
|
struct attr attr; |
2610 |
|
|
struct param_list param[5]; |
2611 |
|
|
int secs; |
2612 |
|
|
|
2613 |
zoff99 |
27 |
// dbg(1, "enter\n"); |
2614 |
zoff99 |
2 |
datawindow_mode(this_->roadbook_window, 1); |
2615 |
|
|
if (nav) |
2616 |
zoff99 |
27 |
map = navigation_get_map(nav); |
2617 |
zoff99 |
2 |
if (map) |
2618 |
zoff99 |
27 |
mr = map_rect_new(map, NULL); |
2619 |
|
|
////DBG dbg(0,"nav=%p map=%p mr=%p\n", nav, map, mr); |
2620 |
|
|
if (mr) |
2621 |
|
|
{ |
2622 |
|
|
////DBG dbg(0,"while loop\n"); |
2623 |
|
|
while ((item = map_rect_get_item(mr))) |
2624 |
|
|
{ |
2625 |
|
|
////DBG dbg(0,"item=%p\n", item); |
2626 |
|
|
attr.u.str = NULL; |
2627 |
|
|
if (item->type != type_nav_position) |
2628 |
|
|
{ |
2629 |
zoff99 |
2 |
item_attr_get(item, attr_navigation_long, &attr); |
2630 |
zoff99 |
27 |
if (attr.u.str == NULL) |
2631 |
|
|
{ |
2632 |
zoff99 |
2 |
continue; |
2633 |
|
|
} |
2634 |
|
|
dbg(2, "Command='%s'\n", attr.u.str); |
2635 |
zoff99 |
27 |
param[0].value = g_strdup(attr.u.str); |
2636 |
|
|
} |
2637 |
|
|
else |
2638 |
|
|
param[0].value = _("Position"); |
2639 |
|
|
param[0].name = _("Command"); |
2640 |
zoff99 |
2 |
|
2641 |
|
|
item_attr_get(item, attr_length, &attr); |
2642 |
|
|
dbg(2, "Length=%d\n", attr.u.num); |
2643 |
zoff99 |
27 |
param[1].name = _("Length"); |
2644 |
zoff99 |
2 |
|
2645 |
zoff99 |
27 |
if (attr.u.num >= 2000) |
2646 |
zoff99 |
2 |
{ |
2647 |
zoff99 |
27 |
param[1].value = g_strdup_printf("%5.1f %s", (float) attr.u.num / 1000, _("km")); |
2648 |
zoff99 |
2 |
} |
2649 |
|
|
else |
2650 |
|
|
{ |
2651 |
zoff99 |
27 |
param[1].value = g_strdup_printf("%7d %s", attr.u.num, _("m")); |
2652 |
zoff99 |
2 |
} |
2653 |
|
|
|
2654 |
|
|
item_attr_get(item, attr_time, &attr); |
2655 |
|
|
dbg(2, "Time=%d\n", attr.u.num); |
2656 |
zoff99 |
27 |
secs = attr.u.num / 10; |
2657 |
|
|
param[2].name = _("Time"); |
2658 |
|
|
if (secs >= 3600) |
2659 |
zoff99 |
2 |
{ |
2660 |
zoff99 |
27 |
param[2].value = g_strdup_printf("%d:%02d:%02d", secs / 60, (secs / 60) % 60, secs % 60); |
2661 |
zoff99 |
2 |
} |
2662 |
|
|
else |
2663 |
|
|
{ |
2664 |
zoff99 |
27 |
param[2].value = g_strdup_printf("%d:%02d", secs / 60, secs % 60); |
2665 |
zoff99 |
2 |
} |
2666 |
|
|
|
2667 |
|
|
item_attr_get(item, attr_destination_length, &attr); |
2668 |
|
|
dbg(2, "Destlength=%d\n", attr.u.num); |
2669 |
zoff99 |
27 |
param[3].name = _("Destination Length"); |
2670 |
|
|
if (attr.u.num >= 2000) |
2671 |
zoff99 |
2 |
{ |
2672 |
zoff99 |
27 |
param[3].value = g_strdup_printf("%5.1f %s", (float) attr.u.num / 1000, _("km")); |
2673 |
zoff99 |
2 |
} |
2674 |
|
|
else |
2675 |
|
|
{ |
2676 |
zoff99 |
27 |
param[3].value = g_strdup_printf("%d %s", attr.u.num, _("m")); |
2677 |
zoff99 |
2 |
} |
2678 |
|
|
|
2679 |
|
|
item_attr_get(item, attr_destination_time, &attr); |
2680 |
|
|
dbg(2, "Desttime=%d\n", attr.u.num); |
2681 |
zoff99 |
27 |
secs = attr.u.num / 10; |
2682 |
|
|
param[4].name = _("Destination Time"); |
2683 |
|
|
if (secs >= 3600) |
2684 |
zoff99 |
2 |
{ |
2685 |
zoff99 |
27 |
param[4].value = g_strdup_printf("%d:%02d:%02d", secs / 3600, (secs / 60) % 60, secs % 60); |
2686 |
zoff99 |
2 |
} |
2687 |
|
|
else |
2688 |
|
|
{ |
2689 |
zoff99 |
27 |
param[4].value = g_strdup_printf("%d:%02d", secs / 60, secs % 60); |
2690 |
zoff99 |
2 |
} |
2691 |
|
|
datawindow_add(this_->roadbook_window, param, 5); |
2692 |
|
|
} |
2693 |
|
|
map_rect_destroy(mr); |
2694 |
|
|
} |
2695 |
|
|
datawindow_mode(this_->roadbook_window, 0); |
2696 |
|
|
} |
2697 |
|
|
|
2698 |
zoff99 |
27 |
void navit_window_roadbook_destroy(struct navit *this_) |
2699 |
zoff99 |
2 |
{ |
2700 |
zoff99 |
40 |
|
2701 |
|
|
|
2702 |
zoff99 |
27 |
////DBG dbg(0, "enter\n"); |
2703 |
zoff99 |
2 |
navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback); |
2704 |
zoff99 |
27 |
this_->roadbook_window = NULL; |
2705 |
|
|
this_->roadbook_callback = NULL; |
2706 |
zoff99 |
2 |
} |
2707 |
zoff99 |
28 |
|
2708 |
zoff99 |
27 |
void navit_window_roadbook_new(struct navit *this_) |
2709 |
zoff99 |
2 |
{ |
2710 |
zoff99 |
40 |
|
2711 |
|
|
|
2712 |
zoff99 |
27 |
if (!this_->gui || this_->roadbook_callback || this_->roadbook_window) |
2713 |
|
|
{ |
2714 |
zoff99 |
2 |
return; |
2715 |
|
|
} |
2716 |
|
|
|
2717 |
zoff99 |
27 |
this_->roadbook_callback = callback_new_1(callback_cast(navit_window_roadbook_update), this_); |
2718 |
zoff99 |
2 |
navigation_register_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback); |
2719 |
zoff99 |
27 |
this_->roadbook_window = gui_datawindow_new(this_->gui, _("Roadbook"), NULL, callback_new_1(callback_cast(navit_window_roadbook_destroy), this_)); |
2720 |
zoff99 |
2 |
navit_window_roadbook_update(this_); |
2721 |
|
|
} |
2722 |
|
|
|
2723 |
zoff99 |
27 |
void navit_remove_all_maps(struct navit *this_) |
2724 |
zoff99 |
2 |
{ |
2725 |
zoff99 |
40 |
|
2726 |
|
|
|
2727 |
|
|
|
2728 |
|
|
dbg(0,"ROUTExxPOSxx:navit_remove_all_maps:enter\n"); |
2729 |
|
|
|
2730 |
zoff99 |
2 |
struct mapset *ms; |
2731 |
|
|
struct map *map3; |
2732 |
|
|
|
2733 |
zoff99 |
28 |
// hold map drawing |
2734 |
|
|
// this_->ready = 1; |
2735 |
|
|
|
2736 |
zoff99 |
27 |
// first: stop navigation! |
2737 |
|
|
//if (global_navit->destination_valid != 0) |
2738 |
|
|
//{ |
2739 |
|
|
navit_set_destination(global_navit, NULL, NULL, 0); |
2740 |
|
|
//} |
2741 |
|
|
|
2742 |
|
|
|
2743 |
zoff99 |
34 |
if (this_->tracking) |
2744 |
|
|
{ |
2745 |
|
|
tracking_flush(this_->tracking); |
2746 |
|
|
} |
2747 |
|
|
|
2748 |
zoff99 |
28 |
if (this_->route) |
2749 |
|
|
{ |
2750 |
|
|
struct attr callback; |
2751 |
|
|
// this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); |
2752 |
zoff99 |
40 |
|
2753 |
|
|
|
2754 |
zoff99 |
28 |
callback.type = attr_callback; |
2755 |
|
|
callback.u.callback = this_->route_cb; |
2756 |
|
|
route_remove_attr(this_->route, &callback); |
2757 |
zoff99 |
27 |
|
2758 |
zoff99 |
28 |
this_->route->ms = NULL; |
2759 |
|
|
// route_set_mapset(this_->route, ms); |
2760 |
|
|
// route_set_projection(this_->route, transform_get_projection(this_->trans)); |
2761 |
zoff99 |
27 |
|
2762 |
zoff99 |
28 |
//*********route_destroy(this_->route); |
2763 |
zoff99 |
27 |
|
2764 |
zoff99 |
28 |
//route_path_destroy(this_->route->path2,1); |
2765 |
|
|
//this_->route->path2 = NULL; |
2766 |
|
|
//route_graph_destroy(this_->route->graph); |
2767 |
|
|
//this_->route->graph=NULL; |
2768 |
|
|
} |
2769 |
zoff99 |
27 |
|
2770 |
|
|
/* |
2771 |
|
|
map_rect_destroy(displaylist->mr); |
2772 |
|
|
if (!route_selection) |
2773 |
|
|
map_selection_destroy(displaylist->sel); |
2774 |
|
|
mapset_close(displaylist->msh); |
2775 |
|
|
displaylist->mr=NULL; |
2776 |
|
|
displaylist->sel=NULL; |
2777 |
|
|
displaylist->m=NULL; |
2778 |
|
|
displaylist->msh=NULL; |
2779 |
|
|
profile(1,"callback\n"); |
2780 |
|
|
callback_call_1(displaylist->cb, cancel); |
2781 |
|
|
*/ |
2782 |
|
|
|
2783 |
|
|
struct displaylist *dl = navit_get_displaylist(this_); |
2784 |
|
|
dl->m = NULL; |
2785 |
|
|
dl->msh = NULL; |
2786 |
|
|
|
2787 |
zoff99 |
2 |
if (this_->mapsets) |
2788 |
|
|
{ |
2789 |
|
|
struct mapset_handle *msh; |
2790 |
zoff99 |
27 |
ms = this_->mapsets->data; |
2791 |
|
|
msh = mapset_open(ms); |
2792 |
|
|
////DBG dbg(0,"removing map bb0\n"); |
2793 |
|
|
while (msh && (map3 = mapset_next(msh, 0))) |
2794 |
zoff99 |
2 |
{ |
2795 |
zoff99 |
27 |
////DBG dbg(0,"removing map bb1\n"); |
2796 |
zoff99 |
2 |
struct attr map_name_attr; |
2797 |
zoff99 |
27 |
if (map_get_attr(map3, attr_name, &map_name_attr, NULL)) |
2798 |
zoff99 |
2 |
{ |
2799 |
zoff99 |
27 |
//DBG dbg(0, "map name=%s", map_name_attr.u.str); |
2800 |
zoff99 |
2 |
if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) |
2801 |
|
|
{ |
2802 |
zoff99 |
28 |
dbg(0, "removing map name=%s", map_name_attr.u.str); |
2803 |
zoff99 |
27 |
//DBG dbg(0, "removing map a0\n"); |
2804 |
|
|
struct attr active; |
2805 |
|
|
active.type = attr_active; |
2806 |
|
|
active.u.num = 0; |
2807 |
|
|
//map_set_attr(map3, &active); |
2808 |
|
|
|
2809 |
|
|
//DBG dbg(0, "removing map a1\n"); |
2810 |
zoff99 |
2 |
struct attr map_attr; |
2811 |
zoff99 |
27 |
map_attr.u.map = map3; |
2812 |
|
|
map_attr.type = attr_map; |
2813 |
zoff99 |
2 |
mapset_remove_attr(ms, &map_attr); |
2814 |
zoff99 |
27 |
|
2815 |
|
|
//DBG dbg(0, "removing map a2\n"); |
2816 |
|
|
map3->refcount = 1; |
2817 |
zoff99 |
2 |
map_destroy(map3); |
2818 |
zoff99 |
27 |
//DBG dbg(0, "removing map a3\n"); |
2819 |
|
|
map3 = NULL; |
2820 |
zoff99 |
2 |
} |
2821 |
zoff99 |
28 |
else if (strncmp("-special-:", map_name_attr.u.str, 10) == 0) |
2822 |
|
|
{ |
2823 |
|
|
dbg(0, "removing (special) map name=%s", map_name_attr.u.str); |
2824 |
|
|
struct attr active; |
2825 |
|
|
active.type = attr_active; |
2826 |
|
|
active.u.num = 0; |
2827 |
|
|
|
2828 |
|
|
struct attr map_attr; |
2829 |
|
|
map_attr.u.map = map3; |
2830 |
|
|
map_attr.type = attr_map; |
2831 |
|
|
mapset_remove_attr(ms, &map_attr); |
2832 |
|
|
|
2833 |
|
|
map3->refcount = 1; |
2834 |
|
|
map_destroy(map3); |
2835 |
|
|
map3 = NULL; |
2836 |
|
|
} |
2837 |
zoff99 |
2 |
} |
2838 |
|
|
} |
2839 |
|
|
mapset_close(msh); |
2840 |
zoff99 |
27 |
//DBG dbg(0, "removing map bb4\n"); |
2841 |
zoff99 |
2 |
} |
2842 |
zoff99 |
27 |
|
2843 |
|
|
dl->ms = this_->mapsets->data; |
2844 |
|
|
|
2845 |
|
|
// int async = 0; |
2846 |
|
|
// transform_setup_source_rect(this_->trans); |
2847 |
|
|
// graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1); |
2848 |
|
|
//this_->displaylist->ms=this_->mapsets->data; |
2849 |
|
|
|
2850 |
zoff99 |
2 |
} |
2851 |
|
|
|
2852 |
zoff99 |
28 |
void navit_map_active_flag(struct navit *this_, int activate, const char *mapname) |
2853 |
|
|
{ |
2854 |
|
|
// activate = 0 -> deactivate |
2855 |
|
|
// activate = 1 -> activate |
2856 |
|
|
|
2857 |
zoff99 |
40 |
|
2858 |
|
|
|
2859 |
zoff99 |
28 |
struct mapset *ms; |
2860 |
|
|
struct map *map3; |
2861 |
|
|
|
2862 |
|
|
if (this_->mapsets) |
2863 |
|
|
{ |
2864 |
|
|
struct mapset_handle *msh; |
2865 |
|
|
ms = this_->mapsets->data; |
2866 |
|
|
msh = mapset_open(ms); |
2867 |
|
|
while (msh && (map3 = mapset_next(msh, 0))) |
2868 |
|
|
{ |
2869 |
|
|
struct attr map_name_attr; |
2870 |
|
|
if (map_get_attr(map3, attr_name, &map_name_attr, NULL)) |
2871 |
|
|
{ |
2872 |
|
|
dbg(0, "map name=%s\n", map_name_attr.u.str); |
2873 |
|
|
if (strcmp(mapname, map_name_attr.u.str) == 0) |
2874 |
|
|
{ |
2875 |
|
|
dbg(0, "setting active flag on map:%s\n", map_name_attr.u.str); |
2876 |
|
|
|
2877 |
|
|
struct attr active; |
2878 |
|
|
active.type = attr_active; |
2879 |
|
|
active.u.num = activate; |
2880 |
|
|
map_set_attr(map3, &active); |
2881 |
|
|
} |
2882 |
|
|
} |
2883 |
|
|
} |
2884 |
|
|
mapset_close(msh); |
2885 |
|
|
} |
2886 |
|
|
|
2887 |
|
|
} |
2888 |
|
|
|
2889 |
zoff99 |
27 |
void navit_add_all_maps(struct navit *this_) |
2890 |
zoff99 |
2 |
{ |
2891 |
zoff99 |
40 |
__F_START__ |
2892 |
|
|
|
2893 |
zoff99 |
2 |
struct map *map3; |
2894 |
|
|
|
2895 |
|
|
if (this_->mapsets) |
2896 |
|
|
{ |
2897 |
zoff99 |
27 |
//DBG dbg(0, "xADDx all maps - start\n"); |
2898 |
zoff99 |
2 |
|
2899 |
zoff99 |
27 |
struct mapset *ms; |
2900 |
|
|
ms = this_->mapsets->data; |
2901 |
|
|
|
2902 |
zoff99 |
2 |
struct attr type; |
2903 |
|
|
struct attr parent; |
2904 |
|
|
struct attr data; |
2905 |
|
|
struct attr flags; |
2906 |
|
|
struct map *map2; |
2907 |
|
|
struct attr map2_attr; |
2908 |
|
|
struct attr *attrs[4]; |
2909 |
|
|
char *map_file; |
2910 |
|
|
|
2911 |
zoff99 |
40 |
dbg(0, "001\n"); |
2912 |
|
|
|
2913 |
zoff99 |
27 |
parent.type = attr_navit; |
2914 |
|
|
parent.u.navit = this_; |
2915 |
|
|
type.type = attr_type; |
2916 |
|
|
type.u.str = "binfile"; |
2917 |
|
|
data.type = attr_data; |
2918 |
|
|
map_file = g_strdup_printf("%sborders.bin", navit_maps_dir); |
2919 |
|
|
data.u.str = map_file; |
2920 |
zoff99 |
2 |
|
2921 |
zoff99 |
27 |
////DBG dbg(0,"map name=%s",map_file); |
2922 |
zoff99 |
2 |
|
2923 |
zoff99 |
27 |
flags.type = attr_flags; |
2924 |
|
|
flags.u.num = 0; |
2925 |
|
|
attrs[0] = &type; |
2926 |
|
|
attrs[1] = &data; |
2927 |
|
|
attrs[2] = &flags; |
2928 |
|
|
attrs[3] = NULL; |
2929 |
|
|
map2 = map_new(&parent, attrs); |
2930 |
zoff99 |
2 |
if (map2) |
2931 |
|
|
{ |
2932 |
zoff99 |
27 |
map2_attr.u.data = map2; |
2933 |
|
|
map2_attr.type = attr_map; |
2934 |
|
|
// mapset_add_attr_name(ms, &map2_attr); |
2935 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/borders.bin"); |
2936 |
|
|
struct attr active; |
2937 |
|
|
active.type = attr_active; |
2938 |
|
|
active.u.num = 0; |
2939 |
|
|
//map_set_attr(map2, &active); |
2940 |
zoff99 |
34 |
|
2941 |
|
|
active.type = attr_route_active; |
2942 |
|
|
active.u.num = 0; // by default deactivate rounting on this map |
2943 |
|
|
map_set_attr(map2, &active); |
2944 |
zoff99 |
2 |
} |
2945 |
|
|
g_free(map_file); |
2946 |
|
|
|
2947 |
zoff99 |
50 |
|
2948 |
|
|
|
2949 |
|
|
/* |
2950 |
zoff99 |
27 |
parent.type = attr_navit; |
2951 |
|
|
parent.u.navit = this_; |
2952 |
|
|
type.type = attr_type; |
2953 |
|
|
type.u.str = "binfile"; |
2954 |
|
|
data.type = attr_data; |
2955 |
|
|
map_file = g_strdup_printf("%scoastline.bin", navit_maps_dir); |
2956 |
|
|
data.u.str = map_file; |
2957 |
zoff99 |
2 |
|
2958 |
zoff99 |
27 |
////DBG dbg(0,"map name=%s",map_file); |
2959 |
zoff99 |
2 |
|
2960 |
zoff99 |
27 |
flags.type = attr_flags; |
2961 |
|
|
flags.u.num = 0; |
2962 |
|
|
attrs[0] = &type; |
2963 |
|
|
attrs[1] = &data; |
2964 |
|
|
attrs[2] = &flags; |
2965 |
|
|
attrs[3] = NULL; |
2966 |
|
|
map2 = map_new(&parent, attrs); |
2967 |
zoff99 |
2 |
if (map2) |
2968 |
|
|
{ |
2969 |
zoff99 |
27 |
map2_attr.u.data = map2; |
2970 |
|
|
map2_attr.type = attr_map; |
2971 |
|
|
// mapset_add_attr_name(ms, &map2_attr); |
2972 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/coastline.bin"); |
2973 |
|
|
struct attr active; |
2974 |
|
|
active.type = attr_active; |
2975 |
|
|
active.u.num = 0; |
2976 |
|
|
//map_set_attr(map2, &active); |
2977 |
zoff99 |
34 |
|
2978 |
|
|
active.type = attr_route_active; |
2979 |
|
|
active.u.num = 0; // by default deactivate rounting on this map |
2980 |
|
|
map_set_attr(map2, &active); |
2981 |
zoff99 |
2 |
} |
2982 |
|
|
g_free(map_file); |
2983 |
|
|
|
2984 |
zoff99 |
50 |
|
2985 |
|
|
*/ |
2986 |
|
|
|
2987 |
|
|
|
2988 |
zoff99 |
28 |
// gpx tracks map -------------------- |
2989 |
|
|
parent.type = attr_navit; |
2990 |
|
|
parent.u.navit = this_; |
2991 |
|
|
type.type = attr_type; |
2992 |
|
|
type.u.str = "textfile"; |
2993 |
|
|
data.type = attr_data; |
2994 |
|
|
map_file = g_strdup_printf("%sgpxtracks.txt", navit_maps_dir); |
2995 |
|
|
data.u.str = map_file; |
2996 |
|
|
|
2997 |
|
|
flags.type = attr_flags; |
2998 |
|
|
flags.u.num = 0; |
2999 |
|
|
attrs[0] = &type; |
3000 |
|
|
attrs[1] = &data; |
3001 |
|
|
attrs[2] = &flags; |
3002 |
|
|
attrs[3] = NULL; |
3003 |
|
|
map2 = map_new(&parent, attrs); |
3004 |
|
|
if (map2) |
3005 |
|
|
{ |
3006 |
|
|
map2_attr.u.data = map2; |
3007 |
|
|
map2_attr.type = attr_map; |
3008 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, "-special-:gpxtracks.txt"); |
3009 |
|
|
struct attr active; |
3010 |
|
|
active.type = attr_active; |
3011 |
|
|
active.u.num = 0; |
3012 |
|
|
//map_set_attr(map2, &active); |
3013 |
|
|
} |
3014 |
|
|
g_free(map_file); |
3015 |
|
|
// gpx tracks map -------------------- |
3016 |
|
|
|
3017 |
|
|
|
3018 |
|
|
// traffic map -------------------- |
3019 |
|
|
parent.type = attr_navit; |
3020 |
|
|
parent.u.navit = this_; |
3021 |
|
|
type.type = attr_type; |
3022 |
|
|
type.u.str = "textfile"; |
3023 |
|
|
data.type = attr_data; |
3024 |
|
|
map_file = g_strdup_printf("%straffic.txt", navit_maps_dir); |
3025 |
|
|
data.u.str = map_file; |
3026 |
|
|
|
3027 |
|
|
flags.type = attr_flags; |
3028 |
|
|
flags.u.num = 0; |
3029 |
|
|
attrs[0] = &type; |
3030 |
|
|
attrs[1] = &data; |
3031 |
|
|
attrs[2] = &flags; |
3032 |
|
|
attrs[3] = NULL; |
3033 |
|
|
map2 = map_new(&parent, attrs); |
3034 |
|
|
if (map2) |
3035 |
|
|
{ |
3036 |
|
|
map2_attr.u.data = map2; |
3037 |
|
|
map2_attr.type = attr_map; |
3038 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, "-special-:traffic.txt"); |
3039 |
|
|
struct attr active; |
3040 |
|
|
active.type = attr_active; |
3041 |
|
|
active.u.num = 0; |
3042 |
|
|
//map_set_attr(map2, &active); |
3043 |
|
|
} |
3044 |
|
|
g_free(map_file); |
3045 |
|
|
// traffic map -------------------- |
3046 |
|
|
|
3047 |
|
|
|
3048 |
zoff99 |
40 |
dbg(0, "002\n"); |
3049 |
zoff99 |
34 |
|
3050 |
zoff99 |
40 |
|
3051 |
zoff99 |
34 |
// world map2 -------------------- |
3052 |
|
|
parent.type = attr_navit; |
3053 |
|
|
parent.u.navit = this_; |
3054 |
|
|
type.type = attr_type; |
3055 |
|
|
type.u.str = "textfile"; |
3056 |
|
|
data.type = attr_data; |
3057 |
|
|
map_file = g_strdup_printf("%sworldmap2.txt", navit_maps_dir); |
3058 |
|
|
data.u.str = map_file; |
3059 |
|
|
|
3060 |
|
|
dbg(0, "activate map:%s\n", map_file); |
3061 |
|
|
|
3062 |
|
|
flags.type = attr_flags; |
3063 |
|
|
flags.u.num = 0; |
3064 |
|
|
attrs[0] = &type; |
3065 |
|
|
attrs[1] = &data; |
3066 |
|
|
attrs[2] = &flags; |
3067 |
|
|
attrs[3] = NULL; |
3068 |
|
|
map2 = map_new(&parent, attrs); |
3069 |
|
|
if (map2) |
3070 |
|
|
{ |
3071 |
|
|
map2_attr.u.data = map2; |
3072 |
|
|
map2_attr.type = attr_map; |
3073 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap2.txt"); |
3074 |
|
|
struct attr active; |
3075 |
|
|
active.type = attr_active; |
3076 |
|
|
active.u.num = 1; // by default activate map |
3077 |
|
|
// map_set_attr(map2, &active); |
3078 |
|
|
|
3079 |
|
|
active.type = attr_route_active; |
3080 |
|
|
active.u.num = 0; // by default deactivate routing on this map |
3081 |
|
|
map_set_attr(map2, &active); |
3082 |
|
|
|
3083 |
|
|
} |
3084 |
|
|
g_free(map_file); |
3085 |
|
|
// world map2 -------------------- |
3086 |
|
|
|
3087 |
|
|
|
3088 |
|
|
// world map5 -------------------- |
3089 |
|
|
parent.type = attr_navit; |
3090 |
|
|
parent.u.navit = this_; |
3091 |
|
|
type.type = attr_type; |
3092 |
|
|
type.u.str = "textfile"; |
3093 |
|
|
data.type = attr_data; |
3094 |
|
|
map_file = g_strdup_printf("%sworldmap5.txt", navit_maps_dir); |
3095 |
|
|
data.u.str = map_file; |
3096 |
|
|
|
3097 |
|
|
dbg(0, "activate map:%s\n", map_file); |
3098 |
|
|
|
3099 |
|
|
flags.type = attr_flags; |
3100 |
|
|
flags.u.num = 0; |
3101 |
|
|
attrs[0] = &type; |
3102 |
|
|
attrs[1] = &data; |
3103 |
|
|
attrs[2] = &flags; |
3104 |
|
|
attrs[3] = NULL; |
3105 |
|
|
map2 = map_new(&parent, attrs); |
3106 |
|
|
if (map2) |
3107 |
|
|
{ |
3108 |
|
|
map2_attr.u.data = map2; |
3109 |
|
|
map2_attr.type = attr_map; |
3110 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap5.txt"); |
3111 |
|
|
struct attr active; |
3112 |
|
|
active.type = attr_active; |
3113 |
|
|
active.u.num = 1; // by default activate map |
3114 |
|
|
// map_set_attr(map2, &active); |
3115 |
|
|
|
3116 |
|
|
active.type = attr_route_active; |
3117 |
|
|
active.u.num = 0; // by default deactivate routing on this map |
3118 |
|
|
map_set_attr(map2, &active); |
3119 |
|
|
} |
3120 |
|
|
g_free(map_file); |
3121 |
|
|
// world map5 -------------------- |
3122 |
|
|
|
3123 |
zoff99 |
40 |
dbg(0, "003\n"); |
3124 |
zoff99 |
34 |
|
3125 |
zoff99 |
40 |
|
3126 |
zoff99 |
34 |
#if 0 |
3127 |
|
|
// world map6 -------------------- |
3128 |
|
|
parent.type = attr_navit; |
3129 |
|
|
parent.u.navit = this_; |
3130 |
|
|
type.type = attr_type; |
3131 |
|
|
type.u.str = "textfile"; |
3132 |
|
|
data.type = attr_data; |
3133 |
|
|
map_file = g_strdup_printf("%sworldmap6.txt", navit_maps_dir); |
3134 |
|
|
data.u.str = map_file; |
3135 |
|
|
|
3136 |
|
|
dbg(0, "activate map:%s\n", map_file); |
3137 |
|
|
|
3138 |
|
|
flags.type = attr_flags; |
3139 |
|
|
flags.u.num = 0; |
3140 |
|
|
attrs[0] = &type; |
3141 |
|
|
attrs[1] = &data; |
3142 |
|
|
attrs[2] = &flags; |
3143 |
|
|
attrs[3] = NULL; |
3144 |
|
|
map2 = map_new(&parent, attrs); |
3145 |
|
|
if (map2) |
3146 |
|
|
{ |
3147 |
|
|
map2_attr.u.data = map2; |
3148 |
|
|
map2_attr.type = attr_map; |
3149 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap6.txt"); |
3150 |
|
|
struct attr active; |
3151 |
|
|
active.type = attr_active; |
3152 |
|
|
active.u.num = 1; // by default activate map |
3153 |
|
|
// map_set_attr(map2, &active); |
3154 |
|
|
|
3155 |
|
|
active.type = attr_route_active; |
3156 |
|
|
active.u.num = 0; // by default deactivate routing on this map |
3157 |
|
|
map_set_attr(map2, &active); |
3158 |
|
|
} |
3159 |
|
|
g_free(map_file); |
3160 |
|
|
// world map6 -------------------- |
3161 |
|
|
#endif |
3162 |
|
|
|
3163 |
zoff99 |
40 |
dbg(0, "004\n"); |
3164 |
zoff99 |
34 |
|
3165 |
zoff99 |
40 |
|
3166 |
zoff99 |
27 |
int i = 1; |
3167 |
|
|
for (i = 1; i < 10; i++) |
3168 |
zoff99 |
2 |
{ |
3169 |
|
|
struct map *map22; |
3170 |
|
|
struct attr map22_attr; |
3171 |
zoff99 |
27 |
parent.type = attr_navit; |
3172 |
|
|
parent.u.navit = this_; |
3173 |
|
|
type.type = attr_type; |
3174 |
|
|
type.u.str = "binfile"; |
3175 |
|
|
data.type = attr_data; |
3176 |
|
|
map_file = g_strdup_printf("%snavitmap_00%d.bin", navit_maps_dir, i); |
3177 |
|
|
data.u.str = map_file; |
3178 |
|
|
flags.type = attr_flags; |
3179 |
|
|
flags.u.num = 0; |
3180 |
|
|
attrs[0] = &type; |
3181 |
|
|
attrs[1] = &data; |
3182 |
|
|
attrs[2] = &flags; |
3183 |
|
|
attrs[3] = NULL; |
3184 |
|
|
map22 = map_new(&parent, attrs); |
3185 |
zoff99 |
2 |
if (map22) |
3186 |
|
|
{ |
3187 |
zoff99 |
27 |
//DBG dbg(0, "*add* map name=%s\n", map_file); |
3188 |
|
|
map22_attr.u.data = map22; |
3189 |
|
|
map22_attr.type = attr_map; |
3190 |
|
|
// mapset_add_attr_name(ms, &map22_attr); |
3191 |
|
|
char *map_name_str; |
3192 |
|
|
map_name_str = g_strdup_printf("/sdcard/zanavi/maps/navitmap_00%d.bin", i); |
3193 |
|
|
mapset_add_attr_name_str(ms, &map22_attr, map_name_str); |
3194 |
|
|
struct attr active; |
3195 |
|
|
active.type = attr_active; |
3196 |
|
|
active.u.num = 0; |
3197 |
|
|
//map_set_attr(map22, &active); |
3198 |
|
|
g_free(map_name_str); |
3199 |
zoff99 |
2 |
} |
3200 |
|
|
g_free(map_file); |
3201 |
|
|
} |
3202 |
|
|
|
3203 |
zoff99 |
27 |
i = 10; |
3204 |
zoff99 |
50 |
for (i = 10; i < 61; i++) |
3205 |
zoff99 |
2 |
{ |
3206 |
zoff99 |
27 |
parent.type = attr_navit; |
3207 |
|
|
parent.u.navit = this_; |
3208 |
|
|
type.type = attr_type; |
3209 |
|
|
type.u.str = "binfile"; |
3210 |
|
|
data.type = attr_data; |
3211 |
|
|
map_file = g_strdup_printf("%snavitmap_0%d.bin", navit_maps_dir, i); |
3212 |
|
|
data.u.str = map_file; |
3213 |
|
|
////DBG dbg(0,"map name=%s",map_file); |
3214 |
|
|
flags.type = attr_flags; |
3215 |
|
|
flags.u.num = 0; |
3216 |
|
|
attrs[0] = &type; |
3217 |
|
|
attrs[1] = &data; |
3218 |
|
|
attrs[2] = &flags; |
3219 |
|
|
attrs[3] = NULL; |
3220 |
|
|
map2 = map_new(&parent, attrs); |
3221 |
zoff99 |
2 |
if (map2) |
3222 |
|
|
{ |
3223 |
zoff99 |
27 |
map2_attr.u.data = map2; |
3224 |
|
|
map2_attr.type = attr_map; |
3225 |
|
|
// mapset_add_attr_name(ms, &map2_attr); |
3226 |
|
|
char *map_name_str; |
3227 |
|
|
map_name_str = g_strdup_printf("/sdcard/zanavi/maps/navitmap_0%d.bin", i); |
3228 |
|
|
mapset_add_attr_name_str(ms, &map2_attr, map_name_str); |
3229 |
|
|
struct attr active; |
3230 |
|
|
active.type = attr_active; |
3231 |
|
|
active.u.num = 0; |
3232 |
|
|
//map_set_attr(map2, &active); |
3233 |
|
|
g_free(map_name_str); |
3234 |
zoff99 |
2 |
} |
3235 |
|
|
g_free(map_file); |
3236 |
|
|
} |
3237 |
|
|
} |
3238 |
zoff99 |
27 |
|
3239 |
|
|
/* |
3240 |
|
|
if (this_->mapsets) |
3241 |
|
|
{ |
3242 |
|
|
struct mapset_handle *msh; |
3243 |
|
|
struct map *map; |
3244 |
|
|
struct mapset *ms; |
3245 |
|
|
|
3246 |
|
|
//DBG dbg(0,"xx ms callbacks xx\n"); |
3247 |
|
|
|
3248 |
|
|
ms=this_->mapsets->data; |
3249 |
|
|
this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); |
3250 |
|
|
msh=mapset_open(ms); |
3251 |
|
|
while (msh && (map=mapset_next(msh, 0))) |
3252 |
|
|
{ |
3253 |
|
|
//pass new callback instance for each map in the mapset to make map callback list destruction work correctly |
3254 |
|
|
struct callback *pcb = callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); |
3255 |
|
|
map_add_callback(map, pcb); |
3256 |
|
|
} |
3257 |
|
|
mapset_close(msh); |
3258 |
|
|
} |
3259 |
|
|
*/ |
3260 |
|
|
|
3261 |
zoff99 |
28 |
/* |
3262 |
zoff99 |
30 |
struct attr parent; |
3263 |
|
|
parent.type = attr_navit; |
3264 |
|
|
parent.u.navit = global_navit; |
3265 |
zoff99 |
27 |
|
3266 |
zoff99 |
30 |
struct attr *attrs_r[2]; |
3267 |
|
|
attrs_r[0] = NULL; |
3268 |
|
|
attrs_r[1] = NULL; |
3269 |
|
|
*/ |
3270 |
zoff99 |
27 |
|
3271 |
|
|
//***this_->route = route_new(&parent, attrs_r); |
3272 |
|
|
|
3273 |
|
|
|
3274 |
|
|
//int async = 0; |
3275 |
|
|
//transform_setup_source_rect(this_->trans); |
3276 |
|
|
//graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1); |
3277 |
|
|
|
3278 |
zoff99 |
40 |
if (this_->mapsets) |
3279 |
zoff99 |
27 |
{ |
3280 |
zoff99 |
40 |
dbg(0, "005\n"); |
3281 |
zoff99 |
27 |
|
3282 |
zoff99 |
40 |
struct displaylist *dl = navit_get_displaylist(this_); |
3283 |
|
|
dbg(0, "005a dl=%p\n", dl); |
3284 |
|
|
dbg(0, "005a1 ms=%p\n", this_->mapsets); |
3285 |
|
|
dbg(0, "005a2 ms=%p\n", this_->mapsets->data); |
3286 |
|
|
dl->ms = this_->mapsets->data; |
3287 |
|
|
dbg(0, "005b\n"); |
3288 |
|
|
dl->m = NULL; |
3289 |
|
|
dbg(0, "005c\n"); |
3290 |
|
|
dl->msh = NULL; |
3291 |
zoff99 |
27 |
|
3292 |
zoff99 |
40 |
dbg(0, "005.1\n"); |
3293 |
zoff99 |
27 |
|
3294 |
|
|
if (this_->route) |
3295 |
|
|
{ |
3296 |
zoff99 |
40 |
dbg(0, "005.2\n"); |
3297 |
|
|
|
3298 |
|
|
struct mapset *ms; |
3299 |
|
|
dbg(0, "005.3\n"); |
3300 |
|
|
ms = this_->mapsets->data; |
3301 |
|
|
dbg(0, "005.4\n"); |
3302 |
|
|
route_set_mapset(this_->route, ms); |
3303 |
|
|
|
3304 |
|
|
dbg(0, "005.5\n"); |
3305 |
|
|
|
3306 |
|
|
struct attr callback; |
3307 |
|
|
this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); |
3308 |
|
|
dbg(0, "005.6\n"); |
3309 |
|
|
callback_add_names(this_->route_cb, "navit_add_all_maps", "navit_redraw_route"); |
3310 |
|
|
dbg(0, "005.7\n"); |
3311 |
|
|
callback.type = attr_callback; |
3312 |
|
|
dbg(0, "005.8\n"); |
3313 |
|
|
callback.u.callback = this_->route_cb; |
3314 |
|
|
dbg(0, "005.9\n"); |
3315 |
|
|
route_add_attr(this_->route, &callback); |
3316 |
|
|
dbg(0, "005.10\n"); |
3317 |
|
|
// ***** route_set_projection(this_->route, transform_get_projection(this_->trans)); |
3318 |
|
|
|
3319 |
|
|
|
3320 |
zoff99 |
27 |
} |
3321 |
zoff99 |
40 |
|
3322 |
|
|
|
3323 |
|
|
dbg(0, "006\n"); |
3324 |
|
|
|
3325 |
|
|
|
3326 |
|
|
if (this_->tracking) |
3327 |
|
|
{ |
3328 |
|
|
struct mapset *ms; |
3329 |
|
|
ms = this_->mapsets->data; |
3330 |
|
|
|
3331 |
|
|
tracking_set_mapset(this_->tracking, ms); |
3332 |
|
|
if (this_->route) |
3333 |
|
|
{ |
3334 |
|
|
tracking_set_route(this_->tracking, this_->route); |
3335 |
|
|
} |
3336 |
|
|
} |
3337 |
|
|
|
3338 |
zoff99 |
27 |
} |
3339 |
|
|
|
3340 |
zoff99 |
28 |
// ready for drawing map |
3341 |
|
|
// this_->ready = 3; |
3342 |
zoff99 |
27 |
|
3343 |
zoff99 |
28 |
// draw map |
3344 |
|
|
// navit_draw(this_); |
3345 |
zoff99 |
40 |
|
3346 |
|
|
__F_END__ |
3347 |
zoff99 |
2 |
} |
3348 |
|
|
|
3349 |
zoff99 |
27 |
void navit_reload_maps(struct navit *this_) |
3350 |
zoff99 |
2 |
{ |
3351 |
zoff99 |
40 |
|
3352 |
|
|
|
3353 |
|
|
|
3354 |
|
|
dbg(0,"ROUTExxPOSxx:navit_reload_maps:enter\n"); |
3355 |
|
|
|
3356 |
zoff99 |
2 |
navit_remove_all_maps(this_); |
3357 |
|
|
navit_add_all_maps(this_); |
3358 |
|
|
} |
3359 |
|
|
|
3360 |
zoff99 |
40 |
|
3361 |
|
|
// --- forward def ---- |
3362 |
|
|
void navit_set_vehicle_position_to_screen_center(struct navit *this_); |
3363 |
|
|
// --- forward def ---- |
3364 |
|
|
|
3365 |
zoff99 |
27 |
void navit_init(struct navit *this_) |
3366 |
zoff99 |
2 |
{ |
3367 |
zoff99 |
40 |
|
3368 |
|
|
|
3369 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
3370 |
zoff99 |
2 |
struct mapset *ms; |
3371 |
|
|
struct map *map; |
3372 |
|
|
int callback; |
3373 |
|
|
char *center_file; |
3374 |
|
|
|
3375 |
zoff99 |
30 |
// dbg(0,"GGGGG:set global_navit\n"); |
3376 |
|
|
// global_navit = this_; |
3377 |
|
|
|
3378 |
zoff99 |
27 |
// default value |
3379 |
|
|
navit_maps_dir = "/sdcard/zanavi/maps/"; |
3380 |
zoff99 |
2 |
|
3381 |
zoff99 |
27 |
global_img_waypoint = NULL; |
3382 |
|
|
|
3383 |
|
|
//DBG dbg(0, "enter gui %p graphics %p\n", this_->gui, this_->gra); |
3384 |
|
|
|
3385 |
|
|
if (!this_->gui && !(this_->flags & 2)) |
3386 |
|
|
{ |
3387 |
|
|
dbg(0, "no gui\n"); |
3388 |
zoff99 |
2 |
navit_destroy(this_); |
3389 |
|
|
return; |
3390 |
|
|
} |
3391 |
zoff99 |
27 |
|
3392 |
|
|
if (!this_->gra && !(this_->flags & 1)) |
3393 |
|
|
{ |
3394 |
|
|
dbg(0, "no graphics\n"); |
3395 |
zoff99 |
2 |
navit_destroy(this_); |
3396 |
|
|
return; |
3397 |
|
|
} |
3398 |
zoff99 |
27 |
|
3399 |
zoff99 |
40 |
|
3400 |
|
|
#ifdef NAVIT_FREE_TEXT_DEBUG_PRINT |
3401 |
|
|
dbg(0, "DEST::route_clear_freetext_list(000)\n"); |
3402 |
|
|
route_clear_freetext_list(); |
3403 |
|
|
#endif |
3404 |
|
|
|
3405 |
|
|
|
3406 |
zoff99 |
27 |
//DBG dbg(0, "Connecting gui to graphics\n"); |
3407 |
|
|
|
3408 |
|
|
if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra)) |
3409 |
|
|
{ |
3410 |
zoff99 |
2 |
struct attr attr_type_gui, attr_type_graphics; |
3411 |
|
|
gui_get_attr(this_->gui, attr_type, &attr_type_gui, NULL); |
3412 |
|
|
graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL); |
3413 |
|
|
|
3414 |
zoff99 |
28 |
dbg(0, "failed to connect to graphics\n"); |
3415 |
zoff99 |
2 |
navit_destroy(this_); |
3416 |
|
|
return; |
3417 |
|
|
} |
3418 |
zoff99 |
27 |
|
3419 |
|
|
if (this_->speech && this_->navigation) |
3420 |
|
|
{ |
3421 |
zoff99 |
2 |
struct attr speech; |
3422 |
zoff99 |
27 |
speech.type = attr_speech; |
3423 |
|
|
speech.u.speech = this_->speech; |
3424 |
zoff99 |
2 |
navigation_set_attr(this_->navigation, &speech); |
3425 |
|
|
} |
3426 |
zoff99 |
27 |
|
3427 |
|
|
//DBG dbg(0, "Initializing graphics\n"); |
3428 |
|
|
//DBG dbg(0, "Setting Vehicle\n"); |
3429 |
zoff99 |
2 |
navit_set_vehicle(this_, this_->vehicle); |
3430 |
zoff99 |
28 |
|
3431 |
zoff99 |
27 |
//DBG dbg(0, "Adding dynamic maps to mapset %p\n", this_->mapsets); |
3432 |
|
|
if (this_->mapsets) |
3433 |
|
|
{ |
3434 |
zoff99 |
2 |
struct mapset_handle *msh; |
3435 |
zoff99 |
27 |
ms = this_->mapsets->data; |
3436 |
|
|
// **D** // this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); |
3437 |
|
|
msh = mapset_open(ms); |
3438 |
|
|
while (msh && (map = mapset_next(msh, 0))) |
3439 |
|
|
{ |
3440 |
zoff99 |
2 |
//pass new callback instance for each map in the mapset to make map callback list destruction work correctly |
3441 |
zoff99 |
27 |
// **D** // struct callback *pcb = callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); |
3442 |
|
|
// **D** // map_add_callback(map, pcb); |
3443 |
zoff99 |
2 |
} |
3444 |
|
|
mapset_close(msh); |
3445 |
zoff99 |
27 |
|
3446 |
|
|
if (this_->route) |
3447 |
|
|
{ |
3448 |
|
|
if ((map = route_get_map(this_->route))) |
3449 |
|
|
{ |
3450 |
|
|
struct attr map_a, map_name; |
3451 |
|
|
map_a.type = attr_map; |
3452 |
|
|
map_a.u.map = map; |
3453 |
|
|
map_name.type = attr_name; |
3454 |
|
|
map_name.u.str = "_ms_route"; |
3455 |
zoff99 |
2 |
map_set_attr(map_a.u.map, &map_name); |
3456 |
|
|
mapset_add_attr(ms, &map_a); |
3457 |
|
|
} |
3458 |
zoff99 |
27 |
|
3459 |
|
|
if ((map = route_get_graph_map(this_->route))) |
3460 |
|
|
{ |
3461 |
|
|
struct attr map_a, active, map_name; |
3462 |
|
|
map_a.type = attr_map; |
3463 |
|
|
map_a.u.map = map; |
3464 |
|
|
active.type = attr_active; |
3465 |
|
|
active.u.num = 0; |
3466 |
|
|
map_name.type = attr_name; |
3467 |
|
|
map_name.u.str = "_ms_route_graph"; |
3468 |
zoff99 |
2 |
map_set_attr(map_a.u.map, &map_name); |
3469 |
|
|
mapset_add_attr(ms, &map_a); |
3470 |
|
|
map_set_attr(map, &active); |
3471 |
|
|
} |
3472 |
|
|
route_set_mapset(this_->route, ms); |
3473 |
|
|
route_set_projection(this_->route, transform_get_projection(this_->trans)); |
3474 |
|
|
} |
3475 |
zoff99 |
27 |
|
3476 |
|
|
if (this_->tracking) |
3477 |
|
|
{ |
3478 |
zoff99 |
2 |
tracking_set_mapset(this_->tracking, ms); |
3479 |
|
|
if (this_->route) |
3480 |
zoff99 |
27 |
{ |
3481 |
zoff99 |
2 |
tracking_set_route(this_->tracking, this_->route); |
3482 |
zoff99 |
27 |
} |
3483 |
zoff99 |
2 |
} |
3484 |
zoff99 |
27 |
|
3485 |
|
|
if (this_->navigation) |
3486 |
|
|
{ |
3487 |
|
|
if ((map = navigation_get_map(this_->navigation))) |
3488 |
|
|
{ |
3489 |
|
|
struct attr map_a, active, map_name; |
3490 |
|
|
map_a.type = attr_map; |
3491 |
|
|
map_a.u.map = map; |
3492 |
|
|
active.type = attr_active; |
3493 |
|
|
active.u.num = 0; |
3494 |
|
|
map_name.type = attr_name; |
3495 |
|
|
map_name.u.str = "_ms_navigation"; |
3496 |
zoff99 |
2 |
map_set_attr(map_a.u.map, &map_name); |
3497 |
|
|
mapset_add_attr(ms, &map_a); |
3498 |
|
|
map_set_attr(map, &active); |
3499 |
|
|
} |
3500 |
|
|
} |
3501 |
zoff99 |
27 |
|
3502 |
|
|
if (this_->tracking) |
3503 |
|
|
{ |
3504 |
|
|
if ((map = tracking_get_map(this_->tracking))) |
3505 |
|
|
{ |
3506 |
|
|
struct attr map_a, active, map_name; |
3507 |
|
|
map_a.type = attr_map; |
3508 |
|
|
map_a.u.map = map; |
3509 |
|
|
active.type = attr_active; |
3510 |
|
|
active.u.num = 0; |
3511 |
|
|
map_name.type = attr_name; |
3512 |
|
|
map_name.u.str = "_ms_tracking"; |
3513 |
zoff99 |
14 |
map_set_attr(map_a.u.map, &map_name); |
3514 |
zoff99 |
2 |
mapset_add_attr(ms, &map_a); |
3515 |
|
|
map_set_attr(map, &active); |
3516 |
|
|
} |
3517 |
|
|
} |
3518 |
zoff99 |
14 |
// *DISABLED* navit_add_former_destinations_from_file(this_); |
3519 |
zoff99 |
2 |
} |
3520 |
zoff99 |
27 |
|
3521 |
|
|
if (this_->route) |
3522 |
|
|
{ |
3523 |
zoff99 |
40 |
/* |
3524 |
|
|
*DISABLED* done in "navit_add_all_maps" |
3525 |
|
|
|
3526 |
zoff99 |
2 |
struct attr callback; |
3527 |
zoff99 |
27 |
this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); |
3528 |
zoff99 |
30 |
callback_add_names(this_->route_cb, "navit_init", "navit_redraw_route"); |
3529 |
zoff99 |
27 |
callback.type = attr_callback; |
3530 |
|
|
callback.u.callback = this_->route_cb; |
3531 |
zoff99 |
2 |
route_add_attr(this_->route, &callback); |
3532 |
zoff99 |
40 |
*/ |
3533 |
zoff99 |
2 |
} |
3534 |
zoff99 |
27 |
|
3535 |
|
|
if (this_->navigation) |
3536 |
|
|
{ |
3537 |
|
|
if (this_->speech) |
3538 |
|
|
{ |
3539 |
|
|
this_->nav_speech_cb = callback_new_1(callback_cast(navit_speak), this_); |
3540 |
zoff99 |
30 |
callback_add_names(this_->nav_speech_cb, "navit_init", "navit_speak"); |
3541 |
zoff99 |
2 |
navigation_register_callback(this_->navigation, attr_navigation_speech, this_->nav_speech_cb); |
3542 |
|
|
} |
3543 |
zoff99 |
27 |
|
3544 |
zoff99 |
2 |
if (this_->route) |
3545 |
zoff99 |
27 |
{ |
3546 |
zoff99 |
2 |
navigation_set_route(this_->navigation, this_->route); |
3547 |
zoff99 |
27 |
} |
3548 |
zoff99 |
2 |
} |
3549 |
zoff99 |
27 |
|
3550 |
|
|
dbg(0, "Setting Center\n"); |
3551 |
zoff99 |
2 |
center_file = bookmarks_get_center_file(FALSE); |
3552 |
zoff99 |
27 |
//dbg(0, "g0\n"); |
3553 |
zoff99 |
2 |
bookmarks_set_center_from_file(this_->bookmarks, center_file); |
3554 |
|
|
g_free(center_file); |
3555 |
zoff99 |
30 |
|
3556 |
zoff99 |
40 |
dbg(0, "Set Vehicle Position to Center\n"); |
3557 |
|
|
navit_set_vehicle_position_to_screen_center(this_); |
3558 |
|
|
|
3559 |
zoff99 |
2 |
#if 0 |
3560 |
zoff99 |
27 |
if (this_->menubar) |
3561 |
|
|
{ |
3562 |
zoff99 |
2 |
men=menu_add(this_->menubar, "Data", menu_type_submenu, NULL); |
3563 |
zoff99 |
27 |
if (men) |
3564 |
|
|
{ |
3565 |
zoff99 |
2 |
navit_add_menu_windows_items(this_, men); |
3566 |
|
|
} |
3567 |
|
|
} |
3568 |
|
|
#endif |
3569 |
zoff99 |
30 |
|
3570 |
zoff99 |
2 |
#if 0 |
3571 |
|
|
navit_window_roadbook_new(this_); |
3572 |
|
|
navit_window_items_new(this_); |
3573 |
|
|
#endif |
3574 |
|
|
|
3575 |
zoff99 |
27 |
//dbg(0, "g1\n"); |
3576 |
|
|
//messagelist_init(this_->messages); |
3577 |
zoff99 |
2 |
|
3578 |
zoff99 |
27 |
//dbg(0, "g2\n"); |
3579 |
zoff99 |
2 |
navit_set_cursors(this_); |
3580 |
|
|
|
3581 |
|
|
callback_list_call_attr_1(this_->attr_cbl, attr_navit, this_); |
3582 |
zoff99 |
27 |
callback = (this_->ready == 2); |
3583 |
zoff99 |
28 |
dbg(0, "pre this_->ready=%d\n", this_->ready); |
3584 |
|
|
this_->ready = this_->ready | 1; |
3585 |
|
|
dbg(0, "set this_->ready=%d\n", this_->ready); |
3586 |
zoff99 |
27 |
////DBG dbg(0,"ready=%d\n",this_->ready); |
3587 |
|
|
|
3588 |
zoff99 |
28 |
|
3589 |
|
|
//if (this_->ready == 3) |
3590 |
|
|
//{ |
3591 |
|
|
// ////DBG dbg(0,"navit_draw_async_003\n"); |
3592 |
|
|
// navit_draw_async(this_, 1); |
3593 |
|
|
//} |
3594 |
|
|
|
3595 |
zoff99 |
30 |
dbg(0, "init ready=%d\n", this_->ready); |
3596 |
zoff99 |
28 |
|
3597 |
|
|
// draw??????? |
3598 |
|
|
// dbg(0,"init DRAW 11\n"); |
3599 |
|
|
// ready to draw map |
3600 |
|
|
// navit_draw(this_); |
3601 |
|
|
// dbg(0,"init DRAW 22\n"); |
3602 |
|
|
// draw??????? |
3603 |
|
|
|
3604 |
zoff99 |
2 |
if (callback) |
3605 |
zoff99 |
27 |
{ |
3606 |
zoff99 |
2 |
callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); |
3607 |
zoff99 |
27 |
} |
3608 |
zoff99 |
2 |
#if 0 |
3609 |
|
|
routech_test(this_); |
3610 |
|
|
#endif |
3611 |
zoff99 |
27 |
//dbg(0, "1111111111\n"); |
3612 |
zoff99 |
2 |
} |
3613 |
|
|
|
3614 |
zoff99 |
40 |
|
3615 |
|
|
|
3616 |
|
|
// ----- forward def! ----- |
3617 |
|
|
void navit_set_position_without_map_drawing(struct navit *this_, struct pcoord *c); |
3618 |
|
|
// ----- forward def! ----- |
3619 |
|
|
|
3620 |
|
|
void navit_set_vehicle_position_to_screen_center_only_for_route_struct(struct navit *this_) |
3621 |
|
|
{ |
3622 |
|
|
struct coord c; |
3623 |
|
|
char *center_file; |
3624 |
|
|
center_file = bookmarks_get_center_file(FALSE); |
3625 |
|
|
bookmarks_get_center_from_file(this_->bookmarks, center_file, &c); |
3626 |
|
|
g_free(center_file); |
3627 |
|
|
|
3628 |
|
|
struct pcoord pc; |
3629 |
|
|
pc.x = c.x; |
3630 |
|
|
pc.y = c.y; |
3631 |
|
|
pc.pro = transform_get_projection(this_->trans); |
3632 |
|
|
// result: pc.x, pc.y |
3633 |
|
|
|
3634 |
|
|
// set position |
3635 |
|
|
navit_set_position_without_map_drawing(this_, &pc); |
3636 |
|
|
} |
3637 |
|
|
|
3638 |
|
|
void navit_set_vehicle_position_to_screen_center(struct navit *this_) |
3639 |
|
|
{ |
3640 |
|
|
|
3641 |
|
|
// map center to pixel x,y on screen |
3642 |
|
|
// enum projection pro = transform_get_projection(this_->trans); |
3643 |
|
|
// struct point pnt; |
3644 |
|
|
// struct coord *c992; |
3645 |
|
|
// c992 = transform_get_center(this_->trans); |
3646 |
|
|
// transform(this_->trans, pro, c992, &pnt, 1, 0, 0, NULL); |
3647 |
|
|
// dbg(0, "navit_set_vehicle_position_to_screen_center pnt.x=%d pnt.y=%d\n", pnt.x, pnt.y); |
3648 |
|
|
// result: pnt.x, pnt.y |
3649 |
|
|
|
3650 |
|
|
|
3651 |
|
|
// geo to pixel-on-screen |
3652 |
|
|
// struct coord c99; |
3653 |
|
|
// struct coord_geo g99; |
3654 |
|
|
// g99.lat = lat; |
3655 |
|
|
// g99.lng = lon; |
3656 |
|
|
// dbg(0,"zzzzz %f, %f\n",a, b); |
3657 |
|
|
// dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); |
3658 |
|
|
// transform_from_geo(projection_mg, &g99, &c99); |
3659 |
|
|
// dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); |
3660 |
|
|
|
3661 |
|
|
// enum projection pro = transform_get_projection(global_navit->trans_cursor); |
3662 |
|
|
// struct point pnt; |
3663 |
|
|
// transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); |
3664 |
|
|
// dbg(0,"x=%d\n",pnt.x); |
3665 |
|
|
// dbg(0,"y=%d\n",pnt.y); |
3666 |
|
|
|
3667 |
|
|
|
3668 |
|
|
struct coord c; |
3669 |
|
|
char *center_file; |
3670 |
|
|
center_file = bookmarks_get_center_file(FALSE); |
3671 |
|
|
bookmarks_get_center_from_file(this_->bookmarks, center_file, &c); |
3672 |
|
|
g_free(center_file); |
3673 |
|
|
|
3674 |
|
|
|
3675 |
|
|
// coord to geo |
3676 |
|
|
struct coord_geo g22; |
3677 |
|
|
// struct coord c22; |
3678 |
|
|
////DBG // dbg(0,"%f, %f\n",a, b); |
3679 |
|
|
////DBG // dbg(0,"%d, %d\n",p.x, p.y); |
3680 |
|
|
transform_to_geo(projection_mg, &c, &g22); |
3681 |
|
|
dbg(0,"navit_set_vehicle_position_to_screen_center: %d, %d, %f, %f\n",c.x, c.y, g22.lat, g22.lng); |
3682 |
|
|
// result = g_strdup_printf("%f:%f", g22.lat, g22.lng); |
3683 |
|
|
|
3684 |
|
|
|
3685 |
|
|
// set vehicle position to pixel x,y |
3686 |
|
|
//struct point p; |
3687 |
|
|
//struct coord c; |
3688 |
|
|
|
3689 |
|
|
// pixel-x |
3690 |
|
|
//p.x = pnt.x; |
3691 |
|
|
// pixel-y |
3692 |
|
|
//p.y = pnt.y; |
3693 |
|
|
|
3694 |
|
|
//transform_reverse(this_->trans, &p, &c); |
3695 |
|
|
|
3696 |
|
|
struct pcoord pc; |
3697 |
|
|
pc.x = c.x; |
3698 |
|
|
pc.y = c.y; |
3699 |
|
|
pc.pro = transform_get_projection(this_->trans); |
3700 |
|
|
// result: pc.x, pc.y |
3701 |
|
|
|
3702 |
|
|
// set position |
3703 |
|
|
navit_set_position_without_map_drawing(this_, &pc); |
3704 |
|
|
|
3705 |
|
|
|
3706 |
|
|
//center.pro = projection_screen; |
3707 |
|
|
//center.x = 0; |
3708 |
|
|
//center.y = 0; |
3709 |
|
|
//DBG dbg(0, "veh new 5\n"); |
3710 |
|
|
// transform_setup(this_->vehicle->vehicle->trans, &pc, 16, 0); |
3711 |
|
|
// transform_set_center(this_->vehicle->vehicle->trans, &c); |
3712 |
|
|
// zzzzzzzzzzzzzz int vehicle_set_cursor_data_01(struct vehicle *this, struct point *pnt) |
3713 |
|
|
|
3714 |
|
|
if ((this_) && (this_->vehicle)) |
3715 |
|
|
{ |
3716 |
|
|
this_->vehicle->coord.x = c.x; |
3717 |
|
|
this_->vehicle->coord.y = c.y; |
3718 |
|
|
} |
3719 |
|
|
|
3720 |
|
|
if ((this_) && (this_->vehicle) && (this_->vehicle->vehicle)) |
3721 |
|
|
{ |
3722 |
|
|
float speed = 0; |
3723 |
|
|
float direction = 0; |
3724 |
|
|
double height = 0; |
3725 |
|
|
float radius = 0; |
3726 |
|
|
long gpstime = 0; |
3727 |
|
|
vehicle_update_(this_->vehicle->vehicle, g22.lat, g22.lng, speed, direction, height, radius, gpstime); |
3728 |
|
|
} |
3729 |
|
|
else |
3730 |
|
|
{ |
3731 |
|
|
dbg(0, "navit_set_vehicle_position_to_screen_center: no vehicle set !!\n"); |
3732 |
|
|
} |
3733 |
|
|
} |
3734 |
|
|
|
3735 |
|
|
|
3736 |
|
|
|
3737 |
|
|
|
3738 |
zoff99 |
27 |
void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r) |
3739 |
zoff99 |
2 |
{ |
3740 |
|
|
struct coord c; |
3741 |
zoff99 |
27 |
int scale = 16; |
3742 |
zoff99 |
2 |
|
3743 |
zoff99 |
27 |
c.x = (r->rl.x + r->lu.x) / 2; |
3744 |
|
|
c.y = (r->rl.y + r->lu.y) / 2; |
3745 |
zoff99 |
2 |
transform_set_center(this_->trans, &c); |
3746 |
zoff99 |
40 |
|
3747 |
zoff99 |
27 |
while (scale < 1 << 20) |
3748 |
|
|
{ |
3749 |
|
|
struct point p1, p2; |
3750 |
zoff99 |
2 |
transform_set_scale(this_->trans, scale); |
3751 |
|
|
transform_setup_source_rect(this_->trans); |
3752 |
|
|
transform(this_->trans, transform_get_projection(this_->trans), &r->lu, &p1, 1, 0, 0, NULL); |
3753 |
|
|
transform(this_->trans, transform_get_projection(this_->trans), &r->rl, &p2, 1, 0, 0, NULL); |
3754 |
zoff99 |
40 |
|
3755 |
zoff99 |
27 |
if (p1.x < 0 || p2.x < 0 || p1.x > this_->w || p2.x > this_->w || p1.y < 0 || p2.y < 0 || p1.y > this_->h || p2.y > this_->h) |
3756 |
zoff99 |
40 |
{ |
3757 |
zoff99 |
27 |
scale *= 2; |
3758 |
zoff99 |
40 |
} |
3759 |
zoff99 |
2 |
else |
3760 |
zoff99 |
40 |
{ |
3761 |
zoff99 |
2 |
break; |
3762 |
zoff99 |
40 |
} |
3763 |
|
|
} |
3764 |
zoff99 |
27 |
|
3765 |
zoff99 |
40 |
dbg(0, "scale=%d\n", scale); |
3766 |
|
|
dbg(0, "this_->ready=%d\n", this_->ready); |
3767 |
|
|
|
3768 |
zoff99 |
2 |
if (this_->ready == 3) |
3769 |
|
|
{ |
3770 |
zoff99 |
40 |
// dbg(0,"navit_draw_async_004\n"); |
3771 |
zoff99 |
30 |
//dbg(0,"DO__DRAW:navit_draw_async call\n"); |
3772 |
zoff99 |
27 |
navit_draw_async(this_, 0); |
3773 |
zoff99 |
2 |
} |
3774 |
|
|
} |
3775 |
|
|
|
3776 |
zoff99 |
27 |
void navit_zoom_to_route(struct navit *this_, int orientation) |
3777 |
zoff99 |
2 |
{ |
3778 |
|
|
struct map *map; |
3779 |
zoff99 |
27 |
struct map_rect *mr = NULL; |
3780 |
zoff99 |
2 |
struct item *item; |
3781 |
|
|
struct coord c; |
3782 |
|
|
struct coord_rect r; |
3783 |
zoff99 |
27 |
int count = 0; |
3784 |
zoff99 |
40 |
|
3785 |
zoff99 |
27 |
if (!this_->route) |
3786 |
zoff99 |
40 |
{ |
3787 |
zoff99 |
2 |
return; |
3788 |
zoff99 |
40 |
} |
3789 |
|
|
|
3790 |
zoff99 |
27 |
map = route_get_map(this_->route); |
3791 |
zoff99 |
40 |
|
3792 |
zoff99 |
2 |
if (map) |
3793 |
zoff99 |
40 |
{ |
3794 |
zoff99 |
27 |
mr = map_rect_new(map, NULL); |
3795 |
zoff99 |
40 |
} |
3796 |
|
|
|
3797 |
zoff99 |
27 |
if (mr) |
3798 |
|
|
{ |
3799 |
|
|
while ((item = map_rect_get_item(mr))) |
3800 |
|
|
{ |
3801 |
|
|
while (item_coord_get(item, &c, 1)) |
3802 |
|
|
{ |
3803 |
|
|
if (!count) |
3804 |
zoff99 |
40 |
{ |
3805 |
zoff99 |
27 |
r.lu = r.rl = c; |
3806 |
zoff99 |
40 |
} |
3807 |
zoff99 |
2 |
else |
3808 |
zoff99 |
40 |
{ |
3809 |
zoff99 |
27 |
coord_rect_extend(&r, &c); |
3810 |
zoff99 |
40 |
} |
3811 |
zoff99 |
2 |
count++; |
3812 |
|
|
} |
3813 |
|
|
} |
3814 |
|
|
map_rect_destroy(mr); |
3815 |
|
|
} |
3816 |
zoff99 |
40 |
|
3817 |
zoff99 |
27 |
if (!count) |
3818 |
zoff99 |
40 |
{ |
3819 |
zoff99 |
2 |
return; |
3820 |
zoff99 |
40 |
} |
3821 |
|
|
|
3822 |
zoff99 |
2 |
if (orientation != -1) |
3823 |
zoff99 |
40 |
{ |
3824 |
zoff99 |
2 |
transform_set_yaw(this_->trans, orientation); |
3825 |
zoff99 |
40 |
} |
3826 |
|
|
|
3827 |
zoff99 |
41 |
// if overspill > 1 ? |
3828 |
|
|
if (global_overspill_factor > 1.0f) |
3829 |
|
|
{ |
3830 |
|
|
coord_rect_extend_by_percent(&r, (global_overspill_factor - 1.0f)); |
3831 |
|
|
} |
3832 |
|
|
|
3833 |
zoff99 |
2 |
navit_zoom_to_rect(this_, &r); |
3834 |
|
|
} |
3835 |
|
|
|
3836 |
zoff99 |
27 |
static void navit_cmd_zoom_to_route(struct navit *this) |
3837 |
zoff99 |
2 |
{ |
3838 |
zoff99 |
40 |
|
3839 |
|
|
|
3840 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
3841 |
zoff99 |
2 |
navit_zoom_to_route(this, 0); |
3842 |
|
|
} |
3843 |
|
|
|
3844 |
|
|
/** |
3845 |
|
|
* show point on map |
3846 |
|
|
* |
3847 |
|
|
* @param navit The navit instance |
3848 |
|
|
* @param center The point where to center the map, including its projection |
3849 |
|
|
* @returns nothing |
3850 |
|
|
*/ |
3851 |
zoff99 |
27 |
void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout) |
3852 |
zoff99 |
2 |
{ |
3853 |
zoff99 |
40 |
|
3854 |
|
|
|
3855 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
3856 |
|
|
struct coord *c = transform_center(this_->trans); |
3857 |
|
|
struct coord c1, c2; |
3858 |
zoff99 |
2 |
enum projection pro = transform_get_projection(this_->trans); |
3859 |
zoff99 |
34 |
|
3860 |
zoff99 |
27 |
if (pro != center->pro) |
3861 |
|
|
{ |
3862 |
zoff99 |
2 |
c1.x = center->x; |
3863 |
|
|
c1.y = center->y; |
3864 |
|
|
transform_from_to(&c1, center->pro, &c2, pro); |
3865 |
zoff99 |
27 |
} |
3866 |
|
|
else |
3867 |
|
|
{ |
3868 |
zoff99 |
2 |
c2.x = center->x; |
3869 |
|
|
c2.y = center->y; |
3870 |
|
|
} |
3871 |
zoff99 |
34 |
|
3872 |
zoff99 |
27 |
*c = c2; |
3873 |
|
|
if (set_timeout) |
3874 |
|
|
{ |
3875 |
zoff99 |
2 |
navit_set_timeout(this_); |
3876 |
zoff99 |
27 |
} |
3877 |
zoff99 |
34 |
|
3878 |
zoff99 |
2 |
if (this_->ready == 3) |
3879 |
zoff99 |
27 |
{ |
3880 |
zoff99 |
2 |
navit_draw(this_); |
3881 |
zoff99 |
27 |
} |
3882 |
zoff99 |
2 |
} |
3883 |
|
|
|
3884 |
zoff99 |
41 |
|
3885 |
|
|
void navit_set_center_no_draw(struct navit *this_, struct pcoord *center, int set_timeout) |
3886 |
|
|
{ |
3887 |
|
|
|
3888 |
|
|
|
3889 |
|
|
////DBG dbg(0,"EEnter\n"); |
3890 |
|
|
struct coord *c = transform_center(this_->trans); |
3891 |
|
|
struct coord c1, c2; |
3892 |
|
|
enum projection pro = transform_get_projection(this_->trans); |
3893 |
|
|
|
3894 |
|
|
if (pro != center->pro) |
3895 |
|
|
{ |
3896 |
|
|
c1.x = center->x; |
3897 |
|
|
c1.y = center->y; |
3898 |
|
|
transform_from_to(&c1, center->pro, &c2, pro); |
3899 |
|
|
} |
3900 |
|
|
else |
3901 |
|
|
{ |
3902 |
|
|
c2.x = center->x; |
3903 |
|
|
c2.y = center->y; |
3904 |
|
|
} |
3905 |
|
|
|
3906 |
|
|
*c = c2; |
3907 |
|
|
if (set_timeout) |
3908 |
|
|
{ |
3909 |
|
|
navit_set_timeout(this_); |
3910 |
|
|
} |
3911 |
|
|
} |
3912 |
|
|
|
3913 |
zoff99 |
27 |
static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout) |
3914 |
zoff99 |
2 |
{ |
3915 |
zoff99 |
40 |
|
3916 |
|
|
|
3917 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
3918 |
zoff99 |
2 |
int width, height; |
3919 |
|
|
struct point po; |
3920 |
|
|
transform_set_center(this_->trans, c); |
3921 |
|
|
transform_get_size(this_->trans, &width, &height); |
3922 |
zoff99 |
27 |
po.x = width / 2; |
3923 |
|
|
po.y = height / 2; |
3924 |
zoff99 |
2 |
update_transformation(this_->trans, &po, p, NULL); |
3925 |
|
|
if (set_timeout) |
3926 |
zoff99 |
27 |
{ |
3927 |
zoff99 |
2 |
navit_set_timeout(this_); |
3928 |
zoff99 |
27 |
} |
3929 |
zoff99 |
2 |
} |
3930 |
|
|
|
3931 |
|
|
/** |
3932 |
|
|
* Links all vehicles to a cursor depending on the current profile. |
3933 |
|
|
* |
3934 |
|
|
* @param this_ A navit instance |
3935 |
|
|
* @author Ralph Sennhauser (10/2009) |
3936 |
|
|
*/ |
3937 |
zoff99 |
27 |
void navit_set_cursors(struct navit *this_) |
3938 |
zoff99 |
2 |
{ |
3939 |
zoff99 |
40 |
|
3940 |
|
|
|
3941 |
zoff99 |
2 |
struct attr name; |
3942 |
|
|
struct navit_vehicle *nv; |
3943 |
|
|
struct cursor *c; |
3944 |
|
|
GList *v; |
3945 |
|
|
|
3946 |
zoff99 |
27 |
//dbg(0, "Enter\n"); |
3947 |
|
|
|
3948 |
|
|
v = g_list_first(this_->vehicles); // GList of navit_vehicles |
3949 |
|
|
while (v) |
3950 |
|
|
{ |
3951 |
|
|
dbg(0, "* found vehicle *\n"); |
3952 |
|
|
nv = v->data; |
3953 |
|
|
if (vehicle_get_attr(nv->vehicle, attr_cursorname, &name, NULL)) |
3954 |
|
|
{ |
3955 |
|
|
if (!strcmp(name.u.str, "none")) |
3956 |
|
|
{ |
3957 |
|
|
c = NULL; |
3958 |
|
|
} |
3959 |
zoff99 |
2 |
else |
3960 |
zoff99 |
27 |
{ |
3961 |
|
|
c = layout_get_cursor(this_->layout_current, name.u.str); |
3962 |
|
|
} |
3963 |
|
|
} |
3964 |
|
|
else |
3965 |
|
|
{ |
3966 |
|
|
c = layout_get_cursor(this_->layout_current, "default"); |
3967 |
|
|
} |
3968 |
zoff99 |
2 |
vehicle_set_cursor(nv->vehicle, c, 0); |
3969 |
zoff99 |
27 |
v = g_list_next(v); |
3970 |
zoff99 |
2 |
} |
3971 |
|
|
return; |
3972 |
|
|
} |
3973 |
|
|
|
3974 |
zoff99 |
27 |
void navit_remove_cursors(struct navit *this_) |
3975 |
zoff99 |
2 |
{ |
3976 |
zoff99 |
40 |
|
3977 |
|
|
|
3978 |
zoff99 |
27 |
struct attr name; |
3979 |
|
|
struct navit_vehicle *nv; |
3980 |
|
|
struct cursor *c; |
3981 |
|
|
GList *v; |
3982 |
|
|
|
3983 |
|
|
//dbg(0, "Enter\n"); |
3984 |
|
|
name.type = attr_cursor; |
3985 |
|
|
|
3986 |
|
|
v = g_list_first(this_->vehicles); // GList of navit_vehicles |
3987 |
|
|
while (v) |
3988 |
|
|
{ |
3989 |
|
|
dbg(0, "* found vehicle *\n"); |
3990 |
|
|
nv = v->data; |
3991 |
|
|
vehicle_remove_attr(nv->vehicle, &name); |
3992 |
|
|
v = g_list_next(v); |
3993 |
|
|
} |
3994 |
|
|
return; |
3995 |
|
|
} |
3996 |
|
|
|
3997 |
|
|
static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir) |
3998 |
|
|
{ |
3999 |
zoff99 |
41 |
//// dbg(0,"EEnter\n"); |
4000 |
zoff99 |
40 |
|
4001 |
zoff99 |
2 |
int width, height; |
4002 |
zoff99 |
27 |
struct navit_vehicle *nv = this_->vehicle; |
4003 |
zoff99 |
2 |
|
4004 |
zoff99 |
41 |
// valid values: 0 - 50 (0 -> center of screen, 50 -> bottom of screen) |
4005 |
|
|
// float offset = this_->radius; // Cursor offset from the center of the screen (percent). // percent of what?? |
4006 |
|
|
|
4007 |
|
|
float offset = 0; |
4008 |
|
|
|
4009 |
|
|
|
4010 |
|
|
#if 0 |
4011 |
|
|
|
4012 |
|
|
/* Better improve track.c to get that issue resolved or make it configurable with being off the default, the jumping back to the center is a bit annoying */ |
4013 |
zoff99 |
27 |
float min_offset = 0.; // Percent offset at min_offset_speed. |
4014 |
|
|
float max_offset = 30.; // Percent offset at max_offset_speed. |
4015 |
|
|
int min_offset_speed = 2; // Speed in km/h |
4016 |
|
|
int max_offset_speed = 50; // Speed ini km/h |
4017 |
|
|
// Calculate cursor offset from the center of the screen, upon speed. |
4018 |
|
|
if (nv->speed <= min_offset_speed) |
4019 |
|
|
{ |
4020 |
|
|
offset = min_offset; |
4021 |
|
|
} |
4022 |
|
|
else if (nv->speed > max_offset_speed) |
4023 |
|
|
{ |
4024 |
|
|
offset = max_offset; |
4025 |
|
|
} |
4026 |
|
|
else |
4027 |
|
|
{ |
4028 |
|
|
offset = (max_offset - min_offset) / (max_offset_speed - min_offset_speed) * (nv->speed - min_offset_speed); |
4029 |
|
|
} |
4030 |
zoff99 |
41 |
|
4031 |
zoff99 |
2 |
#endif |
4032 |
|
|
|
4033 |
|
|
transform_get_size(this_->trans, &width, &height); |
4034 |
zoff99 |
41 |
|
4035 |
|
|
if (height == 0) |
4036 |
|
|
{ |
4037 |
|
|
offset = 0; |
4038 |
|
|
} |
4039 |
|
|
else |
4040 |
|
|
{ |
4041 |
|
|
// dbg(0, "VEHICLE_OFFSET:a:r=%d %d %d\n", (int)this_->radius, (int)(height - this_->radius), (int)((height - this_->radius) - (height / 2))); |
4042 |
|
|
offset = (float)((height - this_->radius) - (height / 2)) / (float)height * (float)50.0; |
4043 |
|
|
// dbg(0, "VEHICLE_OFFSET:b:o=%d\n", (int)offset); |
4044 |
|
|
} |
4045 |
|
|
|
4046 |
|
|
|
4047 |
|
|
// dbg(0, "VEHICLE_OFFSET:or=%d keep_or=%d\n", this_->orientation, keep_orientation); |
4048 |
|
|
|
4049 |
zoff99 |
27 |
if (this_->orientation == -1 || keep_orientation) |
4050 |
|
|
{ |
4051 |
zoff99 |
41 |
p->x = 50 * width / 100; // = (width / 2) // why doesnt it just say that? |
4052 |
|
|
p->y = (50 + (int)offset) * height / 100; |
4053 |
|
|
|
4054 |
|
|
// dbg(0, "VEHICLE_OFFSET:2:%d %d %d\n", p->y, width, height); |
4055 |
|
|
|
4056 |
zoff99 |
27 |
if (dir) |
4057 |
zoff99 |
30 |
{ |
4058 |
zoff99 |
27 |
*dir = keep_orientation ? this_->orientation : nv->dir; |
4059 |
zoff99 |
30 |
} |
4060 |
zoff99 |
27 |
} |
4061 |
|
|
else |
4062 |
|
|
{ |
4063 |
zoff99 |
2 |
int mdir; |
4064 |
zoff99 |
27 |
if (this_->tracking && this_->tracking_flag) |
4065 |
|
|
{ |
4066 |
zoff99 |
2 |
mdir = tracking_get_angle(this_->tracking) - this_->orientation; |
4067 |
zoff99 |
41 |
// dbg(0, "+++++tr angle=%d\n", tracking_get_angle(this_->tracking)); |
4068 |
|
|
// dbg(0, "+++++this ori=%d\n", this_->orientation); |
4069 |
zoff99 |
2 |
} |
4070 |
zoff99 |
27 |
else |
4071 |
|
|
{ |
4072 |
|
|
mdir = nv->dir - this_->orientation; |
4073 |
|
|
} |
4074 |
zoff99 |
2 |
|
4075 |
zoff99 |
27 |
p->x = (50 - offset * sin(M_PI * mdir / 180.)) * width / 100; |
4076 |
|
|
p->y = (50 + offset * cos(M_PI * mdir / 180.)) * height / 100; |
4077 |
zoff99 |
41 |
|
4078 |
|
|
// dbg(0, "VEHICLE_OFFSET:3:%d %d %d\n", p->y, width, height); |
4079 |
|
|
|
4080 |
zoff99 |
2 |
if (dir) |
4081 |
zoff99 |
30 |
{ |
4082 |
zoff99 |
27 |
*dir = this_->orientation; |
4083 |
zoff99 |
30 |
} |
4084 |
zoff99 |
2 |
} |
4085 |
|
|
return 1; |
4086 |
|
|
} |
4087 |
|
|
|
4088 |
zoff99 |
27 |
void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) |
4089 |
zoff99 |
2 |
{ |
4090 |
zoff99 |
40 |
|
4091 |
|
|
|
4092 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
4093 |
zoff99 |
2 |
int dir; |
4094 |
|
|
struct point pn; |
4095 |
zoff99 |
27 |
struct navit_vehicle *nv = this_->vehicle; |
4096 |
zoff99 |
2 |
navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); |
4097 |
|
|
transform_set_yaw(this_->trans, dir); |
4098 |
|
|
navit_set_center_coord_screen(this_, &nv->coord, &pn, 0); |
4099 |
zoff99 |
41 |
// OLD // navit_aXXutozoom(this_, &nv->coord, nv->speed, 0); |
4100 |
zoff99 |
2 |
} |
4101 |
|
|
|
4102 |
zoff99 |
27 |
static void navit_set_center_cursor_draw(struct navit *this_) |
4103 |
zoff99 |
2 |
{ |
4104 |
zoff99 |
40 |
|
4105 |
|
|
|
4106 |
zoff99 |
28 |
//dbg(0,"EEnter\n"); |
4107 |
zoff99 |
27 |
navit_set_center_cursor(this_, 1, 0); |
4108 |
zoff99 |
2 |
if (this_->ready == 3) |
4109 |
|
|
{ |
4110 |
zoff99 |
40 |
// dbg(0,"navit_draw_async_005\n"); |
4111 |
zoff99 |
30 |
//dbg(0,"DO__DRAW:navit_draw_async call (AS)\n"); |
4112 |
zoff99 |
40 |
// zzz554 // navit_draw_async(this_, 1); |
4113 |
zoff99 |
2 |
} |
4114 |
|
|
} |
4115 |
|
|
|
4116 |
zoff99 |
27 |
static void navit_cmd_set_center_cursor(struct navit *this_) |
4117 |
zoff99 |
2 |
{ |
4118 |
zoff99 |
40 |
|
4119 |
|
|
|
4120 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
4121 |
zoff99 |
2 |
navit_set_center_cursor_draw(this_); |
4122 |
|
|
} |
4123 |
|
|
|
4124 |
zoff99 |
27 |
void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout) |
4125 |
zoff99 |
2 |
{ |
4126 |
zoff99 |
40 |
|
4127 |
|
|
|
4128 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
4129 |
zoff99 |
2 |
struct coord c; |
4130 |
|
|
struct pcoord pc; |
4131 |
|
|
transform_reverse(this_->trans, p, &c); |
4132 |
|
|
pc.x = c.x; |
4133 |
|
|
pc.y = c.y; |
4134 |
|
|
pc.pro = transform_get_projection(this_->trans); |
4135 |
|
|
navit_set_center(this_, &pc, set_timeout); |
4136 |
|
|
} |
4137 |
|
|
|
4138 |
|
|
#if 0 |
4139 |
zoff99 |
27 |
switch((*attrs)->type) |
4140 |
|
|
{ |
4141 |
|
|
case attr_zoom: |
4142 |
|
|
zoom=(*attrs)->u.num; |
4143 |
|
|
break; |
4144 |
|
|
case attr_center: |
4145 |
|
|
g=*((*attrs)->u.coord_geo); |
4146 |
|
|
break; |
4147 |
zoff99 |
2 |
#endif |
4148 |
|
|
|
4149 |
zoff99 |
27 |
static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) |
4150 |
zoff99 |
2 |
{ |
4151 |
zoff99 |
40 |
|
4152 |
zoff99 |
27 |
int dir = 0, orient_old = 0, attr_updated = 0; |
4153 |
zoff99 |
2 |
struct coord co; |
4154 |
|
|
long zoom; |
4155 |
|
|
GList *l; |
4156 |
|
|
struct navit_vehicle *nv; |
4157 |
|
|
struct layout *lay; |
4158 |
|
|
struct attr active; |
4159 |
zoff99 |
27 |
active.type = attr_active; |
4160 |
|
|
active.u.num = 0; |
4161 |
zoff99 |
2 |
|
4162 |
zoff99 |
27 |
switch (attr->type) |
4163 |
|
|
{ |
4164 |
|
|
case attr_autozoom: |
4165 |
|
|
attr_updated = (this_->autozoom_secs != attr->u.num); |
4166 |
|
|
this_->autozoom_secs = attr->u.num; |
4167 |
|
|
break; |
4168 |
|
|
case attr_autozoom_active: |
4169 |
|
|
attr_updated = (this_->autozoom_active != attr->u.num); |
4170 |
|
|
this_->autozoom_active = attr->u.num; |
4171 |
|
|
break; |
4172 |
|
|
case attr_center: |
4173 |
|
|
transform_from_geo(transform_get_projection(this_->trans), attr->u.coord_geo, &co); |
4174 |
|
|
// dbg(1, "0x%x,0x%x\n", co.x, co.y); |
4175 |
|
|
transform_set_center(this_->trans, &co); |
4176 |
|
|
break; |
4177 |
|
|
case attr_drag_bitmap: |
4178 |
|
|
attr_updated = (this_->drag_bitmap != !!attr->u.num); |
4179 |
|
|
this_->drag_bitmap = !!attr->u.num; |
4180 |
|
|
break; |
4181 |
|
|
case attr_flags: |
4182 |
|
|
attr_updated = (this_->flags != attr->u.num); |
4183 |
|
|
this_->flags = attr->u.num; |
4184 |
|
|
break; |
4185 |
|
|
case attr_flags_graphics: |
4186 |
|
|
attr_updated = (this_->graphics_flags != attr->u.num); |
4187 |
|
|
this_->graphics_flags = attr->u.num; |
4188 |
|
|
break; |
4189 |
|
|
case attr_follow: |
4190 |
|
|
if (!this_->vehicle) |
4191 |
|
|
return 0; |
4192 |
|
|
attr_updated = (this_->vehicle->follow_curr != attr->u.num); |
4193 |
|
|
this_->vehicle->follow_curr = attr->u.num; |
4194 |
|
|
break; |
4195 |
|
|
case attr_layout: |
4196 |
|
|
if (this_->layout_current != attr->u.layout) |
4197 |
|
|
{ |
4198 |
|
|
this_->layout_current = attr->u.layout; |
4199 |
|
|
graphics_font_destroy_all(this_->gra); |
4200 |
|
|
navit_set_cursors(this_); |
4201 |
|
|
if (this_->ready == 3) |
4202 |
|
|
navit_draw(this_); |
4203 |
|
|
attr_updated = 1; |
4204 |
|
|
} |
4205 |
|
|
break; |
4206 |
|
|
case attr_layout_name: |
4207 |
|
|
l = this_->layouts; |
4208 |
|
|
while (l) |
4209 |
|
|
{ |
4210 |
|
|
lay = l->data; |
4211 |
|
|
if (!strcmp(lay->name, attr->u.str)) |
4212 |
|
|
{ |
4213 |
|
|
struct attr attr; |
4214 |
|
|
attr.type = attr_layout; |
4215 |
|
|
attr.u.layout = lay; |
4216 |
|
|
return navit_set_attr_do(this_, &attr, init); |
4217 |
|
|
} |
4218 |
|
|
l = g_list_next(l); |
4219 |
|
|
} |
4220 |
zoff99 |
2 |
return 0; |
4221 |
zoff99 |
27 |
case attr_map_border: |
4222 |
|
|
if (this_->border != attr->u.num) |
4223 |
|
|
{ |
4224 |
|
|
this_->border = attr->u.num; |
4225 |
|
|
attr_updated = 1; |
4226 |
zoff99 |
2 |
} |
4227 |
zoff99 |
27 |
break; |
4228 |
|
|
case attr_orientation: |
4229 |
|
|
orient_old = this_->orientation; |
4230 |
|
|
this_->orientation = attr->u.num; |
4231 |
|
|
if (!init) |
4232 |
|
|
{ |
4233 |
|
|
if (this_->orientation != -1) |
4234 |
|
|
{ |
4235 |
|
|
dir = this_->orientation; |
4236 |
zoff99 |
2 |
} |
4237 |
zoff99 |
27 |
else |
4238 |
|
|
{ |
4239 |
|
|
if (this_->vehicle) |
4240 |
|
|
{ |
4241 |
|
|
dir = this_->vehicle->dir; |
4242 |
|
|
} |
4243 |
|
|
} |
4244 |
|
|
transform_set_yaw(this_->trans, dir); |
4245 |
|
|
if (orient_old != this_->orientation) |
4246 |
|
|
{ |
4247 |
zoff99 |
2 |
#if 0 |
4248 |
zoff99 |
27 |
if (this_->ready == 3) |
4249 |
zoff99 |
2 |
navit_draw(this_); |
4250 |
|
|
#endif |
4251 |
zoff99 |
27 |
attr_updated = 1; |
4252 |
|
|
} |
4253 |
zoff99 |
2 |
} |
4254 |
zoff99 |
27 |
break; |
4255 |
|
|
case attr_osd_configuration: |
4256 |
|
|
//DBG dbg(0, "setting osd_configuration to %d (was %d)\n", attr->u.num, this_->osd_configuration); |
4257 |
|
|
attr_updated = (this_->osd_configuration != attr->u.num); |
4258 |
|
|
this_->osd_configuration = attr->u.num; |
4259 |
|
|
break; |
4260 |
|
|
case attr_pitch: |
4261 |
|
|
attr_updated = (this_->pitch != attr->u.num); |
4262 |
|
|
this_->pitch = attr->u.num; |
4263 |
|
|
transform_set_pitch(this_->trans, this_->pitch); |
4264 |
|
|
if (!init && attr_updated && this_->ready == 3) |
4265 |
|
|
navit_draw(this_); |
4266 |
|
|
break; |
4267 |
|
|
case attr_projection: |
4268 |
|
|
if (this_->trans && transform_get_projection(this_->trans) != attr->u.projection) |
4269 |
|
|
{ |
4270 |
|
|
navit_projection_set(this_, attr->u.projection, !init); |
4271 |
|
|
attr_updated = 1; |
4272 |
|
|
} |
4273 |
|
|
break; |
4274 |
|
|
case attr_radius: |
4275 |
|
|
attr_updated = (this_->radius != attr->u.num); |
4276 |
|
|
this_->radius = attr->u.num; |
4277 |
|
|
break; |
4278 |
|
|
case attr_recent_dest: |
4279 |
|
|
attr_updated = (this_->recentdest_count != attr->u.num); |
4280 |
|
|
this_->recentdest_count = attr->u.num; |
4281 |
|
|
break; |
4282 |
|
|
case attr_speech: |
4283 |
|
|
if (this_->speech && this_->speech != attr->u.speech) |
4284 |
|
|
{ |
4285 |
|
|
attr_updated = 1; |
4286 |
|
|
this_->speech = attr->u.speech; |
4287 |
|
|
} |
4288 |
|
|
break; |
4289 |
|
|
case attr_timeout: |
4290 |
|
|
attr_updated = (this_->center_timeout != attr->u.num); |
4291 |
|
|
this_->center_timeout = attr->u.num; |
4292 |
|
|
break; |
4293 |
|
|
case attr_tracking: |
4294 |
|
|
attr_updated = (this_->tracking_flag != !!attr->u.num); |
4295 |
zoff99 |
40 |
// dbg(0, "set attr:attr_tracking old=%d\n", this_->tracking_flag); |
4296 |
zoff99 |
27 |
this_->tracking_flag = !!attr->u.num; |
4297 |
zoff99 |
40 |
// dbg(0, "set attr:attr_tracking new=%d\n", this_->tracking_flag); |
4298 |
zoff99 |
27 |
break; |
4299 |
|
|
case attr_transformation: |
4300 |
|
|
this_->trans = attr->u.transformation; |
4301 |
|
|
break; |
4302 |
|
|
case attr_use_mousewheel: |
4303 |
|
|
attr_updated = (this_->use_mousewheel != !!attr->u.num); |
4304 |
|
|
this_->use_mousewheel = !!attr->u.num; |
4305 |
|
|
break; |
4306 |
|
|
case attr_vehicle: |
4307 |
|
|
l = this_->vehicles; |
4308 |
|
|
while (l) |
4309 |
|
|
{ |
4310 |
|
|
nv = l->data; |
4311 |
|
|
if (nv->vehicle == attr->u.vehicle) |
4312 |
|
|
{ |
4313 |
|
|
if (!this_->vehicle || this_->vehicle->vehicle != attr->u.vehicle) |
4314 |
|
|
{ |
4315 |
|
|
if (this_->vehicle) |
4316 |
zoff99 |
28 |
{ |
4317 |
zoff99 |
27 |
vehicle_set_attr(this_->vehicle->vehicle, &active); |
4318 |
zoff99 |
28 |
} |
4319 |
zoff99 |
27 |
active.u.num = 1; |
4320 |
|
|
vehicle_set_attr(nv->vehicle, &active); |
4321 |
|
|
attr_updated = 1; |
4322 |
|
|
} |
4323 |
|
|
navit_set_vehicle(this_, nv); |
4324 |
zoff99 |
2 |
} |
4325 |
zoff99 |
27 |
l = g_list_next(l); |
4326 |
zoff99 |
2 |
} |
4327 |
zoff99 |
27 |
break; |
4328 |
|
|
case attr_zoom: |
4329 |
|
|
zoom = transform_get_scale(this_->trans); |
4330 |
|
|
attr_updated = (zoom != attr->u.num); |
4331 |
|
|
transform_set_scale(this_->trans, attr->u.num); |
4332 |
|
|
if (attr_updated && !init) |
4333 |
|
|
navit_draw(this_); |
4334 |
|
|
break; |
4335 |
|
|
case attr_zoom_min: |
4336 |
|
|
attr_updated = (attr->u.num != this_->zoom_min); |
4337 |
|
|
this_->zoom_min = attr->u.num; |
4338 |
|
|
break; |
4339 |
|
|
case attr_zoom_max: |
4340 |
|
|
attr_updated = (attr->u.num != this_->zoom_max); |
4341 |
|
|
this_->zoom_max = attr->u.num; |
4342 |
|
|
break; |
4343 |
|
|
case attr_message: |
4344 |
|
|
//navit_add_message(this_, attr->u.str); |
4345 |
|
|
break; |
4346 |
|
|
case attr_follow_cursor: |
4347 |
|
|
attr_updated = (this_->follow_cursor != !!attr->u.num); |
4348 |
|
|
this_->follow_cursor = !!attr->u.num; |
4349 |
|
|
break; |
4350 |
|
|
case attr_imperial: |
4351 |
|
|
attr_updated = (this_->imperial != attr->u.num); |
4352 |
|
|
this_->imperial = attr->u.num; |
4353 |
|
|
break; |
4354 |
|
|
default: |
4355 |
|
|
return 0; |
4356 |
zoff99 |
2 |
} |
4357 |
zoff99 |
40 |
|
4358 |
zoff99 |
27 |
if (attr_updated && !init) |
4359 |
|
|
{ |
4360 |
zoff99 |
40 |
// dbg(0, "set attr:call callback_list_call_attr_2\n"); |
4361 |
zoff99 |
2 |
callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); |
4362 |
zoff99 |
40 |
|
4363 |
zoff99 |
2 |
if (attr->type == attr_osd_configuration) |
4364 |
zoff99 |
28 |
{ |
4365 |
zoff99 |
2 |
graphics_draw_mode(this_->gra, draw_mode_end); |
4366 |
zoff99 |
28 |
} |
4367 |
zoff99 |
2 |
} |
4368 |
zoff99 |
28 |
|
4369 |
zoff99 |
2 |
return 1; |
4370 |
|
|
} |
4371 |
|
|
|
4372 |
zoff99 |
27 |
int navit_set_attr(struct navit *this_, struct attr *attr) |
4373 |
zoff99 |
2 |
{ |
4374 |
|
|
return navit_set_attr_do(this_, attr, 0); |
4375 |
|
|
} |
4376 |
|
|
|
4377 |
zoff99 |
27 |
int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) |
4378 |
zoff99 |
2 |
{ |
4379 |
zoff99 |
40 |
|
4380 |
zoff99 |
2 |
struct message *msg; |
4381 |
zoff99 |
27 |
int len, offset; |
4382 |
|
|
int ret = 1; |
4383 |
zoff99 |
2 |
|
4384 |
zoff99 |
27 |
switch (type) |
4385 |
|
|
{ |
4386 |
|
|
case attr_message: |
4387 |
zoff99 |
2 |
return 0; |
4388 |
zoff99 |
27 |
/* |
4389 |
|
|
msg = navit_get_messages(this_); |
4390 |
zoff99 |
2 |
|
4391 |
zoff99 |
27 |
if (!msg) |
4392 |
|
|
{ |
4393 |
|
|
return 0; |
4394 |
|
|
} |
4395 |
zoff99 |
2 |
|
4396 |
zoff99 |
27 |
len = 0; |
4397 |
|
|
while (msg) |
4398 |
|
|
{ |
4399 |
|
|
len += strlen(msg->text) + 1; |
4400 |
|
|
msg = msg->next; |
4401 |
|
|
} |
4402 |
|
|
attr->u.str = g_malloc(len + 1); |
4403 |
zoff99 |
2 |
|
4404 |
zoff99 |
27 |
msg = navit_get_messages(this_); |
4405 |
|
|
offset = 0; |
4406 |
|
|
while (msg) |
4407 |
|
|
{ |
4408 |
|
|
g_stpcpy((attr->u.str + offset), msg->text); |
4409 |
|
|
offset += strlen(msg->text); |
4410 |
|
|
attr->u.str[offset] = '\n'; |
4411 |
|
|
offset++; |
4412 |
|
|
|
4413 |
|
|
msg = msg->next; |
4414 |
|
|
} |
4415 |
|
|
|
4416 |
|
|
attr->u.str[len] = '\0'; |
4417 |
|
|
*/ |
4418 |
|
|
break; |
4419 |
|
|
case attr_imperial: |
4420 |
|
|
attr->u.num = this_->imperial; |
4421 |
|
|
break; |
4422 |
|
|
case attr_bookmark_map: |
4423 |
|
|
attr->u.map = bookmarks_get_map(this_->bookmarks); |
4424 |
|
|
break; |
4425 |
|
|
case attr_bookmarks: |
4426 |
|
|
attr->u.bookmarks = this_->bookmarks; |
4427 |
|
|
break; |
4428 |
|
|
case attr_callback_list: |
4429 |
|
|
attr->u.callback_list = this_->attr_cbl; |
4430 |
|
|
break; |
4431 |
|
|
case attr_destination: |
4432 |
|
|
if (!this_->destination_valid) |
4433 |
|
|
return 0; |
4434 |
|
|
attr->u.pcoord = &this_->destination; |
4435 |
|
|
break; |
4436 |
|
|
case attr_displaylist: |
4437 |
|
|
attr->u.displaylist = this_->displaylist; |
4438 |
|
|
return (attr->u.displaylist != NULL); |
4439 |
|
|
case attr_follow: |
4440 |
|
|
if (!this_->vehicle) |
4441 |
|
|
return 0; |
4442 |
|
|
attr->u.num = this_->vehicle->follow_curr; |
4443 |
|
|
break; |
4444 |
|
|
case attr_former_destination_map: |
4445 |
|
|
attr->u.map = this_->former_destination; |
4446 |
|
|
break; |
4447 |
|
|
case attr_graphics: |
4448 |
|
|
attr->u.graphics = this_->gra; |
4449 |
|
|
ret = (attr->u.graphics != NULL); |
4450 |
|
|
break; |
4451 |
|
|
case attr_gui: |
4452 |
|
|
attr->u.gui = this_->gui; |
4453 |
|
|
ret = (attr->u.gui != NULL); |
4454 |
|
|
break; |
4455 |
|
|
case attr_layout: |
4456 |
|
|
if (iter) |
4457 |
zoff99 |
2 |
{ |
4458 |
zoff99 |
27 |
if (iter->u.list) |
4459 |
|
|
{ |
4460 |
|
|
iter->u.list = g_list_next(iter->u.list); |
4461 |
|
|
} |
4462 |
|
|
else |
4463 |
|
|
{ |
4464 |
|
|
iter->u.list = this_->layouts; |
4465 |
|
|
} |
4466 |
|
|
if (!iter->u.list) |
4467 |
|
|
{ |
4468 |
|
|
return 0; |
4469 |
|
|
} |
4470 |
|
|
attr->u.layout = (struct layout *) iter->u.list->data; |
4471 |
zoff99 |
2 |
} |
4472 |
|
|
else |
4473 |
|
|
{ |
4474 |
zoff99 |
27 |
attr->u.layout = this_->layout_current; |
4475 |
zoff99 |
2 |
} |
4476 |
zoff99 |
27 |
break; |
4477 |
|
|
case attr_map: |
4478 |
|
|
if (iter && this_->mapsets) |
4479 |
zoff99 |
2 |
{ |
4480 |
zoff99 |
27 |
if (!iter->u.mapset_handle) |
4481 |
|
|
{ |
4482 |
|
|
iter->u.mapset_handle = mapset_open((struct mapset *) this_->mapsets->data); |
4483 |
|
|
} |
4484 |
|
|
attr->u.map = mapset_next(iter->u.mapset_handle, 0); |
4485 |
|
|
if (!attr->u.map) |
4486 |
|
|
{ |
4487 |
|
|
mapset_close(iter->u.mapset_handle); |
4488 |
|
|
return 0; |
4489 |
|
|
} |
4490 |
|
|
} |
4491 |
|
|
else |
4492 |
|
|
{ |
4493 |
zoff99 |
2 |
return 0; |
4494 |
|
|
} |
4495 |
zoff99 |
27 |
break; |
4496 |
|
|
case attr_mapset: |
4497 |
|
|
attr->u.mapset = this_->mapsets->data; |
4498 |
|
|
ret = (attr->u.mapset != NULL); |
4499 |
|
|
break; |
4500 |
|
|
case attr_navigation: |
4501 |
|
|
attr->u.navigation = this_->navigation; |
4502 |
|
|
break; |
4503 |
|
|
case attr_orientation: |
4504 |
|
|
attr->u.num = this_->orientation; |
4505 |
|
|
break; |
4506 |
|
|
case attr_osd_configuration: |
4507 |
|
|
attr->u.num = this_->osd_configuration; |
4508 |
|
|
break; |
4509 |
|
|
case attr_pitch: |
4510 |
|
|
attr->u.num = transform_get_pitch(this_->trans); |
4511 |
|
|
break; |
4512 |
|
|
case attr_projection: |
4513 |
|
|
if (this_->trans) |
4514 |
|
|
{ |
4515 |
|
|
attr->u.num = transform_get_projection(this_->trans); |
4516 |
zoff99 |
2 |
} |
4517 |
zoff99 |
27 |
else |
4518 |
|
|
{ |
4519 |
zoff99 |
2 |
return 0; |
4520 |
|
|
} |
4521 |
zoff99 |
27 |
break; |
4522 |
|
|
case attr_route: |
4523 |
|
|
attr->u.route = this_->route; |
4524 |
|
|
break; |
4525 |
|
|
case attr_speech: |
4526 |
|
|
attr->u.speech = this_->speech; |
4527 |
|
|
break; |
4528 |
|
|
case attr_tracking: |
4529 |
|
|
attr->u.num = this_->tracking_flag; |
4530 |
|
|
break; |
4531 |
|
|
case attr_trackingo: |
4532 |
|
|
attr->u.tracking = this_->tracking; |
4533 |
|
|
break; |
4534 |
|
|
case attr_transformation: |
4535 |
|
|
attr->u.transformation = this_->trans; |
4536 |
|
|
break; |
4537 |
|
|
case attr_vehicle: |
4538 |
|
|
if (iter) |
4539 |
|
|
{ |
4540 |
|
|
if (iter->u.list) |
4541 |
|
|
{ |
4542 |
|
|
iter->u.list = g_list_next(iter->u.list); |
4543 |
|
|
} |
4544 |
|
|
else |
4545 |
|
|
{ |
4546 |
|
|
iter->u.list = this_->vehicles; |
4547 |
|
|
} |
4548 |
|
|
if (!iter->u.list) |
4549 |
|
|
return 0; |
4550 |
|
|
attr->u.vehicle = ((struct navit_vehicle*) iter->u.list->data)->vehicle; |
4551 |
zoff99 |
2 |
} |
4552 |
zoff99 |
27 |
else |
4553 |
|
|
{ |
4554 |
|
|
if (this_->vehicle) |
4555 |
|
|
{ |
4556 |
|
|
attr->u.vehicle = this_->vehicle->vehicle; |
4557 |
|
|
} |
4558 |
|
|
else |
4559 |
|
|
{ |
4560 |
|
|
return 0; |
4561 |
|
|
} |
4562 |
zoff99 |
2 |
} |
4563 |
zoff99 |
27 |
break; |
4564 |
|
|
case attr_vehicleprofile: |
4565 |
|
|
attr->u.vehicleprofile = this_->vehicleprofile; |
4566 |
|
|
break; |
4567 |
|
|
case attr_zoom: |
4568 |
|
|
attr->u.num = transform_get_scale(this_->trans); |
4569 |
|
|
break; |
4570 |
|
|
case attr_autozoom_active: |
4571 |
|
|
attr->u.num = this_->autozoom_active; |
4572 |
|
|
break; |
4573 |
|
|
case attr_follow_cursor: |
4574 |
|
|
attr->u.num = this_->follow_cursor; |
4575 |
|
|
break; |
4576 |
|
|
default: |
4577 |
|
|
return 0; |
4578 |
zoff99 |
2 |
} |
4579 |
zoff99 |
27 |
attr->type = type; |
4580 |
zoff99 |
28 |
|
4581 |
zoff99 |
2 |
return ret; |
4582 |
|
|
} |
4583 |
|
|
|
4584 |
zoff99 |
31 |
void displaylist_shift_order_in_map_layers(struct navit *this_, int shift_value) |
4585 |
|
|
{ |
4586 |
|
|
|
4587 |
zoff99 |
40 |
|
4588 |
|
|
|
4589 |
zoff99 |
31 |
GList *l; |
4590 |
|
|
struct layout *lay; |
4591 |
|
|
GList *l2; |
4592 |
|
|
struct layer *layer; |
4593 |
|
|
GList *ig; |
4594 |
|
|
struct itemgra *itemgr; |
4595 |
|
|
GList *elements; |
4596 |
|
|
struct element *e; |
4597 |
|
|
|
4598 |
|
|
// loop through all the layouts |
4599 |
|
|
l = this_->layouts; |
4600 |
|
|
while (l) |
4601 |
|
|
{ |
4602 |
|
|
lay = l->data; |
4603 |
|
|
//dbg(0,"layout name=%s\n", lay->name); |
4604 |
|
|
if (!strcmp(lay->name, "Android-Car")) |
4605 |
|
|
{ |
4606 |
|
|
//dbg(0,"layout found\n"); |
4607 |
|
|
l2 = lay->layers; |
4608 |
|
|
while (l2) |
4609 |
|
|
{ |
4610 |
|
|
layer = l2->data; |
4611 |
|
|
//dbg(0,"layer name=%s\n", layer->name); |
4612 |
|
|
// only change the zoom of these layers |
4613 |
|
|
if ((!strcmp(layer->name, "polygons001")) |
4614 |
|
|
|| (!strcmp(layer->name, "polygons")) |
4615 |
|
|
|| (!strcmp(layer->name, "streets")) |
4616 |
zoff99 |
34 |
|| (!strcmp(layer->name, "streets_STR_ONLY")) |
4617 |
zoff99 |
31 |
|| (!strcmp(layer->name, "streets_1")) |
4618 |
zoff99 |
34 |
|| (!strcmp(layer->name, "streets_1_STR_ONLY")) |
4619 |
zoff99 |
31 |
|| (!strcmp(layer->name, "streets_2")) |
4620 |
zoff99 |
34 |
|| (!strcmp(layer->name, "streets_2_STR_ONLY")) |
4621 |
zoff99 |
31 |
|| (!strcmp(layer->name, "route_001")) |
4622 |
|
|
|| (!strcmp(layer->name, "route_002")) |
4623 |
zoff99 |
34 |
|| (!strcmp(layer->name, "route_003")) |
4624 |
zoff99 |
31 |
) |
4625 |
|
|
{ |
4626 |
|
|
//dbg(0,"layer found\n"); |
4627 |
|
|
ig = layer->itemgras; |
4628 |
|
|
while (ig) |
4629 |
|
|
{ |
4630 |
|
|
//dbg(0,"*itgr*\n"); |
4631 |
|
|
itemgr = ig->data; |
4632 |
|
|
|
4633 |
|
|
// now shift "order"-value of itemgra by "shift_value" |
4634 |
|
|
// ! max order == 18 ! |
4635 |
|
|
// ! min order == -2 ! |
4636 |
|
|
|
4637 |
|
|
|
4638 |
|
|
int was_shifted = 0; |
4639 |
|
|
|
4640 |
|
|
//if (itemgr->order.min < 20) |
4641 |
|
|
//{ |
4642 |
|
|
itemgr->order.min = itemgr->order.min - shift_value; |
4643 |
|
|
was_shifted = 1; |
4644 |
|
|
//} |
4645 |
|
|
//if (itemgr->order.min < -2) |
4646 |
|
|
//{ |
4647 |
|
|
// itemgr->order.min = -2; |
4648 |
|
|
//} |
4649 |
|
|
if (itemgr->order.min > 18) |
4650 |
|
|
{ |
4651 |
|
|
itemgr->order.min = 18; |
4652 |
|
|
} |
4653 |
|
|
|
4654 |
|
|
// ------------------------------ |
4655 |
|
|
|
4656 |
|
|
if (itemgr->order.max < 18) |
4657 |
|
|
{ |
4658 |
|
|
itemgr->order.max = itemgr->order.max - shift_value; |
4659 |
|
|
was_shifted = 1; |
4660 |
|
|
} |
4661 |
|
|
// |
4662 |
|
|
//if (itemgr->order.max < -2) |
4663 |
|
|
//{ |
4664 |
|
|
// itemgr->order.max = -2; |
4665 |
|
|
//} |
4666 |
|
|
if (itemgr->order.max > 18) |
4667 |
|
|
{ |
4668 |
|
|
itemgr->order.max = 18; |
4669 |
|
|
} |
4670 |
|
|
|
4671 |
|
|
float sv_001 = ((float) shift_value * 1.34f); |
4672 |
|
|
float sv_002 = ((float) shift_value * 0.75f); |
4673 |
|
|
|
4674 |
|
|
if (was_shifted == 1) |
4675 |
|
|
{ |
4676 |
|
|
// loop thru all the elements in this "itemgra" |
4677 |
|
|
elements = itemgr->elements; |
4678 |
|
|
while (elements) |
4679 |
|
|
{ |
4680 |
|
|
e = elements->data; |
4681 |
|
|
|
4682 |
|
|
if (e->type == element_polyline) |
4683 |
|
|
{ |
4684 |
|
|
// shift polyline width |
4685 |
|
|
e->u.polyline.width = ((float) e->u.polyline.width / sv_001) + 0; |
4686 |
|
|
if (e->u.polyline.width < 1) |
4687 |
|
|
{ |
4688 |
|
|
e->u.polyline.width = 1; |
4689 |
|
|
} |
4690 |
|
|
} |
4691 |
|
|
|
4692 |
|
|
if (e->type == element_circle) |
4693 |
|
|
{ |
4694 |
|
|
// shift circle witdh |
4695 |
|
|
e->u.circle.width = ((float) e->u.circle.width / sv_001) + 0; |
4696 |
|
|
if (e->u.circle.width < 1) |
4697 |
|
|
{ |
4698 |
|
|
e->u.circle.width = 1; |
4699 |
|
|
} |
4700 |
|
|
|
4701 |
|
|
e->u.circle.radius = ((float) e->u.circle.radius / sv_001) + 0; |
4702 |
|
|
if (e->u.circle.radius < 1) |
4703 |
|
|
{ |
4704 |
|
|
e->u.circle.radius = 1; |
4705 |
|
|
} |
4706 |
|
|
} |
4707 |
|
|
|
4708 |
|
|
if (e->type == element_text) |
4709 |
|
|
{ |
4710 |
|
|
// shift text size |
4711 |
|
|
e->text_size = (float) e->text_size / sv_002; |
4712 |
|
|
if (e->text_size < 1) |
4713 |
|
|
{ |
4714 |
|
|
e->text_size = 1; |
4715 |
|
|
} |
4716 |
|
|
} |
4717 |
|
|
elements = g_list_next(elements); |
4718 |
|
|
} |
4719 |
|
|
// loop thru all the elements in this "itemgra" |
4720 |
|
|
} |
4721 |
|
|
|
4722 |
|
|
ig = g_list_next(ig); |
4723 |
|
|
} |
4724 |
|
|
} |
4725 |
|
|
l2 = g_list_next(l2); |
4726 |
|
|
} |
4727 |
|
|
} |
4728 |
|
|
l = g_list_next(l); |
4729 |
|
|
} |
4730 |
|
|
|
4731 |
|
|
#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
4732 |
|
|
dbg(0,"+#+:leave\n"); |
4733 |
|
|
#endif |
4734 |
|
|
} |
4735 |
|
|
|
4736 |
zoff99 |
34 |
void displaylist_shift_for_dpi_value_in_layers(struct navit *this_, double factor) |
4737 |
|
|
{ |
4738 |
|
|
|
4739 |
zoff99 |
40 |
|
4740 |
|
|
|
4741 |
zoff99 |
34 |
GList *l; |
4742 |
|
|
struct layout *lay; |
4743 |
|
|
GList *l2; |
4744 |
|
|
struct layer *layer; |
4745 |
|
|
GList *ig; |
4746 |
|
|
struct itemgra *itemgr; |
4747 |
|
|
GList *elements; |
4748 |
|
|
struct element *e; |
4749 |
|
|
|
4750 |
|
|
// loop through all the layouts |
4751 |
|
|
l = this_->layouts; |
4752 |
|
|
while (l) |
4753 |
|
|
{ |
4754 |
|
|
lay = l->data; |
4755 |
|
|
//dbg(0,"layout name=%s\n", lay->name); |
4756 |
|
|
if (!strcmp(lay->name, "Android-Car")) |
4757 |
|
|
{ |
4758 |
|
|
//dbg(0,"layout found\n"); |
4759 |
|
|
l2 = lay->layers; |
4760 |
|
|
while (l2) |
4761 |
|
|
{ |
4762 |
|
|
layer = l2->data; |
4763 |
|
|
//dbg(0,"layer name=%s\n", layer->name); |
4764 |
|
|
// only change the zoom of these layers |
4765 |
|
|
/* |
4766 |
|
|
if ((!strcmp(layer->name, "polygons001")) |
4767 |
|
|
|| (!strcmp(layer->name, "polygons")) |
4768 |
|
|
|| (!strcmp(layer->name, "streets")) |
4769 |
|
|
|| (!strcmp(layer->name, "streets_1")) |
4770 |
|
|
|| (!strcmp(layer->name, "streets_2")) |
4771 |
|
|
|| (!strcmp(layer->name, "route_001")) |
4772 |
|
|
|| (!strcmp(layer->name, "route_002")) |
4773 |
|
|
|| (!strcmp(layer->name, "route_003")) |
4774 |
|
|
) |
4775 |
|
|
*/ |
4776 |
|
|
//{ |
4777 |
|
|
//dbg(0,"layer found\n"); |
4778 |
|
|
ig = layer->itemgras; |
4779 |
|
|
while (ig) |
4780 |
|
|
{ |
4781 |
|
|
//dbg(0,"*itgr*\n"); |
4782 |
|
|
itemgr = ig->data; |
4783 |
|
|
|
4784 |
|
|
// loop thru all the elements in this "itemgra" |
4785 |
|
|
elements = itemgr->elements; |
4786 |
|
|
while (elements) |
4787 |
|
|
{ |
4788 |
|
|
e = elements->data; |
4789 |
|
|
|
4790 |
|
|
if (e->type == element_polyline) |
4791 |
|
|
{ |
4792 |
|
|
// polyline width |
4793 |
|
|
e->u.polyline.width = (int)((float)e->u.polyline.width * factor) + 0; |
4794 |
|
|
if (e->u.polyline.width < 1) |
4795 |
|
|
{ |
4796 |
|
|
e->u.polyline.width = 1; |
4797 |
|
|
} |
4798 |
|
|
} |
4799 |
|
|
|
4800 |
|
|
if (e->type == element_circle) |
4801 |
|
|
{ |
4802 |
|
|
// circle witdh |
4803 |
|
|
e->u.circle.width = (int)((float)e->u.circle.width * factor) + 0; |
4804 |
|
|
if (e->u.circle.width < 1) |
4805 |
|
|
{ |
4806 |
|
|
e->u.circle.width = 1; |
4807 |
|
|
} |
4808 |
|
|
|
4809 |
|
|
e->u.circle.radius = (int)((float)e->u.circle.radius * factor) + 0; |
4810 |
|
|
if (e->u.circle.radius < 1) |
4811 |
|
|
{ |
4812 |
|
|
e->u.circle.radius = 1; |
4813 |
|
|
} |
4814 |
|
|
|
4815 |
|
|
// text size |
4816 |
|
|
e->text_size = (int)((float)(e->text_size * factor)); |
4817 |
|
|
if (e->text_size < 1) |
4818 |
|
|
{ |
4819 |
|
|
e->text_size = 1; |
4820 |
|
|
} |
4821 |
|
|
|
4822 |
|
|
} |
4823 |
|
|
|
4824 |
|
|
if (e->type == element_text) |
4825 |
|
|
{ |
4826 |
|
|
// text size |
4827 |
|
|
e->text_size = (int)((float)(e->text_size * factor)); |
4828 |
|
|
if (e->text_size < 1) |
4829 |
|
|
{ |
4830 |
|
|
e->text_size = 1; |
4831 |
|
|
} |
4832 |
|
|
} |
4833 |
|
|
elements = g_list_next(elements); |
4834 |
|
|
} |
4835 |
|
|
// loop thru all the elements in this "itemgra" |
4836 |
|
|
ig = g_list_next(ig); |
4837 |
|
|
} |
4838 |
|
|
//} |
4839 |
|
|
l2 = g_list_next(l2); |
4840 |
|
|
} |
4841 |
|
|
} |
4842 |
|
|
l = g_list_next(l); |
4843 |
|
|
} |
4844 |
|
|
|
4845 |
|
|
#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
4846 |
|
|
dbg(0,"+#+:leave\n"); |
4847 |
|
|
#endif |
4848 |
|
|
} |
4849 |
|
|
|
4850 |
|
|
|
4851 |
zoff99 |
27 |
static int navit_add_log(struct navit *this_, struct log *log) |
4852 |
zoff99 |
2 |
{ |
4853 |
zoff99 |
40 |
|
4854 |
|
|
|
4855 |
zoff99 |
2 |
struct attr type_attr; |
4856 |
|
|
if (!log_get_attr(log, attr_type, &type_attr, NULL)) |
4857 |
|
|
return 0; |
4858 |
zoff99 |
27 |
if (!strcmp(type_attr.u.str, "textfile_debug")) |
4859 |
|
|
{ |
4860 |
zoff99 |
2 |
char *header = "type=track_tracked\n"; |
4861 |
|
|
if (this_->textfile_debug_log) |
4862 |
|
|
return 0; |
4863 |
|
|
log_set_header(log, header, strlen(header)); |
4864 |
zoff99 |
27 |
this_->textfile_debug_log = log; |
4865 |
zoff99 |
2 |
return 1; |
4866 |
|
|
} |
4867 |
|
|
return 0; |
4868 |
|
|
} |
4869 |
|
|
|
4870 |
zoff99 |
27 |
static int navit_add_layout(struct navit *this_, struct layout *layout) |
4871 |
zoff99 |
2 |
{ |
4872 |
zoff99 |
40 |
|
4873 |
|
|
|
4874 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
4875 |
zoff99 |
2 |
struct attr active; |
4876 |
|
|
this_->layouts = g_list_append(this_->layouts, layout); |
4877 |
|
|
layout_get_attr(layout, attr_active, &active, NULL); |
4878 |
zoff99 |
27 |
if (active.u.num || !this_->layout_current) |
4879 |
|
|
{ |
4880 |
|
|
this_->layout_current = layout; |
4881 |
zoff99 |
2 |
return 1; |
4882 |
|
|
} |
4883 |
|
|
return 0; |
4884 |
|
|
} |
4885 |
|
|
|
4886 |
zoff99 |
27 |
int navit_add_attr(struct navit *this_, struct attr *attr) |
4887 |
zoff99 |
2 |
{ |
4888 |
zoff99 |
40 |
|
4889 |
|
|
|
4890 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
4891 |
zoff99 |
2 |
|
4892 |
zoff99 |
27 |
int ret = 1; |
4893 |
|
|
switch (attr->type) |
4894 |
|
|
{ |
4895 |
|
|
case attr_callback: |
4896 |
|
|
navit_add_callback(this_, attr->u.callback); |
4897 |
|
|
break; |
4898 |
|
|
case attr_log: |
4899 |
|
|
ret = navit_add_log(this_, attr->u.log); |
4900 |
|
|
break; |
4901 |
|
|
case attr_gui: |
4902 |
|
|
ret = navit_set_gui(this_, attr->u.gui); |
4903 |
|
|
break; |
4904 |
|
|
case attr_graphics: |
4905 |
|
|
ret = navit_set_graphics(this_, attr->u.graphics); |
4906 |
|
|
break; |
4907 |
|
|
case attr_layout: |
4908 |
|
|
ret = navit_add_layout(this_, attr->u.layout); |
4909 |
|
|
break; |
4910 |
|
|
case attr_route: |
4911 |
|
|
this_->route = attr->u.route; |
4912 |
|
|
break; |
4913 |
|
|
case attr_mapset: |
4914 |
|
|
this_->mapsets = g_list_append(this_->mapsets, attr->u.mapset); |
4915 |
|
|
break; |
4916 |
|
|
case attr_navigation: |
4917 |
|
|
this_->navigation = attr->u.navigation; |
4918 |
|
|
break; |
4919 |
|
|
case attr_recent_dest: |
4920 |
|
|
this_->recentdest_count = attr->u.num; |
4921 |
|
|
break; |
4922 |
|
|
case attr_speech: |
4923 |
|
|
this_->speech = attr->u.speech; |
4924 |
|
|
break; |
4925 |
|
|
case attr_tracking: |
4926 |
|
|
this_->tracking = attr->u.tracking; |
4927 |
|
|
break; |
4928 |
|
|
case attr_vehicle: |
4929 |
|
|
ret = navit_add_vehicle(this_, attr->u.vehicle); |
4930 |
|
|
break; |
4931 |
|
|
case attr_vehicleprofile: |
4932 |
|
|
this_->vehicleprofiles = g_list_prepend(this_->vehicleprofiles, attr->u.vehicleprofile); |
4933 |
|
|
break; |
4934 |
|
|
case attr_autozoom_min: |
4935 |
|
|
this_->autozoom_min = attr->u.num; |
4936 |
|
|
break; |
4937 |
|
|
default: |
4938 |
|
|
return 0; |
4939 |
zoff99 |
2 |
} |
4940 |
|
|
callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); |
4941 |
zoff99 |
28 |
|
4942 |
|
|
#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
4943 |
|
|
dbg(0,"+#+:leave\n"); |
4944 |
|
|
#endif |
4945 |
|
|
|
4946 |
zoff99 |
2 |
return ret; |
4947 |
|
|
} |
4948 |
|
|
|
4949 |
zoff99 |
27 |
int navit_remove_attr(struct navit *this_, struct attr *attr) |
4950 |
zoff99 |
2 |
{ |
4951 |
zoff99 |
40 |
|
4952 |
|
|
|
4953 |
zoff99 |
27 |
int ret = 1; |
4954 |
|
|
switch (attr->type) |
4955 |
|
|
{ |
4956 |
|
|
case attr_callback: |
4957 |
|
|
navit_remove_callback(this_, attr->u.callback); |
4958 |
|
|
break; |
4959 |
|
|
default: |
4960 |
|
|
return 0; |
4961 |
zoff99 |
2 |
} |
4962 |
zoff99 |
28 |
|
4963 |
|
|
#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
4964 |
|
|
dbg(0,"+#+:leave\n"); |
4965 |
|
|
#endif |
4966 |
|
|
|
4967 |
zoff99 |
2 |
return ret; |
4968 |
|
|
} |
4969 |
|
|
|
4970 |
|
|
struct attr_iter * |
4971 |
|
|
navit_attr_iter_new(void) |
4972 |
|
|
{ |
4973 |
zoff99 |
40 |
|
4974 |
|
|
|
4975 |
zoff99 |
27 |
return g_new0(struct attr_iter, 1); |
4976 |
zoff99 |
2 |
} |
4977 |
|
|
|
4978 |
zoff99 |
27 |
void navit_attr_iter_destroy(struct attr_iter *iter) |
4979 |
zoff99 |
2 |
{ |
4980 |
zoff99 |
40 |
|
4981 |
|
|
|
4982 |
zoff99 |
2 |
g_free(iter); |
4983 |
|
|
} |
4984 |
|
|
|
4985 |
zoff99 |
27 |
void navit_add_callback(struct navit *this_, struct callback *cb) |
4986 |
zoff99 |
2 |
{ |
4987 |
zoff99 |
40 |
|
4988 |
|
|
|
4989 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
4990 |
zoff99 |
2 |
|
4991 |
|
|
callback_list_add(this_->attr_cbl, cb); |
4992 |
|
|
} |
4993 |
|
|
|
4994 |
zoff99 |
27 |
void navit_remove_callback(struct navit *this_, struct callback *cb) |
4995 |
zoff99 |
2 |
{ |
4996 |
zoff99 |
40 |
|
4997 |
|
|
|
4998 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
4999 |
zoff99 |
2 |
|
5000 |
|
|
callback_list_remove(this_->attr_cbl, cb); |
5001 |
|
|
} |
5002 |
|
|
|
5003 |
|
|
/** |
5004 |
|
|
* Toggle the cursor update : refresh the map each time the cursor has moved (instead of only when it reaches a border) |
5005 |
|
|
* |
5006 |
|
|
* @param navit The navit instance |
5007 |
|
|
* @returns nothing |
5008 |
|
|
*/ |
5009 |
zoff99 |
27 |
static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt) |
5010 |
zoff99 |
2 |
{ |
5011 |
zoff99 |
40 |
__F_START__ |
5012 |
zoff99 |
2 |
|
5013 |
|
|
struct point cursor_pnt; |
5014 |
|
|
enum projection pro; |
5015 |
|
|
|
5016 |
|
|
if (this_->blocked) |
5017 |
zoff99 |
30 |
{ |
5018 |
zoff99 |
40 |
return2; |
5019 |
zoff99 |
30 |
} |
5020 |
|
|
|
5021 |
zoff99 |
2 |
if (pnt) |
5022 |
|
|
{ |
5023 |
zoff99 |
27 |
cursor_pnt = *pnt; |
5024 |
zoff99 |
2 |
} |
5025 |
|
|
else |
5026 |
|
|
{ |
5027 |
zoff99 |
27 |
pro = transform_get_projection(this_->trans_cursor); |
5028 |
zoff99 |
2 |
if (!pro) |
5029 |
zoff99 |
30 |
{ |
5030 |
zoff99 |
40 |
return2; |
5031 |
zoff99 |
30 |
} |
5032 |
zoff99 |
2 |
transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); |
5033 |
|
|
} |
5034 |
|
|
|
5035 |
zoff99 |
30 |
//dbg(0,"xx=%d\n",cursor_pnt.x); |
5036 |
|
|
//dbg(0,"yy=%d\n",cursor_pnt.y); |
5037 |
|
|
|
5038 |
zoff99 |
27 |
global_vehicle_pos_onscreen.x = cursor_pnt.x; |
5039 |
|
|
global_vehicle_pos_onscreen.y = cursor_pnt.y; |
5040 |
zoff99 |
2 |
|
5041 |
zoff99 |
30 |
//dbg(0,"xx=%d\n",cursor_pnt.x); |
5042 |
|
|
//dbg(0,"yy=%d\n",cursor_pnt.y); |
5043 |
|
|
//dbg(0,"vehicle_draw_001\n"); |
5044 |
|
|
vehicle_draw(nv->vehicle, this_->gra, &cursor_pnt, 0, nv->dir - transform_get_yaw(this_->trans_cursor), nv->speed); |
5045 |
zoff99 |
2 |
#if 0 |
5046 |
|
|
if (pnt) |
5047 |
zoff99 |
27 |
pnt2=*pnt; |
5048 |
|
|
else |
5049 |
|
|
{ |
5050 |
zoff99 |
2 |
pro=transform_get_projection(this_->trans); |
5051 |
|
|
transform(this_->trans, pro, &nv->coord, &pnt2, 1); |
5052 |
|
|
} |
5053 |
|
|
#if 1 |
5054 |
|
|
cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, pnt == NULL); |
5055 |
|
|
#else |
5056 |
|
|
cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, 1); |
5057 |
|
|
#endif |
5058 |
|
|
#endif |
5059 |
zoff99 |
40 |
|
5060 |
|
|
__F_END__ |
5061 |
zoff99 |
2 |
} |
5062 |
|
|
|
5063 |
zoff99 |
34 |
|
5064 |
|
|
|
5065 |
zoff99 |
30 |
// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ |
5066 |
|
|
// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ |
5067 |
|
|
// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ |
5068 |
zoff99 |
27 |
static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv) |
5069 |
zoff99 |
2 |
{ |
5070 |
zoff99 |
40 |
|
5071 |
|
|
__F_START__ |
5072 |
|
|
|
5073 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5074 |
|
|
dbg(0, "\n"); |
5075 |
|
|
dbg(0, "==================================================================================\n"); |
5076 |
|
|
dbg(0, "==================================================================================\n"); |
5077 |
|
|
dbg(0, "\n"); |
5078 |
zoff99 |
28 |
#endif |
5079 |
zoff99 |
2 |
|
5080 |
zoff99 |
40 |
|
5081 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5082 |
|
|
dbg(0, "ROUTExxPOSxx:navit_vehicle_update:enter\n"); |
5083 |
|
|
#endif |
5084 |
|
|
|
5085 |
zoff99 |
28 |
#ifdef NAVIT_MEASURE_TIME_DEBUG |
5086 |
|
|
clock_t s_ = debug_measure_start(); |
5087 |
|
|
#endif |
5088 |
|
|
|
5089 |
zoff99 |
2 |
struct attr attr_valid, attr_dir, attr_speed, attr_pos; |
5090 |
|
|
struct pcoord cursor_pc; |
5091 |
zoff99 |
27 |
struct point cursor_pnt, *pnt = &cursor_pnt; |
5092 |
zoff99 |
30 |
struct point old_cursor_pnt; |
5093 |
zoff99 |
27 |
struct tracking *tracking = NULL; |
5094 |
zoff99 |
2 |
struct pcoord pc[16]; |
5095 |
zoff99 |
34 |
|
5096 |
zoff99 |
27 |
enum projection pro = transform_get_projection(this_->trans_cursor); |
5097 |
zoff99 |
34 |
|
5098 |
zoff99 |
2 |
int count; |
5099 |
zoff99 |
30 |
int old_dir; |
5100 |
|
|
int old_pos_invalid; |
5101 |
zoff99 |
2 |
int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *); |
5102 |
|
|
void *attr_object; |
5103 |
|
|
char *destination_file; |
5104 |
zoff99 |
34 |
long new_scale_value; |
5105 |
|
|
long old_scale_value; |
5106 |
zoff99 |
41 |
int l_old; |
5107 |
|
|
int l_new; |
5108 |
zoff99 |
2 |
|
5109 |
zoff99 |
27 |
if (this_->ready != 3) |
5110 |
|
|
{ |
5111 |
zoff99 |
2 |
//profile(0,"return 1\n"); |
5112 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5113 |
|
|
dbg(0, "ROUTExxPOSxx:return 003\n"); |
5114 |
|
|
#endif |
5115 |
|
|
|
5116 |
|
|
|
5117 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5118 |
|
|
dbg(0, "\n"); |
5119 |
|
|
dbg(0, "==================================================================================\n"); |
5120 |
|
|
dbg(0, "==================================================================================\n"); |
5121 |
|
|
dbg(0, "\n"); |
5122 |
|
|
#endif |
5123 |
|
|
|
5124 |
|
|
return2; |
5125 |
zoff99 |
2 |
} |
5126 |
zoff99 |
28 |
|
5127 |
zoff99 |
40 |
// **OLD** navit_layout_switch(this_); |
5128 |
zoff99 |
2 |
if (this_->vehicle == nv && this_->tracking_flag) |
5129 |
zoff99 |
28 |
{ |
5130 |
zoff99 |
27 |
tracking = this_->tracking; |
5131 |
zoff99 |
28 |
} |
5132 |
zoff99 |
40 |
//// else tracking = NULL !! -> important for next "if" clause!! |
5133 |
zoff99 |
28 |
|
5134 |
zoff99 |
40 |
// ------ DEBUG ------ remember real GPS postion (unchanged) ------- |
5135 |
|
|
// ------ DEBUG ------ remember real GPS postion (unchanged) ------- |
5136 |
|
|
// ------ DEBUG ------ remember real GPS postion (unchanged) ------- |
5137 |
|
|
struct attr attr_pos_unchanged; |
5138 |
|
|
if (vehicle_get_attr(nv->vehicle, attr_position_coord_geo, &attr_pos_unchanged, NULL)) |
5139 |
|
|
{ |
5140 |
|
|
if (attr_pos_unchanged.u.coord_geo) |
5141 |
|
|
{ |
5142 |
|
|
global_v_pos_lat = attr_pos_unchanged.u.coord_geo->lat; |
5143 |
|
|
global_v_pos_lng = attr_pos_unchanged.u.coord_geo->lng; |
5144 |
|
|
|
5145 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5146 |
|
|
struct coord cc999; |
5147 |
|
|
transform_from_geo(pro, attr_pos_unchanged.u.coord_geo, &cc999); |
5148 |
|
|
dbg(0, "ROUTExxPOSxx:navit_vehicle_update: %d %d\n", cc999.x, cc999.y); |
5149 |
|
|
#endif |
5150 |
|
|
|
5151 |
|
|
} |
5152 |
|
|
} |
5153 |
|
|
|
5154 |
|
|
if (vehicle_get_attr(nv->vehicle, attr_position_direction, &attr_pos_unchanged, NULL)) |
5155 |
|
|
{ |
5156 |
|
|
global_v_pos_dir = *attr_pos_unchanged.u.numd; |
5157 |
|
|
|
5158 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5159 |
|
|
dbg(0, "ROUTExxPOSxx:navit_vehicle_update: dir=%f\n", (float)global_v_pos_dir); |
5160 |
|
|
#endif |
5161 |
|
|
} |
5162 |
|
|
// ------ DEBUG ------ remember real GPS postion (unchanged) ------- |
5163 |
|
|
// ------ DEBUG ------ remember real GPS postion (unchanged) ------- |
5164 |
|
|
// ------ DEBUG ------ remember real GPS postion (unchanged) ------- |
5165 |
|
|
|
5166 |
|
|
|
5167 |
zoff99 |
27 |
if (tracking) |
5168 |
|
|
{ |
5169 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5170 |
|
|
dbg(0, "ROUTExxPOSxx:tracking_update: 001\n"); |
5171 |
|
|
#endif |
5172 |
|
|
|
5173 |
|
|
// set postition from tracking (changing it to nearest street) |
5174 |
zoff99 |
2 |
tracking_update(tracking, nv->vehicle, this_->vehicleprofile, pro); |
5175 |
zoff99 |
27 |
attr_object = tracking; |
5176 |
|
|
get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) tracking_get_attr; |
5177 |
zoff99 |
40 |
|
5178 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5179 |
|
|
dbg(0, "ROUTExxPOSxx:tracking_update: 001-a\n"); |
5180 |
|
|
#endif |
5181 |
zoff99 |
2 |
} |
5182 |
zoff99 |
27 |
else |
5183 |
|
|
{ |
5184 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5185 |
|
|
dbg(0, "ROUTExxPOSxx:tracking_update (unchanged): 001.bb\n"); |
5186 |
|
|
#endif |
5187 |
|
|
|
5188 |
|
|
// set position from vehicle (unchanged) |
5189 |
zoff99 |
27 |
attr_object = nv->vehicle; |
5190 |
|
|
get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) vehicle_get_attr; |
5191 |
zoff99 |
40 |
|
5192 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5193 |
|
|
dbg(0, "ROUTExxPOSxx:tracking_update (unchanged): 001.bb-a\n"); |
5194 |
|
|
#endif |
5195 |
zoff99 |
27 |
} |
5196 |
zoff99 |
28 |
|
5197 |
zoff99 |
2 |
if (get_attr(attr_object, attr_position_valid, &attr_valid, NULL)) |
5198 |
zoff99 |
28 |
{ |
5199 |
zoff99 |
2 |
if (!attr_valid.u.num != attr_position_valid_invalid) |
5200 |
zoff99 |
28 |
{ |
5201 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5202 |
|
|
dbg(0, "ROUTExxPOSxx:return 001\n"); |
5203 |
|
|
#endif |
5204 |
|
|
|
5205 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5206 |
|
|
dbg(0, "\n"); |
5207 |
|
|
dbg(0, "==================================================================================\n"); |
5208 |
|
|
dbg(0, "==================================================================================\n"); |
5209 |
|
|
dbg(0, "\n"); |
5210 |
|
|
#endif |
5211 |
|
|
|
5212 |
|
|
return2; |
5213 |
zoff99 |
28 |
} |
5214 |
|
|
} |
5215 |
|
|
|
5216 |
zoff99 |
40 |
|
5217 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5218 |
|
|
struct attr attr_pos_99; |
5219 |
|
|
if (get_attr(attr_object, attr_position_coord_geo, &attr_pos_99, NULL)) |
5220 |
|
|
{ |
5221 |
|
|
if (attr_pos_99.u.coord_geo) |
5222 |
|
|
{ |
5223 |
|
|
struct coord cc999; |
5224 |
|
|
transform_from_geo(pro, attr_pos_99.u.coord_geo, &cc999); |
5225 |
|
|
dbg(0, "ROUTExxPOSxx:get pos: %d %d\n", cc999.x, cc999.y); |
5226 |
|
|
} |
5227 |
|
|
} |
5228 |
|
|
#endif |
5229 |
|
|
|
5230 |
|
|
|
5231 |
zoff99 |
30 |
// load attrs with data from vehicle |
5232 |
zoff99 |
27 |
if (!get_attr(attr_object, attr_position_direction, &attr_dir, NULL) || !get_attr(attr_object, attr_position_speed, &attr_speed, NULL) || !get_attr(attr_object, attr_position_coord_geo, &attr_pos, NULL)) |
5233 |
|
|
{ |
5234 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5235 |
|
|
dbg(0, "ROUTExxPOSxx:return 002\n"); |
5236 |
|
|
#endif |
5237 |
|
|
|
5238 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5239 |
|
|
dbg(0, "\n"); |
5240 |
|
|
dbg(0, "==================================================================================\n"); |
5241 |
|
|
dbg(0, "==================================================================================\n"); |
5242 |
|
|
dbg(0, "\n"); |
5243 |
|
|
#endif |
5244 |
|
|
|
5245 |
|
|
return2; |
5246 |
zoff99 |
2 |
} |
5247 |
zoff99 |
30 |
// load attrs with data from vehicle |
5248 |
zoff99 |
28 |
|
5249 |
zoff99 |
30 |
|
5250 |
|
|
// save old value |
5251 |
|
|
old_dir = nv->dir; |
5252 |
zoff99 |
34 |
global_old_vehicle_speed = nv->speed; |
5253 |
|
|
old_scale_value = transform_get_scale(this_->trans); |
5254 |
zoff99 |
30 |
|
5255 |
zoff99 |
27 |
nv->dir = *attr_dir.u.numd; |
5256 |
|
|
nv->speed = *attr_speed.u.numd; |
5257 |
zoff99 |
30 |
|
5258 |
|
|
// old values --------- |
5259 |
|
|
if ((global_last_vehicle_pos_geo.lat != 0.0) && (global_last_vehicle_pos_geo.lng != 0.0)) |
5260 |
zoff99 |
2 |
{ |
5261 |
zoff99 |
30 |
transform_from_geo(pro, &global_last_vehicle_pos_geo, &nv->coord); |
5262 |
|
|
transform(this_->trans_cursor, pro, &nv->coord, &old_cursor_pnt, 1, 0, 0, NULL); |
5263 |
|
|
old_pos_invalid = 0; |
5264 |
|
|
|
5265 |
|
|
// XXX // dbg(0,"old values lat:%f lon:%f px:%d py:%d\n", global_last_vehicle_pos_geo.lat, global_last_vehicle_pos_geo.lng, old_cursor_pnt.x, old_cursor_pnt.y); |
5266 |
zoff99 |
2 |
} |
5267 |
zoff99 |
30 |
else |
5268 |
|
|
{ |
5269 |
|
|
old_pos_invalid = 1; |
5270 |
|
|
} |
5271 |
|
|
// old values --------- |
5272 |
|
|
|
5273 |
|
|
transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord); |
5274 |
|
|
|
5275 |
|
|
// save this position |
5276 |
|
|
global_last_vehicle_pos_geo.lat = attr_pos.u.coord_geo->lat; |
5277 |
|
|
global_last_vehicle_pos_geo.lng = attr_pos.u.coord_geo->lng; |
5278 |
zoff99 |
41 |
|
5279 |
|
|
ggggg_lat = attr_pos.u.coord_geo->lat; |
5280 |
|
|
ggggg_lon = attr_pos.u.coord_geo->lng; |
5281 |
|
|
// dbg(0, "PPPOS:%f %f lll=%f", global_last_vehicle_pos_geo.lat, global_last_vehicle_pos_geo.lng, ggggg_lat); |
5282 |
|
|
|
5283 |
zoff99 |
30 |
// save this position |
5284 |
|
|
|
5285 |
|
|
|
5286 |
|
|
// XXX // dbg(0,"v1 lat:%f lon:%f x:%d y:%d\n",attr_pos.u.coord_geo->lat, attr_pos.u.coord_geo->lng, nv->coord.x, nv->coord.y); |
5287 |
|
|
|
5288 |
|
|
//if (nv != this_->vehicle) |
5289 |
|
|
//{ |
5290 |
|
|
// if (hold_drawing == 0) |
5291 |
|
|
// { |
5292 |
|
|
// navit_vehicle_draw(this_, nv, NULL); |
5293 |
|
|
// } |
5294 |
|
|
// return; |
5295 |
|
|
//} |
5296 |
zoff99 |
2 |
cursor_pc.x = nv->coord.x; |
5297 |
|
|
cursor_pc.y = nv->coord.y; |
5298 |
|
|
cursor_pc.pro = pro; |
5299 |
zoff99 |
34 |
|
5300 |
zoff99 |
27 |
if (this_->route) |
5301 |
|
|
{ |
5302 |
zoff99 |
2 |
if (tracking) |
5303 |
zoff99 |
28 |
{ |
5304 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5305 |
|
|
dbg(0, "ROUTExxPOSxx:navit_vehicle_update: 001\n"); |
5306 |
|
|
#endif |
5307 |
zoff99 |
2 |
route_set_position_from_tracking(this_->route, tracking, pro); |
5308 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5309 |
|
|
dbg(0, "ROUTExxPOSxx:navit_vehicle_update: 001-a\n"); |
5310 |
|
|
#endif |
5311 |
zoff99 |
28 |
} |
5312 |
zoff99 |
2 |
else |
5313 |
zoff99 |
28 |
{ |
5314 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5315 |
|
|
dbg(0, "ROUTExxPOSxx:YYYYY:navit_vehicle_update: 002\n"); |
5316 |
|
|
#endif |
5317 |
zoff99 |
2 |
route_set_position(this_->route, &cursor_pc); |
5318 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5319 |
|
|
dbg(0, "ROUTExxPOSxx:navit_vehicle_update: 002-a\n"); |
5320 |
|
|
#endif |
5321 |
zoff99 |
28 |
} |
5322 |
zoff99 |
2 |
} |
5323 |
zoff99 |
28 |
|
5324 |
zoff99 |
40 |
// -------------------------------------------------------------- |
5325 |
|
|
// -------------------------------------------------------------- |
5326 |
|
|
// this calls: graphics_load_mapset (and draws the map) |
5327 |
|
|
// -------------------------------------------------------------- |
5328 |
|
|
/// -------**++**-- DISABLE --**++**---- callback_list_call_attr_0(this_->attr_cbl, attr_position); |
5329 |
|
|
// -------------------------------------------------------------- |
5330 |
|
|
// -------------------------------------------------------------- |
5331 |
zoff99 |
28 |
|
5332 |
zoff99 |
27 |
// navit_textfile_debug_log(this_, "type=trackpoint_tracked"); |
5333 |
zoff99 |
28 |
/* |
5334 |
zoff99 |
30 |
if (this_->gui && nv->speed > MYSTERY_SPEED) |
5335 |
|
|
{ |
5336 |
|
|
// stupid!!!! this gets called every second!!! fixme!!!!!! |
5337 |
|
|
navit_disable_suspend(); |
5338 |
|
|
// stupid!!!! this gets called every second!!! fixme!!!!!! |
5339 |
|
|
} |
5340 |
|
|
*/ |
5341 |
|
|
|
5342 |
|
|
transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); |
5343 |
|
|
// XXX // dbg(0,"v2 px:%d py:%d x:%d y:%d\n", cursor_pnt.x, cursor_pnt.y, nv->coord.x, nv->coord.y); |
5344 |
|
|
|
5345 |
zoff99 |
34 |
// ------- AUTOZOOM --------- |
5346 |
zoff99 |
41 |
l_old = 0; |
5347 |
|
|
l_new = 0; |
5348 |
|
|
new_scale_value = navit_autozoom(this_, &nv->coord, nv->speed, 0, &l_old, &l_new); |
5349 |
|
|
// dbg(0, "l_old=%d l_new=%d\n", l_old, l_new); |
5350 |
zoff99 |
34 |
// ------- AUTOZOOM --------- |
5351 |
zoff99 |
30 |
|
5352 |
|
|
if (old_pos_invalid == 0) |
5353 |
zoff99 |
28 |
{ |
5354 |
zoff99 |
30 |
int delta_x = cursor_pnt.x - old_cursor_pnt.x; |
5355 |
|
|
int delta_y = cursor_pnt.y - old_cursor_pnt.y; |
5356 |
|
|
int delta_angle = nv->dir - old_dir; |
5357 |
zoff99 |
34 |
int delta_zoom = 0; |
5358 |
zoff99 |
30 |
|
5359 |
zoff99 |
34 |
if (new_scale_value != -1) |
5360 |
|
|
{ |
5361 |
|
|
delta_zoom = (int)(new_scale_value - old_scale_value); |
5362 |
|
|
} |
5363 |
|
|
|
5364 |
zoff99 |
30 |
#ifdef HAVE_API_ANDROID |
5365 |
|
|
//dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle); |
5366 |
zoff99 |
41 |
set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle, delta_zoom, l_old, l_new); |
5367 |
zoff99 |
30 |
#endif |
5368 |
zoff99 |
28 |
} |
5369 |
|
|
|
5370 |
zoff99 |
40 |
|
5371 |
|
|
|
5372 |
|
|
// -------- ?????????? |
5373 |
|
|
// -------- ?????????? |
5374 |
|
|
// -------- ?????????? |
5375 |
|
|
// -------- ?????????? |
5376 |
|
|
// -------- ?????????? |
5377 |
zoff99 |
27 |
if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border))) |
5378 |
zoff99 |
2 |
{ |
5379 |
zoff99 |
28 |
if (hold_drawing == 0) |
5380 |
|
|
{ |
5381 |
|
|
//dbg(0,"call:navit_set_center_cursor_draw:start\n"); |
5382 |
|
|
navit_set_center_cursor_draw(this_); |
5383 |
|
|
//dbg(0,"call:navit_set_center_cursor_draw:end\n"); |
5384 |
|
|
} |
5385 |
zoff99 |
2 |
} |
5386 |
|
|
else |
5387 |
|
|
{ |
5388 |
zoff99 |
28 |
if (hold_drawing == 0) |
5389 |
|
|
{ |
5390 |
|
|
navit_vehicle_draw(this_, nv, pnt); |
5391 |
|
|
} |
5392 |
zoff99 |
2 |
} |
5393 |
zoff99 |
40 |
// -------- ?????????? |
5394 |
|
|
// -------- ?????????? |
5395 |
|
|
// -------- ?????????? |
5396 |
|
|
// -------- ?????????? |
5397 |
|
|
// -------- ?????????? |
5398 |
zoff99 |
2 |
|
5399 |
zoff99 |
40 |
|
5400 |
|
|
|
5401 |
|
|
|
5402 |
zoff99 |
2 |
if (nv->follow_curr > 1) |
5403 |
zoff99 |
28 |
{ |
5404 |
zoff99 |
2 |
nv->follow_curr--; |
5405 |
zoff99 |
28 |
} |
5406 |
zoff99 |
2 |
else |
5407 |
zoff99 |
28 |
{ |
5408 |
zoff99 |
27 |
nv->follow_curr = nv->follow; |
5409 |
zoff99 |
28 |
} |
5410 |
|
|
|
5411 |
zoff99 |
40 |
|
5412 |
|
|
|
5413 |
|
|
// where does this go????? ---------- |
5414 |
|
|
// where does this go????? ---------- |
5415 |
zoff99 |
41 |
// |
5416 |
|
|
// i think this updates the OSD GUIs |
5417 |
|
|
// |
5418 |
zoff99 |
2 |
callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle); |
5419 |
zoff99 |
40 |
// where does this go????? ---------- |
5420 |
|
|
// where does this go????? ---------- |
5421 |
zoff99 |
2 |
|
5422 |
zoff99 |
40 |
|
5423 |
|
|
|
5424 |
zoff99 |
2 |
/* Finally, if we reached our destination, stop navigation. */ |
5425 |
zoff99 |
27 |
if (this_->route) |
5426 |
|
|
{ |
5427 |
|
|
switch (route_destination_reached(this_->route)) |
5428 |
|
|
{ |
5429 |
|
|
case 1: |
5430 |
|
|
route_remove_waypoint(this_->route); |
5431 |
|
|
count = route_get_destinations(this_->route, pc, 16); |
5432 |
|
|
|
5433 |
|
|
// destination_file = bookmarks_get_destination_file(TRUE); |
5434 |
|
|
// bookmarks_append_coord(this_->bookmarks, destination_file, pc, count, "former_itinerary_part", NULL, NULL, this_->recentdest_count); |
5435 |
|
|
|
5436 |
zoff99 |
14 |
#ifdef HAVE_API_ANDROID |
5437 |
zoff99 |
27 |
// waypoint reached |
5438 |
|
|
android_return_generic_int(5, 1); |
5439 |
zoff99 |
28 |
#ifdef NAVIT_SAY_DEBUG_PRINT |
5440 |
zoff99 |
27 |
android_send_generic_text(1,"+*#O:Waypoint reached\n"); |
5441 |
zoff99 |
28 |
#endif |
5442 |
zoff99 |
41 |
if (global_routing_engine != 1) // not OSRM routing |
5443 |
|
|
{ |
5444 |
|
|
// say it |
5445 |
|
|
navit_say(this_, _("Waypoint reached")); |
5446 |
|
|
} |
5447 |
zoff99 |
14 |
#endif |
5448 |
zoff99 |
27 |
break; |
5449 |
|
|
case 2: |
5450 |
|
|
navit_set_destination(this_, NULL, NULL, 0); |
5451 |
|
|
// ** inform java that we reached our destination ** |
5452 |
zoff99 |
14 |
#ifdef HAVE_API_ANDROID |
5453 |
zoff99 |
27 |
android_return_generic_int(4, 1); |
5454 |
zoff99 |
28 |
#ifdef NAVIT_SAY_DEBUG_PRINT |
5455 |
zoff99 |
27 |
android_send_generic_text(1,"+*#O:You have reached your destination\n"); |
5456 |
zoff99 |
28 |
#endif |
5457 |
zoff99 |
27 |
// say it |
5458 |
|
|
navit_say(this_, _("You have reached your destination")); |
5459 |
zoff99 |
14 |
#endif |
5460 |
zoff99 |
27 |
break; |
5461 |
zoff99 |
2 |
} |
5462 |
|
|
} |
5463 |
zoff99 |
28 |
|
5464 |
|
|
if (hold_drawing == 0) |
5465 |
|
|
{ |
5466 |
|
|
// draw??????? |
5467 |
|
|
// navit_draw(this_); |
5468 |
|
|
if (this_->ready == 3) |
5469 |
|
|
{ |
5470 |
|
|
//dbg(0,"location update:draw:start\n"); |
5471 |
zoff99 |
40 |
// dbg(0,"navit_draw_async_006\n"); |
5472 |
|
|
// zzz554 // |
5473 |
|
|
navit_draw_async(this_, 0); |
5474 |
zoff99 |
28 |
//dbg(0,"location update:draw:end\n"); |
5475 |
|
|
} |
5476 |
|
|
// draw??????? |
5477 |
|
|
} |
5478 |
|
|
|
5479 |
|
|
#ifdef NAVIT_MEASURE_TIME_DEBUG |
5480 |
|
|
debug_mrp("navit_vehicle_update:", debug_measure_end(s_)); |
5481 |
|
|
#endif |
5482 |
|
|
|
5483 |
zoff99 |
40 |
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5484 |
|
|
dbg(0, "ROUTExxPOSxx:navit_vehicle_update:leave\n"); |
5485 |
zoff99 |
28 |
#endif |
5486 |
zoff99 |
40 |
|
5487 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5488 |
|
|
dbg(0, "\n"); |
5489 |
|
|
dbg(0, "==================================================================================\n"); |
5490 |
|
|
dbg(0, "==================================================================================\n"); |
5491 |
|
|
dbg(0, "\n"); |
5492 |
|
|
#endif |
5493 |
|
|
|
5494 |
|
|
__F_END__ |
5495 |
|
|
|
5496 |
zoff99 |
2 |
} |
5497 |
zoff99 |
30 |
// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ |
5498 |
|
|
// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ |
5499 |
|
|
// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ |
5500 |
zoff99 |
2 |
|
5501 |
zoff99 |
30 |
|
5502 |
zoff99 |
34 |
|
5503 |
zoff99 |
40 |
int navit_is_demo_vehicle() |
5504 |
|
|
{ |
5505 |
|
|
if (global_demo_vehicle == 1) |
5506 |
|
|
{ |
5507 |
|
|
return 1; |
5508 |
|
|
} |
5509 |
zoff99 |
34 |
|
5510 |
zoff99 |
40 |
return 0; |
5511 |
|
|
} |
5512 |
|
|
|
5513 |
|
|
|
5514 |
zoff99 |
2 |
/** |
5515 |
|
|
* Set the position of the vehicle |
5516 |
|
|
* |
5517 |
|
|
* @param navit The navit instance |
5518 |
|
|
* @param c The coordinate to set as position |
5519 |
|
|
* @returns nothing |
5520 |
|
|
*/ |
5521 |
zoff99 |
27 |
void navit_set_position(struct navit *this_, struct pcoord *c) |
5522 |
zoff99 |
2 |
{ |
5523 |
zoff99 |
40 |
__F_START__ |
5524 |
|
|
|
5525 |
zoff99 |
27 |
//DBG dbg(0,"EEnter\n"); |
5526 |
zoff99 |
2 |
|
5527 |
zoff99 |
27 |
if (this_->route) |
5528 |
|
|
{ |
5529 |
zoff99 |
40 |
//#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5530 |
|
|
// dbg(0, "ROUTExxPOSxx:YYYYY:navit_set_position: 001\n"); |
5531 |
|
|
//#endif |
5532 |
|
|
// ******* NOT USE ******** // route_set_position(this_->route, c); |
5533 |
|
|
// ******* NOT USE ******** // callback_list_call_attr_0(this_->attr_cbl, attr_position); |
5534 |
zoff99 |
2 |
} |
5535 |
zoff99 |
28 |
|
5536 |
zoff99 |
2 |
if (this_->ready == 3) |
5537 |
zoff99 |
28 |
{ |
5538 |
zoff99 |
2 |
navit_draw(this_); |
5539 |
zoff99 |
28 |
} |
5540 |
zoff99 |
40 |
|
5541 |
|
|
__F_END__ |
5542 |
zoff99 |
2 |
} |
5543 |
|
|
|
5544 |
zoff99 |
40 |
/** |
5545 |
|
|
* Set the position of the vehicle, without drawing the map |
5546 |
|
|
* |
5547 |
|
|
*/ |
5548 |
|
|
void navit_set_position_without_map_drawing(struct navit *this_, struct pcoord *c) |
5549 |
zoff99 |
2 |
{ |
5550 |
zoff99 |
40 |
|
5551 |
|
|
|
5552 |
|
|
|
5553 |
|
|
if (this_->route) |
5554 |
|
|
{ |
5555 |
|
|
#ifdef NAVIT_ROUTING_DEBUG_PRINT |
5556 |
|
|
dbg(0, "ROUTExxPOSxx:YYYYY:navit_set_position_without_map_drawing: 001\n"); |
5557 |
zoff99 |
28 |
#endif |
5558 |
zoff99 |
40 |
route_set_position(this_->route, c); |
5559 |
|
|
callback_list_call_attr_0(this_->attr_cbl, attr_position); |
5560 |
|
|
} |
5561 |
|
|
} |
5562 |
|
|
|
5563 |
|
|
|
5564 |
|
|
int navit_set_vehicleprofile(struct navit *this_, char *name) |
5565 |
|
|
{ |
5566 |
|
|
|
5567 |
|
|
|
5568 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
5569 |
zoff99 |
2 |
|
5570 |
|
|
struct attr attr; |
5571 |
|
|
GList *l; |
5572 |
zoff99 |
27 |
l = this_->vehicleprofiles; |
5573 |
|
|
while (l) |
5574 |
|
|
{ |
5575 |
|
|
if (vehicleprofile_get_attr(l->data, attr_name, &attr, NULL)) |
5576 |
|
|
{ |
5577 |
|
|
if (!strcmp(attr.u.str, name)) |
5578 |
|
|
{ |
5579 |
|
|
this_->vehicleprofile = l->data; |
5580 |
zoff99 |
2 |
if (this_->route) |
5581 |
zoff99 |
40 |
{ |
5582 |
zoff99 |
2 |
route_set_profile(this_->route, this_->vehicleprofile); |
5583 |
zoff99 |
40 |
} |
5584 |
zoff99 |
2 |
return 1; |
5585 |
|
|
} |
5586 |
|
|
} |
5587 |
zoff99 |
27 |
l = g_list_next(l); |
5588 |
zoff99 |
2 |
} |
5589 |
|
|
return 0; |
5590 |
|
|
} |
5591 |
|
|
|
5592 |
zoff99 |
27 |
static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv) |
5593 |
zoff99 |
2 |
{ |
5594 |
zoff99 |
40 |
|
5595 |
|
|
|
5596 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
5597 |
zoff99 |
2 |
|
5598 |
|
|
struct attr attr; |
5599 |
zoff99 |
27 |
this_->vehicle = nv; |
5600 |
zoff99 |
28 |
|
5601 |
zoff99 |
27 |
if (nv && vehicle_get_attr(nv->vehicle, attr_profilename, &attr, NULL)) |
5602 |
|
|
{ |
5603 |
zoff99 |
2 |
if (navit_set_vehicleprofile(this_, attr.u.str)) |
5604 |
zoff99 |
27 |
{ |
5605 |
zoff99 |
2 |
return; |
5606 |
zoff99 |
27 |
} |
5607 |
zoff99 |
2 |
} |
5608 |
zoff99 |
28 |
|
5609 |
zoff99 |
27 |
if (!navit_set_vehicleprofile(this_, "car")) |
5610 |
|
|
{ |
5611 |
zoff99 |
2 |
/* We do not have a fallback "car" profile |
5612 |
zoff99 |
27 |
* so lets set any profile */ |
5613 |
zoff99 |
2 |
GList *l; |
5614 |
zoff99 |
27 |
l = this_->vehicleprofiles; |
5615 |
|
|
if (l) |
5616 |
|
|
{ |
5617 |
|
|
this_->vehicleprofile = l->data; |
5618 |
|
|
if (this_->route) |
5619 |
|
|
{ |
5620 |
|
|
route_set_profile(this_->route, this_->vehicleprofile); |
5621 |
|
|
} |
5622 |
zoff99 |
2 |
} |
5623 |
|
|
} |
5624 |
|
|
} |
5625 |
|
|
|
5626 |
|
|
/** |
5627 |
|
|
* Register a new vehicle |
5628 |
|
|
* |
5629 |
|
|
* @param navit The navit instance |
5630 |
|
|
* @param v The vehicle instance |
5631 |
|
|
* @returns 1 for success |
5632 |
|
|
*/ |
5633 |
zoff99 |
27 |
int navit_add_vehicle(struct navit *this_, struct vehicle *v) |
5634 |
zoff99 |
2 |
{ |
5635 |
|
|
|
5636 |
zoff99 |
40 |
|
5637 |
|
|
|
5638 |
zoff99 |
2 |
struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1); |
5639 |
|
|
struct attr follow, active, animate; |
5640 |
zoff99 |
27 |
nv->vehicle = v; |
5641 |
|
|
nv->follow = 0; |
5642 |
zoff99 |
2 |
nv->last.x = 0; |
5643 |
|
|
nv->last.y = 0; |
5644 |
zoff99 |
30 |
|
5645 |
|
|
global_last_vehicle_pos_geo.lat = 0; |
5646 |
|
|
global_last_vehicle_pos_geo.lng = 0; |
5647 |
|
|
|
5648 |
zoff99 |
40 |
// global_cur_vehicle_pos_geo.lat = 0; |
5649 |
|
|
// global_cur_vehicle_pos_geo.lon = 0; |
5650 |
|
|
|
5651 |
zoff99 |
27 |
nv->animate_cursor = 0; |
5652 |
zoff99 |
2 |
if ((vehicle_get_attr(v, attr_follow, &follow, NULL))) |
5653 |
zoff99 |
27 |
nv->follow = follow.u.num; |
5654 |
zoff99 |
40 |
|
5655 |
zoff99 |
27 |
nv->follow_curr = nv->follow; |
5656 |
|
|
this_->vehicles = g_list_append(this_->vehicles, nv); |
5657 |
zoff99 |
40 |
|
5658 |
zoff99 |
2 |
if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num) |
5659 |
|
|
navit_set_vehicle(this_, nv); |
5660 |
zoff99 |
40 |
|
5661 |
zoff99 |
2 |
if ((vehicle_get_attr(v, attr_animate, &animate, NULL))) |
5662 |
zoff99 |
27 |
nv->animate_cursor = animate.u.num; |
5663 |
zoff99 |
40 |
|
5664 |
zoff99 |
27 |
nv->callback.type = attr_callback; |
5665 |
zoff99 |
28 |
|
5666 |
|
|
// gets called via this callback in vehicle_android.c [in function: vehicle_android_callback] |
5667 |
zoff99 |
27 |
nv->callback.u.callback = callback_new_attr_2(callback_cast(navit_vehicle_update), attr_position_coord_geo, this_, nv); |
5668 |
zoff99 |
30 |
callback_add_names(nv->callback.u.callback, "navit_add_vehicle", "navit_vehicle_update"); |
5669 |
zoff99 |
28 |
|
5670 |
|
|
//dbg(0,"EEnter 11\n"); |
5671 |
zoff99 |
2 |
vehicle_add_attr(nv->vehicle, &nv->callback); |
5672 |
zoff99 |
28 |
//dbg(0,"EEnter 22\n"); |
5673 |
zoff99 |
2 |
vehicle_set_attr(nv->vehicle, &this_->self); |
5674 |
zoff99 |
28 |
//dbg(0,"EEnter 33\n"); |
5675 |
|
|
|
5676 |
|
|
#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
5677 |
|
|
dbg(0,"+#+:leave\n"); |
5678 |
|
|
#endif |
5679 |
|
|
|
5680 |
zoff99 |
2 |
return 1; |
5681 |
|
|
} |
5682 |
|
|
|
5683 |
|
|
struct gui * |
5684 |
|
|
navit_get_gui(struct navit *this_) |
5685 |
|
|
{ |
5686 |
|
|
return this_->gui; |
5687 |
|
|
} |
5688 |
|
|
|
5689 |
|
|
struct transformation * |
5690 |
|
|
navit_get_trans(struct navit *this_) |
5691 |
|
|
{ |
5692 |
|
|
return this_->trans; |
5693 |
|
|
} |
5694 |
|
|
|
5695 |
|
|
struct route * |
5696 |
|
|
navit_get_route(struct navit *this_) |
5697 |
|
|
{ |
5698 |
|
|
return this_->route; |
5699 |
|
|
} |
5700 |
|
|
|
5701 |
|
|
struct navigation * |
5702 |
|
|
navit_get_navigation(struct navit *this_) |
5703 |
|
|
{ |
5704 |
|
|
return this_->navigation; |
5705 |
|
|
} |
5706 |
|
|
|
5707 |
|
|
struct displaylist * |
5708 |
|
|
navit_get_displaylist(struct navit *this_) |
5709 |
|
|
{ |
5710 |
|
|
return this_->displaylist; |
5711 |
|
|
} |
5712 |
|
|
|
5713 |
zoff99 |
27 |
void navit_layout_switch(struct navit *n) |
5714 |
zoff99 |
2 |
{ |
5715 |
zoff99 |
40 |
|
5716 |
|
|
|
5717 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
5718 |
zoff99 |
2 |
|
5719 |
zoff99 |
27 |
int currTs = 0; |
5720 |
|
|
struct attr iso8601_attr, geo_attr, valid_attr, layout_attr; |
5721 |
|
|
double trise, tset, trise_actual; |
5722 |
|
|
struct layout *l; |
5723 |
|
|
int year, month, day; |
5724 |
|
|
|
5725 |
|
|
if (navit_get_attr(n, attr_layout, &layout_attr, NULL) != 1) |
5726 |
|
|
{ |
5727 |
|
|
return; //No layout - nothing to switch |
5728 |
zoff99 |
2 |
} |
5729 |
zoff99 |
27 |
if (!n->vehicle) |
5730 |
zoff99 |
2 |
return; |
5731 |
zoff99 |
27 |
l = layout_attr.u.layout; |
5732 |
|
|
|
5733 |
|
|
if (l->dayname || l->nightname) |
5734 |
|
|
{ |
5735 |
|
|
//Ok, we know that we have profile to switch |
5736 |
|
|
|
5737 |
|
|
//Check that we aren't calculating too fast |
5738 |
|
|
if (vehicle_get_attr(n->vehicle->vehicle, attr_position_time_iso8601, &iso8601_attr, NULL) == 1) |
5739 |
|
|
{ |
5740 |
|
|
currTs = iso8601_to_secs(iso8601_attr.u.str); |
5741 |
|
|
// dbg(1, "currTs: %u:%u\n", currTs % 86400 / 3600, ((currTs % 86400) % 3600) / 60); |
5742 |
zoff99 |
2 |
} |
5743 |
zoff99 |
27 |
if (currTs - (n->prevTs) < 60) |
5744 |
|
|
{ |
5745 |
|
|
//We've have to wait a little |
5746 |
|
|
return; |
5747 |
zoff99 |
2 |
} |
5748 |
zoff99 |
27 |
if (sscanf(iso8601_attr.u.str, "%d-%02d-%02dT", &year, &month, &day) != 3) |
5749 |
|
|
return; |
5750 |
|
|
if (vehicle_get_attr(n->vehicle->vehicle, attr_position_valid, &valid_attr, NULL) && valid_attr.u.num == attr_position_valid_invalid) |
5751 |
|
|
{ |
5752 |
|
|
return; //No valid fix yet |
5753 |
|
|
} |
5754 |
|
|
if (vehicle_get_attr(n->vehicle->vehicle, attr_position_coord_geo, &geo_attr, NULL) != 1) |
5755 |
|
|
{ |
5756 |
|
|
//No position - no sun |
5757 |
|
|
return; |
5758 |
|
|
} |
5759 |
|
|
|
5760 |
|
|
//We calculate sunrise anyway, cause it is needed both for day and for night |
5761 |
|
|
if (__sunriset__(year, month, day, geo_attr.u.coord_geo->lng, geo_attr.u.coord_geo->lat, -5, 1, &trise, &tset) != 0) |
5762 |
|
|
{ |
5763 |
|
|
//near the pole sun never rises/sets, so we should never switch profiles |
5764 |
|
|
// dbg(1, "trise: %u:%u, sun never visible, never switch profile\n", HOURS(trise), MINUTES(trise)); |
5765 |
|
|
n->prevTs = currTs; |
5766 |
|
|
return; |
5767 |
|
|
} |
5768 |
|
|
|
5769 |
|
|
trise_actual = trise; |
5770 |
|
|
// dbg(1, "trise: %u:%u\n", HOURS(trise), MINUTES(trise)); |
5771 |
|
|
if (l->dayname) |
5772 |
|
|
{ |
5773 |
|
|
|
5774 |
|
|
if ((HOURS(trise) * 60 + MINUTES(trise) == (currTs % 86400) / 60) || (n->prevTs == 0 && ((HOURS(trise) * 60 + MINUTES(trise) < (currTs % 86400) / 60)))) |
5775 |
|
|
{ |
5776 |
|
|
//The sun is rising now! |
5777 |
|
|
if (strcmp(l->name, l->dayname)) |
5778 |
|
|
{ |
5779 |
|
|
navit_set_layout_by_name(n, l->dayname); |
5780 |
|
|
} |
5781 |
|
|
} |
5782 |
|
|
} |
5783 |
|
|
if (l->nightname) |
5784 |
|
|
{ |
5785 |
|
|
if (__sunriset__(year, month, day, geo_attr.u.coord_geo->lng, geo_attr.u.coord_geo->lat, -5, 1, &trise, &tset) != 0) |
5786 |
|
|
{ |
5787 |
|
|
//near the pole sun never rises/sets, so we should never switch profiles |
5788 |
|
|
// dbg(1,"tset: %u:%u, sun always visible, never switch profile\n",HOURS(tset), MINUTES(tset)); |
5789 |
|
|
n->prevTs = currTs; |
5790 |
|
|
return; |
5791 |
|
|
} |
5792 |
|
|
// dbg(1, "tset: %u:%u\n", HOURS(tset), MINUTES(tset)); |
5793 |
|
|
if (HOURS(tset) * 60 + MINUTES(tset) == ((currTs % 86400) / 60) || (n->prevTs == 0 && (((HOURS(tset) * 60 + MINUTES(tset) < (currTs % 86400) / 60)) || ((HOURS(trise_actual) * 60 + MINUTES(trise_actual) > (currTs % 86400) / 60))))) |
5794 |
|
|
{ |
5795 |
|
|
//Time to sleep |
5796 |
|
|
if (strcmp(l->name, l->nightname)) |
5797 |
|
|
{ |
5798 |
|
|
navit_set_layout_by_name(n, l->nightname); |
5799 |
|
|
} |
5800 |
|
|
} |
5801 |
|
|
} |
5802 |
|
|
|
5803 |
|
|
n->prevTs = currTs; |
5804 |
zoff99 |
2 |
} |
5805 |
|
|
} |
5806 |
|
|
|
5807 |
zoff99 |
27 |
int navit_set_vehicle_by_name(struct navit *n, const char *name) |
5808 |
zoff99 |
2 |
{ |
5809 |
zoff99 |
40 |
|
5810 |
|
|
|
5811 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
5812 |
zoff99 |
2 |
|
5813 |
zoff99 |
27 |
struct vehicle *v; |
5814 |
|
|
struct attr_iter *iter; |
5815 |
|
|
struct attr vehicle_attr, name_attr; |
5816 |
zoff99 |
2 |
|
5817 |
zoff99 |
27 |
iter = navit_attr_iter_new(); |
5818 |
zoff99 |
2 |
|
5819 |
zoff99 |
27 |
while (navit_get_attr(n, attr_vehicle, &vehicle_attr, iter)) |
5820 |
|
|
{ |
5821 |
|
|
v = vehicle_attr.u.vehicle; |
5822 |
|
|
vehicle_get_attr(v, attr_name, &name_attr, NULL); |
5823 |
|
|
if (name_attr.type == attr_name) |
5824 |
|
|
{ |
5825 |
|
|
if (!strcmp(name, name_attr.u.str)) |
5826 |
|
|
{ |
5827 |
|
|
navit_set_attr(n, &vehicle_attr); |
5828 |
zoff99 |
2 |
navit_attr_iter_destroy(iter); |
5829 |
|
|
return 1; |
5830 |
|
|
} |
5831 |
|
|
} |
5832 |
|
|
} |
5833 |
zoff99 |
27 |
navit_attr_iter_destroy(iter); |
5834 |
|
|
return 0; |
5835 |
zoff99 |
2 |
} |
5836 |
|
|
|
5837 |
zoff99 |
27 |
int navit_set_layout_by_name(struct navit *n, const char *name) |
5838 |
zoff99 |
2 |
{ |
5839 |
zoff99 |
40 |
|
5840 |
|
|
|
5841 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
5842 |
zoff99 |
2 |
|
5843 |
zoff99 |
27 |
struct layout *l; |
5844 |
|
|
struct attr_iter iter; |
5845 |
|
|
struct attr layout_attr; |
5846 |
zoff99 |
2 |
|
5847 |
zoff99 |
27 |
iter.u.list = 0x00; |
5848 |
zoff99 |
2 |
|
5849 |
zoff99 |
27 |
if (navit_get_attr(n, attr_layout, &layout_attr, &iter) != 1) |
5850 |
|
|
{ |
5851 |
|
|
return 0; //No layouts - nothing to do |
5852 |
zoff99 |
2 |
} |
5853 |
zoff99 |
27 |
if (iter.u.list == NULL) |
5854 |
|
|
{ |
5855 |
|
|
return 0; |
5856 |
|
|
} |
5857 |
zoff99 |
2 |
|
5858 |
zoff99 |
27 |
iter.u.list = g_list_first(iter.u.list); |
5859 |
|
|
|
5860 |
|
|
while (iter.u.list) |
5861 |
|
|
{ |
5862 |
|
|
l = (struct layout*) iter.u.list->data; |
5863 |
|
|
if (!strcmp(name, l->name)) |
5864 |
|
|
{ |
5865 |
|
|
layout_attr.u.layout = l; |
5866 |
|
|
layout_attr.type = attr_layout; |
5867 |
|
|
navit_set_attr(n, &layout_attr); |
5868 |
|
|
iter.u.list = g_list_first(iter.u.list); |
5869 |
|
|
return 1; |
5870 |
|
|
} |
5871 |
|
|
iter.u.list = g_list_next(iter.u.list); |
5872 |
|
|
} |
5873 |
|
|
|
5874 |
|
|
iter.u.list = g_list_first(iter.u.list); |
5875 |
|
|
return 0; |
5876 |
zoff99 |
2 |
} |
5877 |
|
|
|
5878 |
zoff99 |
27 |
void navit_disable_suspend() |
5879 |
|
|
{ |
5880 |
zoff99 |
40 |
|
5881 |
|
|
|
5882 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
5883 |
zoff99 |
2 |
|
5884 |
|
|
gui_disable_suspend(global_navit->gui); |
5885 |
zoff99 |
27 |
callback_list_call_attr_0(global_navit->attr_cbl, attr_unsuspend); |
5886 |
zoff99 |
2 |
} |
5887 |
|
|
|
5888 |
zoff99 |
28 |
/** |
5889 |
zoff99 |
29 |
* @brief Dumps item attrs to string |
5890 |
|
|
* |
5891 |
|
|
* @param item item |
5892 |
|
|
* @param pretty 0 -> normal, 1 -> pretty output |
5893 |
|
|
* @return string with attrs separated by '\n' |
5894 |
|
|
*/ |
5895 |
|
|
char* navit_item_dump(struct item *item, int pretty) |
5896 |
|
|
{ |
5897 |
|
|
char *temp_str = NULL; |
5898 |
|
|
char *ret_value = NULL; |
5899 |
|
|
struct attr attr; |
5900 |
|
|
struct attr attr2; |
5901 |
|
|
int had_flags = 0; |
5902 |
|
|
int *f; |
5903 |
|
|
int flags; |
5904 |
|
|
|
5905 |
|
|
if (item == NULL) |
5906 |
|
|
{ |
5907 |
zoff99 |
40 |
ret_value = g_strdup(""); |
5908 |
zoff99 |
29 |
return ret_value; |
5909 |
|
|
} |
5910 |
|
|
|
5911 |
|
|
if (pretty == 1) |
5912 |
|
|
{ |
5913 |
|
|
ret_value = g_strdup_printf("+*TYPE*+:%s", item_to_name(item->type)); |
5914 |
|
|
} |
5915 |
|
|
else |
5916 |
|
|
{ |
5917 |
|
|
ret_value = g_strdup_printf("type=%s", item_to_name(item->type)); |
5918 |
|
|
} |
5919 |
|
|
|
5920 |
|
|
while (item_attr_get(item, attr_any, &attr)) |
5921 |
|
|
{ |
5922 |
|
|
if (attr.type == attr_flags) |
5923 |
|
|
{ |
5924 |
|
|
had_flags = 1; |
5925 |
|
|
|
5926 |
|
|
flags = attr.u.num; |
5927 |
|
|
if (flags == 0) |
5928 |
|
|
{ |
5929 |
|
|
f = item_get_default_flags(item->type); |
5930 |
|
|
if (f) |
5931 |
|
|
{ |
5932 |
|
|
flags = *f; |
5933 |
|
|
} |
5934 |
|
|
else |
5935 |
|
|
{ |
5936 |
|
|
flags = 0; |
5937 |
|
|
} |
5938 |
|
|
} |
5939 |
|
|
|
5940 |
|
|
if (pretty == 1) |
5941 |
|
|
{ |
5942 |
|
|
temp_str = g_strdup_printf("%s\n%s=%s", ret_value, attr_to_name(attr.type), flags_to_text(flags)); |
5943 |
|
|
} |
5944 |
|
|
else |
5945 |
|
|
{ |
5946 |
|
|
temp_str = g_strdup_printf("%s\n%s='%s'", ret_value, attr_to_name(attr.type), flags_to_text(flags)); |
5947 |
|
|
} |
5948 |
|
|
} |
5949 |
|
|
else |
5950 |
|
|
{ |
5951 |
|
|
if (pretty == 1) |
5952 |
|
|
{ |
5953 |
|
|
temp_str = g_strdup_printf("%s\n%s=%s", ret_value, attr_to_name(attr.type), attr_to_text(&attr, NULL, 1)); |
5954 |
|
|
} |
5955 |
|
|
else |
5956 |
|
|
{ |
5957 |
|
|
temp_str = g_strdup_printf("%s\n%s='%s'", ret_value, attr_to_name(attr.type), attr_to_text(&attr, NULL, 1)); |
5958 |
|
|
} |
5959 |
|
|
} |
5960 |
|
|
g_free(ret_value); |
5961 |
|
|
ret_value = g_strdup(temp_str); |
5962 |
|
|
g_free(temp_str); |
5963 |
|
|
} |
5964 |
|
|
|
5965 |
|
|
if (had_flags == 0) |
5966 |
|
|
{ |
5967 |
|
|
f = item_get_default_flags(item->type); |
5968 |
|
|
if (f) |
5969 |
|
|
{ |
5970 |
|
|
flags = *f; |
5971 |
|
|
|
5972 |
|
|
if (pretty == 1) |
5973 |
|
|
{ |
5974 |
|
|
temp_str = g_strdup_printf("%s\n%s=%s", ret_value, attr_to_name(attr_flags), flags_to_text(flags)); |
5975 |
|
|
} |
5976 |
|
|
else |
5977 |
|
|
{ |
5978 |
|
|
temp_str = g_strdup_printf("%s\n%s='%s'", ret_value, attr_to_name(attr_flags), flags_to_text(flags)); |
5979 |
|
|
} |
5980 |
|
|
|
5981 |
|
|
g_free(ret_value); |
5982 |
|
|
ret_value = g_strdup(temp_str); |
5983 |
|
|
g_free(temp_str); |
5984 |
|
|
} |
5985 |
|
|
} |
5986 |
|
|
|
5987 |
|
|
// g_free(item); |
5988 |
|
|
|
5989 |
|
|
return ret_value; |
5990 |
|
|
} |
5991 |
|
|
|
5992 |
|
|
int navit_normal_item(enum item_type type) |
5993 |
|
|
{ |
5994 |
zoff99 |
30 |
if ((type > type_none) && (type < type_waypoint)) |
5995 |
zoff99 |
29 |
{ |
5996 |
|
|
return 1; |
5997 |
|
|
} |
5998 |
zoff99 |
30 |
else if ((type >= type_poi_land_feature) && (type <= type_poi_zoo)) |
5999 |
zoff99 |
29 |
{ |
6000 |
|
|
return 1; |
6001 |
|
|
} |
6002 |
zoff99 |
30 |
else if ((type >= type_traffic_signals) && (type <= type_poi_cafe)) |
6003 |
zoff99 |
29 |
{ |
6004 |
|
|
return 1; |
6005 |
|
|
} |
6006 |
zoff99 |
30 |
else if ((type >= type_poi_peak) && (type <= type_poi_ruins)) |
6007 |
zoff99 |
29 |
{ |
6008 |
|
|
return 1; |
6009 |
|
|
} |
6010 |
zoff99 |
30 |
else if ((type >= type_poi_post_box) && (type <= type_house_number)) |
6011 |
zoff99 |
29 |
{ |
6012 |
|
|
return 1; |
6013 |
|
|
} |
6014 |
zoff99 |
30 |
else if ((type >= type_poi_playground) && (type <= type_poi_shop_photo)) |
6015 |
zoff99 |
29 |
{ |
6016 |
|
|
return 1; |
6017 |
|
|
} |
6018 |
|
|
else if (type == type_place_label) |
6019 |
|
|
{ |
6020 |
|
|
return 1; |
6021 |
|
|
} |
6022 |
zoff99 |
30 |
else if ((type >= type_line) && (type <= type_ferry)) |
6023 |
zoff99 |
29 |
{ |
6024 |
|
|
return 1; |
6025 |
|
|
} |
6026 |
|
|
else if (type == type_street_unkn) |
6027 |
|
|
{ |
6028 |
|
|
return 1; |
6029 |
|
|
} |
6030 |
zoff99 |
41 |
else if (type == type_street_service) |
6031 |
|
|
{ |
6032 |
|
|
return 1; |
6033 |
|
|
} |
6034 |
|
|
else if (type == type_street_pedestrian) |
6035 |
|
|
{ |
6036 |
|
|
return 1; |
6037 |
|
|
} |
6038 |
|
|
else if (type == type_street_parking_lane) |
6039 |
|
|
{ |
6040 |
|
|
return 1; |
6041 |
|
|
} |
6042 |
|
|
else if (type == type_ramp_highway_land) |
6043 |
|
|
{ |
6044 |
|
|
return 1; |
6045 |
|
|
} |
6046 |
|
|
else if (type == type_ramp_street_4_city) |
6047 |
|
|
{ |
6048 |
|
|
return 1; |
6049 |
|
|
} |
6050 |
|
|
else if (type == type_ramp_street_3_city) |
6051 |
|
|
{ |
6052 |
|
|
return 1; |
6053 |
|
|
} |
6054 |
|
|
else if (type == type_ramp_street_2_city) |
6055 |
|
|
{ |
6056 |
|
|
return 1; |
6057 |
|
|
} |
6058 |
zoff99 |
30 |
else if ((type >= type_aeroway_runway) && (type <= type_footway_and_piste_nordic)) |
6059 |
zoff99 |
29 |
{ |
6060 |
|
|
return 1; |
6061 |
|
|
} |
6062 |
zoff99 |
30 |
else if ((type >= type_house_number_interpolation_even) && (type <= type_city_wall)) |
6063 |
zoff99 |
29 |
{ |
6064 |
|
|
return 1; |
6065 |
|
|
} |
6066 |
zoff99 |
30 |
else if ((type >= type_border_city) && (type <= type_border_county)) |
6067 |
zoff99 |
29 |
{ |
6068 |
|
|
return 1; |
6069 |
|
|
} |
6070 |
zoff99 |
30 |
else if ((type >= type_forest_way_1) && (type <= type_forest_way_4)) |
6071 |
zoff99 |
29 |
{ |
6072 |
|
|
return 1; |
6073 |
|
|
} |
6074 |
zoff99 |
30 |
else if ((type >= type_area) && (type <= type_poly_museum)) |
6075 |
zoff99 |
29 |
{ |
6076 |
|
|
return 1; |
6077 |
|
|
} |
6078 |
zoff99 |
30 |
else if ((type >= type_poly_commercial_center) && (type <= type_tundra)) |
6079 |
zoff99 |
29 |
{ |
6080 |
|
|
return 1; |
6081 |
|
|
} |
6082 |
zoff99 |
30 |
else if ((type >= type_poly_building) && (type <= type_poly_terminal)) |
6083 |
zoff99 |
29 |
{ |
6084 |
|
|
return 1; |
6085 |
|
|
} |
6086 |
zoff99 |
30 |
else if ((type >= type_poly_sports_centre) && (type <= type_poly_aeroway_runway)) |
6087 |
zoff99 |
29 |
{ |
6088 |
|
|
return 1; |
6089 |
|
|
} |
6090 |
|
|
|
6091 |
|
|
return 0; |
6092 |
|
|
} |
6093 |
|
|
|
6094 |
|
|
char* navit_find_nearest_item_dump(struct mapset *ms, struct pcoord *pc, int pretty) |
6095 |
|
|
{ |
6096 |
|
|
int max_dist = 0; // smallest rectangle possible |
6097 |
|
|
int dist, mindist = 0, pos; |
6098 |
|
|
int mindist_hn = 0; |
6099 |
|
|
struct mapset_handle *h; |
6100 |
|
|
struct map *m; |
6101 |
|
|
struct map_rect *mr; |
6102 |
|
|
struct item *item; |
6103 |
|
|
struct coord lp; |
6104 |
|
|
struct street_data *sd; |
6105 |
|
|
struct coord c; |
6106 |
|
|
struct coord_geo g; |
6107 |
|
|
struct map_selection sel; |
6108 |
|
|
struct attr street_name_attr; |
6109 |
|
|
struct attr hn_attr; |
6110 |
|
|
char *ret_str = NULL; |
6111 |
|
|
|
6112 |
|
|
|
6113 |
zoff99 |
40 |
|
6114 |
|
|
|
6115 |
zoff99 |
29 |
mindist = 1000; |
6116 |
|
|
|
6117 |
|
|
h = mapset_open(ms); |
6118 |
|
|
if (!h) |
6119 |
|
|
{ |
6120 |
|
|
// dbg(0,"return 1\n"); |
6121 |
zoff99 |
40 |
ret_str = g_strdup(""); |
6122 |
zoff99 |
29 |
return ret_str; |
6123 |
|
|
} |
6124 |
|
|
|
6125 |
|
|
while ((m = mapset_next(h, 0))) |
6126 |
|
|
{ |
6127 |
|
|
c.x = pc->x; |
6128 |
|
|
c.y = pc->y; |
6129 |
|
|
if (map_projection(m) != pc->pro) |
6130 |
|
|
{ |
6131 |
|
|
transform_to_geo(pc->pro, &c, &g); |
6132 |
|
|
transform_from_geo(map_projection(m), &g, &c); |
6133 |
|
|
} |
6134 |
|
|
|
6135 |
|
|
sel.next = NULL; |
6136 |
|
|
sel.order = 18; |
6137 |
|
|
sel.range.min = type_none; |
6138 |
|
|
sel.range.max = type_last; |
6139 |
|
|
sel.u.c_rect.lu.x = c.x - max_dist; |
6140 |
|
|
sel.u.c_rect.lu.y = c.y + max_dist; |
6141 |
|
|
sel.u.c_rect.rl.x = c.x + max_dist; |
6142 |
|
|
sel.u.c_rect.rl.y = c.y - max_dist; |
6143 |
|
|
|
6144 |
|
|
mr = map_rect_new(m, &sel); |
6145 |
|
|
if (!mr) |
6146 |
|
|
{ |
6147 |
|
|
continue; |
6148 |
|
|
} |
6149 |
|
|
|
6150 |
|
|
while ((item = map_rect_get_item(mr))) |
6151 |
|
|
{ |
6152 |
|
|
if (navit_normal_item(item->type) == 1) |
6153 |
|
|
{ |
6154 |
|
|
//dbg(0,"*type=%s\n", item_to_name(item->type)); |
6155 |
|
|
|
6156 |
|
|
struct coord c2[101]; |
6157 |
|
|
int count22 = item_coord_get(item, c2, 100); |
6158 |
|
|
if (count22 == 0) |
6159 |
|
|
{ |
6160 |
|
|
continue; |
6161 |
|
|
} |
6162 |
|
|
else if (count22 > 1) |
6163 |
|
|
{ |
6164 |
|
|
dist = transform_distance_polyline_sq__v2(c2, count22, &c); |
6165 |
|
|
if (dist < mindist) |
6166 |
|
|
{ |
6167 |
|
|
mindist = dist; |
6168 |
|
|
if (ret_str != NULL) |
6169 |
|
|
{ |
6170 |
|
|
g_free(ret_str); |
6171 |
|
|
} |
6172 |
zoff99 |
30 |
ret_str = navit_item_dump(item, pretty); |
6173 |
zoff99 |
29 |
} |
6174 |
|
|
} |
6175 |
|
|
else |
6176 |
|
|
{ |
6177 |
|
|
dist = transform_distance_sq(&c, &c2); |
6178 |
|
|
if (dist <= (mindist + 4)) |
6179 |
|
|
{ |
6180 |
|
|
mindist = dist; |
6181 |
|
|
if (ret_str != NULL) |
6182 |
|
|
{ |
6183 |
|
|
g_free(ret_str); |
6184 |
|
|
} |
6185 |
zoff99 |
30 |
ret_str = navit_item_dump(item, pretty); |
6186 |
zoff99 |
29 |
} |
6187 |
|
|
} |
6188 |
|
|
// dbg(0,"*end\n"); |
6189 |
|
|
} |
6190 |
|
|
} |
6191 |
|
|
|
6192 |
|
|
if (mr) |
6193 |
|
|
{ |
6194 |
|
|
map_rect_destroy(mr); |
6195 |
|
|
} |
6196 |
|
|
} |
6197 |
|
|
mapset_close(h); |
6198 |
|
|
|
6199 |
|
|
if (ret_str == NULL) |
6200 |
|
|
{ |
6201 |
|
|
// dbg(0,"was NULL\n"); |
6202 |
zoff99 |
40 |
ret_str = g_strdup(""); |
6203 |
zoff99 |
29 |
} |
6204 |
|
|
|
6205 |
|
|
return ret_str; |
6206 |
|
|
} |
6207 |
|
|
|
6208 |
|
|
/** |
6209 |
zoff99 |
28 |
* @brief Finds the nearest street to a given coordinate |
6210 |
|
|
* |
6211 |
|
|
* @param ms The mapset to search in for the street |
6212 |
|
|
* @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ] |
6213 |
|
|
* @return The nearest street |
6214 |
|
|
*/ |
6215 |
|
|
char* |
6216 |
|
|
navit_find_nearest_street(struct mapset *ms, struct pcoord *pc) |
6217 |
|
|
{ |
6218 |
zoff99 |
29 |
int max_dist = 0; // smallest rectangle possible |
6219 |
zoff99 |
28 |
int dist, mindist = 0, pos; |
6220 |
|
|
struct mapset_handle *h; |
6221 |
|
|
struct map *m; |
6222 |
|
|
struct map_rect *mr; |
6223 |
|
|
struct item *item; |
6224 |
|
|
struct coord lp; |
6225 |
|
|
struct street_data *sd; |
6226 |
|
|
struct coord c; |
6227 |
|
|
struct coord_geo g; |
6228 |
|
|
struct map_selection sel; |
6229 |
|
|
struct attr street_name_attr; |
6230 |
|
|
char *street_name = NULL; |
6231 |
|
|
|
6232 |
|
|
|
6233 |
zoff99 |
40 |
|
6234 |
|
|
|
6235 |
zoff99 |
28 |
mindist = 10000; // start with small radius at the beginning! |
6236 |
zoff99 |
40 |
street_name = g_strdup(" "); |
6237 |
zoff99 |
28 |
|
6238 |
|
|
h = mapset_open(ms); |
6239 |
|
|
|
6240 |
|
|
if (!h) |
6241 |
|
|
{ |
6242 |
zoff99 |
29 |
// set global value :-( |
6243 |
|
|
dist_to_street = mindist; |
6244 |
zoff99 |
28 |
return street_name; |
6245 |
|
|
} |
6246 |
|
|
|
6247 |
|
|
while ((m = mapset_next(h, 0))) |
6248 |
|
|
{ |
6249 |
|
|
c.x = pc->x; |
6250 |
|
|
c.y = pc->y; |
6251 |
|
|
if (map_projection(m) != pc->pro) |
6252 |
|
|
{ |
6253 |
|
|
transform_to_geo(pc->pro, &c, &g); |
6254 |
|
|
transform_from_geo(map_projection(m), &g, &c); |
6255 |
|
|
} |
6256 |
|
|
|
6257 |
|
|
sel.next = NULL; |
6258 |
|
|
sel.order = 18; |
6259 |
|
|
sel.range.min = type_line; |
6260 |
|
|
sel.range.max = type_area; |
6261 |
|
|
sel.u.c_rect.lu.x = c.x - max_dist; |
6262 |
|
|
sel.u.c_rect.lu.y = c.y + max_dist; |
6263 |
|
|
sel.u.c_rect.rl.x = c.x + max_dist; |
6264 |
|
|
sel.u.c_rect.rl.y = c.y - max_dist; |
6265 |
|
|
|
6266 |
|
|
mr = map_rect_new(m, &sel); |
6267 |
|
|
if (!mr) |
6268 |
|
|
{ |
6269 |
|
|
continue; |
6270 |
|
|
} |
6271 |
|
|
|
6272 |
|
|
while ((item = map_rect_get_item(mr))) |
6273 |
|
|
{ |
6274 |
|
|
if (item_get_default_flags(item->type)) |
6275 |
|
|
{ |
6276 |
|
|
sd = street_get_data(item); |
6277 |
|
|
if (!sd) |
6278 |
|
|
{ |
6279 |
|
|
continue; |
6280 |
|
|
} |
6281 |
zoff99 |
41 |
|
6282 |
zoff99 |
28 |
//dbg(0,"6 sd x:%d sd y:%d count:%d\n", sd->c->x, sd->c->y, sd->count); |
6283 |
|
|
//dbg(0,"6 c x:%d c y:%d\n", c.x, c.y); |
6284 |
zoff99 |
29 |
dist = transform_distance_polyline_sq__v2(sd->c, sd->count, &c); |
6285 |
zoff99 |
28 |
//dbg(0,"mindist:%d dist:%d\n", mindist, dist); |
6286 |
|
|
if (dist < mindist) |
6287 |
|
|
{ |
6288 |
|
|
//dbg(0,"6.a\n"); |
6289 |
|
|
mindist = dist; |
6290 |
|
|
|
6291 |
zoff99 |
29 |
if (item_attr_get(item, attr_street_name, &street_name_attr)) |
6292 |
zoff99 |
28 |
{ |
6293 |
|
|
if (street_name) |
6294 |
|
|
{ |
6295 |
|
|
g_free(street_name); |
6296 |
|
|
street_name = NULL; |
6297 |
|
|
} |
6298 |
|
|
street_name = g_strdup_printf("%s", street_name_attr.u.str); |
6299 |
zoff99 |
29 |
//dbg(0,"r3 %s\n", street_name); |
6300 |
zoff99 |
28 |
} |
6301 |
zoff99 |
29 |
else if (item_attr_get(item, attr_label, &street_name_attr)) |
6302 |
zoff99 |
28 |
{ |
6303 |
|
|
if (street_name) |
6304 |
|
|
{ |
6305 |
|
|
g_free(street_name); |
6306 |
|
|
street_name = NULL; |
6307 |
|
|
} |
6308 |
|
|
street_name = g_strdup_printf("%s", street_name_attr.u.str); |
6309 |
zoff99 |
29 |
//dbg(0,"r1 %s\n", street_name); |
6310 |
zoff99 |
28 |
} |
6311 |
|
|
else if (item_attr_get(item, attr_street_name_systematic, &street_name_attr)) |
6312 |
|
|
{ |
6313 |
|
|
if (street_name) |
6314 |
|
|
{ |
6315 |
|
|
g_free(street_name); |
6316 |
|
|
street_name = NULL; |
6317 |
|
|
} |
6318 |
|
|
street_name = g_strdup_printf("%s", street_name_attr.u.str); |
6319 |
|
|
//dbg(0,"r4 %s\n", street_name); |
6320 |
|
|
} |
6321 |
|
|
else |
6322 |
|
|
{ |
6323 |
|
|
//if (street_name) |
6324 |
|
|
//{ |
6325 |
|
|
// g_free(street_name); |
6326 |
|
|
// street_name = NULL; |
6327 |
|
|
//} |
6328 |
|
|
//street_name = g_strdup_printf("---"); |
6329 |
|
|
} |
6330 |
|
|
} |
6331 |
|
|
street_data_free(sd); |
6332 |
|
|
} |
6333 |
|
|
} |
6334 |
|
|
|
6335 |
|
|
if (mr) |
6336 |
|
|
{ |
6337 |
|
|
map_rect_destroy(mr); |
6338 |
|
|
} |
6339 |
|
|
} |
6340 |
|
|
mapset_close(h); |
6341 |
zoff99 |
29 |
// set global value :-( |
6342 |
|
|
dist_to_street = mindist; |
6343 |
zoff99 |
28 |
return street_name; |
6344 |
|
|
} |
6345 |
|
|
|
6346 |
|
|
/** |
6347 |
zoff99 |
29 |
* @brief Finds the nearest street or housenumber to a given coordinate |
6348 |
|
|
* |
6349 |
|
|
* @param ms The mapset to search in for the street |
6350 |
|
|
* @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ] |
6351 |
|
|
* @return The nearest street or housenumber |
6352 |
|
|
*/ |
6353 |
|
|
char* |
6354 |
|
|
navit_find_nearest_street_hn(struct mapset *ms, struct pcoord *pc) |
6355 |
|
|
{ |
6356 |
|
|
int max_dist = 0; // smallest rectangle possible |
6357 |
|
|
int dist, mindist = 0, pos; |
6358 |
|
|
int mindist_hn = 0; |
6359 |
|
|
struct mapset_handle *h; |
6360 |
|
|
struct map *m; |
6361 |
|
|
struct map_rect *mr; |
6362 |
|
|
struct item *item; |
6363 |
|
|
struct coord lp; |
6364 |
|
|
struct street_data *sd; |
6365 |
|
|
struct coord c; |
6366 |
|
|
struct coord_geo g; |
6367 |
|
|
struct map_selection sel; |
6368 |
|
|
struct attr street_name_attr; |
6369 |
|
|
struct attr hn_attr; |
6370 |
|
|
char *street_name = NULL; |
6371 |
|
|
char *street_name_saved = NULL; |
6372 |
|
|
|
6373 |
|
|
|
6374 |
zoff99 |
40 |
|
6375 |
|
|
|
6376 |
zoff99 |
29 |
// first find a street |
6377 |
|
|
street_name_saved = navit_find_nearest_street(ms, pc); |
6378 |
|
|
// street_name = g_strdup_printf(" "); |
6379 |
|
|
street_name = g_strdup(street_name_saved); |
6380 |
|
|
// first find a street |
6381 |
|
|
|
6382 |
|
|
mindist = dist_to_street; // start with small radius at the beginning! (only use housenumber of different street, if we are really close to it!!) |
6383 |
zoff99 |
30 |
// global value -> this is naughty :-) |
6384 |
zoff99 |
29 |
|
6385 |
|
|
if (mindist < 8) |
6386 |
|
|
{ |
6387 |
|
|
// so we can find other housenumbers if we are very close |
6388 |
|
|
mindist = 8; |
6389 |
|
|
} |
6390 |
|
|
|
6391 |
|
|
mindist_hn = 10000; |
6392 |
|
|
|
6393 |
|
|
//dbg(0,"given streetname %s %s dist %d\n", street_name, street_name_saved, dist_to_street); |
6394 |
|
|
|
6395 |
|
|
|
6396 |
|
|
h = mapset_open(ms); |
6397 |
|
|
|
6398 |
|
|
if (!h) |
6399 |
|
|
{ |
6400 |
|
|
if (street_name_saved) |
6401 |
|
|
{ |
6402 |
|
|
g_free(street_name_saved); |
6403 |
|
|
street_name_saved = NULL; |
6404 |
|
|
} |
6405 |
|
|
return street_name; |
6406 |
|
|
} |
6407 |
|
|
|
6408 |
|
|
while ((m = mapset_next(h, 0))) |
6409 |
|
|
{ |
6410 |
|
|
c.x = pc->x; |
6411 |
|
|
c.y = pc->y; |
6412 |
|
|
if (map_projection(m) != pc->pro) |
6413 |
|
|
{ |
6414 |
|
|
transform_to_geo(pc->pro, &c, &g); |
6415 |
|
|
transform_from_geo(map_projection(m), &g, &c); |
6416 |
|
|
} |
6417 |
|
|
|
6418 |
|
|
sel.next = NULL; |
6419 |
|
|
sel.order = 18; |
6420 |
|
|
sel.range.min = type_none; |
6421 |
|
|
sel.range.max = type_area; |
6422 |
|
|
sel.u.c_rect.lu.x = c.x - max_dist; |
6423 |
|
|
sel.u.c_rect.lu.y = c.y + max_dist; |
6424 |
|
|
sel.u.c_rect.rl.x = c.x + max_dist; |
6425 |
|
|
sel.u.c_rect.rl.y = c.y - max_dist; |
6426 |
|
|
|
6427 |
|
|
mr = map_rect_new(m, &sel); |
6428 |
|
|
if (!mr) |
6429 |
|
|
{ |
6430 |
|
|
continue; |
6431 |
|
|
} |
6432 |
|
|
|
6433 |
|
|
while ((item = map_rect_get_item(mr))) |
6434 |
|
|
{ |
6435 |
|
|
if (item->type == type_house_number) |
6436 |
|
|
{ |
6437 |
|
|
//dbg(0,"hn found\n"); |
6438 |
|
|
struct coord c2; |
6439 |
|
|
int rrr = item_coord_get(item, &c2, 1); |
6440 |
|
|
if (rrr) |
6441 |
|
|
{ |
6442 |
|
|
dist = transform_distance_sq(&c, &c2); |
6443 |
|
|
//dbg(0,"dist=%d\n", dist); |
6444 |
|
|
if (dist < mindist) |
6445 |
|
|
{ |
6446 |
|
|
if (item_attr_get(item, attr_street_name, &street_name_attr)) |
6447 |
|
|
{ |
6448 |
|
|
if (item_attr_get(item, attr_house_number, &hn_attr)) |
6449 |
|
|
{ |
6450 |
|
|
if (street_name) |
6451 |
|
|
{ |
6452 |
|
|
g_free(street_name); |
6453 |
|
|
street_name = NULL; |
6454 |
|
|
} |
6455 |
|
|
street_name = g_strdup_printf("%s %s", street_name_attr.u.str, hn_attr.u.str); |
6456 |
|
|
//dbg(0,"sn 1\n"); |
6457 |
|
|
mindist = dist; |
6458 |
|
|
mindist_hn = dist; |
6459 |
|
|
} |
6460 |
|
|
} |
6461 |
|
|
} |
6462 |
|
|
// else try to find housenumbers for our current street |
6463 |
|
|
// just take the nearest housenumber for our current street |
6464 |
|
|
else if (dist < mindist_hn) |
6465 |
|
|
{ |
6466 |
|
|
//dbg(0,"sn 2.1\n"); |
6467 |
|
|
if (item_attr_get(item, attr_street_name, &street_name_attr)) |
6468 |
|
|
{ |
6469 |
|
|
//dbg(0,"sn 2.2\n"); |
6470 |
|
|
if (item_attr_get(item, attr_house_number, &hn_attr)) |
6471 |
|
|
{ |
6472 |
|
|
//dbg(0,"sn 2.3\n"); |
6473 |
|
|
if ((street_name != NULL) && (street_name_saved != NULL)) |
6474 |
|
|
{ |
6475 |
|
|
// dbg(0,"sn 2.4 -%s- -%s-\n", street_name_saved, street_name_attr.u.str); |
6476 |
|
|
if (!strcmp(street_name_saved, street_name_attr.u.str)) |
6477 |
|
|
{ |
6478 |
|
|
g_free(street_name); |
6479 |
|
|
street_name = NULL; |
6480 |
|
|
|
6481 |
|
|
// dbg(0,"sn 2.99\n"); |
6482 |
|
|
|
6483 |
|
|
street_name = g_strdup_printf("%s %s", street_name_attr.u.str, hn_attr.u.str); |
6484 |
|
|
mindist_hn = dist; |
6485 |
|
|
} |
6486 |
|
|
} |
6487 |
|
|
} |
6488 |
|
|
} |
6489 |
|
|
} |
6490 |
|
|
} |
6491 |
|
|
} |
6492 |
|
|
|
6493 |
|
|
#if 0 |
6494 |
|
|
//else if (item->type > type_line) |
6495 |
|
|
if (1 == 0) // DISABLED !!!!!! |
6496 |
zoff99 |
30 |
|
6497 |
zoff99 |
29 |
{ |
6498 |
|
|
if (item_get_default_flags(item->type)) |
6499 |
|
|
{ |
6500 |
|
|
sd = street_get_data(item); |
6501 |
|
|
if (!sd) |
6502 |
|
|
{ |
6503 |
|
|
continue; |
6504 |
|
|
} |
6505 |
|
|
dist = transform_distance_polyline_sq(sd->c, sd->count, &c, &lp, &pos); |
6506 |
|
|
if (dist < mindist) |
6507 |
|
|
{ |
6508 |
|
|
mindist = dist; |
6509 |
|
|
|
6510 |
|
|
if (item_attr_get(item, attr_label, &street_name_attr)) |
6511 |
|
|
{ |
6512 |
|
|
if (street_name) |
6513 |
|
|
{ |
6514 |
|
|
g_free(street_name); |
6515 |
|
|
street_name = NULL; |
6516 |
|
|
} |
6517 |
|
|
if (street_name_saved) |
6518 |
|
|
{ |
6519 |
|
|
g_free(street_name_saved); |
6520 |
|
|
street_name_saved = NULL; |
6521 |
|
|
} |
6522 |
|
|
street_name = g_strdup_printf("%s", street_name_attr.u.str); |
6523 |
|
|
street_name_saved = g_strdup(street_name); |
6524 |
|
|
} |
6525 |
|
|
else if (item_attr_get(item, attr_street_name, &street_name_attr)) |
6526 |
|
|
{ |
6527 |
|
|
if (street_name) |
6528 |
|
|
{ |
6529 |
|
|
g_free(street_name); |
6530 |
|
|
street_name = NULL; |
6531 |
|
|
} |
6532 |
|
|
if (street_name_saved) |
6533 |
|
|
{ |
6534 |
|
|
g_free(street_name_saved); |
6535 |
|
|
street_name_saved = NULL; |
6536 |
|
|
} |
6537 |
|
|
street_name = g_strdup_printf("%s", street_name_attr.u.str); |
6538 |
|
|
street_name_saved = g_strdup(street_name); |
6539 |
|
|
} |
6540 |
|
|
else if (item_attr_get(item, attr_street_name_systematic, &street_name_attr)) |
6541 |
|
|
{ |
6542 |
|
|
if (street_name) |
6543 |
|
|
{ |
6544 |
|
|
g_free(street_name); |
6545 |
|
|
street_name = NULL; |
6546 |
|
|
} |
6547 |
|
|
if (street_name_saved) |
6548 |
|
|
{ |
6549 |
|
|
g_free(street_name_saved); |
6550 |
|
|
street_name_saved = NULL; |
6551 |
|
|
} |
6552 |
|
|
street_name = g_strdup_printf("%s", street_name_attr.u.str); |
6553 |
|
|
street_name_saved = g_strdup(street_name); |
6554 |
|
|
} |
6555 |
|
|
} |
6556 |
|
|
street_data_free(sd); |
6557 |
|
|
} |
6558 |
|
|
} |
6559 |
|
|
#endif |
6560 |
|
|
} |
6561 |
|
|
|
6562 |
|
|
if (mr) |
6563 |
|
|
{ |
6564 |
|
|
map_rect_destroy(mr); |
6565 |
|
|
} |
6566 |
|
|
} |
6567 |
|
|
|
6568 |
|
|
if (street_name_saved) |
6569 |
|
|
{ |
6570 |
|
|
g_free(street_name_saved); |
6571 |
|
|
street_name_saved = NULL; |
6572 |
|
|
} |
6573 |
|
|
|
6574 |
|
|
mapset_close(h); |
6575 |
|
|
return street_name; |
6576 |
|
|
} |
6577 |
|
|
|
6578 |
|
|
/** |
6579 |
zoff99 |
28 |
* @brief Finds the nearest street to a given coordinate |
6580 |
|
|
* |
6581 |
|
|
* @param ms The mapset to search in for the street |
6582 |
|
|
* @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ] |
6583 |
|
|
* @return The nearest street (as a string of coords "0xFFF 0xFFF\n..." seperated by "\n") |
6584 |
|
|
*/ |
6585 |
|
|
char* |
6586 |
|
|
navit_find_nearest_street_coords(struct mapset *ms, struct pcoord *pc) |
6587 |
|
|
{ |
6588 |
zoff99 |
29 |
int max_dist = 0; // smallest rectangle possible |
6589 |
zoff99 |
28 |
int dist, mindist = 0, pos; |
6590 |
|
|
struct mapset_handle *h; |
6591 |
|
|
struct map *m; |
6592 |
|
|
struct map_rect *mr; |
6593 |
|
|
struct item *item; |
6594 |
|
|
struct coord lp; |
6595 |
|
|
struct street_data *sd = NULL; |
6596 |
|
|
struct street_data *sd_copy = NULL; |
6597 |
|
|
struct coord c; |
6598 |
|
|
struct coord_geo g; |
6599 |
|
|
struct map_selection sel; |
6600 |
|
|
int i; |
6601 |
|
|
int found_good = 0; |
6602 |
|
|
struct attr street_name_attr; |
6603 |
|
|
char *street_coords = NULL; |
6604 |
|
|
char *street_coords_tmp = NULL; |
6605 |
|
|
|
6606 |
|
|
|
6607 |
zoff99 |
40 |
|
6608 |
|
|
|
6609 |
zoff99 |
28 |
mindist = 10000; // start with small radius at the beginning! |
6610 |
zoff99 |
40 |
street_coords = g_strdup_printf("", ""); |
6611 |
zoff99 |
28 |
|
6612 |
|
|
h = mapset_open(ms); |
6613 |
|
|
|
6614 |
|
|
if (!h) |
6615 |
|
|
{ |
6616 |
|
|
return street_coords; |
6617 |
|
|
} |
6618 |
|
|
|
6619 |
|
|
while ((m = mapset_next(h, 0))) |
6620 |
|
|
{ |
6621 |
|
|
c.x = pc->x; |
6622 |
|
|
c.y = pc->y; |
6623 |
|
|
if (map_projection(m) != pc->pro) |
6624 |
|
|
{ |
6625 |
|
|
transform_to_geo(pc->pro, &c, &g); |
6626 |
|
|
transform_from_geo(map_projection(m), &g, &c); |
6627 |
|
|
} |
6628 |
|
|
|
6629 |
|
|
sel.next = NULL; |
6630 |
|
|
sel.order = 18; |
6631 |
|
|
sel.range.min = type_line; |
6632 |
|
|
sel.range.max = type_area; |
6633 |
|
|
sel.u.c_rect.lu.x = c.x - max_dist; |
6634 |
|
|
sel.u.c_rect.lu.y = c.y + max_dist; |
6635 |
|
|
sel.u.c_rect.rl.x = c.x + max_dist; |
6636 |
|
|
sel.u.c_rect.rl.y = c.y - max_dist; |
6637 |
|
|
|
6638 |
|
|
mr = map_rect_new(m, &sel); |
6639 |
|
|
if (!mr) |
6640 |
|
|
{ |
6641 |
|
|
continue; |
6642 |
|
|
} |
6643 |
|
|
|
6644 |
|
|
while ((item = map_rect_get_item(mr))) |
6645 |
|
|
{ |
6646 |
|
|
if (item_get_default_flags(item->type)) |
6647 |
|
|
{ |
6648 |
|
|
sd = street_get_data(item); |
6649 |
|
|
if (!sd) |
6650 |
|
|
{ |
6651 |
|
|
continue; |
6652 |
|
|
} |
6653 |
|
|
found_good = 0; |
6654 |
zoff99 |
29 |
// OLD // dist = transform_distance_polyline_sq(sd->c, sd->count, &c, &lp, &pos); |
6655 |
|
|
dist = transform_distance_polyline_sq__v2(sd->c, sd->count, &c); |
6656 |
zoff99 |
28 |
if (dist < mindist) |
6657 |
|
|
{ |
6658 |
|
|
mindist = dist; |
6659 |
|
|
|
6660 |
|
|
/* |
6661 |
zoff99 |
30 |
if (item_attr_get(item, attr_label, &street_name_attr)) |
6662 |
|
|
{ |
6663 |
|
|
found_good = 1; |
6664 |
|
|
} |
6665 |
|
|
else if (item_attr_get(item, attr_street_name, &street_name_attr)) |
6666 |
|
|
{ |
6667 |
|
|
found_good = 1; |
6668 |
|
|
} |
6669 |
|
|
else if (item_attr_get(item, attr_street_name_systematic, &street_name_attr)) |
6670 |
|
|
{ |
6671 |
|
|
found_good = 1; |
6672 |
|
|
} |
6673 |
|
|
*/ |
6674 |
zoff99 |
28 |
|
6675 |
|
|
// allow any street/line, so you can select streets without name also! |
6676 |
|
|
found_good = 1; |
6677 |
|
|
} |
6678 |
|
|
|
6679 |
|
|
if (found_good == 1) |
6680 |
|
|
{ |
6681 |
|
|
if (sd_copy) |
6682 |
|
|
{ |
6683 |
|
|
street_data_free(sd_copy); |
6684 |
|
|
} |
6685 |
|
|
sd_copy = street_data_dup(sd); |
6686 |
|
|
} |
6687 |
|
|
street_data_free(sd); |
6688 |
|
|
} |
6689 |
|
|
} |
6690 |
|
|
|
6691 |
|
|
if (mr) |
6692 |
|
|
{ |
6693 |
|
|
map_rect_destroy(mr); |
6694 |
|
|
} |
6695 |
|
|
} |
6696 |
|
|
mapset_close(h); |
6697 |
|
|
|
6698 |
|
|
if (sd_copy) |
6699 |
|
|
{ |
6700 |
|
|
//struct coord ca[sd_copy->count]; |
6701 |
|
|
//item_coord_get(&sd_copy->item, ca, sd_copy->count); |
6702 |
|
|
|
6703 |
|
|
// dbg(0,"sd_copy->count=%d\n", sd_copy->count); |
6704 |
|
|
|
6705 |
|
|
for (i = 0; i < sd_copy->count; i++) |
6706 |
|
|
{ |
6707 |
|
|
/* |
6708 |
zoff99 |
30 |
unsigned int x; |
6709 |
|
|
unsigned int y; |
6710 |
|
|
char *sign_x = ""; |
6711 |
|
|
char *sign_y = ""; |
6712 |
zoff99 |
28 |
|
6713 |
zoff99 |
30 |
if ( c->x < 0 ) { |
6714 |
|
|
x = -c->x; |
6715 |
|
|
sign_x = "-"; |
6716 |
|
|
} else { |
6717 |
|
|
x = c->x; |
6718 |
|
|
} |
6719 |
|
|
if ( c->y < 0 ) { |
6720 |
|
|
y = -c->y; |
6721 |
|
|
sign_y = "-"; |
6722 |
|
|
} else { |
6723 |
|
|
y = c->y; |
6724 |
|
|
} |
6725 |
|
|
*/ |
6726 |
|
|
|
6727 |
zoff99 |
28 |
street_coords_tmp = street_coords; |
6728 |
|
|
if (street_coords == NULL) |
6729 |
|
|
{ |
6730 |
|
|
street_coords = g_strdup_printf("0x%x 0x%x\n", sd_copy->c[i].x, sd_copy->c[i].y); |
6731 |
|
|
} |
6732 |
|
|
else |
6733 |
|
|
{ |
6734 |
|
|
char *tmp2 = g_strdup_printf("0x%x 0x%x\n", sd_copy->c[i].x, sd_copy->c[i].y); |
6735 |
|
|
street_coords = g_strconcat(street_coords_tmp, tmp2, NULL); |
6736 |
|
|
g_free(street_coords_tmp); |
6737 |
|
|
g_free(tmp2); |
6738 |
|
|
} |
6739 |
|
|
} |
6740 |
|
|
|
6741 |
|
|
street_data_free(sd_copy); |
6742 |
|
|
} |
6743 |
|
|
|
6744 |
|
|
return street_coords; |
6745 |
|
|
} |
6746 |
|
|
|
6747 |
zoff99 |
30 |
// UNUSDED ------- |
6748 |
|
|
// UNUSDED ------- |
6749 |
zoff99 |
27 |
int navit_block(struct navit *this_, int block) |
6750 |
zoff99 |
2 |
{ |
6751 |
zoff99 |
40 |
|
6752 |
|
|
|
6753 |
zoff99 |
27 |
////DBG dbg(0,"EEnter\n"); |
6754 |
zoff99 |
2 |
|
6755 |
zoff99 |
27 |
if (block > 0) |
6756 |
|
|
{ |
6757 |
zoff99 |
2 |
this_->blocked |= 1; |
6758 |
|
|
if (graphics_draw_cancel(this_->gra, this_->displaylist)) |
6759 |
|
|
this_->blocked |= 2; |
6760 |
|
|
return 0; |
6761 |
|
|
} |
6762 |
zoff99 |
27 |
if ((this_->blocked & 2) || block < 0) |
6763 |
|
|
{ |
6764 |
|
|
this_->blocked = 0; |
6765 |
zoff99 |
2 |
navit_draw(this_); |
6766 |
|
|
return 1; |
6767 |
|
|
} |
6768 |
zoff99 |
27 |
this_->blocked = 0; |
6769 |
zoff99 |
2 |
return 0; |
6770 |
|
|
} |
6771 |
|
|
|
6772 |
zoff99 |
40 |
FILE * navit_start_gpx_file(char *filename) |
6773 |
zoff99 |
2 |
{ |
6774 |
zoff99 |
40 |
char *header1 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" |
6775 |
|
|
"<gpx version=\"1.1\" creator=\"ZANavi http://zanavi.cc\"\n" |
6776 |
|
|
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" |
6777 |
|
|
" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" |
6778 |
|
|
" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n" |
6779 |
|
|
"<metadata>\n" |
6780 |
|
|
" <name>ZANavi Debug log</name>\n" |
6781 |
|
|
" <desc>ZANavi</desc>\n" |
6782 |
|
|
" <author>\n" |
6783 |
|
|
" <name>ZANavi</name>\n" |
6784 |
|
|
" </author>\n" |
6785 |
|
|
"</metadata>\n" |
6786 |
|
|
"<trk>\n" |
6787 |
|
|
"<trkseg>\n" |
6788 |
|
|
" <name>ACTIVE LOG</name>\n"; |
6789 |
|
|
|
6790 |
|
|
FILE *fp; |
6791 |
|
|
|
6792 |
|
|
if (filename) |
6793 |
|
|
{ |
6794 |
|
|
fp = fopen(filename,"w"); |
6795 |
|
|
} |
6796 |
|
|
else |
6797 |
|
|
{ |
6798 |
|
|
fp = fopen("/sdcard/zanavi_debug_001.gpx","w"); |
6799 |
|
|
} |
6800 |
|
|
|
6801 |
|
|
fprintf(fp, "%s", header1); |
6802 |
|
|
|
6803 |
|
|
return fp; |
6804 |
|
|
} |
6805 |
|
|
|
6806 |
|
|
void navit_add_trkpoint_to_gpx_file(FILE *fp, struct coord *c) |
6807 |
|
|
{ |
6808 |
|
|
struct coord_geo g; |
6809 |
|
|
transform_to_geo(projection_mg, c, &g); |
6810 |
|
|
fprintf(fp, " <trkpt lat='%4.6f' lon='%4.6f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lat, g.lng); |
6811 |
|
|
} |
6812 |
|
|
|
6813 |
|
|
|
6814 |
|
|
void navit_end_gpx_track_seg(FILE *fp) |
6815 |
|
|
{ |
6816 |
|
|
fprintf(fp,"</trkseg>\n</trk>\n"); |
6817 |
|
|
} |
6818 |
|
|
|
6819 |
|
|
void navit_start_gpx_track_seg(FILE *fp) |
6820 |
|
|
{ |
6821 |
|
|
fprintf(fp,"<trk>\n<trkseg>\n"); |
6822 |
|
|
} |
6823 |
|
|
|
6824 |
|
|
|
6825 |
|
|
void navit_end_gpx_file(FILE *fp) |
6826 |
|
|
{ |
6827 |
|
|
char *trailer1= "</trkseg>\n" |
6828 |
|
|
"</trk>\n" |
6829 |
|
|
"</gpx>\n"; |
6830 |
|
|
|
6831 |
|
|
fprintf(fp,"%s",trailer1); |
6832 |
|
|
fclose(fp); |
6833 |
|
|
} |
6834 |
|
|
|
6835 |
zoff99 |
41 |
GList* navit_route_export_to_java_string(struct navit *this_, int result_id) |
6836 |
|
|
{ |
6837 |
|
|
struct point p; |
6838 |
|
|
struct map *map=NULL; |
6839 |
|
|
struct navigation *nav = NULL; |
6840 |
|
|
struct map_rect *mr=NULL; |
6841 |
|
|
struct item *item =NULL; |
6842 |
|
|
struct attr attr,route; |
6843 |
|
|
struct coord c; |
6844 |
|
|
// struct coord c_end; |
6845 |
|
|
struct coord_geo g; |
6846 |
|
|
struct transformation *trans; |
6847 |
|
|
char *d = NULL; |
6848 |
|
|
char *result_string = NULL; |
6849 |
|
|
GList* result = NULL; |
6850 |
|
|
|
6851 |
|
|
nav = navit_get_navigation(this_); |
6852 |
|
|
|
6853 |
|
|
if (!nav) |
6854 |
|
|
{ |
6855 |
|
|
return NULL; |
6856 |
|
|
} |
6857 |
|
|
|
6858 |
|
|
map = navigation_get_map(nav); |
6859 |
|
|
|
6860 |
|
|
if (map) |
6861 |
|
|
{ |
6862 |
|
|
mr = map_rect_new(map,NULL); |
6863 |
|
|
} |
6864 |
|
|
else |
6865 |
|
|
{ |
6866 |
zoff99 |
56 |
return NULL; |
6867 |
zoff99 |
41 |
} |
6868 |
|
|
|
6869 |
|
|
trans = navit_get_trans(this_); |
6870 |
|
|
|
6871 |
|
|
mr = map_rect_new(map,NULL); |
6872 |
|
|
while ((item = map_rect_get_item(mr))) |
6873 |
|
|
{ |
6874 |
|
|
|
6875 |
|
|
// dbg(0, "005 ============== = %s : %d\n", item_to_name(item->type), item->id_lo); |
6876 |
|
|
|
6877 |
|
|
//if (item_attr_get(item, attr_navigation_short, &attr)) |
6878 |
|
|
//{ |
6879 |
|
|
// dbg(0, "005.c.01:%s\n", attr.u.str); |
6880 |
|
|
//} |
6881 |
|
|
|
6882 |
|
|
if (item_attr_get(item, attr_length, &attr)) |
6883 |
|
|
{ |
6884 |
|
|
if (attr.u.num > 0) |
6885 |
|
|
{ |
6886 |
|
|
d = get_distance(nav, attr.u.num, attr_navigation_short, 1); |
6887 |
|
|
} |
6888 |
|
|
|
6889 |
|
|
// dbg(0, "005.c.02:%d %s\n", attr.u.num, d); // dist to next turn in meters! (take care when in imperial mode!) |
6890 |
|
|
} |
6891 |
|
|
else |
6892 |
|
|
{ |
6893 |
|
|
d = NULL; |
6894 |
|
|
} |
6895 |
|
|
|
6896 |
|
|
if ((item_attr_get(item, attr_navigation_long_exact, &attr)) || (item->type == type_nav_waypoint)) |
6897 |
|
|
{ |
6898 |
|
|
dbg(0, "NAVICG:call type=%s\n", item_to_name(item->type)); |
6899 |
|
|
item_coord_get(item, &c, 1); |
6900 |
|
|
dbg(0, "NAVICG:call END\n"); |
6901 |
|
|
|
6902 |
|
|
//int num_coords = 0; |
6903 |
|
|
//while (item_coord_get(item, &c_end, 1)) |
6904 |
|
|
//{ |
6905 |
|
|
// num_coords++; |
6906 |
|
|
//} |
6907 |
|
|
|
6908 |
|
|
transform_to_geo(projection_mg, &c, &g); |
6909 |
|
|
|
6910 |
|
|
if (result) |
6911 |
|
|
{ |
6912 |
|
|
} |
6913 |
|
|
else |
6914 |
|
|
{ |
6915 |
zoff99 |
48 |
// 1st line is the ID |
6916 |
zoff99 |
41 |
result = g_list_append(result, g_strdup_printf("%d", result_id)); |
6917 |
zoff99 |
48 |
if (result_id == 9990001) |
6918 |
|
|
{ |
6919 |
|
|
// 2nd line is distance to target in meters |
6920 |
|
|
int len_meters_to_target = 0; |
6921 |
|
|
if (nav) |
6922 |
|
|
{ |
6923 |
|
|
if (nav->first) |
6924 |
|
|
{ |
6925 |
|
|
len_meters_to_target = nav->first->dest_length; |
6926 |
|
|
} |
6927 |
|
|
} |
6928 |
|
|
result = g_list_append(result, g_strdup_printf("meters:%d", len_meters_to_target)); |
6929 |
|
|
} |
6930 |
zoff99 |
41 |
} |
6931 |
|
|
|
6932 |
|
|
dbg(0, "013 %s %s\n", item_to_name(item->type), map_convert_string(item->map, attr.u.str)); |
6933 |
|
|
|
6934 |
|
|
if (item->type == type_nav_waypoint) |
6935 |
|
|
{ |
6936 |
|
|
result = g_list_append(result, g_strdup_printf("%s:%4.8f:%4.8f:%s:%s", d ? d : "", g.lat, g.lng, item_to_name(item->type), _("Waypoint"))); |
6937 |
|
|
} |
6938 |
|
|
else |
6939 |
|
|
{ |
6940 |
|
|
result = g_list_append(result, g_strdup_printf("%s:%4.8f:%4.8f:%s:%s", d ? d : "", g.lat, g.lng, item_to_name(item->type), map_convert_string(item->map,attr.u.str))); |
6941 |
|
|
} |
6942 |
|
|
} |
6943 |
|
|
else |
6944 |
|
|
{ |
6945 |
|
|
// must be the start point (without navigation command) |
6946 |
|
|
item_coord_get(item, &c, 1); |
6947 |
|
|
transform_to_geo(projection_mg, &c, &g); |
6948 |
|
|
|
6949 |
|
|
if (result) |
6950 |
|
|
{ |
6951 |
|
|
} |
6952 |
|
|
else |
6953 |
|
|
{ |
6954 |
zoff99 |
48 |
// 1st line is the ID |
6955 |
zoff99 |
41 |
result = g_list_append(result, g_strdup_printf("%d", result_id)); |
6956 |
zoff99 |
48 |
if (result_id == 9990001) |
6957 |
|
|
{ |
6958 |
|
|
// 2nd line is distance to target in meters |
6959 |
|
|
int len_meters_to_target = 0; |
6960 |
|
|
if (nav) |
6961 |
|
|
{ |
6962 |
|
|
if (nav->first) |
6963 |
|
|
{ |
6964 |
|
|
len_meters_to_target = nav->first->dest_length; |
6965 |
|
|
} |
6966 |
|
|
} |
6967 |
|
|
result = g_list_append(result, g_strdup_printf("meters:%d", len_meters_to_target)); |
6968 |
|
|
} |
6969 |
zoff99 |
41 |
} |
6970 |
|
|
|
6971 |
|
|
// dbg(0, "019.0 %p\n", attr.u.str); |
6972 |
|
|
// dbg(0, "019.b %d\n", item->type); |
6973 |
|
|
// dbg(0, "019.c %s\n", item_to_name(item->type)); |
6974 |
|
|
result = g_list_append(result, g_strdup_printf("%s:%4.8f:%4.8f:+start+:", d ? d : "", g.lat, g.lng)); |
6975 |
|
|
} |
6976 |
|
|
|
6977 |
|
|
if (d) |
6978 |
|
|
{ |
6979 |
|
|
g_free(d); |
6980 |
|
|
d = NULL; |
6981 |
|
|
} |
6982 |
|
|
|
6983 |
|
|
} |
6984 |
|
|
|
6985 |
|
|
map_rect_destroy(mr); |
6986 |
|
|
|
6987 |
|
|
return result; |
6988 |
|
|
|
6989 |
|
|
} |
6990 |
|
|
|
6991 |
zoff99 |
40 |
void navit_route_export_gpx_to_file(struct navit *this_, char *filename) |
6992 |
|
|
{ |
6993 |
|
|
|
6994 |
|
|
|
6995 |
|
|
|
6996 |
|
|
dbg(0,"Dumping route to %s\n", filename); |
6997 |
|
|
|
6998 |
|
|
struct point p; |
6999 |
|
|
struct map *map=NULL; |
7000 |
|
|
struct navigation *nav = NULL; |
7001 |
|
|
struct map_rect *mr=NULL; |
7002 |
|
|
struct item *item =NULL; |
7003 |
|
|
struct attr attr,route; |
7004 |
|
|
struct coord c; |
7005 |
|
|
struct coord_geo g; |
7006 |
|
|
struct transformation *trans; |
7007 |
|
|
|
7008 |
|
|
char *header1 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" |
7009 |
|
|
"<gpx version=\"1.1\" creator=\"ZANavi http://zanavi.cc\"\n" |
7010 |
|
|
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" |
7011 |
|
|
" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" |
7012 |
|
|
" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n" |
7013 |
|
|
"<metadata>\n" |
7014 |
|
|
" <name>ZANavi Track log</name>\n" |
7015 |
|
|
" <desc>ZANavi</desc>\n" |
7016 |
|
|
" <author>\n" |
7017 |
|
|
" <name>ZANavi</name>\n" |
7018 |
|
|
" </author>\n" |
7019 |
|
|
"</metadata>\n" |
7020 |
|
|
"<trk>\n" |
7021 |
|
|
"<trkseg>\n" |
7022 |
|
|
" <name>ACTIVE LOG</name>\n"; |
7023 |
|
|
|
7024 |
|
|
char *trailer1= "</trkseg>\n" |
7025 |
|
|
"</trk>\n"; |
7026 |
|
|
|
7027 |
|
|
// char *trkcolor= "<extensions>\n" |
7028 |
|
|
// " <gpxx:TrackExtension>\n" |
7029 |
|
|
// " <gpxx:DisplayColor>Magenta</gpxx:DisplayColor>\n" |
7030 |
|
|
// " </gpxx:TrackExtension>\n" |
7031 |
|
|
// "</extensions>\n"; |
7032 |
|
|
|
7033 |
|
|
char *header2 = "<rte>\n"; |
7034 |
|
|
|
7035 |
|
|
char *trailer2= "</rte>\n" |
7036 |
|
|
"</gpx>\n"; |
7037 |
|
|
|
7038 |
|
|
|
7039 |
|
|
// -------- full route --------- |
7040 |
|
|
// -------- full route --------- |
7041 |
|
|
struct route *route2 = NULL; |
7042 |
|
|
struct map *route_map2 = NULL; |
7043 |
|
|
struct map_rect *mr2 = NULL; |
7044 |
|
|
struct item *item2 = NULL; |
7045 |
|
|
struct coord c2; |
7046 |
|
|
|
7047 |
|
|
route2 = navit_get_route(this_); |
7048 |
|
|
|
7049 |
|
|
if (route2) |
7050 |
|
|
{ |
7051 |
|
|
route_map2 = route_get_map(route2); |
7052 |
|
|
} |
7053 |
|
|
|
7054 |
|
|
if (route_map2) |
7055 |
|
|
{ |
7056 |
|
|
mr2 = map_rect_new(route_map2, NULL); |
7057 |
|
|
} |
7058 |
|
|
|
7059 |
|
|
if (mr2) |
7060 |
|
|
{ |
7061 |
|
|
item2 = map_rect_get_item(mr2); |
7062 |
|
|
} |
7063 |
|
|
|
7064 |
|
|
if (item2 && item2->type == type_route_start) |
7065 |
|
|
{ |
7066 |
|
|
item2 = map_rect_get_item(mr2); |
7067 |
|
|
} |
7068 |
|
|
|
7069 |
|
|
FILE *fp; |
7070 |
|
|
fp = fopen(filename,"w"); |
7071 |
|
|
fprintf(fp, "%s", header1); |
7072 |
|
|
int first3 = 0; |
7073 |
|
|
|
7074 |
|
|
if (item2 && item_coord_get(item2, &c2, 1)) |
7075 |
|
|
{ |
7076 |
|
|
transform_to_geo(projection_mg, &c2, &g); |
7077 |
|
|
fprintf(fp, " <trkpt lat='%4.16f' lon='%4.16f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lat, g.lng); |
7078 |
|
|
|
7079 |
|
|
while (item2) |
7080 |
|
|
{ |
7081 |
|
|
if (!item_coord_get(item2, &c2, 1)) |
7082 |
|
|
{ |
7083 |
|
|
item2 = map_rect_get_item(mr2); |
7084 |
|
|
first3 = 1; |
7085 |
|
|
continue; |
7086 |
|
|
} |
7087 |
|
|
|
7088 |
|
|
if (first3 == 0) |
7089 |
|
|
{ |
7090 |
|
|
transform_to_geo(projection_mg, &c2, &g); |
7091 |
|
|
fprintf(fp, " <trkpt lat='%4.16f' lon='%4.16f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lat, g.lng); |
7092 |
|
|
} |
7093 |
|
|
else |
7094 |
|
|
{ |
7095 |
|
|
first3 = 0; |
7096 |
|
|
// fprintf(fp, "Y**********\n"); |
7097 |
|
|
} |
7098 |
|
|
} |
7099 |
|
|
} |
7100 |
|
|
|
7101 |
|
|
map_rect_destroy(mr2); |
7102 |
|
|
|
7103 |
|
|
// -------- full route --------- |
7104 |
|
|
// -------- full route --------- |
7105 |
|
|
|
7106 |
|
|
|
7107 |
|
|
|
7108 |
|
|
|
7109 |
|
|
|
7110 |
|
|
nav = navit_get_navigation(this_); |
7111 |
|
|
|
7112 |
|
|
if (!nav) |
7113 |
|
|
{ |
7114 |
|
|
return; |
7115 |
|
|
} |
7116 |
|
|
|
7117 |
|
|
map = navigation_get_map(nav); |
7118 |
|
|
|
7119 |
|
|
if (map) |
7120 |
|
|
{ |
7121 |
|
|
mr = map_rect_new(map,NULL); |
7122 |
|
|
} |
7123 |
|
|
else |
7124 |
|
|
{ |
7125 |
|
|
return; |
7126 |
|
|
} |
7127 |
|
|
|
7128 |
|
|
trans = navit_get_trans(this_); |
7129 |
|
|
|
7130 |
|
|
|
7131 |
|
|
//while((item = map_rect_get_item(mr))) |
7132 |
|
|
//{ |
7133 |
|
|
// item_coord_get(item, &c, 1); |
7134 |
|
|
// transform_to_geo(projection_mg, &c, &g); |
7135 |
|
|
// fprintf(fp, " <trkpt lon='%4.16f' lat='%4.16f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lng, g.lat); |
7136 |
|
|
//} |
7137 |
|
|
map_rect_destroy(mr); |
7138 |
|
|
|
7139 |
|
|
|
7140 |
|
|
|
7141 |
|
|
fprintf(fp,"%s",trailer1); |
7142 |
|
|
|
7143 |
|
|
|
7144 |
|
|
|
7145 |
|
|
mr = map_rect_new(map,NULL); |
7146 |
|
|
while ((item = map_rect_get_item(mr))) |
7147 |
|
|
{ |
7148 |
|
|
if (item_attr_get(item, attr_navigation_long, &attr)) |
7149 |
|
|
{ |
7150 |
|
|
item_coord_get(item, &c, 1); |
7151 |
|
|
transform_to_geo(projection_mg, &c, &g); |
7152 |
|
|
fprintf(fp, "<wpt lat=\"%4.16f\" lon=\"%4.16f\"><time>2014-10-02T09:30:10Z</time><name>%s:%s</name><sym>Dot</sym><type>Dot></type></wpt>\n", g.lat, g.lng, item_to_name(item->type), map_convert_string(item->map,attr.u.str)); |
7153 |
|
|
} |
7154 |
|
|
else |
7155 |
|
|
{ |
7156 |
|
|
// must be the start point (without navigation command) |
7157 |
|
|
item_coord_get(item, &c, 1); |
7158 |
|
|
transform_to_geo(projection_mg, &c, &g); |
7159 |
|
|
fprintf(fp, "<wpt lat=\"%4.16f\" lon=\"%4.16f\"><time>2014-10-02T09:30:10Z</time><name>START</name><sym>Dot</sym><type>Dot></type></wpt>\n", g.lat, g.lng); |
7160 |
|
|
} |
7161 |
|
|
} |
7162 |
|
|
map_rect_destroy(mr); |
7163 |
|
|
|
7164 |
|
|
|
7165 |
|
|
|
7166 |
|
|
fprintf(fp,"%s",header2); |
7167 |
|
|
|
7168 |
|
|
|
7169 |
|
|
|
7170 |
|
|
mr = map_rect_new(map,NULL); |
7171 |
|
|
while ((item = map_rect_get_item(mr))) |
7172 |
|
|
{ |
7173 |
|
|
if (item_attr_get(item, attr_navigation_long, &attr)) |
7174 |
|
|
{ |
7175 |
|
|
item_coord_get(item, &c, 1); |
7176 |
|
|
transform_to_geo(projection_mg, &c, &g); |
7177 |
|
|
fprintf(fp, "<rtept lat='%4.16f' lon='%4.16f'><name>%s:%s</name></rtept>\n", g.lat, g.lng, item_to_name(item->type), map_convert_string(item->map,attr.u.str)); |
7178 |
|
|
} |
7179 |
|
|
else |
7180 |
|
|
{ |
7181 |
|
|
// must be the start point (without navigation command) |
7182 |
|
|
item_coord_get(item, &c, 1); |
7183 |
|
|
transform_to_geo(projection_mg, &c, &g); |
7184 |
|
|
fprintf(fp, "<rtept lat='%4.16f' lon='%4.16f'><name>START</name></rtept>\n", g.lat, g.lng); |
7185 |
|
|
} |
7186 |
|
|
} |
7187 |
|
|
map_rect_destroy(mr); |
7188 |
|
|
|
7189 |
|
|
fprintf(fp,"%s",trailer2); |
7190 |
|
|
|
7191 |
|
|
fclose(fp); |
7192 |
|
|
|
7193 |
zoff99 |
28 |
#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
7194 |
zoff99 |
40 |
dbg(0,"+#+:leave\n"); |
7195 |
zoff99 |
28 |
#endif |
7196 |
zoff99 |
40 |
|
7197 |
|
|
} |
7198 |
|
|
|
7199 |
|
|
|
7200 |
|
|
void navit_destroy(struct navit *this_) |
7201 |
|
|
{ |
7202 |
|
|
|
7203 |
|
|
|
7204 |
zoff99 |
28 |
dbg(0, "EEnter\n"); |
7205 |
zoff99 |
2 |
|
7206 |
|
|
struct mapset*ms; |
7207 |
|
|
callback_list_call_attr_1(this_->attr_cbl, attr_destroy, this_); |
7208 |
|
|
|
7209 |
zoff99 |
27 |
// //DBG dbg(0,"enter"); |
7210 |
zoff99 |
2 |
|
7211 |
|
|
/* TODO: destroy objects contained in this_ */ |
7212 |
|
|
if (this_->vehicle) |
7213 |
zoff99 |
28 |
{ |
7214 |
zoff99 |
2 |
vehicle_destroy(this_->vehicle->vehicle); |
7215 |
zoff99 |
28 |
} |
7216 |
|
|
|
7217 |
|
|
/* |
7218 |
zoff99 |
30 |
if (this_->bookmarks) |
7219 |
|
|
{ |
7220 |
|
|
dbg(0, "save position to file\n"); |
7221 |
|
|
char *center_file = bookmarks_get_center_file(TRUE); |
7222 |
|
|
bookmarks_write_center_to_file(this_->bookmarks, center_file); |
7223 |
|
|
g_free(center_file); |
7224 |
|
|
bookmarks_destroy(this_->bookmarks); |
7225 |
|
|
dbg(0, "save position to file -> ready\n"); |
7226 |
|
|
} |
7227 |
|
|
*/ |
7228 |
zoff99 |
28 |
|
7229 |
|
|
dbg(0, "ex 001\n"); |
7230 |
zoff99 |
2 |
callback_destroy(this_->nav_speech_cb); |
7231 |
zoff99 |
28 |
dbg(0, "ex 002\n"); |
7232 |
zoff99 |
2 |
callback_destroy(this_->roadbook_callback); |
7233 |
zoff99 |
28 |
dbg(0, "ex 003\n"); |
7234 |
zoff99 |
2 |
callback_destroy(this_->popup_callback); |
7235 |
zoff99 |
28 |
dbg(0, "ex 004\n"); |
7236 |
zoff99 |
2 |
callback_destroy(this_->motion_timeout_callback); |
7237 |
zoff99 |
28 |
dbg(0, "ex 005\n"); |
7238 |
zoff99 |
2 |
callback_destroy(this_->progress_cb); |
7239 |
zoff99 |
28 |
dbg(0, "ex 006\n"); |
7240 |
|
|
/* |
7241 |
zoff99 |
30 |
if (this_->gra) |
7242 |
|
|
graphics_remove_callback(this_->gra, this_->resize_callback); |
7243 |
|
|
callback_destroy(this_->resize_callback); |
7244 |
|
|
*/ |
7245 |
zoff99 |
28 |
dbg(0, "ex 007\n"); |
7246 |
|
|
/* |
7247 |
zoff99 |
30 |
if (this_->gra) |
7248 |
|
|
graphics_remove_callback(this_->gra, this_->button_callback); |
7249 |
|
|
callback_destroy(this_->button_callback); |
7250 |
|
|
*/ |
7251 |
zoff99 |
28 |
dbg(0, "ex 008\n"); |
7252 |
|
|
/* |
7253 |
zoff99 |
30 |
if (this_->gra) |
7254 |
|
|
graphics_remove_callback(this_->gra, this_->motion_callback); |
7255 |
|
|
callback_destroy(this_->motion_callback); |
7256 |
|
|
*/ |
7257 |
zoff99 |
28 |
dbg(0, "ex 009\n"); |
7258 |
zoff99 |
27 |
if (this_->gra) |
7259 |
zoff99 |
28 |
{ |
7260 |
zoff99 |
27 |
graphics_remove_callback(this_->gra, this_->predraw_callback); |
7261 |
zoff99 |
28 |
} |
7262 |
zoff99 |
2 |
callback_destroy(this_->predraw_callback); |
7263 |
zoff99 |
28 |
dbg(0, "ex 010\n"); |
7264 |
zoff99 |
2 |
route_destroy(this_->route); |
7265 |
zoff99 |
28 |
dbg(0, "ex 011\n"); |
7266 |
zoff99 |
2 |
ms = navit_get_mapset(this_); |
7267 |
zoff99 |
28 |
dbg(0, "ex 012\n"); |
7268 |
zoff99 |
34 |
|
7269 |
zoff99 |
27 |
if (ms) |
7270 |
zoff99 |
28 |
{ |
7271 |
zoff99 |
2 |
mapset_destroy(ms); |
7272 |
zoff99 |
28 |
} |
7273 |
zoff99 |
34 |
|
7274 |
zoff99 |
28 |
dbg(0, "ex 013\n"); |
7275 |
zoff99 |
2 |
graphics_free(this_->gra); |
7276 |
zoff99 |
28 |
dbg(0, "ex 014\n"); |
7277 |
zoff99 |
2 |
g_free(this_); |
7278 |
zoff99 |
28 |
dbg(0, "ex 015\n"); |
7279 |
zoff99 |
2 |
} |
7280 |
|
|
|
7281 |
|
|
/** @} */ |
7282 |
zoff99 |
50 |
|