You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(92) |
Dec
(141) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(126) |
Feb
(72) |
Mar
(31) |
Apr
(200) |
May
(81) |
Jun
(130) |
Jul
(112) |
Aug
(134) |
Sep
(76) |
Oct
(89) |
Nov
(153) |
Dec
(9) |
2007 |
Jan
(59) |
Feb
(82) |
Mar
(50) |
Apr
(20) |
May
(9) |
Jun
(81) |
Jul
(41) |
Aug
(109) |
Sep
(91) |
Oct
(87) |
Nov
(33) |
Dec
(60) |
2008 |
Jan
(21) |
Feb
(15) |
Mar
(38) |
Apr
(75) |
May
(59) |
Jun
(46) |
Jul
(30) |
Aug
(20) |
Sep
(35) |
Oct
(32) |
Nov
(34) |
Dec
(19) |
2009 |
Jan
(29) |
Feb
(71) |
Mar
(54) |
Apr
(17) |
May
(4) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(58) |
Sep
(7) |
Oct
(7) |
Nov
(12) |
Dec
(18) |
2011 |
Jan
(17) |
Feb
(29) |
Mar
(11) |
Apr
(5) |
May
(1) |
Jun
|
Jul
|
Aug
(11) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(87) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(44) |
Jun
(79) |
Jul
(16) |
Aug
(31) |
Sep
|
Oct
(51) |
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: Ehud S. <esh...@us...> - 2005-11-30 08:13:35
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/export In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8704 Modified Files: editor_export.c editor_export.h Log Message: Added speed limit attribute. Index: editor_export.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/editor/export/editor_export.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** editor_export.h 28 Nov 2005 19:47:50 -0000 1.1 --- editor_export.h 30 Nov 2005 08:13:27 -0000 1.2 *************** *** 25,29 **** #define INCLUDE__EDITOR_EXPORT__H ! int editor_export_data(const char *name); void editor_export_reset_dirty (void); --- 25,29 ---- #define INCLUDE__EDITOR_EXPORT__H ! void editor_export_gpx (void); void editor_export_reset_dirty (void); Index: editor_export.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/editor/export/editor_export.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** editor_export.c 28 Nov 2005 19:47:50 -0000 1.1 --- editor_export.c 30 Nov 2005 08:13:27 -0000 1.2 *************** *** 36,39 **** --- 36,40 ---- #include "roadmap_layer.h" #include "roadmap_point.h" + #include "roadmap_fileselection.h" #include "../editor_log.h" *************** *** 45,49 **** --- 46,52 ---- #include "../db/editor_trkseg.h" #include "../db/editor_street.h" + #include "../db/editor_route.h" + #include "../track/editor_track_main.h" #include "editor_export.h" *************** *** 192,195 **** --- 195,200 ---- int roadmap_from_id; int roadmap_to_id; + int route_id; + short speed_limit; fprintf (file, "<extensions>\n"); *************** *** 256,259 **** --- 261,278 ---- (&properties, ED_STREET_LEFT_SIDE)); + route_id = editor_line_get_route (line_id); + + if (route_id != -1) { + + editor_route_segment_get + (route_id, NULL, NULL, &speed_limit); + + if (speed_limit) { + char str[100]; + snprintf (str, sizeof(str), "%d", speed_limit); + add_attribute (file, "city_name", str); + } + } + fprintf (file, "</attributes>\n"); *************** *** 333,337 **** ! int editor_export_data(const char *name) { FILE *file = create_export_file (name); --- 352,356 ---- ! static int editor_export_data(const char *name) { FILE *file = create_export_file (name); *************** *** 464,465 **** --- 483,503 ---- } + + static void editor_export_file_dialog_ok + (const char *filename, const char *mode) { + + editor_export_data (filename); + } + + + void editor_export_gpx (void) { + + editor_track_end (); + + roadmap_fileselection_new ("Export data", + NULL, /* no filter. */ + roadmap_path_user (), + "w", + editor_export_file_dialog_ok); + } + |
From: Ehud S. <esh...@us...> - 2005-11-30 08:12:57
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8558 Modified Files: editor_route.c editor_route.h Log Message: Added speed limit attribute. Index: editor_route.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/editor/db/editor_route.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** editor_route.h 28 Nov 2005 19:47:50 -0000 1.1 --- editor_route.h 30 Nov 2005 08:12:48 -0000 1.2 *************** *** 34,45 **** EditorRouteFlag from_flags; EditorRouteFlag to_flags; } editor_db_route_segment; int editor_route_segment_add ! (short from_flags, short to_flags) ; ! void editor_route_segment_get (int route, short *from_flags, short *to_flags); ! void editor_route_segment_set (int route, short from_flags, short to_flags); void editor_route_segment_copy (int source_line, int plugin_id, int dest_line); --- 34,48 ---- EditorRouteFlag from_flags; EditorRouteFlag to_flags; + short speed_limit; } editor_db_route_segment; int editor_route_segment_add ! (short from_flags, short to_flags, short speed_limit); ! void editor_route_segment_get ! (int route, short *from_flags, short *to_flags, short *speed_limit); ! void editor_route_segment_set ! (int route, short from_flags, short to_flags, short speed_limit); void editor_route_segment_copy (int source_line, int plugin_id, int dest_line); Index: editor_route.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/editor/db/editor_route.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** editor_route.c 28 Nov 2005 19:47:50 -0000 1.1 --- editor_route.c 30 Nov 2005 08:12:48 -0000 1.2 *************** *** 89,93 **** editor_route_segment_add (route->from_flags, ! route->to_flags); if (route_id < 0) { --- 89,94 ---- editor_route_segment_add (route->from_flags, ! route->to_flags, ! route->speed_limit); if (route_id < 0) { *************** *** 103,107 **** int editor_route_segment_add ! (EditorRouteFlag from_flags, EditorRouteFlag to_flags) { editor_db_route_segment route; --- 104,108 ---- int editor_route_segment_add ! (EditorRouteFlag from_flags, EditorRouteFlag to_flags, short speed_limit) { editor_db_route_segment route; *************** *** 110,113 **** --- 111,115 ---- route.from_flags = from_flags; route.to_flags = to_flags; + route.speed_limit = speed_limit; id = editor_db_add_item (ActiveSegmentRouteDB, &route); *************** *** 157,162 **** ! void editor_route_segment_get ! (int route_id, EditorRouteFlag *from_flags, EditorRouteFlag *to_flags) { editor_db_route_segment *route; --- 159,166 ---- ! void editor_route_segment_get (int route_id, ! EditorRouteFlag *from_flags, ! EditorRouteFlag *to_flags, ! short *speed_limit) { editor_db_route_segment *route; *************** *** 183,194 **** } ! *from_flags = route->from_flags; ! *to_flags = route->to_flags; } ! void editor_route_segment_set ! (int route_id, EditorRouteFlag from_flags, EditorRouteFlag to_flags) { editor_db_route_segment *route; --- 187,201 ---- } ! if (from_flags != NULL) *from_flags = route->from_flags; ! if (to_flags != NULL) *to_flags = route->to_flags; ! if (speed_limit != NULL) *speed_limit = route->speed_limit; } ! void editor_route_segment_set (int route_id, ! EditorRouteFlag from_flags, ! EditorRouteFlag to_flags, ! short speed_limit) { editor_db_route_segment *route; *************** *** 217,220 **** --- 224,228 ---- route->from_flags = from_flags; route->to_flags = to_flags; + route->speed_limit = speed_limit; } |
From: Ehud S. <esh...@us...> - 2005-11-30 08:12:25
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8396 Modified Files: editor_plugin.c Log Message: Added shutdown callback. Text to speech value is now returned in plugin street properties. Index: editor_plugin.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/editor/editor_plugin.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** editor_plugin.c 28 Nov 2005 19:47:50 -0000 1.1 --- editor_plugin.c 30 Nov 2005 08:12:13 -0000 1.2 *************** *** 35,38 **** --- 35,39 ---- #include "db/editor_street.h" + #include "track/editor_track_main.h" #include "editor_main.h" #include "editor_screen.h" *************** *** 113,116 **** --- 114,118 ---- props->address = editor_street_get_street_address (&properties); props->street = editor_street_get_street_name (&properties); + props->street_t2s = editor_street_get_street_t2s (&properties); props->city = editor_street_get_street_city (&properties, ED_STREET_LEFT_SIDE); *************** *** 132,136 **** &editor_street_get_connected_lines, &editor_screen_adjust_layer, ! &editor_street_get_closest }; --- 134,139 ---- &editor_street_get_connected_lines, &editor_screen_adjust_layer, ! &editor_street_get_closest, ! &editor_track_end }; |
From: Ehud S. <esh...@us...> - 2005-11-30 08:09:55
|
Update of /cvsroot/roadmap/roadmap_editor/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7649 Modified Files: roadmap_start.c Log Message: Call plugin_shutdown on exit. Index: roadmap_start.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_start.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** roadmap_start.c 28 Nov 2005 19:36:34 -0000 1.3 --- roadmap_start.c 30 Nov 2005 08:09:47 -0000 1.4 *************** *** 154,158 **** static void roadmap_start_export_data (void) { ! editor_export_data ("test.xml"); } --- 154,158 ---- static void roadmap_start_export_data (void) { ! editor_export_gpx (); } *************** *** 887,890 **** --- 887,891 ---- void roadmap_start_exit (void) { + roadmap_plugin_shutdown (); roadmap_driver_shutdown (); roadmap_history_save(); |
From: Ehud S. <esh...@us...> - 2005-11-30 08:07:48
|
Update of /cvsroot/roadmap/roadmap_editor/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7083 Modified Files: roadmap_plugin.c roadmap_plugin.h Log Message: Added shutdown callback. Text to speech value is now returned in plugin street properties. Index: roadmap_plugin.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_plugin.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** roadmap_plugin.h 28 Nov 2005 19:47:50 -0000 1.1 --- roadmap_plugin.h 30 Nov 2005 08:07:40 -0000 1.2 *************** *** 53,56 **** --- 53,57 ---- const char *address; const char *street; + const char *street_t2s; const char *city; } PluginStreetProperties; *************** *** 142,145 **** --- 143,148 ---- int max); + typedef void (*plugin_shutdown) (void); + typedef struct { plugin_line_pos_func line_from; *************** *** 156,159 **** --- 159,163 ---- plugin_adjust_layer_hook adjust_layer; plugin_get_closest_func get_closest; + plugin_shutdown shutdown; } RoadMapPluginHooks; *************** *** 194,197 **** --- 198,203 ---- int max); + void roadmap_plugin_shutdown (void); + #endif /* INCLUDE__ROADMAP_PLUGIN__H */ Index: roadmap_plugin.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_plugin.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** roadmap_plugin.c 28 Nov 2005 19:47:50 -0000 1.1 --- roadmap_plugin.c 30 Nov 2005 08:07:40 -0000 1.2 *************** *** 386,389 **** --- 386,390 ---- props->address = roadmap_street_get_street_address (&rm_properties); props->street = roadmap_street_get_street_name (&rm_properties); + props->street_t2s = ""; props->city = roadmap_street_get_city_name (&rm_properties); return; *************** *** 394,397 **** --- 395,399 ---- props->address = ""; props->street = ""; + props->street_t2s = ""; props->city = ""; *************** *** 472,473 **** --- 474,492 ---- + void roadmap_plugin_shutdown (void) { + + int i; + + for (i=1; i<=PluginCount; i++) { + + RoadMapPluginHooks *hooks = get_hooks (i); + if (hooks == NULL) continue; + + if (hooks->shutdown != NULL) { + + hooks->shutdown (); + } + } + } + + |
From: Ehud S. <esh...@us...> - 2005-11-30 08:05:31
|
Update of /cvsroot/roadmap/roadmap_editor/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5951 Modified Files: Makefile Log Message: Clean editor objects. Index: Makefile =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 28 Nov 2005 19:36:34 -0000 1.5 --- Makefile 30 Nov 2005 08:05:23 -0000 1.6 *************** *** 326,329 **** --- 326,330 ---- fi ; \ done + find editor/ -name \*.o -exec rm {} \; rebuild: cleanall everything |
From: Ehud S. <esh...@us...> - 2005-11-28 20:43:15
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13523 Added Files: editor_log.h editor_main.c editor_main.h editor_screen.c editor_screen.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- NEW FILE: editor_main.c --- /* editor_main.c - main plugin file * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_main.h */ #include "../roadmap.h" #include "../roadmap_pointer.h" #include "../roadmap_plugin.h" #include "../roadmap_layer.h" #include "editor_screen.h" #include "track/editor_track.h" #include "editor_plugin.h" #include "editor_main.h" int EditorEnabled = 0; int EditorPluginID = -1; int editor_is_enabled (void) { return EditorEnabled; } void editor_main_initialize (void) { editor_screen_initialize (); editor_track_initialize (); editor_main_set (1); EditorPluginID = editor_plugin_register (); roadmap_layer_adjust (); } void editor_main_set (int status) { if (status && EditorEnabled) { return; } else if (!status && !EditorEnabled) { return; } EditorEnabled = status; editor_screen_set (status); } --- NEW FILE: editor_main.h --- /* editor_main.h - main plugin file * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef INCLUDE__EDITOR_MAIN__H #define INCLUDE__EDITOR_MAIN__H extern int EditorPluginID; int editor_is_enabled (void); void editor_main_initialize (void); void editor_main_set (int status); #endif /* INCLUDE__EDITOR_MAIN__H */ --- NEW FILE: editor_screen.c --- /* editor_screen.c - screen drawing * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_screen.h */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "roadmap.h" #include "roadmap_canvas.h" #include "roadmap_screen.h" #include "roadmap_math.h" #include "roadmap_navigate.h" #include "roadmap_pointer.h" #include "roadmap_line.h" #include "roadmap_shape.h" #include "roadmap_square.h" #include "roadmap_layer.h" #include "roadmap_locator.h" #include "roadmap_hash.h" #include "roadmap_main.h" #include "db/editor_db.h" #include "db/editor_point.h" #include "db/editor_shape.h" #include "db/editor_line.h" #include "db/editor_square.h" #include "db/editor_street.h" #include "db/editor_route.h" #include "db/editor_override.h" #include "db/editor_trkseg.h" #include "editor_main.h" #include "static/editor_dialog.h" #include "track/editor_track.h" #include "editor_screen.h" #define MIN_THICKNESS 3 #define MAX_LAYERS (ROADMAP_ROAD_LAST + 1) #define MAX_LINE_SELECTIONS 100 #define MAX_PEN_LAYERS 2 #define MAX_ROAD_STATES 4 #define SELECTED_STATE 0 #define NO_DATA_STATE 1 #define MISSING_ROUTE_STATE 2 #define MISSING_NAME_STATE 3 #define NO_ROAD_STATE 4 typedef struct editor_pen_s { int in_use; int thickness; RoadMapPen pen; } editor_pen; static editor_pen EditorPens[MAX_LAYERS][MAX_PEN_LAYERS][MAX_ROAD_STATES]; static editor_pen EditorTrackPens[MAX_PEN_LAYERS]; SelectedLine SelectedLines[MAX_LINE_SELECTIONS]; static int select_count; static RoadMapPointerHandler SaveShortClickHandler; static RoadMapPointerHandler SaveLongClickHandler; /* track which lines were drawn */ #define DEFAULT_LINES_DRAWN_SIZE 100 static int *LinesDrawn; static int LinesDrawnCount; static int LinesDrawnSize; static RoadMapHash *LinesDrawnHash; static void init_lines_drawn (void) { if (LinesDrawn == NULL) { LinesDrawnSize = DEFAULT_LINES_DRAWN_SIZE; LinesDrawn = malloc (LinesDrawnSize * sizeof(int)); LinesDrawnHash = roadmap_hash_new ("LinesDrawn", LinesDrawnSize); LinesDrawnCount = 0; } else { LinesDrawnCount = 0; roadmap_hash_free (LinesDrawnHash); LinesDrawnHash = roadmap_hash_new ("LinesDrawn", LinesDrawnSize); } } static int should_draw_line (int line) { int i; for (i = roadmap_hash_get_first (LinesDrawnHash, line); i >= 0; i = roadmap_hash_get_next (LinesDrawnHash, i)) { if (line == LinesDrawn[i]) return 0; } if (LinesDrawnSize == LinesDrawnCount) { LinesDrawnSize *= 2; LinesDrawn = realloc (LinesDrawn, LinesDrawnSize * sizeof(int)); roadmap_hash_resize (LinesDrawnHash, LinesDrawnSize); } LinesDrawn[LinesDrawnCount] = line; roadmap_hash_add (LinesDrawnHash, line, LinesDrawnCount); LinesDrawnCount++; return 1; } static void editor_screen_update_segments (void) { editor_segments_properties (SelectedLines, select_count); } static void editor_screen_delete_segments (void) { int i; for (i=0; i<select_count; i++) { SelectedLine *line = &SelectedLines[i]; if (editor_db_activate (roadmap_plugin_get_fips(&line->line)) == -1) { editor_db_create (roadmap_plugin_get_fips(&line->line)); if (editor_db_activate (roadmap_plugin_get_fips(&line->line)) == -1) { continue; } } if (roadmap_plugin_get_id (&line->line) == ROADMAP_PLUGIN_ID) { int line_id = roadmap_plugin_get_line_id (&line->line); editor_override_line_set_flags (line_id, editor_override_line_get_flags (line_id) | ED_LINE_DELETED); } else if (roadmap_plugin_get_id (&line->line) == EditorPluginID) { //TODO: The flag should be added and nor reset other flags editor_line_modify_properties (roadmap_plugin_get_line_id (&line->line), roadmap_plugin_get_line_cfcc (&line->line), ED_LINE_DELETED); } } select_count = 0; roadmap_screen_redraw (); return; } void editor_screen_long_click (RoadMapGuiPoint *point) { static RoadMapMenu menu; if (select_count == 0) return; if (menu == NULL) { menu = roadmap_main_new_menu (); roadmap_main_add_menu_item (menu, "Properties", "Update road properties", editor_screen_update_segments); roadmap_main_add_separator (menu); roadmap_main_add_menu_item (menu, "Delete", "Delete selected roads", editor_screen_delete_segments); } roadmap_main_popup_menu (menu, point->x, point->y); } void editor_screen_short_click (RoadMapGuiPoint *point) { RoadMapPosition position; PluginLine line; int distance; int i; roadmap_math_to_position (point, &position); if (roadmap_navigate_retrieve_line (&position, 20, &line, &distance) == -1) { select_count = 0; roadmap_screen_redraw (); return; } for (i=0; i<select_count; i++) { if (roadmap_plugin_same_line(&SelectedLines[i].line, &line)) break; } if (i<select_count) { /* line was already selected, remove it */ int j; for (j=i+1; j<select_count; j++) { SelectedLines[j-1] = SelectedLines[j]; } select_count--; roadmap_screen_redraw (); return; } if (select_count == MAX_LINE_SELECTIONS) return; SelectedLines[select_count].line = line; select_count++; roadmap_screen_redraw (); } /* TODO: this is a bad callback which is called from roadmap_layer_adjust(). * This should be changed. Currently when the editor is enabled, an explicit * call to roadmap_layer_adjust() is called. When this is fixed, that call * should be removed. */ void editor_screen_adjust_layer (int layer, int thickness, int pen_count) { int i; int j; if (layer > ROADMAP_ROAD_LAST) return; if (!editor_is_enabled()) return; if ((pen_count > 1) && (thickness < 3)) { pen_count = 1; } for (i=0; i<MAX_PEN_LAYERS; i++) for (j=0; j<MAX_ROAD_STATES; j++) { editor_pen *pen = &EditorPens[layer][i][j]; pen->in_use = i<pen_count; if (!pen->in_use) continue; roadmap_canvas_select_pen (pen->pen); if (i == 1) { pen->thickness = thickness-2; } else { pen->thickness = thickness; } roadmap_canvas_set_thickness (pen->thickness); } if (layer == ROADMAP_ROAD_STREET) { roadmap_canvas_select_pen (EditorTrackPens[0].pen); EditorTrackPens[0].thickness = thickness; EditorTrackPens[0].in_use = 1; roadmap_canvas_set_thickness (EditorTrackPens[0].thickness); if (pen_count == 1) { EditorTrackPens[1].in_use = 0; } else { roadmap_canvas_select_pen (EditorTrackPens[1].pen); EditorTrackPens[1].thickness = thickness - 2; EditorTrackPens[1].in_use = 1; roadmap_canvas_set_thickness (EditorTrackPens[1].thickness); } } } static int editor_screen_get_road_state (int line, int plugin_id, int fips) { int route; int has_street = 0; int has_route = 0; //TODO get route from roadmap if (editor_db_activate (fips) != -1) { if (!plugin_id) { route = editor_override_line_get_route (line); } else { route = editor_line_get_route (line); } if (route != -1) { has_route = 1; } } if (plugin_id == 0) { RoadMapStreetProperties properties; roadmap_locator_activate (fips); roadmap_street_get_properties (line, &properties); if (properties.street != -1) { has_street = 1; } } else { EditorStreetProperties properties; editor_db_activate (fips); editor_street_get_properties (line, &properties); if (properties.street != -1) { has_street = 1; } } if (has_street && has_route) return NO_ROAD_STATE; else if (!has_street && !has_route) return NO_DATA_STATE; else if (has_street) return MISSING_ROUTE_STATE; else return MISSING_NAME_STATE; } int editor_screen_override_pen (int line, int cfcc, int fips, int pen_type, RoadMapPen *override_pen) { int i; int ActiveDB; int road_state; int is_selected = 0; editor_pen *pen = NULL; int route = -1; if (cfcc > ROADMAP_ROAD_LAST) return 0; ActiveDB = editor_db_activate (fips); if (!editor_is_enabled()) return 0; for (i=0; i<select_count; i++) { if ((line == SelectedLines[i].line.line_id) && (SelectedLines[i].line.plugin_id != EditorPluginID) && (fips == SelectedLines[i].line.fips)) { is_selected = 1; break; } } if (is_selected) { road_state = SELECTED_STATE; } else { road_state = editor_screen_get_road_state (line, 0, fips); } if (road_state != NO_ROAD_STATE) { if (pen_type > 1) return 0; pen = &EditorPens[cfcc][pen_type][road_state]; if (!pen->in_use) { *override_pen = NULL; return 1; } *override_pen = pen->pen; } if (ActiveDB != -1) { //TODO check roadmap route data route = editor_override_line_get_route (line); } return 1; #if 0 if ((pen->thickness > 20) && (roadmap_layer_get_pen (cfcc, pen_type+1) == NULL) && (route != -1)) { RoadMapPosition from; RoadMapPosition to; direction = editor_route_get_direction (route, ED_ROUTE_CAR); if (direction <= 0) { return 0; } roadmap_line_from (line, &from); roadmap_line_to (line, &to); if (*override_pen == NULL) { *override_pen = roadmap_layer_get_pen (cfcc, pen_type); } roadmap_screen_draw_one_line (&from, &to, 0, &from, first_shape, last_shape, roadmap_shape_get_position, *override_pen); roadmap_screen_draw_line_direction (&from, &to, &from, first_shape, last_shape, roadmap_shape_get_position, pen->thickness, direction); return 1; } return 0; #endif } static char *editor_screen_get_pen_color (int pen_type, int road_state) { if (pen_type == 0) { switch (road_state) { case SELECTED_STATE: return "yellow"; default: return "black"; } } switch (road_state) { case SELECTED_STATE: return "black"; case NO_DATA_STATE: return "dark red"; case MISSING_NAME_STATE: return "red"; case MISSING_ROUTE_STATE: return "orange"; default: assert (0); return "black"; } } void editor_screen_initialize (void) { int i; int j; int k; char name[80]; /* FIXME should only create pens for road class */ for (i=1; i<MAX_LAYERS; ++i) for (j=0; j<MAX_PEN_LAYERS; j++) for (k=0; k<MAX_ROAD_STATES; k++) { editor_pen *pen = &EditorPens[i][j][k]; pen->in_use = 0; snprintf (name, sizeof(name), "EditorPen%d", i*100+j*10+k); pen->pen = roadmap_canvas_create_pen (name); roadmap_canvas_set_foreground (editor_screen_get_pen_color(j,k)); roadmap_canvas_set_thickness (1); } EditorTrackPens[0].pen = roadmap_canvas_create_pen ("EditorTrack0"); roadmap_canvas_set_foreground ("black"); roadmap_canvas_set_thickness (1); EditorTrackPens[1].pen = roadmap_canvas_create_pen ("EditorTrack1"); roadmap_canvas_set_foreground ("blue"); roadmap_canvas_set_thickness (1); } static void editor_screen_draw_square (int square, int fips, int min_cfcc, int pen_type) { int line; int count; int i; int j; RoadMapPosition from; RoadMapPosition to; RoadMapPosition trk_from_pos; int first_shape; int last_shape; int cfcc; int flag; int square_cfccs; int fully_visible = 0; int road_state; RoadMapPen pen = NULL; int trkseg; int route; roadmap_log_push ("editor_screen_draw_square"); square_cfccs = editor_square_get_cfccs (square); if (! (square_cfccs && (-1 << min_cfcc))) { roadmap_log_pop (); return; } count = editor_square_get_num_lines (square); for (i=0; i<count; i++) { line = editor_square_get_line (square, i); editor_line_get (line, &from, &to, &trkseg, &cfcc, &flag); if (cfcc < min_cfcc) continue; if (!should_draw_line (line)) continue; if (flag & ED_LINE_DELETED) continue; if (editor_is_enabled () ) { int is_selected = 0; for (j=0; j<select_count; j++) { if ((line == SelectedLines[j].line.line_id) && (SelectedLines[j].line.plugin_id == EditorPluginID) && (fips == SelectedLines[j].line.fips)) { is_selected = 1; break; } } if (is_selected) { road_state = SELECTED_STATE; } else { road_state = editor_screen_get_road_state (line, 1, fips); } } else { road_state = NO_ROAD_STATE; } if (road_state == NO_ROAD_STATE) { pen = roadmap_layer_get_pen (cfcc, pen_type); } else { if (pen_type > 1) continue; if (!EditorPens[cfcc][pen_type][road_state].in_use) continue; pen = EditorPens[cfcc][pen_type][road_state].pen; } if (pen == NULL) continue; editor_trkseg_get (trkseg, &j, &first_shape, &last_shape, NULL); editor_point_position (j, &trk_from_pos); roadmap_screen_draw_one_line (&from, &to, fully_visible, &trk_from_pos, first_shape, last_shape, editor_shape_position, pen); if ((EditorPens[cfcc][pen_type][0].thickness > 20) && (pen_type == 1)) { int direction; route = editor_line_get_route (line); if (route != -1) { direction = editor_route_get_direction (route, ED_ROUTE_CAR); if (direction > 0) { roadmap_screen_draw_line_direction (&from, &to, &trk_from_pos, first_shape, last_shape, editor_shape_position, EditorPens[cfcc][pen_type][0].thickness, direction); } } } } roadmap_log_pop (); } static void editor_screen_repaint_square (int square, int fips, int pen_type) { int i; int count; int layers[256]; int min_category = 256; roadmap_log_push ("editor_screen_repaint_square"); count = roadmap_layer_visible_lines (layers, 256, pen_type); for (i = 0; i < count; ++i) { if (min_category > layers[i]) min_category = layers[i]; } editor_screen_draw_square (square, fips, min_category, pen_type); roadmap_log_pop (); } void editor_screen_repaint (int max_pen) { int x0, y0, x1, y1; int x,y; int k; int fips = roadmap_locator_active (); if (editor_db_activate(fips) != -1) { editor_square_view (&x0, &y0, &x1, &y1); for (k = 0; k < max_pen; ++k) { init_lines_drawn (); for (y=y0; y<=y1; y++) for (x=x0; x<=x1; x++) { int square; square = editor_square_find (x, y); if (square < 0) continue; editor_screen_repaint_square (square, fips, k); } } } for (k = 0; k < max_pen; ++k) { if (k < MAX_PEN_LAYERS) { if (EditorTrackPens[k].in_use) { editor_track_draw_current (EditorTrackPens[k].pen); } } } } void editor_screen_set (int status) { if (status) { SaveShortClickHandler = roadmap_pointer_register_short_click (editor_screen_short_click); SaveLongClickHandler = roadmap_pointer_register_long_click (editor_screen_long_click); /* TODO: remove this call */ roadmap_layer_adjust(); } else { roadmap_pointer_register_short_click (SaveShortClickHandler); roadmap_pointer_register_long_click (SaveLongClickHandler); select_count = 0; } } void editor_screen_reset_selected (void) { select_count = 0; roadmap_screen_redraw (); } --- NEW FILE: editor_log.h --- /* editor_log.h - database layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_LOG__H #define INCLUDE__EDITOR_LOG__H #include "../roadmap.h" #define editor_log roadmap_log #define editor_log_push roadmap_log_push #define editor_log_pop roadmap_log_pop #endif // INCLUDE__EDITOR_LOG__H --- NEW FILE: editor_screen.h --- /* editor_screen.h - manage screen drawing * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_SCREEN__H #define INCLUDE__EDITOR_SCREEN__H #include "../roadmap_canvas.h" #include "../roadmap_plugin.h" typedef struct selected_line_s { PluginLine line; } SelectedLine; void editor_screen_adjust_layer (int layer, int thickness, int pen_count); void editor_screen_initialize (void); int editor_screen_override_pen (int line, int cfcc, int fips, int pen_type, RoadMapPen *override_pen); void editor_screen_set (int status); void editor_screen_update_fips (int fips); void editor_screen_repaint (int max_pen); void editor_screen_reset_selected (void); #endif // INCLUDE__EDITOR_SCREEN__H |
From: Ehud S. <esh...@us...> - 2005-11-28 19:48:10
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2745/src/editor Added Files: editor_plugin.c editor_plugin.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- NEW FILE: editor_plugin.c --- /* editor_plugin.c - implement plugin interfaces * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_plugin.h */ #include <stdlib.h> #include "roadmap_plugin.h" #include "db/editor_db.h" #include "db/editor_line.h" #include "db/editor_override.h" #include "db/editor_street.h" #include "editor_main.h" #include "editor_screen.h" #include "editor_plugin.h" static int editor_plugin_override_line (int line, int cfcc, int fips) { if (editor_db_activate (fips) == -1) { return 0; } if (editor_override_line_get_flags (line) & ED_LINE_DELETED) { return 1; } return 0; } static int editor_plugin_activate_db (const PluginLine *line) { return editor_db_activate (roadmap_plugin_get_fips (line)); } static void editor_plugin_line_from (const PluginLine *line, RoadMapPosition *pos) { int line_id = roadmap_plugin_get_line_id (line); editor_line_get (line_id, pos, NULL, NULL, NULL, NULL); } static void editor_plugin_line_to (const PluginLine *line, RoadMapPosition *pos) { int line_id = roadmap_plugin_get_line_id (line); editor_line_get (line_id, NULL, pos, NULL, NULL, NULL); } static void editor_plugin_get_street (const PluginLine *line, PluginStreet *street) { int street_id; int line_id = roadmap_plugin_get_line_id (line); if (editor_line_get_street (line_id, &street_id, NULL) == -1) { street_id = -1; } roadmap_plugin_set_street (street, EditorPluginID, street_id); } static const char *editor_plugin_street_full_name (const PluginLine *line) { EditorStreetProperties properties; int line_id = roadmap_plugin_get_line_id (line); editor_street_get_properties (line_id, &properties); return editor_street_get_full_name (&properties); } static void editor_plugin_street_properties (const PluginLine *line, PluginStreetProperties *props) { EditorStreetProperties properties; int line_id = roadmap_plugin_get_line_id (line); editor_street_get_properties (line_id, &properties); props->address = editor_street_get_street_address (&properties); props->street = editor_street_get_street_name (&properties); props->city = editor_street_get_street_city (&properties, ED_STREET_LEFT_SIDE); } static RoadMapPluginHooks editor_plugin_hooks = { &editor_plugin_line_from, &editor_plugin_line_to, &editor_plugin_activate_db, &editor_street_get_distance, &editor_plugin_override_line, &editor_screen_override_pen, &editor_screen_repaint, &editor_plugin_get_street, &editor_plugin_street_full_name, &editor_plugin_street_properties, &editor_street_get_connected_lines, &editor_screen_adjust_layer, &editor_street_get_closest }; int editor_plugin_register (void) { return roadmap_plugin_register (&editor_plugin_hooks); } void editor_plugin_unregister (int plugin_id) { roadmap_plugin_unregister (plugin_id); } --- NEW FILE: editor_plugin.h --- /* editor_plugin.h - Editor plugin interfaces * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_PLUGIN__H #define INCLUDE__EDITOR_PLUGIN__H int editor_plugin_register (void); void editor_plugin_unregister (int plugin_id); #endif // INCLUDE__EDITOR_PLUGIN__H |
From: Ehud S. <esh...@us...> - 2005-11-28 19:48:03
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/static In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2745/src/editor/static Added Files: editor_dialog.c editor_dialog.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- NEW FILE: editor_dialog.c --- /* editor_dialog.c - editor navigation * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_dialog.h */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <assert.h> #include "roadmap.h" #include "roadmap_dialog.h" #include "roadmap_layer.h" #include "roadmap_line.h" #include "roadmap_shape.h" #include "roadmap_square.h" #include "roadmap_locator.h" #include "../db/editor_db.h" #include "../db/editor_line.h" #include "../db/editor_shape.h" #include "../db/editor_point.h" #include "../db/editor_street.h" #include "../db/editor_route.h" #include "../db/editor_override.h" #include "../editor_main.h" #include "../editor_log.h" #include "editor_dialog.h" typedef struct dialog_selected_lines { SelectedLine *lines; int count; } DialogSelectedLines; /* NOTE: This function modifies the street_range parameter */ static void decode_range (char *street_range, int *from1, int *to1, int *from2, int *to2) { int i = 0; int max = strlen(street_range); char *ranges[4]; int num_ranges=0; while (i <= max) { while (!isdigit (street_range[i]) && (i <= max)) i++; if (i>max) break; ranges[num_ranges++] = street_range+i; if (num_ranges == (sizeof(ranges) / sizeof(ranges[0]))) break; while (isdigit (street_range[i]) && (i <= max)) i++; street_range[i] = '\0'; i++; } if (num_ranges == 4) { *from1 = atoi (ranges[0]); *to1 = atoi (ranges[1]); if (from2 && to2) { *from2 = atoi (ranges[2]); *to2 = atoi (ranges[3]); } } else if (num_ranges > 1) { *from1 = atoi (ranges[0]); *to1 = atoi (ranges[1]); if (((*from1 & 1) && !(*to1 & 1)) || (!(*from1 & 1) && (*to1 & 1))) { (*to1)--; } if (from2 && to2) { *from2 = (*from1) + 1; *to2 = (*to1) + 1; } } } static const char *editor_segments_find_city (int line, int plugin_id, int fips) { int i; int count; int layers_count; int layers[128]; RoadMapPosition point; RoadMapNeighbour neighbours[50]; roadmap_locator_activate (fips); editor_db_activate (fips); if (plugin_id == EditorPluginID) { editor_line_get (line, &point, NULL, NULL, NULL, NULL); } else { roadmap_line_from (line, &point); } layers_count = roadmap_layer_all_roads (layers, 128); count = roadmap_street_get_closest (&point, layers, layers_count, neighbours, sizeof(neighbours) / sizeof(RoadMapNeighbour)); for (i = 0; i < count; ++i) { const char *city; if (roadmap_plugin_get_id (&neighbours[i].line) == EditorPluginID) { EditorStreetProperties properties; editor_street_get_properties (roadmap_plugin_get_line_id (&neighbours[i].line), &properties); city = editor_street_get_street_city (&properties, ED_STREET_LEFT_SIDE); } else if (roadmap_plugin_get_id (&neighbours[i].line) == ROADMAP_PLUGIN_ID) { RoadMapStreetProperties properties; roadmap_street_get_properties (roadmap_plugin_get_line_id (&neighbours[i].line), &properties); city = roadmap_street_get_street_city (&properties, ROADMAP_STREET_LEFT_SIDE); } else { city = ""; } if (strlen(city)) { return city; } } return ""; } static void editor_segments_cancel (const char *name, void *context) { free (context); roadmap_dialog_hide (name); } static void editor_segments_apply (const char *name, void *context) { DialogSelectedLines *selected_lines = (DialogSelectedLines *)context; int i; int route_id; EditorRouteFlag route_from_flags; EditorRouteFlag route_to_flags; int type = (int) roadmap_dialog_get_data ("General", "Road type"); int cfcc = type + ROADMAP_ROAD_FIRST; int direction = (int) roadmap_dialog_get_data ("General", "Direction"); char *street_type = (char *) roadmap_dialog_get_data ("General", "Street type"); char *street_name = (char *) roadmap_dialog_get_data ("General", "Name"); char *t2s = (char *) roadmap_dialog_get_data ("General", "Text to Speech"); char *street_range = (char *) roadmap_dialog_get_data ("General", "Street range"); char *city = (char *) roadmap_dialog_get_data ("General", "City"); char *zip = (char *) roadmap_dialog_get_data ("General", "Zip code"); int street_id; int street_range_id; int city_id; int zip_id; int l_from, l_to; int r_from, r_to; l_from = l_to = r_from = r_to = -1; decode_range (street_range, &l_from, &l_to, &r_from, &r_to); for (i=0; i<selected_lines->count; i++) { SelectedLine *line = &selected_lines->lines[i]; if (editor_db_activate (line->line.fips) == -1) { editor_db_create (line->line.fips); if (editor_db_activate (line->line.fips) == -1) { continue; } } if (line->line.plugin_id == EditorPluginID) { editor_line_modify_properties (line->line.line_id, cfcc, 0); } else { /* != Editor line */ int new_line = editor_line_copy (line->line.line_id, line->line.cfcc, line->line.fips); if (new_line == -1) { editor_log (ROADMAP_ERROR, "Can't set line attributes - copy line failed."); return; } line->line.line_id = new_line; line->line.plugin_id = EditorPluginID; } editor_line_get_street (line->line.line_id, &street_id, &street_range_id); street_id = editor_street_create (street_name, street_type, "", ""); editor_street_set_t2s (street_id, t2s); city_id = editor_street_create_city (city); zip_id = editor_street_create_zip (zip); if (street_range_id == -1) { street_range_id = editor_street_add_range (city_id, zip_id, l_from, l_to, city_id, zip_id, r_from, r_to); } else { editor_street_set_range (street_range_id, ED_STREET_LEFT_SIDE, &city_id, &zip_id, &l_from, &l_to); editor_street_set_range (street_range_id, ED_STREET_RIGHT_SIDE, &city_id, &zip_id, &r_from, &r_to); } editor_line_set_street (line->line.line_id, &street_id, &street_range_id); route_id = editor_line_get_route (line->line.line_id); if (route_id == -1) { route_id = editor_route_segment_add (0, 0); editor_line_set_route (line->line.line_id, route_id); } else { editor_route_segment_get (route_id, &route_from_flags, &route_to_flags); } if ((direction == 1) || (direction == 3)) { route_from_flags |= ED_ROUTE_CAR; } else { route_from_flags &= ~ED_ROUTE_CAR; } if ((direction == 2) || (direction == 3)) { route_to_flags |= ED_ROUTE_CAR; } else { route_to_flags &= ~ED_ROUTE_CAR; } if (route_id != -1) { editor_route_segment_set (route_id, route_from_flags, route_to_flags); } editor_line_mark_dirty (line->line.line_id); } if (selected_lines->count > 1) { int lines[100]; unsigned int count = selected_lines->count; unsigned int i; if (count > sizeof(lines)/sizeof(int)) { count = sizeof(lines)/sizeof(int); } for (i=0; i < count; i++) { lines[i] = selected_lines->lines[i].line.line_id; } editor_street_distribute_range (lines, count, l_from, l_to, r_from, r_to); } editor_screen_reset_selected (); free (context); roadmap_dialog_hide (name); } void editor_segments_fill_dialog (SelectedLine *lines, int lines_count) { const char *street_name = ""; const char *street_type = ""; const char *t2s = ""; const char *l_city = ""; const char *r_city = ""; const char *l_zip = ""; const char *r_zip = ""; int l_from = -1; int l_to = -1; int r_from = -1; int r_to = -1; int direction = 0; int cfcc = ROADMAP_ROAD_LAST; int same_street = 1; int same_direction = 1; int same_l_city = 1; int same_r_city = 1; int same_l_zip = 1; int same_r_zip = 1; char range_str[100]; int i; for (i=0; i<lines_count; i++) { const char *this_name = ""; const char *this_type = ""; const char *this_t2s = ""; const char *this_l_city = ""; const char *this_r_city = ""; const char *this_l_zip = ""; const char *this_r_zip = ""; int this_l_from = -1; int this_l_to = -1; int this_r_from = -1; int this_r_to = -1; int this_direction = 0; int route_id; if (lines[i].line.plugin_id == EditorPluginID) { if (editor_db_activate (lines[i].line.fips) != -1) { EditorStreetProperties properties; editor_street_get_properties (lines[i].line.line_id, &properties); this_name = editor_street_get_street_fename (&properties); this_type = editor_street_get_street_fetype (&properties); this_t2s = editor_street_get_street_t2s (&properties); this_l_city = editor_street_get_street_city (&properties, ED_STREET_LEFT_SIDE); this_r_city = editor_street_get_street_city (&properties, ED_STREET_RIGHT_SIDE); this_l_zip = editor_street_get_street_zip (&properties, ED_STREET_LEFT_SIDE); this_r_zip = editor_street_get_street_zip (&properties, ED_STREET_RIGHT_SIDE); editor_street_get_street_range (&properties, ED_STREET_LEFT_SIDE, &this_l_from, &this_l_to); editor_street_get_street_range (&properties, ED_STREET_RIGHT_SIDE, &this_r_from, &this_r_to); route_id = editor_line_get_route (lines[i].line.line_id); if (route_id != -1) { this_direction = editor_route_get_direction (route_id, ED_ROUTE_CAR); } } } else { RoadMapStreetProperties properties; roadmap_locator_activate (lines[i].line.fips); roadmap_street_get_properties (lines[i].line.line_id, &properties); this_name = roadmap_street_get_street_fename (&properties); this_type = roadmap_street_get_street_fetype (&properties); this_t2s = roadmap_street_get_street_t2s (&properties); this_l_city = roadmap_street_get_street_city (&properties, ROADMAP_STREET_LEFT_SIDE); this_r_city = roadmap_street_get_street_city (&properties, ROADMAP_STREET_RIGHT_SIDE); this_l_zip = roadmap_street_get_street_zip (&properties, ROADMAP_STREET_LEFT_SIDE); this_r_zip = roadmap_street_get_street_zip (&properties, ROADMAP_STREET_RIGHT_SIDE); roadmap_street_get_street_range (&properties, ROADMAP_STREET_LEFT_SIDE, &this_l_from, &this_l_to); roadmap_street_get_street_range (&properties, ROADMAP_STREET_RIGHT_SIDE, &this_r_from, &this_r_to); //TODO check roadmap route route_id = editor_override_line_get_route (lines[0].line.line_id); if (route_id != -1) { this_direction = editor_route_get_direction (route_id, ED_ROUTE_CAR); } } if (same_street) { if (!strlen(street_type)) { street_type = this_type; } if (!strlen(t2s)) { t2s = this_t2s; } if (l_from == -1) { l_from = this_l_from; } l_to = this_l_to; if (r_from == -1) { r_from = this_r_from; } r_to = this_r_to; if (!strlen(street_name)) { street_name = this_name; } else { if (strlen(this_name) && strcmp(this_name, street_name)) { street_name = ""; street_type = ""; t2s = ""; same_street = 0; l_from = l_to = r_from = r_to = -1; } } } if (same_direction) { if (!direction) { direction = this_direction; } else { if (this_direction && (direction != this_direction)) { direction = 0; same_direction = 0; } } } if (same_l_city) { if (!strlen(l_city)) { l_city = this_l_city; } else { if (strlen(this_l_city) && strcmp(this_l_city, l_city)) { same_l_city = 0; l_city = ""; } } } if (same_r_city) { if (!strlen(r_city)) { r_city = this_r_city; } else { if (strlen(this_r_city) && strcmp(this_r_city, r_city)) { same_r_city = 0; r_city = ""; } } } if (same_l_zip) { if (!strlen(l_zip)) { l_zip = this_l_zip; } else { if (strlen(this_l_zip) && strcmp(this_l_zip, l_zip)) { same_l_zip = 0; l_zip = ""; } } } if (same_r_zip) { if (!strlen(r_zip)) { r_zip = this_r_zip; } else { if (strlen(this_r_zip) && strcmp(this_r_zip, r_zip)) { same_r_zip = 0; r_zip = ""; } } } if (lines[i].line.cfcc < cfcc) { cfcc = lines[i].line.cfcc; } } if (same_l_city && same_r_city && !strlen(l_city) && !strlen(r_city)) { l_city = r_city = editor_segments_find_city (lines[0].line.line_id, lines[0].line.plugin_id, lines[0].line.fips); } roadmap_dialog_set_data ("General", "Road type", (void *) (cfcc - ROADMAP_ROAD_FIRST)); roadmap_dialog_set_data ("General", "Street type", street_type); roadmap_dialog_set_data ("General", "Name", street_name); roadmap_dialog_set_data ("General", "Text to Speech", t2s); if ((l_from != -1) && (l_to != -1) && (r_from != -1) && (r_to != -1)) { snprintf (range_str, sizeof(range_str), "%d-%d, %d-%d", l_from, l_to, r_from, r_to); } else { range_str[0] = '\0'; } roadmap_dialog_set_data ("General", "Street range", range_str); if (strlen(l_city)) { roadmap_dialog_set_data ("General", "City", l_city); } else { roadmap_dialog_set_data ("General", "City", r_city); } if (strlen(l_zip)) { roadmap_dialog_set_data ("General", "Zip code", l_zip); } else { roadmap_dialog_set_data ("General", "Zip code", r_zip); } roadmap_dialog_set_data ("General", "Direction", (void *)direction); /* Left side */ if ((l_from != -1) && (l_to != -1)) { snprintf (range_str, sizeof(range_str), "%d-%d", l_from , l_to); } else { range_str[0] = '\0'; } roadmap_dialog_set_data ("Left", "Street range", range_str); roadmap_dialog_set_data ("Left", "City", l_city); roadmap_dialog_set_data ("Left", "Zip code", l_zip); /* Right side */ if ((r_from != -1) && (r_to != -1)) { snprintf (range_str, sizeof(range_str), "%d-%d", r_from , r_to); } else { range_str[0] = '\0'; } roadmap_dialog_set_data ("Right", "Street range", range_str); roadmap_dialog_set_data ("Right", "City", r_city); roadmap_dialog_set_data ("Right", "Zip code", r_zip); } void editor_segments_properties (SelectedLine *lines, int lines_count) { char str[100]; int total_length = 0; int total_time = 0; int i; DialogSelectedLines *selected_lines = malloc (sizeof(*selected_lines)); selected_lines->lines = lines; selected_lines->count = lines_count; if (roadmap_dialog_activate ("Segment Properties", selected_lines)) { int *values; int count = ROADMAP_ROAD_LAST - ROADMAP_ROAD_FIRST + 1; int i; char **categories; char *direction_txts[] = { "Unknown", "With road", "Against road", "Both directions"}; int direction_values[] = {0, 1, 2, 3}; roadmap_dialog_new_label ("Info", "Length"); roadmap_dialog_new_label ("Info", "Time"); roadmap_dialog_new_entry ("Right", "Street range"); roadmap_dialog_new_entry ("Right", "City"); roadmap_dialog_new_entry ("Right", "Zip code"); roadmap_dialog_new_entry ("Left", "Street range"); roadmap_dialog_new_entry ("Left", "City"); roadmap_dialog_new_entry ("Left", "Zip code"); roadmap_layer_get_categories_names (&categories, &i); values = malloc ((count+1) * sizeof (int)); for (i=0; i<count; i++) { values[i] = i; } roadmap_dialog_new_choice ("General", "Road type", count, categories, (void**)values, NULL); free (values); roadmap_dialog_new_entry ("General", "Street type"); roadmap_dialog_new_entry ("General", "Name"); roadmap_dialog_new_entry ("General", "Text to Speech"); roadmap_dialog_new_entry ("General", "Street range"); roadmap_dialog_new_entry ("General", "City"); roadmap_dialog_new_entry ("General", "Zip code"); roadmap_dialog_new_choice ("General", "Direction", 4, direction_txts, (void**)direction_values, NULL); roadmap_dialog_add_button ("Cancel", editor_segments_cancel); roadmap_dialog_add_button ("OK", editor_segments_apply); roadmap_dialog_complete (0); /* No need for a keyboard. */ } editor_segments_fill_dialog (lines, lines_count); /* Collect info data */ for (i=0; i<selected_lines->count; i++) { int line_length; double speed; SelectedLine *line = &selected_lines->lines[i]; if (line->line.plugin_id == EditorPluginID) { line_length = editor_line_length (line->line.line_id); speed = editor_line_get_avg_speed (line->line.line_id, 1); } else { line_length = roadmap_line_length (line->line.line_id); speed = -1; //TODO get real speed } if (speed > 0) { total_time += (int)(1.0 * line_length / speed) + 1; } else { if ((total_time == 0) || (total_length == 0)) { total_time += (int)(1.0 *line_length / 10); } else { total_time += (int)(1.0 * line_length / (total_length/total_time)) + 1; } } total_length += line_length; } snprintf (str, sizeof(str), "%d meters", total_length); roadmap_dialog_set_data ("Info", "Length", str); snprintf (str, sizeof(str), "%d seconds", total_time); roadmap_dialog_set_data ("Info", "Time", str); } --- NEW FILE: editor_dialog.h --- /* editor_dialog.h - manage editor dialogs * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_DIALOG__H #define INCLUDE__EDITOR_DIALOG__H #include "../editor_screen.h" void editor_segments_properties (SelectedLine *lines, int count); #endif // INCLUDE__EDITOR_DIALOG__H |
From: Ehud S. <esh...@us...> - 2005-11-28 19:48:02
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/track In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2745/src/editor/track Added Files: editor_track_filter.c editor_track_filter.h editor_track_known.c editor_track_known.h editor_track_main.c editor_track_main.h editor_track_unknown.c editor_track_unknown.h editor_track_util.c editor_track_util.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- NEW FILE: editor_track_util.c --- /* editor_track_util.c - misc functions used by editor track modules * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * NOTE: * This file implements all the "dynamic" editor functionality. * The code here is experimental and needs to be reorganized. * * SYNOPSYS: * * See editor_track_util.h */ #include <assert.h> #include <string.h> #include <stdlib.h> #include <math.h> #include "roadmap.h" #include "roadmap_math.h" #include "roadmap_gps.h" #include "roadmap_fuzzy.h" #include "roadmap_layer.h" #include "roadmap_locator.h" #include "roadmap_line.h" #include "roadmap_point.h" #include "roadmap_navigate.h" #include "../db/editor_db.h" #include "../db/editor_point.h" #include "../db/editor_line.h" #include "../db/editor_shape.h" #include "../db/editor_street.h" #include "../db/editor_route.h" #include "../db/editor_trkseg.h" #include "../db/editor_override.h" #include "../editor_main.h" #include "../editor_log.h" #include "editor_track_main.h" #include "editor_track_util.h" #define FOCUS_RANGE 1000 #define SPLIT_START 0x1 #define SPLIT_END 0x2 #define SPLIT_NODE 0x4 #define SPLIT_CHECK 0x8 static void editor_track_util_set_focus(const RoadMapPosition *position) { RoadMapArea focus; focus.west = position->longitude - FOCUS_RANGE; focus.east = position->longitude + FOCUS_RANGE; focus.south = position->latitude - FOCUS_RANGE; focus.north = position->latitude + FOCUS_RANGE; roadmap_math_set_focus (&focus); } static void editor_track_util_release_focus() { roadmap_math_release_focus (); } /* Find a good point on the given line to start a new road: * Check if either end points of the line are good candidates. * Check recent GPS points and see if there's a good candidate. */ static int find_split_point (PluginLine *line, const RoadMapPosition *point, int last_point_id, int split_type, int max_distance_allowed, int opposite_direction, NodeNeighbour *connect_point) { #define MAX_RECENT_POINTS 50 RoadMapPosition from_pos; RoadMapPosition to_pos; RoadMapPosition split_pos; RoadMapPosition candidate_split_pos; RoadMapNeighbour result; int start_point_id = -1; int points_count = last_point_id + 1; int distance; int min_distance; editor_log_push ("find_split_point"); editor_log (ROADMAP_INFO, "find split point for line:%d (plugin_id:%d). split_type:%d", roadmap_plugin_get_line_id (line), roadmap_plugin_get_id (line), split_type); max_distance_allowed *= editor_track_point_distance (); roadmap_plugin_line_from (line , &from_pos); roadmap_plugin_line_to (line , &to_pos); split_pos = candidate_split_pos = *point; min_distance = roadmap_math_distance (&candidate_split_pos, &from_pos); if (min_distance < max_distance_allowed) { split_pos = from_pos; } distance = roadmap_math_distance (&candidate_split_pos, &to_pos); if ((distance < min_distance) && (distance < max_distance_allowed)) { min_distance = distance; split_pos = to_pos; } if ((min_distance > max_distance_allowed) && !(split_type & SPLIT_NODE)) { /* End points are not good. Check recent gps points. */ int i; RoadMapTracking candidate; RoadMapFuzzy current_fuzzy; RoadMapFuzzy best = roadmap_fuzzy_false (); int last_azymuth_diff = -1; for (i=points_count-1; (i > (points_count-MAX_RECENT_POINTS)) && (i > 0); i--) { RoadMapGpsPosition *current_gps_point = track_point_gps (i); RoadMapPosition *current_pos = track_point_pos (i); int steering = current_gps_point->steering; int current_azymuth_diff; if (!editor_track_util_get_distance (current_pos, line, &result)) { continue; } if (opposite_direction) { steering = steering - 180; } current_azymuth_diff = roadmap_math_delta_direction (steering, roadmap_math_azymuth (&result.from, &result.to)); current_fuzzy = roadmap_navigate_fuzzify (&candidate, NULL, &result, steering); if (start_point_id == -1) { start_point_id = i; split_pos = result.intersection; best = current_fuzzy; last_azymuth_diff = current_azymuth_diff; } if (split_type & SPLIT_START) { /* when looking for a start point, find the first point * which seems ok. */ if ((current_fuzzy <= best) && roadmap_fuzzy_is_certain (best)) { break; } if (abs (last_azymuth_diff - current_azymuth_diff) > 10) { break; } last_azymuth_diff = current_azymuth_diff; if (current_fuzzy > best) { start_point_id = i; split_pos = result.intersection; best = current_fuzzy; } if (roadmap_fuzzy_is_certain (current_fuzzy)) { if (result.distance < editor_track_point_distance ()) { break; } } } else if (split_type & SPLIT_END) { /* when looking for an end point, go backward as * much as possible. */ if (roadmap_fuzzy_is_acceptable (current_fuzzy)) { start_point_id = i; split_pos = result.intersection; } if (!roadmap_fuzzy_is_acceptable (current_fuzzy)) { start_point_id = i; split_pos = result.intersection; break; } } else { assert (0); } } #if 0 if (find_start_point && (start_point_id != (points_count-1))) { RoadMapPosition intersection; int res = roadmap_math_intersection ((RoadMapPosition *)&GpsPoints[start_point_id], (RoadMapPosition *)&GpsPoints[start_point_id+1], &result.from, &result.to, &intersection); if (res && (roadmap_math_distance (&split_pos, &intersection) < editor_track_point_distance ()*50)) { split_pos = intersection; } } #endif /* check end points again */ candidate_split_pos = split_pos; min_distance = roadmap_math_distance (&candidate_split_pos, &from_pos); if (min_distance < max_distance_allowed) { split_pos = from_pos; } distance = roadmap_math_distance (&candidate_split_pos, &to_pos); if ((distance < min_distance) && (distance < max_distance_allowed)) { min_distance = distance; split_pos = to_pos; } } if (min_distance >= max_distance_allowed) { editor_log (ROADMAP_INFO, "End points are not good enough. Need to split. Gone back %d points to find a good position.", points_count - start_point_id); if (split_type & SPLIT_CHECK) { editor_log_pop (); return -1; } if (editor_line_split (line, (split_type & SPLIT_START ? track_point_pos (0) : track_point_pos (points_count-1)), &split_pos, &connect_point->id) == -1) { editor_log (ROADMAP_ERROR, "Can't split line."); editor_log_pop (); return -1; } connect_point->plugin_id = EditorPluginID; } if (connect_point->id == -1) { int from, to; if (roadmap_plugin_get_id (line) != EditorPluginID) { roadmap_line_points (roadmap_plugin_get_line_id (line), &from, &to); } else { editor_line_get_points (roadmap_plugin_get_line_id (line), &from, &to); } if (!roadmap_math_compare_points (&split_pos, &from_pos)) { connect_point->id = from; } else { assert (!roadmap_math_compare_points (&split_pos, &to_pos)); connect_point->id = to; } connect_point->plugin_id = EditorPluginID; } if ((start_point_id == -1) || roadmap_math_compare_points (&from_pos, &to_pos)) { int min_distance = 1000000; int distance; RoadMapPosition intersection; int i; for (i=points_count-1; (i > (points_count-MAX_RECENT_POINTS)) && (i > 0); i--) { distance = roadmap_math_get_distance_from_segment (&split_pos, track_point_pos (i), track_point_pos (i-1), &intersection); if (distance >= min_distance) break; min_distance = distance; start_point_id = i; } if (start_point_id > 1) { if (roadmap_math_distance (track_point_pos (start_point_id-1), &intersection) <= roadmap_math_distance (track_point_pos (start_point_id), &intersection)) { start_point_id--; } } } editor_log_pop (); return start_point_id; } static void editor_track_util_node_pos (NodeNeighbour *node, RoadMapPosition *position) { if (node->plugin_id != EditorPluginID) { roadmap_point_position (node->id, position); } else { editor_point_position (node->id, position); } } static int editor_track_util_same_node (NodeNeighbour *from_node, NodeNeighbour *to_node) { RoadMapPosition from_pos; RoadMapPosition to_pos; /* FIXME this does not really check if the nodes are the same. * It only checks if the location is equal. */ editor_track_util_node_pos (from_node, &from_pos); editor_track_util_node_pos (to_node, &to_pos); if (!roadmap_math_compare_points (&from_pos, &to_pos)) return 1; else return 0; } static void adjust_connect_node (NodeNeighbour *node, PluginLine *line) { RoadMapPosition split_position; RoadMapNeighbour result; editor_track_util_node_pos (node, &split_position); editor_track_util_set_focus(&split_position); if (!roadmap_plugin_get_distance (&split_position, line, &result)) { assert (0); roadmap_math_release_focus(); node->id = -1; return; } editor_track_util_release_focus (); assert (result.distance < 3*editor_track_point_distance ()); split_position.longitude = result.intersection.longitude; split_position.latitude = result.intersection.latitude; if (node->plugin_id == ROADMAP_PLUGIN_ID) { node->id = editor_point_roadmap_to_editor (node->id); node->plugin_id = EditorPluginID; } //TODO: make sure that the point is not shared editor_point_set_pos (node->id, &split_position); } int editor_track_util_new_road_start (RoadMapNeighbour *line, const RoadMapPosition *pos, int points_count, int opposite_direction, NodeNeighbour *node) { node->id = -1; return find_split_point (&line->line, pos, points_count, SPLIT_START, 2, opposite_direction, node); } int editor_track_util_new_road_end (RoadMapNeighbour *line, const RoadMapPosition *pos, int points_count, int opposite_direction, NodeNeighbour *node) { node->id = -1; return find_split_point (&line->line, pos, points_count, SPLIT_END, 2, opposite_direction, node); } int editor_track_util_get_distance (const RoadMapPosition *point, const PluginLine *line, RoadMapNeighbour *result) { int res; editor_track_util_set_focus(point); roadmap_plugin_activate_db (line); res = roadmap_plugin_get_distance (point, line, result); roadmap_math_release_focus(); return res; } int editor_track_util_find_street (const RoadMapGpsPosition *gps_position, RoadMapTracking *nominated, RoadMapTracking *previous_street, RoadMapNeighbour *previous_line, RoadMapNeighbour *neighbourhood, int max, int *found, RoadMapFuzzy *best) { RoadMapTracking candidate; int count; int layers[128]; int layer_count; int result; int i; if (!previous_street->valid) { previous_line = NULL; } editor_track_util_set_focus((RoadMapPosition*)gps_position); layer_count = roadmap_layer_all_roads (layers, 128); count = roadmap_street_get_closest ((RoadMapPosition *)gps_position, layers, layer_count, neighbourhood, max); count = roadmap_plugin_get_closest ((RoadMapPosition *)gps_position, layers, layer_count, neighbourhood, count, max); editor_track_util_release_focus (); for (i = 0, *best = roadmap_fuzzy_false(), *found = 0; i < count; ++i) { result = roadmap_navigate_fuzzify (&candidate, previous_line, neighbourhood+i, gps_position->steering); if (result > *best) { *found = i; *best = result; *nominated = candidate; nominated->opposite_street_direction = 0; } } if (roadmap_fuzzy_is_acceptable (*best)) return count; /* search for a line in the opposite direction */ for (i = 0; i < count; ++i) { result = roadmap_navigate_fuzzify (&candidate, previous_line, neighbourhood+i, gps_position->steering - 180); if (!roadmap_fuzzy_is_good (result)) { RoadMapPosition connection; if (!previous_street->valid || !previous_street->opposite_street_direction) { continue; } /* if this line is the current line, or connected to the * current line, allow it */ if (!roadmap_plugin_same_line (&neighbourhood[i].line, &previous_line->line)) { if (roadmap_fuzzy_is_certain ( roadmap_fuzzy_connected (&neighbourhood[i], previous_line, &connection))) { if (roadmap_math_distance (&connection, (RoadMapPosition *) gps_position) >= 3*editor_track_point_distance ()) { continue; } } else { continue; } } } if (result > *best) { *found = i; *best = result; *nominated = candidate; nominated->opposite_street_direction = 1; } } return count; } int editor_track_util_connect_roads (PluginLine *from, PluginLine *to, int from_opposite_direction, int to_opposite_direction, const RoadMapGpsPosition *gps_position, int last_point_id) { RoadMapPosition position = *(RoadMapPosition *) gps_position; NodeNeighbour from_node = NODE_NEIGHBOUR_NULL; NodeNeighbour to_node = NODE_NEIGHBOUR_NULL; NodeNeighbour connect_node = NODE_NEIGHBOUR_NULL; int from_point; int to_point; editor_log_push ("editor_track_connect_roads"); editor_log (ROADMAP_INFO, "from:%d (plugin_id:%d), to:%d (plugin_id:%d), pos - lon:%d, lat:%d", from->line_id, from->plugin_id, to->line_id, to->plugin_id, gps_position->longitude, gps_position->latitude); //TODO: need to handle a merge of two junctions (each with two roads or more) from_point = find_split_point (from, &position, last_point_id, SPLIT_START|SPLIT_CHECK, 3, from_opposite_direction, &from_node); to_point = find_split_point (to, &position, last_point_id, SPLIT_END|SPLIT_CHECK, 3, to_opposite_direction, &to_node); if ((from_point != -1) && (to_point != -1)) { if (editor_track_util_same_node (&from_node, &to_node)) { editor_log (ROADMAP_INFO, "Both lines share the same node. Done."); editor_log_pop (); return (from_point + to_point) / 2; //return (from_point > to_point) ? from_point : to_point; } //TODO: need to handle a merge of two nodes (each with two roads or more) //Check if there's a small line connecting both nodes. editor_log_pop (); return (from_point + to_point) / 2; } if ((from_point == -1) && (to_point == -1)) { editor_log (ROADMAP_INFO, "Neither lines have a node. Create a node."); from_point = find_split_point (from, &position, last_point_id, SPLIT_START, 3, from_opposite_direction, &from_node); if (from_point == -1) { assert (0); editor_log (ROADMAP_ERROR, "Can't create a connection point."); editor_log_pop (); return -1; } connect_node = from_node; adjust_connect_node (&connect_node, to); } else if (from_point != -1) { connect_node = from_node; adjust_connect_node (&connect_node, to); } else { connect_node = to_node; adjust_connect_node (&connect_node, from); } if (connect_node.id == -1) { editor_log (ROADMAP_ERROR, "Can't find a connection point."); editor_log_pop (); return -1; } editor_track_util_node_pos (&connect_node, &position); if (from_point == -1) { editor_log (ROADMAP_INFO, "'from' line has no node. Need to split."); from_point = find_split_point (from, &position, last_point_id, SPLIT_START|SPLIT_NODE, 3, from_opposite_direction, &connect_node); } if (to_point == -1) { editor_log (ROADMAP_INFO, "'to' line has no node. Need to split."); to_point = find_split_point (to, &position, last_point_id, SPLIT_END|SPLIT_NODE, 3, to_opposite_direction, &connect_node); } if ((from_point == -1) || (to_point == -1)) { editor_log (ROADMAP_ERROR, "Can't create a connection point."); editor_log_pop (); return -1; } editor_log_pop (); return (from_point + to_point) / 2; } int editor_track_util_create_trkseg (int line_id, int first_point, int last_point, int flags) { int trk_from; int first_shape = -1; int last_shape = -1; int trkseg_id; int i; int gps_time = track_point_time (first_point); RoadMapPosition *pos = track_point_pos (first_point); trk_from = editor_point_add (pos, 0, -1); for (i=first_point; i<=last_point; i++) { RoadMapPosition *shape_pos = track_point_pos (i); last_shape = editor_shape_add (shape_pos->longitude - pos->longitude, shape_pos->latitude - pos->latitude, track_point_time (i) - gps_time); if (last_shape == -1) { editor_log (ROADMAP_ERROR, "Can't add shape point."); editor_log_pop (); return -1; } if (first_shape == -1) { first_shape = last_shape; } pos = shape_pos; gps_time = track_point_time (i); } trkseg_id = editor_trkseg_add (line_id, trk_from, first_shape, last_shape, track_point_time (first_point), track_point_time (last_point), flags); if (trkseg_id == -1) return -1; //last_global_trkseg = trkseg_id; return trkseg_id; } void editor_track_add_trkseg (PluginLine *line, int trkseg, int direction, int who) { int first; int last; int route; int plugin_id = roadmap_plugin_get_id (line); if (direction != 0) { short from_flags; short to_flags; if (plugin_id == ROADMAP_PLUGIN_ID) { //TODO get roadmap route data route = editor_override_line_get_route (roadmap_plugin_get_line_id (line)); } else { route = editor_line_get_route (roadmap_plugin_get_line_id (line)); } if (route == -1) { route = editor_route_segment_add (0, 0); from_flags = to_flags = 0; } else { editor_route_segment_get (route, &from_flags, &to_flags); } if (direction == 1) { from_flags |= who; } else if (direction == 2) { to_flags |= who; } else { assert (0); } if (route != -1) { editor_route_segment_set (route, from_flags, to_flags); } } if (plugin_id != EditorPluginID) { editor_override_line_get_trksegs (roadmap_plugin_get_line_id (line), &first, &last); if (first == -1) { first = last = trkseg; } else { editor_trkseg_connect_roads (last, trkseg); last = trkseg; } editor_override_line_set_trksegs (roadmap_plugin_get_line_id (line), first, last); } else { editor_line_get_trksegs (roadmap_plugin_get_line_id (line), &first, &last); if (first == -1) { first = last = trkseg; } else { editor_trkseg_connect_roads (last, trkseg); last = trkseg; } editor_line_set_trksegs (roadmap_plugin_get_line_id (line), first, last); } } int editor_track_util_create_line (int gps_first_point, int gps_last_point, int from_point, int to_point, int cfcc, int is_new_track) { int route; int trkseg; int trkseg2; int line_id; PluginLine line; int fips = editor_db_locator (track_point_pos (gps_last_point)); int trk_flags = 0; assert (gps_first_point != gps_last_point); editor_log_push ("editor_track_create_line"); if (gps_first_point == gps_last_point) { editor_log (ROADMAP_ERROR, "first point == gps_last_point"); editor_log_pop (); return -1; } if (editor_db_activate (fips) == -1) { editor_db_create (fips); if (editor_db_activate (fips) == -1) { editor_log_pop (); return -1; } } /* we skip the first and last points of the GPS track */ trkseg = editor_track_util_create_trkseg (-1, gps_first_point+1, gps_last_point-1, ED_TRKSEG_FAKE|ED_TRKSEG_NO_GLOBAL); if (trkseg == -1) { editor_log (ROADMAP_ERROR, "Can't create new trkseg."); editor_log_pop (); return -1; } line_id = editor_line_add (from_point, to_point, trkseg, cfcc, 0); if (line_id == -1) { editor_log (ROADMAP_ERROR, "Can't create new line."); editor_log_pop (); return -1; } editor_trkseg_set_line (trkseg, line_id); /* this is the second trkseg of the line */ if (is_new_track) { trk_flags |= ED_TRKSEG_NEW_TRACK; } trkseg2 = editor_track_util_create_trkseg (line_id, gps_first_point, gps_last_point, trk_flags); if (trkseg2 == -1) { editor_log (ROADMAP_ERROR, "Can't create new trkseg."); editor_log_pop (); return -1; } editor_trkseg_connect_roads (trkseg, trkseg2); editor_line_set_trksegs (line_id, trkseg, trkseg2); route = editor_route_segment_add (ED_ROUTE_CAR, 0); editor_line_set_route (line_id, route); roadmap_plugin_set_line (&line, EditorPluginID, line_id, cfcc, fips); editor_log_pop (); return line_id; } int editor_track_util_length (int first, int last) { int length = 0; int i; for (i=first; i<last; i++) { length += roadmap_math_distance (track_point_pos (i), track_point_pos (i+1)); } return length; } int editor_track_util_create_db (const RoadMapPosition *pos) { int fips = editor_db_locator (pos); if (editor_db_activate (fips) == -1) { editor_db_create (fips); if (editor_db_activate (fips) == -1) { editor_log_pop (); return -1; } } return fips; } --- NEW FILE: editor_track_filter.h --- /* editor_track_filter.h - Filter GPS points * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_TRACK_FILTER__H #define INCLUDE__EDITOR_TRACK_FILTER__H #define ED_TRACK_END 1 struct GPSFilter; void editor_track_filter_reset (struct GPSFilter *filter); struct GPSFilter *editor_track_filter_new (int max_distance, int max_time, int point_distance); int editor_track_filter_add (struct GPSFilter *filter, time_t gps_time, const RoadMapGpsPrecision *dilution, const RoadMapGpsPosition* gps_position); const RoadMapGpsPosition *editor_track_filter_get (struct GPSFilter *filter); #endif // INCLUDE__EDITOR_TRACK_FILTER__H --- NEW FILE: editor_track_unknown.c --- /* editor_track_unknown.c - handle tracks of unknown points * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * NOTE: * This file implements all the "dynamic" editor functionality. * The code here is experimental and needs to be reorganized. * * SYNOPSYS: * * See editor_track_unknown.h */ #include <assert.h> #include <stdlib.h> #include "roadmap.h" #include "roadmap_math.h" #include "roadmap_gps.h" #include "../editor_log.h" #include "editor_track_main.h" #include "editor_track_util.h" #include "editor_track_unknown.h" #define ROADMAP_NEIGHBOURHOUD 16 static RoadMapNeighbour RoadMapNeighbourhood[ROADMAP_NEIGHBOURHOUD]; /* Find if the current point matches a point on the current new line. * (Detect loops) */ static int match_distance_from_current (const RoadMapGpsPosition *gps_point, int last_point, RoadMapPosition *best_intersection, int *match_point) { int i; int distance; int smallest_distance; int azymuth; RoadMapPosition intersection; smallest_distance = 0x7fffffff; for (i = 0; i < (last_point-1); i++) { distance = roadmap_math_get_distance_from_segment ((RoadMapPosition *)gps_point, track_point_pos (i), track_point_pos (i+1), &intersection); if (distance < smallest_distance) { smallest_distance = distance; *best_intersection = intersection; *match_point = i; azymuth = roadmap_math_azymuth (track_point_pos (i), track_point_pos (i+1)); } } return (smallest_distance < editor_track_point_distance ()) && (roadmap_math_delta_direction (azymuth, gps_point->steering) < 10); } typedef struct angle_pair_s { int index; int angle; } angle_pair; /* we want a descending list so this function inverts the real comparison */ static int angle_pair_cmp (const void *p1, const void *p2) { const angle_pair *pair1 = (const angle_pair *)p1; const angle_pair *pair2 = (const angle_pair *)p2; if (pair1->angle > pair2->angle) return -1; else if (pair1->angle < pair2->angle) return 1; else return 0; } static int find_line_break (int last_point, int last_azymuth, int current_point, int *middle1, int *middle2) { #define MAX_TURN_POINTS 50 angle_pair pairs[MAX_TURN_POINTS]; int i; int j; int max_azymuth_diff = 0; int max_point_azymuth = 0; int max_azymuth_point = -1; int current_azymuth; if ((current_point - last_point + 1) > MAX_TURN_POINTS) return 0; j=0; for (i=last_point; i<=current_point; i++) { int diff; int prev_azymuth; current_azymuth = roadmap_math_azymuth (track_point_pos (i), track_point_pos (i+1)); diff = roadmap_math_delta_direction (last_azymuth, current_azymuth); if (diff > max_azymuth_diff) { max_azymuth_diff = diff; } prev_azymuth = roadmap_math_azymuth (track_point_pos (i-1), track_point_pos (i)); diff = roadmap_math_delta_direction (prev_azymuth, current_azymuth); pairs[j].index = i; pairs[j].angle = diff; j++; if (diff > max_point_azymuth) { max_point_azymuth = diff; max_azymuth_point = i; } } qsort (pairs, j, sizeof(angle_pair), angle_pair_cmp); if (max_azymuth_diff > 45) { int angle_sum = pairs[0].angle; int middle1_angle = pairs[0].angle; int middle2_angle = pairs[0].angle; *middle1 = pairs[0].index; *middle2 = pairs[0].index; j=1; while ((100 * angle_sum / max_azymuth_diff) < 70) { assert (j<(current_point-last_point+1)); angle_sum += pairs[j].angle; if (pairs[j].index < *middle1) { *middle1 = pairs[j].index; middle1_angle = pairs[j].angle; } else if (pairs[j].index > *middle2) { *middle2 = pairs[j].index; middle2_angle = pairs[j].angle; } j++; } return 1; } return 0; } /* Detect roundabouts */ static int is_roundabout (int first_point, int last_point) { //RoadMapPosition middle; int length; //int i; length = editor_track_util_length (first_point, last_point); if ((length < editor_track_point_distance ()*3) || (length > editor_track_point_distance ()*20)) { return 0; } return 1; #if 0 middle.longitude = middle.latitude = 0; for (i=first_point; i<last_point; i++) { middle.longitude += GpsPoints[i].longitude; middle.latitude += GpsPoints[i].latitude; } middle.longitude /= (last_point - first_point); middle.latitude /= (last_point - first_point); /* Fix the end of the segment before the roundabout */ GpsPoints[first_point-1].longitude = middle.longitude; GpsPoints[first_point-1].latitude = middle.latitude; #endif } static int detect_turn(int point_id, const RoadMapGpsPosition *gps_position, TrackNewSegment *new_segment, int max) { static int last_straight_line_point = -1; static int last_straight_azymuth = 0; int middle1; int middle2; if (point_id == 0) return 0; if (point_id == 1) { last_straight_line_point = point_id; last_straight_azymuth = roadmap_math_azymuth (track_point_pos (point_id-1), track_point_pos (point_id)); return 0; } assert (point_id > last_straight_line_point); /* trivial case */ if ((last_straight_line_point == (point_id-1)) && (roadmap_math_delta_direction (roadmap_math_azymuth (track_point_pos (point_id - 1), track_point_pos (point_id)), last_straight_azymuth) > 60)) { new_segment[0].type = TRACK_ROAD_REG; new_segment[0].point_id = point_id - 1; last_straight_line_point = point_id; last_straight_azymuth = roadmap_math_azymuth (track_point_pos (point_id-1), track_point_pos (point_id)); return 1; } if (roadmap_math_delta_direction (roadmap_math_azymuth (track_point_pos (point_id - 1), (RoadMapPosition *)gps_position), roadmap_math_azymuth (track_point_pos (point_id - 3), track_point_pos (point_id - 2))) < 10) { int this_straight_azymuth; /* this is a straight line, save it */ this_straight_azymuth = roadmap_math_azymuth (track_point_pos (point_id - 3), track_point_pos (point_id)); if (last_straight_line_point == -1) { last_straight_line_point = point_id; last_straight_azymuth = this_straight_azymuth; return 0; } if (!find_line_break (last_straight_line_point, last_straight_azymuth, point_id-3, &middle1, &middle2)) { last_straight_line_point = point_id; last_straight_azymuth = this_straight_azymuth; return 0; } last_straight_line_point = point_id - middle2; last_straight_azymuth = this_straight_azymuth; assert (middle1 > 0); if (middle1 > 0) { new_segment[0].type = TRACK_ROAD_REG; new_segment[0].point_id = middle1; } if (middle1 != middle2) { /* make the curve a segment of its own */ new_segment[1].type = TRACK_ROAD_TURN; new_segment[1].point_id = middle2; return 2; } else { return 1; } } return 0; } static int detect_loop(int point_id, const RoadMapGpsPosition *gps_position, TrackNewSegment *new_segment, int max) { RoadMapPosition intersection; int loop_start_point; /* see if we can match the position to the current line */ if ((point_id > 4) && match_distance_from_current (gps_position, point_id, &intersection, &loop_start_point)) { //TODO roundabout - is this needed? //GpsPoints[point_id].longitude = intersection.longitude; //GpsPoints[point_id].latitude = intersection.latitude; if (is_roundabout (loop_start_point, point_id)) { new_segment[0].type = TRACK_ROAD_REG; new_segment[0].point_id = loop_start_point; new_segment[1].type = TRACK_ROAD_ROUNDABOUT; new_segment[1].point_id = point_id; return 2; } else { new_segment[0].type = TRACK_ROAD_REG; new_segment[0].point_id = point_id; return 1; } } return 0; } static int detect_road_segment (int point_id, const RoadMapGpsPosition *gps_position, TrackNewSegment *new_segment, int max) { int count; count = detect_loop (point_id, gps_position, new_segment, max); if (count) return count; count = detect_turn (point_id, gps_position, new_segment, max); return count; } int editor_track_unknown_locate_point (int point_id, const RoadMapGpsPosition *gps_position, RoadMapTracking *confirmed_street, RoadMapNeighbour *confirmed_line, TrackNewSegment *new_segment, int max_segments, int force) { RoadMapFuzzy best; RoadMapTracking nominated; int found; int count; #if 0 if (force) { /* this point is already known to be unknown */ return detect_road_segment (point_id, gps_position, new_segment, max_segments); } #endif /* let's see if we got to a known street line */ count = editor_track_util_find_street (gps_position, &nominated, confirmed_street, confirmed_line, RoadMapNeighbourhood, ROADMAP_NEIGHBOURHOUD, &found, &best); if (roadmap_fuzzy_is_good (best) || confirmed_street->valid) { /* we found an existing road, let's close the new road */ /* delay ending the line until we find the best location to end it */ if (roadmap_fuzzy_is_good (best) && ( !confirmed_street->valid || (best > confirmed_street->fuzzyfied))) { // RoadMapNeighbourhood[found].distance < // confirmed_line->distance)) { *confirmed_line = RoadMapNeighbourhood[found]; *confirmed_street = nominated; confirmed_street->valid = 1; confirmed_street->fuzzyfied = best; /* if (!roadmap_fuzzy_is_certain (best)) { return 0; } */ if (confirmed_line->distance > editor_track_point_distance ()) { return 0; } } new_segment->type = TRACK_ROAD_REG; new_segment->point_id = point_id; if (best != confirmed_street->fuzzyfied) { new_segment->point_id--; } return 1; } else { /* point is unknown, see if we can detect a road segment */ return detect_road_segment (point_id, gps_position, new_segment, max_segments); } } --- NEW FILE: editor_track_filter.c --- /* editor_track_filter.c - filter GPS trace * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * NOTE: * This file implements all the "dynamic" editor functionality. * The code here is experimental and needs to be reorganized. * * SYNOPSYS: * * See editor_track_filter.h */ #include <assert.h> #include <string.h> #include <stdlib.h> #include <math.h> #include "roadmap.h" #include "roadmap_math.h" #include "roadmap_gps.h" #include "../editor_log.h" #include "editor_track_filter.h" typedef struct GPSFilter { int max_distance; int max_time; int point_distance; int first_point; RoadMapGpsPosition last_gps_point; int last_gps_time; int last_azymuth; RoadMapGpsPosition normalized_gps_point; } GPSFilter; void editor_track_filter_reset (GPSFilter *filter) { filter->first_point = 1; } GPSFilter *editor_track_filter_new (int max_distance, int max_time, int point_distance) { GPSFilter *filter = malloc (sizeof(GPSFilter)); filter->max_distance = max_distance; filter->max_time = max_time; filter->point_distance = point_distance; editor_track_filter_reset (filter); return filter; } int editor_track_filter_add (GPSFilter *filter, time_t gps_time, const RoadMapGpsPrecision *dilution, const RoadMapGpsPosition* gps_position) { int azymuth; if (filter->first_point) { filter->first_point = 0; filter->last_azymuth = gps_position->steering; filter->last_gps_point = *gps_position; filter->last_gps_time = gps_time; filter->normalized_gps_point = *gps_position; return 0; } if (gps_position->speed == 0) return 0; if ((filter->last_gps_point.latitude == gps_position->latitude) && (filter->last_gps_point.longitude == gps_position->longitude)) return 0; if ((roadmap_math_distance ((RoadMapPosition *) &filter->last_gps_point, (RoadMapPosition*) gps_position) >= filter->max_distance) || (gps_time < filter->last_gps_time) || ((gps_time - filter->last_gps_time) > filter->max_time)) { editor_track_filter_reset (filter); editor_track_filter_add (filter, gps_time, dilution, gps_position); return ED_TRACK_END; } filter->last_gps_time = gps_time; filter->normalized_gps_point.longitude = (filter->normalized_gps_point.longitude + gps_position->longitude) / 2; filter->normalized_gps_point.latitude = (filter->normalized_gps_point.latitude + gps_position->latitude) / 2; filter->normalized_gps_point.speed = gps_position->speed; filter->normalized_gps_point.steering = gps_position->steering; azymuth = roadmap_math_azymuth ((RoadMapPosition *) &filter->normalized_gps_point, (RoadMapPosition *) &filter->last_gps_point); /* ignore consecutive points which generate a big curve */ if (roadmap_math_delta_direction (azymuth, filter->last_azymuth) > 90) { filter->last_gps_point = filter->normalized_gps_point; } filter->last_azymuth = azymuth; return 0; } const RoadMapGpsPosition *editor_track_filter_get (GPSFilter *filter) { if (roadmap_math_distance ( (RoadMapPosition *) &filter->last_gps_point, (RoadMapPosition*) &filter->normalized_gps_point) >= filter->point_distance) { RoadMapGpsPosition interpolated_point = filter->normalized_gps_point; while (roadmap_math_distance ( (RoadMapPosition*) &filter->last_gps_point, (RoadMapPosition*) &interpolated_point ) >= (filter->point_distance * 2)) { interpolated_point.longitude = (interpolated_point.longitude + filter->last_gps_point.longitude) / 2; interpolated_point.latitude = (interpolated_point.latitude + filter->last_gps_point.latitude) / 2; } filter->last_gps_point = interpolated_point; return &filter->last_gps_point; } return NULL; } --- NEW FILE: editor_track_util.h --- /* editor_track_util.h - misc functions * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_TRACK_UTIL__H #define INCLUDE__EDITOR_TRACK_UTIL__H #include "roadmap_navigate.h" #include "editor_track_main.h" int editor_track_util_get_distance (const RoadMapPosition *point, const PluginLine *line, RoadMapNeighbour *result); int editor_track_util_find_street (const RoadMapGpsPosition *gps_position, RoadMapTracking *candidate, RoadMapTracking *previous_street, RoadMapNeighbour *previous_line, RoadMapNeighbour *neighbourhood, int max, int *found, RoadMapFuzzy *best); int editor_track_util_create_line (int gps_first_point, int gps_last_point, int from_point, int to_point, int cfcc, int is_new_track); int editor_track_util_connect_roads (PluginLine *from, PluginLine *to, int from_opposite_direction, int to_opposite_direction, const RoadMapGpsPosition *gps_position, int last_point_id); int editor_track_util_new_road_start (RoadMapNeighbour *line, const RoadMapPosition *pos, int last_point_id, int opposite_direction, NodeNeighbour *node); int editor_track_util_new_road_end (RoadMapNeighbour *line, const RoadMapPosition *pos, int last_point_id, int opposite_direction, NodeNeighbour *node); int editor_track_util_length (int first, int last); int editor_track_util_create_trkseg (int line_id, int first_point, int last_point, int flags); void editor_track_add_trkseg (PluginLine *line, int trkseg, int direction, int who); int editor_track_util_create_db (const RoadMapPosition *pos); #endif // INCLUDE__EDITOR_TRACK_UTIL__H --- NEW FILE: editor_track_unknown.h --- /* editor_track_unknown.h - handle unknown points * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_TRACK_UNKNOWN__H #define INCLUDE__EDITOR_TRACK_UNKNOWN__H #include "roadmap_navigate.h" #include "editor_track_main.h" int editor_track_unknown_locate_point (int point_id, const RoadMapGpsPosition *gps_position, RoadMapTracking *confirmed_street, RoadMapNeighbour *confirmed_line, TrackNewSegment *new_segment, int max_segments, int force); #endif // INCLUDE__EDITOR_TRACK_UNKNOWN__H --- NEW FILE: editor_track_known.c --- /* editor_track_known.c - handle tracks of known points * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * NOTE: * This file implements all the "dynamic" editor functionality. * The code here is experimental and needs to be reorganized. * * SYNOPSYS: * * See editor_track_unknown.h */ #include <assert.h> #include <stdlib.h> #include "roadmap.h" #include "roadmap_math.h" #include "roadmap_gps.h" #include "roadmap_line.h" #include "../db/editor_db.h" #include "../db/editor_line.h" #include "../db/editor_trkseg.h" #include "../db/editor_route.h" #include "../editor_main.h" #include "../editor_log.h" #include "editor_track_main.h" #include "editor_track_util.h" #include "editor_track_known.h" #define ROADMAP_NEIGHBOURHOUD 16 static RoadMapNeighbour RoadMapNeighbourhood[ROADMAP_NEIGHBOURHOUD]; int editor_track_known_end_segment (PluginLine *previous_line, int last_point_id, PluginLine *line, int is_new_track) { //TODO: add stuff //Notice that previous_line may not be valid (only at first) RoadMapPosition from; RoadMapPosition to; RoadMapPosition *current; int trkseg; int trkseg_line_id; int line_length; int segment_length; int percentage; int flags = 0; editor_log_push ("editor_track_end_known_segment"); assert (last_point_id != 0); if (!last_point_id) return 0; if (editor_db_activate (line->fips) == -1) { editor_db_create (line->fips); if (editor_db_activate (line->fips) == -1) { editor_log_pop (); return 0; } } roadmap_plugin_line_from (line, &from); roadmap_plugin_line_to (line, &to); if (roadmap_plugin_get_id (line) == EditorPluginID) { line_length = editor_line_length (roadmap_plugin_get_line_id (line)); trkseg_line_id = roadmap_plugin_get_line_id (line); } else { line_length = roadmap_line_length (roadmap_plugin_get_line_id (line)); trkseg_line_id = -1; } segment_length = editor_track_util_length (0, last_point_id); editor_log (ROADMAP_INFO, "Ending line %d (plugin_id:%d). Line length:%d, Segment length:%d", roadmap_plugin_get_line_id (line), roadmap_plugin_get_id (line), line_length, segment_length); /* End current segment if we really passed through it * and not only touched a part of it. */ assert (line_length > 0); if (line_length == 0) { editor_log (ROADMAP_ERROR, "line %d (plugin_id:%d) has length of zero.", roadmap_plugin_get_line_id (line), roadmap_plugin_get_id (line)); editor_log_pop (); return 0; } current = track_point_pos (last_point_id); if (roadmap_math_distance (current, &to) > roadmap_math_distance (current, &from)) { flags = ED_TRKSEG_OPPOSITE_DIR; } percentage = 100 * segment_length / line_length; if (percentage < 70) { editor_log (ROADMAP_INFO, "segment is too small to consider: %d%%", percentage); if (segment_length > (editor_track_point_distance ()*1.5)) { trkseg = editor_track_util_create_trkseg (trkseg_line_id, 0, last_point_id, flags|ED_TRKSEG_IGNORE|ED_TRKSEG_END_TRACK); editor_track_add_trkseg (line, trkseg, 0, ED_ROUTE_CAR); editor_log_pop (); return 1; } else { trkseg = editor_track_util_create_trkseg (trkseg_line_id, 0, last_point_id, flags|ED_TRKSEG_IGNORE); editor_track_add_trkseg (line, trkseg, 0, ED_ROUTE_CAR); editor_log_pop (); return 0; } } if (is_new_track) { flags |= ED_TRKSEG_NEW_TRACK; } trkseg = editor_track_util_create_trkseg (trkseg_line_id, 0, last_point_id, flags); if (flags & ED_TRKSEG_OPPOSITE_DIR) { editor_log (ROADMAP_INFO, "Updating route direction: to -> from"); editor_track_add_trkseg (line, trkseg, 2, ED_ROUTE_CAR); } else { editor_log (ROADMAP_INFO, "Updating route direction: from -> to"); editor_track_add_trkseg (line, trkseg, 1, ED_ROUTE_CAR); } editor_log_pop (); return 1; } int editor_track_known_locate_point (int point_id, const RoadMapGpsPosition *gps_position, RoadMapTracking *confirmed_street, RoadMapNeighbour *confirmed_line, RoadMapTracking *new_street, RoadMapNeighbour *new_line) { int found; int count; int current_fuzzy; RoadMapFuzzy best = roadmap_fuzzy_false (); const RoadMapPosition *position = track_point_pos (point_id); RoadMapFuzzy before; if (confirmed_street->valid) { /* We have an existing street match: check if it is still valid. */ before = confirmed_street->fuzzyfied; if (!editor_track_util_get_distance (position, &confirmed_line->line, confirmed_line)) { current_fuzzy = 0; } else { current_fuzzy = roadmap_navigate_fuzzify (confirmed_street, confirmed_line, confirmed_line, gps_position->steering); } if ((current_fuzzy >= before) || roadmap_fuzzy_is_certain(current_fuzzy)) { confirmed_street->fuzzyfied = current_fuzzy; return 0; /* We are on the same street. */ } } /* We must search again for the best street match. */ count = editor_track_util_find_street (gps_position, new_street, confirmed_street, confirmed_line, RoadMapNeighbourhood, ROADMAP_NEIGHBOURHOUD, &found, &best); #if 0 if (count && (RoadMapNeighbourhood[found].distance < 30) && !roadmap_fuzzy_is_acceptable (best)) { /* if we are on a known street, we don't want to start a new road * if we are still close to it. In this case we ignore the fuzzy */ } else #endif if (!roadmap_fuzzy_is_good (best) && roadmap_fuzzy_is_acceptable (best) && confirmed_street->valid) { /* We're not sure that the new line is a real match. * Delay the decision if we're still close to the previous road. */ if (confirmed_line->distance < editor_track_point_distance ()) { return 0; } } if (roadmap_fuzzy_is_acceptable (best)) { if (confirmed_street->valid && (!roadmap_plugin_same_line (&confirmed_line->line, &RoadMapNeighbourhood[found].line) || (confirmed_street->opposite_street_direction != new_street->opposite_street_direction))) { *new_line = RoadMapNeighbourhood[found]; new_street->valid = 1; new_street->fuzzyfied = best; return 1; } *confirmed_line = RoadMapNeighbourhood[found]; confirmed_street->fuzzyfied = best; confirmed_street->valid = 1; return 0; } else { new_street->valid = 0; return 1; } } --- NEW FILE: editor_track_main.c --- /* editor_track.c - street databse layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * NOTE: * This file implements all the "dynamic" editor functionality. * The code here is experimental and needs to be reorganized. * * SYNOPSYS: * * See editor_track.h */ #include <assert.h> #include <string.h> #include <stdlib.h> #include <math.h> #include "roadmap.h" #include "roadmap_math.h" #include "roadmap_gps.h" #include "roadmap_fuzzy.h" #include "roadmap_navigate.h" #include "roadmap_screen.h" #include "../editor_main.h" #include "../db/editor_db.h" #include "../db/editor_point.h" #include "../db/editor_route.h" #include "../editor_log.h" #include "editor_track_filter.h" #include "editor_track_util.h" #include "editor_track_known.h" #include "editor_track_unknown.h" #include "editor_track_main.h" #define GPS_POINTS_DISTANCE "10m" #define MAX_POINTS_IN_SEGMENT 10000 typedef struct { RoadMapGpsPosition gps_point; time_t time; } TrackPoint; static TrackPoint TrackPoints[MAX_POINTS_IN_SEGMENT]; static int points_count = 0; static int cur_active_line = 0; static RoadMapGpsPosition TrackLastPosition; static RoadMapTracking TrackConfirmedStreet = ROADMAP_TRACKING_NULL; static RoadMapNeighbour TrackPreviousLine = ROADMAP_NEIGHBOUR_NULL; static RoadMapNeighbour TrackConfirmedLine = ROADMAP_NEIGHBOUR_NULL; static NodeNeighbour cur_node = {-1, -1}; static int is_new_track = 1; RoadMapPosition* track_point_pos (int ... [truncated message content] |
Update of /cvsroot/roadmap/roadmap_editor/src/editor/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2745/src/editor/db Added Files: editor_db.c editor_db.h editor_dictionary.c editor_dictionary.h editor_line.c editor_line.h editor_override.c editor_override.h editor_point.c editor_point.h editor_route.c editor_route.h editor_shape.c editor_shape.h editor_square.c editor_square.h editor_street.c editor_street.h editor_trkseg.c editor_trkseg.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- NEW FILE: editor_db.c --- /* editor_db.c - databse layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_db.h */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "roadmap.h" #include "roadmap_file.h" #include "roadmap_path.h" #include "roadmap_county.h" #include "roadmap_line.h" #include "roadmap_locator.h" #include "buildmap.h" #include "../editor_log.h" #include "editor_db.h" #include "editor_point.h" #include "editor_shape.h" #include "editor_line.h" #include "editor_square.h" #include "editor_street.h" #include "editor_dictionary.h" #include "editor_route.h" #include "editor_override.h" #include "editor_trkseg.h" /* Use the biggest item size to set the default block size */ #define DB_DEFAULT_BLOCK_SIZE (2 * sizeof (editor_db_square)) /* TODO create a generic cache system - this was copied from roadmap_locator */ #define EDITOR_CACHE_SIZE 10 struct editor_cache_entry { int fips; unsigned int last_access; }; static struct editor_cache_entry *EditorCache = NULL; static int EditorCacheSize = 0; static int EditorActiveCounty; static int EditorNoCounty = -1; static roadmap_db_model *EditorDBModel; static editor_db_header *ActiveDBHeader; static char *ActiveBlocks; static void editor_header_activate (void *context) { ActiveDBHeader = (editor_db_header *) context; } static void editor_blocks_activate (void *context) { ActiveBlocks = (char *) context; } roadmap_db_handler EditorHeaderHandler = { "header", editor_map, editor_header_activate, editor_unmap }; roadmap_db_handler EditorBlocksHandler = { "data_blocks", editor_map, editor_blocks_activate, editor_unmap }; static void editor_db_configure (void) { if (EditorCache == NULL) { EditorDBModel = roadmap_db_register (EditorDBModel, "data_blocks", &EditorBlocksHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "override", &EditorOverrideHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "route", &EditorRouteHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "trkseg", &EditorTrksegHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "squares", &EditorSquaresHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "lines", &EditorLinesHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "ranges", &EditorRangeHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "streets", &EditorStreetHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "shape", &EditorShapeHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "points_del", &EditorPointsDelHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "points", &EditorPointsHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "header", &EditorHeaderHandler); EditorDBModel = roadmap_db_register (EditorDBModel, "strings", &EditorDictionaryHandler); EditorCacheSize = roadmap_option_cache (); if (EditorCacheSize < EDITOR_CACHE_SIZE) { EditorCacheSize = EDITOR_CACHE_SIZE; } EditorCache = (struct editor_cache_entry *) calloc (EditorCacheSize, sizeof(struct editor_cache_entry)); roadmap_check_allocated (EditorCache); } } static void editor_db_remove (int index) { char map_name[64]; snprintf (map_name, sizeof(map_name), "edt%05d", EditorCache[index].fips); roadmap_db_close (map_name); EditorCache[index].fips = 0; EditorCache[index].last_access = 0; } static unsigned int editor_db_new_access (void) { static unsigned int EditorDBAccessCount = 0; int i; EditorDBAccessCount += 1; if (EditorDBAccessCount == 0) { /* Rollover. */ for (i = 0; i < EditorCacheSize; i++) { if (EditorCache[i].fips > 0) { editor_db_remove (i); } } EditorActiveCounty = 0; EditorDBAccessCount += 1; } return EditorDBAccessCount; } static int editor_db_allocate_new_block (editor_db_section *section, int block_id) { if (section->max_blocks == block_id) return -1; if (ActiveDBHeader->num_used_blocks == ActiveDBHeader->num_total_blocks) { return -1; } section->blocks[block_id] = ActiveDBHeader->num_used_blocks++; return 0; } static buildmap_db *add_db_section(buildmap_db *parent, const char *name, const void* private_init, int private_header_size, int item_size, int max_items) { buildmap_db *root; editor_db_section *section; char *private_data; int max_blocks; int i; max_blocks = (item_size * max_items)/DB_DEFAULT_BLOCK_SIZE + 1; root = buildmap_db_add_section (parent, name); buildmap_db_add_data (root, 1, sizeof(editor_db_section) + private_header_size); /* we already got one block allocated in editor_db_section */ buildmap_db_add_data (root, max_blocks-1, sizeof(int)); private_data = buildmap_db_get_data (root); section = (editor_db_section *) (private_data + private_header_size); if (private_init != NULL) { memcpy (private_data, private_init, private_header_size); } section->num_items = 0; section->max_items = max_items; section->max_blocks = max_blocks; section->item_size = item_size; section->items_per_block = DB_DEFAULT_BLOCK_SIZE / item_size; for (i=0; i < section->max_blocks; i++) { section->blocks[i] = -1; } return root; } static void add_db_string_section (buildmap_db *parent, const char *name) { buildmap_db *root; root = buildmap_db_add_section (parent, name); add_db_section (root, "references", NULL, 0, sizeof(struct ed_dictionary_reference), DICTIONARY_INDEX_SIZE * 10); add_db_section (root, "trees", NULL, 0, sizeof(struct ed_dictionary_tree), DICTIONARY_INDEX_SIZE); add_db_section (root, "data", NULL, 0, 1, DICTIONARY_DATA_SIZE); } int editor_db_create (int fips) { char name[100]; buildmap_db *root; editor_db_header *header; int square_count; const RoadMapArea *edges; editor_log_push ("editor_db_create"); if (roadmap_locator_activate (fips) != ROADMAP_US_OK) { editor_log (ROADMAP_ERROR, "Can't activate RoadMap fips: %d", fips); editor_log_pop (); return -1; } edges = roadmap_county_get_edges (fips); if (edges == NULL) { editor_log (ROADMAP_ERROR, "Can't get edges of fips: %d", fips); editor_log_pop (); return -1; } snprintf (name, sizeof(name), "edt%05d", fips); if (buildmap_db_open (roadmap_path_user(), name) == -1) { editor_log (ROADMAP_ERROR, "Can't create new database: %s/%s", roadmap_path_user(), name); editor_log_pop (); return -1; } root = buildmap_db_add_section (NULL, "header"); buildmap_db_add_data (root, 1, sizeof(editor_db_header)); header = (editor_db_header *) buildmap_db_get_data (root); memset (header, 0, sizeof (editor_db_header)); header->fips = fips; header->edges = *edges; header->block_size = DB_DEFAULT_BLOCK_SIZE; header->num_total_blocks = DB_DEFAULT_INITIAL_BLOCKS; add_db_section (NULL, "points", NULL, 0, sizeof(editor_db_point), EDITOR_MAX_POINTS); add_db_section (NULL, "points_del", NULL, 0, sizeof(editor_db_del_point), EDITOR_MAX_POINTS); add_db_section (NULL, "shape", NULL, 0, sizeof(editor_db_shape), EDITOR_MAX_SHAPES); add_db_section (NULL, "lines", NULL, 0, sizeof(editor_db_line), EDITOR_MAX_LINES); square_count = ((edges->east - edges->west) / EDITOR_DB_LONGITUDE_STEP + 1) * ((edges->north - edges->south) / EDITOR_DB_LATITUDE_STEP + 1); add_db_section (NULL, "squares", NULL, 0, sizeof(editor_db_square), square_count); add_db_section (NULL, "streets", NULL, 0, sizeof(editor_db_street), EDITOR_MAX_STREETS); add_db_section (NULL, "ranges", NULL, 0, sizeof(editor_db_range), EDITOR_MAX_LINES*2); add_db_section (NULL, "trkseg", &editor_db_trkseg_private_init, sizeof(editor_db_trkseg_private), sizeof(editor_db_trkseg), EDITOR_MAX_LINES*2); add_db_section (NULL, "route", NULL, 0, sizeof(editor_db_route_segment), EDITOR_MAX_LINES*2); root = buildmap_db_add_section (NULL, "override"); add_db_section (root, "index", NULL, 0, sizeof(int), roadmap_line_count ()); add_db_section (root, "data", NULL, 0, sizeof(editor_db_override), EDITOR_MAX_LINES); root = buildmap_db_add_section (NULL, "strings"); add_db_string_section (root, "streets"); add_db_string_section (root, "cities"); add_db_string_section (root, "types"); add_db_string_section (root, "zips"); add_db_string_section (root, "t2s"); root = buildmap_db_add_section (NULL, "data_blocks"); header->file_size = buildmap_db_add_data (root, DB_DEFAULT_INITIAL_BLOCKS, DB_DEFAULT_BLOCK_SIZE); buildmap_db_close (); if (EditorNoCounty == fips) { EditorNoCounty = -1; } editor_log_pop (); return 0; } static int editor_db_open (int fips) { int i; int access; int oldest = 0; char map_name[64]; if (fips <= 0) { return -1; } snprintf (map_name, sizeof(map_name), "%s/edt%05d", roadmap_path_user(), fips); /* Look for the oldest entry in the cache. */ for (i = EditorCacheSize-1; i >= 0; --i) { if (EditorCache[i].fips == fips) { roadmap_db_activate (map_name); EditorActiveCounty = fips; return 0; } if (EditorCache[i].last_access < EditorCache[oldest].last_access) { oldest = i; } } if (EditorCache[oldest].fips > 0) { editor_db_remove (oldest); if (EditorCache[oldest].fips == EditorActiveCounty) { EditorActiveCounty = 0; } } access = editor_db_new_access (); if (! roadmap_db_open (map_name, EditorDBModel, "rw")) { return -1; } EditorCache[oldest].fips = fips; EditorCache[oldest].last_access = access; EditorActiveCounty = fips; return 0; } int editor_db_activate (int fips) { int res; if (fips == -1) return -1; if (EditorActiveCounty == fips) { return 0; } if (EditorNoCounty == fips) { return -1; } editor_db_configure(); res = editor_db_open (fips); if (res == -1) { EditorNoCounty = fips; } return res; } void editor_db_mark_cfcc (int cfcc) { assert ((unsigned)cfcc < 8*sizeof(cfcc)); ActiveDBHeader->cfccs |= (1 << cfcc); } int editor_db_is_cfcc_marked (int cfcc) { assert ((unsigned)cfcc < 8*sizeof(cfcc)); return ActiveDBHeader->cfccs & (1 << cfcc); } int editor_db_add_item (editor_db_section *section, void *data) { int block = section->num_items / section->items_per_block; int block_offset = section->num_items % section->items_per_block; char *item_addr; if ((section->num_items == 0) || ((section->num_items % section->items_per_block) == 0)) { if (editor_db_allocate_new_block (section, block) == -1) { return -1; } } if (data != NULL) { item_addr = ActiveBlocks + section->blocks[block] * ActiveDBHeader->block_size + block_offset * section->item_size; memcpy (item_addr, data, section->item_size); } return section->num_items++; } int editor_db_insert_item (editor_db_section *section, void *data, int pos) { int i; assert ((pos >= 0) && (pos <= section->num_items)); if (editor_db_add_item (section, data) == -1) { editor_db_grow (); if (editor_db_add_item (section, data) == -1) { return -1; } } if (pos == (section->num_items-1)) return 0; //TODO optimize with memove for (i=section->num_items-1; i>pos; i--) { memcpy (editor_db_get_item (section, i, 0, NULL), editor_db_get_item (section, i-1, 0, NULL), section->item_size); } memcpy (editor_db_get_item (section, pos, 0, NULL), data, section->item_size); return 0; } int editor_db_get_item_count (editor_db_section *section) { return section->num_items; } void *editor_db_get_item (editor_db_section *section, int item_id, int create, editor_item_init init) { int block = item_id / section->items_per_block; int block_offset = item_id % section->items_per_block; assert (item_id < section->max_items); if (section->blocks[block] == -1) { if (!create) return NULL; if (editor_db_allocate_new_block (section, block) == -1) { return NULL; } if (init != NULL) { int i; char *addr = ActiveBlocks + section->blocks[block] * ActiveDBHeader->block_size; for (i=0; i<section->items_per_block; i++) { (*init) (addr + i * section->item_size); } } } return ActiveBlocks + section->blocks[block] * ActiveDBHeader->block_size + block_offset * section->item_size; } RoadMapArea *editor_db_get_active_edges(void) { if (ActiveDBHeader == NULL) return NULL; return &ActiveDBHeader->edges; } int editor_db_get_block_size (void) { return ActiveDBHeader->block_size; } void *editor_db_get_last_item (editor_db_section *section) { int num_items = section->num_items; if (num_items == 0) return NULL; return editor_db_get_item (section, num_items-1, 0, NULL); } int editor_db_allocate_items (editor_db_section *section, int count) { int block = section->num_items / section->items_per_block; int block_offset = section->num_items % section->items_per_block; int first_item_id; if (count > section->items_per_block) return -1; if ((section->num_items == 0) || (block_offset == 0)) { if (editor_db_allocate_new_block (section, block) == -1) { return -1; } } if ((block_offset + count * section->item_size) > ActiveDBHeader->block_size) { block++; if (editor_db_allocate_new_block (section, block) == -1) { return -1; } section->num_items = block * section->items_per_block; block_offset = 0; } first_item_id = section->num_items; section->num_items += count; return first_item_id; } /* FIXME * Hack alert! * This should be rewritten so it uses the roadmap_db layer to grow. * Currently, it just grows the file and changes the blocks number in * the editor header section. The roadmap_db layer doesn't know about * the new size which is bad. */ int editor_db_grow (void) { int i; int file_size; int fips = ActiveDBHeader->fips; char map_name[255]; /* NOTE that after the call to editor_db_remove(), * ActiveDBHeader pointer becomes invalid. */ if (ActiveDBHeader->num_used_blocks < ActiveDBHeader->num_total_blocks) { return 0; } snprintf (map_name, sizeof(map_name), "edt%05d.rdm", ActiveDBHeader->fips); ActiveDBHeader->num_total_blocks += DB_DEFAULT_INITIAL_BLOCKS; ActiveDBHeader->file_size += (DB_DEFAULT_INITIAL_BLOCKS * ActiveDBHeader->block_size); file_size = ActiveDBHeader->file_size; for (i = EditorCacheSize-1; i >= 0; --i) { if (EditorCache[i].fips == ActiveDBHeader->fips) { editor_db_remove (i); break; } } assert (i >= 0); if (roadmap_file_truncate (roadmap_path_user(), map_name, file_size) == -1) { editor_log (ROADMAP_ERROR, "Can't grow database."); return -1; } return editor_db_open (fips); } int editor_db_locator(const RoadMapPosition *position) { RoadMapArea *edges = editor_db_get_active_edges (); static int *fips; int count; if (edges != NULL) { if ((position->longitude >= edges->west) && (position->longitude <= edges->east) && (position->latitude >= edges->south) && (position->latitude <= edges->north)) { return ActiveDBHeader->fips; } } count = roadmap_locator_by_position (position, &fips); if (count) return fips[0]; return -1; } void *editor_map (roadmap_db *root) { return roadmap_db_get_data (root); } void editor_unmap (void *context) {} --- NEW FILE: editor_point.c --- /* editor_point.c - point databse layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_point.h */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "roadmap.h" #include "roadmap_file.h" #include "roadmap_path.h" #include "roadmap_point.h" #include "../editor_log.h" #include "editor_db.h" #include "editor_point.h" static editor_db_section *ActivePointsDB; static editor_db_section *ActivePointsDelDB; static void editor_points_activate (void *context) { ActivePointsDB = (editor_db_section *) context; } static void editor_points_del_activate (void *context) { ActivePointsDelDB = (editor_db_section *) context; } roadmap_db_handler EditorPointsHandler = { "points", editor_map, editor_points_activate, editor_unmap }; roadmap_db_handler EditorPointsDelHandler = { "points_del", editor_map, editor_points_del_activate, editor_unmap }; int editor_point_add (RoadMapPosition *position, int flags, int roadmap_id) { editor_db_point point; int id; point.longitude = position->longitude; point.latitude = position->latitude; point.flags = flags; point.roadmap_id = roadmap_id; id = editor_db_add_item (ActivePointsDB, &point); if (id == -1) { editor_db_grow (); id = editor_db_add_item (ActivePointsDB, &point); } return id; } void editor_point_position (int point, RoadMapPosition *position) { editor_db_point *point_st = editor_db_get_item (ActivePointsDB, point, 0, 0); assert(point_st != NULL); position->longitude = point_st->longitude; position->latitude = point_st->latitude; } int editor_point_set_pos (int point, RoadMapPosition *position) { editor_db_point *point_st = editor_db_get_item (ActivePointsDB, point, 0, 0); assert(point_st != NULL); if (point_st->flags & ED_POINT_SHARED) { position->longitude = point_st->longitude; position->latitude = point_st->latitude; return -1; } point_st->longitude = position->longitude; point_st->latitude = position->latitude; return 0; } int editor_point_roadmap_to_editor (int roadmap_id) { editor_db_del_point *del_point_ptr; editor_db_del_point del_point; int ed_point_id; RoadMapPosition point_pos; int begin = -1; int end; end = editor_db_get_item_count (ActivePointsDelDB); if (end > 0) { while (end - begin > 1) { int middle = (begin + end) / 2; del_point_ptr = editor_db_get_item (ActivePointsDelDB, middle, 0, 0); assert (del_point_ptr != NULL); if (roadmap_id < del_point_ptr->roadmap_id) { end = middle; } if (roadmap_id > del_point_ptr->roadmap_id) { begin = middle; } else { end = middle; break; } } if (roadmap_id == del_point_ptr->roadmap_id) { return del_point_ptr->editor_id; } } roadmap_point_position (roadmap_id, &point_pos); ed_point_id = editor_point_add (&point_pos, ED_POINT_SHARED, roadmap_id); if (ed_point_id == -1) { editor_log (ROADMAP_ERROR, "editor_point_roadmap_to_editor - Can't insert new point"); return -1; } del_point.roadmap_id = roadmap_id; del_point.editor_id = ed_point_id; if (editor_db_insert_item (ActivePointsDelDB, &del_point, end) == -1) { editor_db_grow (); if (editor_db_insert_item (ActivePointsDelDB, &del_point, end) == -1) { editor_log (ROADMAP_ERROR, "editor_point_roadmap_to_editor - Can't insert new item"); return -1; } } return ed_point_id; } void editor_point_roadmap_id (int point_id, int *roadmap_id) { editor_db_point *point_st = editor_db_get_item (ActivePointsDB, point_id, 0, 0); assert(point_st != NULL); *roadmap_id = point_st->roadmap_id; } --- NEW FILE: editor_line.c --- /* editor_line.c - line databse layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_line.h */ #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "roadmap.h" #include "roadmap_file.h" #include "roadmap_path.h" #include "roadmap_locator.h" #include "roadmap_point.h" #include "roadmap_line.h" #include "roadmap_square.h" #include "roadmap_shape.h" #include "roadmap_street.h" #include "roadmap_math.h" #include "roadmap_navigate.h" #include "../editor_log.h" #include "../editor_main.h" #include "editor_db.h" #include "editor_point.h" #include "editor_line.h" #include "editor_trkseg.h" #include "editor_shape.h" #include "editor_square.h" #include "editor_street.h" #include "editor_route.h" #include "editor_override.h" static editor_db_section *ActiveLinesDB; static editor_db_section *ActiveLinesDelDB; static void editor_lines_activate (void *context) { ActiveLinesDB = (editor_db_section *) context; } static void editor_lines_del_activate (void *context) { ActiveLinesDelDB = (editor_db_section *) context; } roadmap_db_handler EditorLinesHandler = { "lines", editor_map, editor_lines_activate, editor_unmap }; roadmap_db_handler EditorLinesDelHandler = { "lines_del", editor_map, editor_lines_del_activate, editor_unmap }; #if 0 int editor_line_del_add (int line_id, int cfcc) { int id = editor_db_add_item (ActiveLinesDelDB, &line_id); if (id == -1) { editor_db_grow (); id = editor_db_add_item (ActiveLinesDelDB, &line_id); } if (id != -1) { editor_db_mark_cfcc (cfcc); } return id; } void editor_line_del_remove (int line_id) { int *line_db = (int *) editor_db_get_item (ActiveLinesDelDB, line_id, 0, NULL); assert (line_db != NULL); *line_db = -1; } int editor_line_del_find (int line_id, int cfcc) { int count; int i; if (cfcc > 0 && !editor_db_is_cfcc_marked (cfcc)) return 0; count = editor_db_get_item_count (ActiveLinesDelDB); for (i=0; i<count; i++) { if (line_id == *(int *)editor_db_get_item (ActiveLinesDelDB, i, 0, NULL)) { return 1; } } return 0; } #endif int editor_line_add (int p_from, int p_to, int trkseg, int cfcc, int flags) { editor_db_line line; int id; line.point_from = p_from; line.point_to = p_to; line.first_trkseg = line.last_trkseg = trkseg; line.cfcc = cfcc; line.flags = flags|ED_LINE_DIRTY; line.street = -1; line.range = -1; line.route = -1; id = editor_db_add_item (ActiveLinesDB, &line); if (id == -1) { editor_db_grow (); id = editor_db_add_item (ActiveLinesDB, &line); } if (id == -1) return -1; assert (editor_line_length (id) > 0); if (editor_line_length (id) == 0) return -1; editor_square_add_line (id, p_from, p_to, trkseg, cfcc); editor_log (ROADMAP_INFO, "Adding new line - from:%d, to:%d, trkseg:%d, cfcc:%d, flags:%d", p_from, p_to, trkseg, cfcc, flags); if (id == -1) { editor_log (ROADMAP_ERROR, "Can't add new line."); } return id; } void editor_line_get (int line, RoadMapPosition *from, RoadMapPosition *to, int *trkseg, int *cfcc, int *flags) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); if (from) editor_point_position (line_db->point_from, from); if (to) editor_point_position (line_db->point_to, to); if (trkseg) *trkseg = line_db->first_trkseg; if (cfcc) *cfcc = line_db->cfcc; if (flags) *flags = line_db->flags; } void editor_line_get_points (int line, int *from, int *to) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); *from = line_db->point_from; *to = line_db->point_to; } void editor_line_modify_properties (int line, int cfcc, int flags) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); assert (line_db != NULL); if (line_db == NULL) return; line_db->cfcc = cfcc; line_db->flags = flags; } int editor_line_copy (int line, int cfcc, int fips) { int p_from, p_to; int trkseg_from; RoadMapPosition pos; int trkseg; int j; int square; int first_shape_line; int last_shape_line; int first; int last; int editor_first_shape = -1; int editor_last_shape = -2; int line_id; editor_db_line *line_db; editor_log_push ("editor_line_copy"); roadmap_locator_activate (fips); if (editor_override_line_set_flags (line, editor_override_line_get_flags (line)|ED_LINE_DELETED)) { editor_log (ROADMAP_ERROR, "Can't override roadmap line."); editor_log_pop (); return -1; } roadmap_line_points (line, &p_from, &p_to); p_from = editor_point_roadmap_to_editor (p_from); p_to = editor_point_roadmap_to_editor (p_to); if ((p_from == -1) || (p_to == -1)) { editor_log (ROADMAP_ERROR, "Can't copy points."); editor_log_pop (); return -1; } roadmap_line_from (line, &pos); trkseg_from = editor_point_add (&pos, 0, -1); if (trkseg_from == -1) { editor_log (ROADMAP_ERROR, "Can't create points."); editor_log_pop (); return -1; } square = roadmap_square_search (&pos); //TODO get avg speed and compute time for this trkseg if ((square >= 0) && (roadmap_shape_in_square (square, &first_shape_line, &last_shape_line) > 0) && (roadmap_shape_of_line (line, first_shape_line, last_shape_line, &first, &last) > 0)) { RoadMapPosition shape_pos; shape_pos = pos; for (j = first; j <= last; j++) { roadmap_shape_get_position (j, &shape_pos); editor_last_shape = editor_shape_add (shape_pos.longitude - pos.longitude, shape_pos.latitude - pos.latitude, -1); if (editor_last_shape == -1) { editor_log (ROADMAP_ERROR, "Can't create new shape. Line creation is aborted."); editor_log_pop (); return -1; } if (editor_first_shape == -1) { editor_first_shape = editor_last_shape; } pos = shape_pos; } } trkseg = editor_trkseg_add (-1, trkseg_from, editor_first_shape, editor_last_shape, -1, -1, ED_TRKSEG_FAKE|ED_TRKSEG_NO_GLOBAL); if (trkseg == -1) { editor_log_pop (); return -1; } line_id = editor_line_add (p_from, p_to, trkseg, cfcc, 0); if (line_id == -1) { editor_log_pop (); return -1; } line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line_id, 0, NULL); j = editor_trkseg_dup (trkseg); if (j == -1) { editor_log_pop (); return -1; } editor_trkseg_connect_roads (trkseg, j); editor_trkseg_set_line (line_db->first_trkseg, line_id); /* Add roadmap line trksegs to copied line */ editor_override_line_get_trksegs (line, &first, &last); if (first != -1) { line_db->last_trkseg = last; editor_trkseg_connect_roads (j, first); } else { line_db->last_trkseg = j; } line_db->first_trkseg = trkseg; editor_route_segment_copy (line, 0, line_id); editor_street_copy_street (line, 0, line_id); editor_street_copy_range (line, 0, line_id); //TODO: copy street editor_log (ROADMAP_INFO, "Copied roadmap line:%d as editor line:%d", line, line_id); editor_log_pop (); return line_id; } int editor_line_split (PluginLine *line, RoadMapPosition *previous_point, RoadMapPosition *split_position, int *split_point) { RoadMapPosition from; RoadMapPosition to; EditorStreetProperties properties; int i; int line_id; int new_point; int new_line_id; editor_db_line *line_db; int azymuth; int lines[2]; int trkseg; int new_trkseg_first; int new_trkseg_curr; int old_trkseg_first; int old_trkseg_curr; int cfcc = line->cfcc; editor_log_push ("editor_line_split"); if (roadmap_plugin_get_id (line) != EditorPluginID) { line_id = editor_line_copy (line->line_id, cfcc, line->fips); if (line_id == -1) { editor_log (ROADMAP_ERROR, "Can't split line. Line copy failed."); editor_log_pop (); return -1; } roadmap_plugin_set_line (line, EditorPluginID, line_id, cfcc, line->fips); } else { line_id = roadmap_plugin_get_line_id (line); } line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line_id, 0, NULL); editor_point_position (line_db->point_from, &from); editor_point_position (line_db->point_to, &to); if (*split_point != -1) { new_point = *split_point; } else { *split_point = new_point = editor_point_add (split_position, 0, -1); if (new_point == -1) { editor_log (ROADMAP_ERROR, "Can't split line. Add point failed."); editor_log_pop (); return -1; } } /* split trksegs */ trkseg = line_db->first_trkseg; new_trkseg_first = new_trkseg_curr = -1; old_trkseg_first = old_trkseg_curr = -1; while (trkseg != -1) { int new_trkseg_prev = new_trkseg_curr; int old_trkseg_prev = old_trkseg_curr; int trkseg_flags; int global_next; int new_trkseg; editor_trkseg_get (trkseg, NULL, NULL, NULL, &trkseg_flags); new_trkseg = editor_trkseg_split (trkseg, &from, &to, split_position); if (trkseg_flags & ED_TRKSEG_OPPOSITE_DIR) { old_trkseg_curr = new_trkseg; new_trkseg_curr = trkseg; } else { old_trkseg_curr = trkseg; new_trkseg_curr = new_trkseg; } if (new_trkseg_first == -1) { new_trkseg_first = new_trkseg_curr; } else { editor_trkseg_connect_roads (new_trkseg_prev, new_trkseg_curr); } if (old_trkseg_first == -1) { old_trkseg_first = old_trkseg_curr; } else { editor_trkseg_connect_roads (old_trkseg_prev, old_trkseg_curr); } global_next = editor_trkseg_next_in_global (trkseg); editor_trkseg_connect_global (trkseg, new_trkseg); editor_trkseg_connect_global (new_trkseg, global_next); trkseg = editor_trkseg_next_in_road (trkseg); } new_line_id = editor_line_add (new_point, line_db->point_to, new_trkseg_first, line_db->cfcc, line_db->flags); if (new_line_id == -1) { editor_log (ROADMAP_ERROR, "Can't create new line."); editor_log_pop (); return -1; } line_db->point_to = new_point; line_db->flags |= ED_LINE_EXPLICIT_SPLIT; editor_trkseg_set_line (new_trkseg_first, new_line_id); editor_line_set_trksegs (new_line_id, new_trkseg_first, new_trkseg_curr); editor_trkseg_set_line (old_trkseg_first, line_id); editor_line_set_trksegs (line_id, old_trkseg_first, old_trkseg_curr); editor_route_segment_copy (line_id, 1, new_line_id); editor_street_copy_street (line_id, 1, new_line_id); editor_street_get_properties (line_id, &properties); if (properties.range_id != -1) { int l_from, l_to, r_from, r_to; editor_street_copy_range (line_id, 1, new_line_id); editor_street_get_street_range (&properties, ED_STREET_LEFT_SIDE, &l_from, &l_to); editor_street_get_street_range (&properties, ED_STREET_RIGHT_SIDE, &r_from, &r_to); lines[0] = line_id; lines[1] = new_line_id; editor_street_distribute_range (lines, 2, l_from, l_to, r_from, r_to); } editor_log (ROADMAP_INFO, "split %d, to %d & %d", line_id, line_id, new_line_id); azymuth = roadmap_math_azymuth (previous_point, split_position); if (roadmap_math_delta_direction (azymuth, roadmap_math_azymuth (&from, split_position)) > roadmap_math_delta_direction (azymuth, roadmap_math_azymuth (&to, split_position))) { i = line_id; line->line_id = new_line_id; new_line_id = 1; } editor_log (ROADMAP_INFO, "current line: %d", line_id); editor_log_pop (); return new_line_id; } int editor_line_length (int line) { RoadMapPosition p1; RoadMapPosition p2; editor_db_line *line_db; int length = 0; int trk_from; int first_shape; int last_shape; int i; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); editor_trkseg_get (line_db->first_trkseg, &trk_from, &first_shape, &last_shape, NULL); editor_point_position (line_db->point_from, &p1); if (first_shape > -1) { editor_point_position (trk_from, &p2); for (i=first_shape; i<=last_shape; i++) { editor_shape_position (i, &p2); length += roadmap_math_distance (&p1, &p2); p1 = p2; } } editor_point_position (line_db->point_to, &p2); length += roadmap_math_distance (&p1, &p2); return length; } int editor_line_get_street (int line, int *street, int *range) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); if (line_db == NULL) return -1; if (street != NULL) *street = line_db->street; if (range != NULL) *range = line_db->range; return 0; } int editor_line_set_street (int line, int *street, int *range) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); if (line_db == NULL) return -1; if (street != NULL) line_db->street = *street; if (range != NULL) line_db->range = *range; return 0; } int editor_line_get_route (int line) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); if (line_db == NULL) return -1; return line_db->route; } int editor_line_set_route (int line, int route) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); if (line_db == NULL) return -1; line_db->route = route; return 0; } void editor_line_get_trksegs (int line, int *first, int *last) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); if (line_db == NULL) { *first = *last = -1; return; } *first = line_db->first_trkseg; *last = line_db->last_trkseg; } void editor_line_set_trksegs (int line, int first, int last) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); if (line_db == NULL) { return; } line_db->first_trkseg = first; line_db->last_trkseg = last; } double editor_line_get_avg_speed (int line, int direction) { editor_db_line *line_db; int length; time_t start_time; time_t end_time; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line, 0, NULL); length = editor_line_length (line); if (!length) return -1; editor_trkseg_get_time (line_db->first_trkseg, &start_time, &end_time); if (start_time == end_time) return -1; return 1.0 * length / (end_time - start_time); } int editor_line_get_count (void) { return ActiveLinesDB->num_items; } int editor_line_mark_dirty (int line_id) { editor_db_line *line_db; line_db = (editor_db_line *) editor_db_get_item (ActiveLinesDB, line_id, 0, NULL); if (line_db == NULL) return -1; line_db->flags |= ED_LINE_DIRTY; return 0; } --- NEW FILE: editor_route.h --- /* editor_route.h - database layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_ROUTE__H #define INCLUDE__EDITOR_ROUTE__H #define ED_ROUTE_CAR 0x0001 #define ED_ROUTE_STOP_LIGHT 0x8000 typedef short EditorRouteFlag; typedef struct editor_route_segment_s { EditorRouteFlag from_flags; EditorRouteFlag to_flags; } editor_db_route_segment; int editor_route_segment_add (short from_flags, short to_flags) ; void editor_route_segment_get (int route, short *from_flags, short *to_flags); void editor_route_segment_set (int route, short from_flags, short to_flags); void editor_route_segment_copy (int source_line, int plugin_id, int dest_line); int editor_route_get_direction (int route_id, int who); extern roadmap_db_handler EditorRouteHandler; #endif // INCLUDE__EDITOR_ROUTE__H --- NEW FILE: editor_dictionary.c --- /* editor_dictionary.c - Build a Map dictionary table & index for RoadMap. * * LICENSE: * * Copyright 2002 Pascal F. Martin * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * BuildMapDictionary editor_dictionary_open (char *name); * int editor_dictionary_add * (BuildMapDictionary d, char *string, int length); * int editor_dictionary_locate * (BuildMapDictionary d, char *string); * char *editor_dictionary_get (BuildMapDictionary d, int index); * void editor_dictionary_save (void); * void editor_dictionary_summary (void); * void editor_dictionary_reset (void); * * These functions are used to build a dictionary of strings from * the Tiger maps. The objective is double: (1) reduce the size of * the Tiger data by sharing all duplicated strings and (2) serve * as the basis for a fast search mechanism by providing an index * table designed to help progressive search (i.e. all possible * characters following the latest input). * * Every string in the dictionary can be retrieved using a character * search tree: * - each node of the tree represents one character in the string. * - each node is a list of references to the next level, one * reference for each possible character in the referenced strings. * - the references are indexes into an indirection table (to keep * the references small), either the string table (leaf) * or the node table (node). */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <assert.h> #include "roadmap.h" #include "editor_db.h" #include "editor_dictionary.h" #define DICTIONARY_MAX_VOLUME_COUNT 16 static struct ed_dictionary_volume *DictionaryVolume = NULL; static int DictionaryDebugOn = 0; static void editor_dictionary_print_subtree (struct ed_dictionary_volume *dictionary, int tree_id) { struct ed_dictionary_reference *reference = NULL; int reference_id; struct ed_dictionary_tree *tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, tree_id, 0, NULL); if (tree == NULL) return; fprintf (stdout, "%*.*s --- start of tree %d (count = %d)\n", tree->position, tree->position, "", tree_id, editor_db_get_item_count (dictionary->tree_db_section)); for (reference_id = tree->first; reference_id != -1; reference_id = reference->next) { reference = (struct ed_dictionary_reference *) editor_db_get_item (dictionary->reference_db_section, reference_id, 0, NULL); fprintf (stdout, "%*.*s '%c' [%d]", tree->position, tree->position, "", reference->character, tree->position); switch (reference->type) { case ROADMAP_DICTIONARY_STRING: fprintf (stdout, " --> \"%s\"\n", (char *) editor_db_get_item (dictionary->data_db_section, reference->child, 0, NULL)); break; case ROADMAP_DICTIONARY_TREE: fprintf (stdout, "\n"); editor_dictionary_print_subtree (dictionary, reference->child); break; default: fprintf (stdout, "\n"); roadmap_log (ROADMAP_FATAL, "corrupted node type %d when printing tree", reference->type); } } } static void editor_dictionary_fatal (struct ed_dictionary_volume *dictionary, int tree_id) { editor_dictionary_print_subtree (dictionary, 0); roadmap_log (ROADMAP_FATAL, "end of corrupted tree dump at tree %d.", tree_id); } static struct ed_dictionary_reference * editor_dictionary_get_reference (struct ed_dictionary_volume *dictionary, struct ed_dictionary_tree *tree, char c) { struct ed_dictionary_reference *reference; int reference_id; c = tolower(c); if (DictionaryDebugOn) { printf ("search for '%c' at position %d in tree 0x%p\n", c, tree->position, tree); for (reference_id = tree->first; reference_id != -1; reference_id = reference->next) { reference = (struct ed_dictionary_reference *) editor_db_get_item (dictionary->reference_db_section, reference_id, 0, NULL); printf ("compare to {'%c', %s, %d}\n", reference->character, (reference->type == ROADMAP_DICTIONARY_STRING) ? "string" : "tree", reference->child); if (reference->character == c) { printf (" found.\n"); return reference; } } printf (" not found.\n"); return NULL; } for (reference_id = tree->first; reference_id != -1; reference_id = reference->next) { reference = (struct ed_dictionary_reference *) editor_db_get_item (dictionary->reference_db_section, reference_id, 0, NULL); if (reference->character == c) { return reference; } } return NULL; } static int editor_dictionary_add_reference (struct ed_dictionary_volume *dictionary, struct ed_dictionary_tree *tree, char character, char type, int child) { struct ed_dictionary_reference reference; int reference_id; reference.type = type; reference.child = child; reference.character = tolower(character); reference.next = tree->first; reference_id = editor_db_add_item (dictionary->reference_db_section, &reference); if (reference_id == -1) { editor_db_grow (); reference_id = editor_db_add_item (dictionary->reference_db_section, &reference); } if (reference_id == -1) { return -1; } tree->first = reference_id; tree->count += 1; return 0; } static void editor_dictionary_initialize (struct ed_dictionary_volume *dictionary) { struct ed_dictionary_tree tree; int string_id; int tree_id; /* Add the empty string. */ string_id = editor_db_add_item ( dictionary->data_db_section, ""); assert (string_id == 0); tree.first = -1; tree.count = 0; tree.position = 0; tree_id = editor_db_add_item (dictionary->tree_db_section, &tree); assert (tree_id == 0); editor_dictionary_add_reference (dictionary, (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, 0, 0, NULL), 0, ROADMAP_DICTIONARY_STRING, 0); } static int editor_dictionary_search (struct ed_dictionary_volume *dictionary, const char *string, int length, int *last_tree_id) { struct ed_dictionary_tree *tree; struct ed_dictionary_reference *reference; int i; const char *cursor; char *stored; *last_tree_id = 0; tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, 0, 0, NULL); if (tree == NULL) { /* this is a new tree. Initialize it. */ editor_dictionary_initialize (dictionary); tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, *last_tree_id, 0, NULL); } for (i= 0, cursor = string; i < length; cursor++, i++) { tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, *last_tree_id, 0, NULL); if (tree == NULL) { /* this is a new tree. Initialize it. */ editor_dictionary_initialize (dictionary); tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, *last_tree_id, 0, NULL); } if (tree->position != i) { roadmap_log (ROADMAP_ERROR, "corrupted tree position %d (should be %d) in tree %d" " when searching for '%s'", tree->position, i, *last_tree_id, string); editor_dictionary_fatal (dictionary, *last_tree_id); } reference = editor_dictionary_get_reference (dictionary, tree, *cursor); if (reference == NULL) { return -1; } switch (reference->type) { case ROADMAP_DICTIONARY_STRING: stored = (char *) editor_db_get_item (dictionary->data_db_section, reference->child, 0, NULL); if ((stored[length] != 0) || (strncasecmp (string, stored, length) != 0)) { return -1; } return reference->child; case ROADMAP_DICTIONARY_TREE: if (*cursor == 0) { roadmap_log (ROADMAP_ERROR, "found a subtree after end of string"); editor_dictionary_fatal (dictionary, *last_tree_id); } if (reference->child >= editor_db_get_item_count (dictionary->tree_db_section)) { roadmap_log (ROADMAP_ERROR, "corrupted tree when searching for %s", string); editor_dictionary_fatal (dictionary, *last_tree_id); } *last_tree_id = reference->child; break; default: roadmap_log (ROADMAP_ERROR, "corrupted node when searching for %s", string); editor_dictionary_fatal (dictionary, *last_tree_id); } } tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, *last_tree_id, 0, NULL); reference = editor_dictionary_get_reference (dictionary, tree, 0); if (reference != NULL) { if (reference->type != ROADMAP_DICTIONARY_STRING) { roadmap_log (ROADMAP_ERROR, "found a subtree after end of string"); editor_dictionary_fatal (dictionary, *last_tree_id); } return reference->child; } return -1; } static struct ed_dictionary_volume * editor_dictionary_initialize_one (roadmap_db *child) { roadmap_db *table; struct ed_dictionary_volume *dictionary; /* Retrieve all the database sections: */ dictionary = malloc (sizeof(struct ed_dictionary_volume)); roadmap_check_allocated(dictionary); dictionary->name = roadmap_db_get_name (child); table = roadmap_db_get_subsection (child, "data"); dictionary->data_db_section = (editor_db_section *)roadmap_db_get_data (table); table = roadmap_db_get_subsection (child, "trees"); dictionary->tree_db_section = (editor_db_section *) roadmap_db_get_data (table); table = roadmap_db_get_subsection (child, "references"); dictionary->reference_db_section = (editor_db_section *) roadmap_db_get_data (table); dictionary->hits = 0; return dictionary; } static void *editor_dictionary_map (roadmap_db *parent) { roadmap_db *child; struct ed_dictionary_volume *volume; struct ed_dictionary_volume *first = NULL; for (child = roadmap_db_get_first(parent); child != NULL; child = roadmap_db_get_next(child)) { volume = editor_dictionary_initialize_one (child); volume->next = first; first = volume; } return first; } static void editor_dictionary_activate (void *context) { DictionaryVolume = (struct ed_dictionary_volume *) context; } static void editor_dictionary_unmap (void *context) { struct ed_dictionary_volume *this = (struct ed_dictionary_volume *) context; if (this == DictionaryVolume) { DictionaryVolume = NULL; } while (this != NULL) { struct ed_dictionary_volume *next = this->next; free (this); this = next; } } roadmap_db_handler EditorDictionaryHandler = { "dictionary", editor_dictionary_map, editor_dictionary_activate, editor_dictionary_unmap }; struct ed_dictionary_volume *editor_dictionary_open (char *name) { struct ed_dictionary_volume *volume; for (volume = DictionaryVolume; volume != NULL; volume = volume->next) { if (strcmp (volume->name, name) == 0) { return volume; } } return NULL; } int editor_dictionary_add (struct ed_dictionary_volume *dictionary, const char *string, int length) { char character; int tree_id; int string_id; char *db_string; struct ed_dictionary_tree *tree; /* Can't just return 0 as the dictionary may not yet be initialized. */ #if 0 if (length == 0) { return 0; /* Empty string optimization (quite frequent). */ } #endif string_id = editor_dictionary_search (dictionary, string, length, &tree_id); tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, tree_id, 0, NULL); if (string_id < 0) { struct ed_dictionary_reference *reference; if (DictionaryDebugOn) { printf (" string not found: adding it.\n"); } string_id = editor_db_allocate_items (dictionary->data_db_section, length+1); if (string_id == -1) { editor_db_grow (); string_id = editor_db_allocate_items (dictionary->data_db_section, length+1); } if (string_id == -1) { roadmap_log (ROADMAP_ERROR, "dictionary data full"); return -1; } db_string = (char *) editor_db_get_item ( dictionary->data_db_section, string_id, 0, NULL); strncpy (db_string, string, length); db_string[length] = 0; /* Update the search tree. */ if (tree->position < length) { character = string[tree->position]; } else { character = 0; } reference = editor_dictionary_get_reference (dictionary, tree, character); while (reference != NULL) { /* There was a similar string: we must create a new tree item * to distinguish between the two. */ int existing = reference->child; int position = tree->position; char *referenced = db_string = (char *) editor_db_get_item ( dictionary->data_db_section, existing, 0, NULL); if (reference->type != ROADMAP_DICTIONARY_STRING) { roadmap_log (ROADMAP_ERROR, "dictionary corrupted (uncomplete search)"); editor_dictionary_fatal (dictionary, tree_id); } tree_id = editor_db_add_item (dictionary->tree_db_section, NULL); if (tree_id == -1) { roadmap_log (ROADMAP_ERROR, "dictionary tree full"); return -1; } if (DictionaryDebugOn) { printf (" pruning string \"%s\".\n", referenced); } reference->type = ROADMAP_DICTIONARY_TREE; reference->child = tree_id; tree = (struct ed_dictionary_tree *) editor_db_get_item (dictionary->tree_db_section, tree_id, 0, NULL); tree->count = 0; tree->first = -1; tree->position = position + 1; if (tree->position < length) { character = string[tree->position]; } else { character = 0; } editor_dictionary_add_reference (dictionary, tree, referenced[tree->position], ROADMAP_DICTIONARY_STRING, existing); reference = editor_dictionary_get_reference (dictionary, tree, character); } editor_dictionary_add_reference (dictionary, tree, character, ROADMAP_DICTIONARY_STRING, string_id); } else { if (DictionaryDebugOn) { printf (" string found.\n"); } dictionary->hits += 1; } return string_id; } char *editor_dictionary_get (struct ed_dictionary_volume *dictionary, int index) { if (index >= editor_db_get_item_count (dictionary->data_db_section)) { return NULL; } return (char *) editor_db_get_item (dictionary->data_db_section, index, 0, NULL); } int editor_dictionary_locate (struct ed_dictionary_volume *dictionary, const char *string) { int tree_id; return editor_dictionary_search (dictionary, string, strlen(string), &tree_id); } --- NEW FILE: editor_square.c --- /* editor_point.c - point databse layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_point.h */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "roadmap.h" #include "roadmap_file.h" #include "roadmap_path.h" #include "roadmap_math.h" #include "../editor_log.h" #include "editor_db.h" #include "editor_point.h" #include "editor_shape.h" #include "editor_trkseg.h" #include "editor_square.h" static editor_db_section *ActiveSquaresDB; static int longitude_count; /* FIXME: depends on the header section activation before the squares activation */ static void editor_squares_activate (void *context) { RoadMapArea *edges = editor_db_get_active_edges (); ActiveS... [truncated message content] |
From: Ehud S. <esh...@us...> - 2005-11-28 19:48:01
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/export In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2745/src/editor/export Added Files: editor_export.c editor_export.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- NEW FILE: editor_export.h --- /* editor_export.h - export editor data * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef INCLUDE__EDITOR_EXPORT__H #define INCLUDE__EDITOR_EXPORT__H int editor_export_data(const char *name); void editor_export_reset_dirty (void); #endif // INCLUDE__EDITOR_EXPORT__H --- NEW FILE: editor_export.c --- /* editor_export.c - export db to GPX * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See editor_export.h */ #include <assert.h> #include "stdlib.h" #include "time.h" #include "string.h" #include "roadmap.h" #include "roadmap_file.h" #include "roadmap_path.h" #include "roadmap_layer.h" #include "roadmap_point.h" #include "../editor_log.h" #include "../db/editor_db.h" #include "../db/editor_point.h" #include "../db/editor_shape.h" #include "../db/editor_line.h" #include "../db/editor_trkseg.h" #include "../db/editor_street.h" #include "editor_export.h" #define NO_ELEVATION 1000000 static void add_timestamp(FILE *file, time_t time) { struct tm *tms = gmtime (&time); fprintf (file, "<time>%04d-%02d-%02dT%02d:%02d:%02dZ</time>\n", tms->tm_year+1900, tms->tm_mon+1, tms->tm_mday, tms->tm_hour, tms->tm_min, tms->tm_sec); } static void add_trkpt(FILE *file, int lon, int lat, int ele, time_t time) { fprintf (file, "<trkpt lat=\"%d.%06d\" lon=\"%d.%06d\">\n", lat / 1000000, lat % 1000000, lon / 1000000, lon % 1000000); if (ele != NO_ELEVATION) { fprintf (file, "<ele>%d</ele>\n", ele); } add_timestamp (file, time); fprintf (file, "</trkpt>\n"); } static void open_trk(FILE *file) { fprintf (file, "<trk>\n"); } static void close_trk(FILE *file) { fprintf (file, "</trk>\n"); } static void open_trkseg(FILE *file) { fprintf (file, "<trkseg>\n"); } static void close_trkseg(FILE *file) { fprintf (file, "</trkseg>\n"); } static FILE *create_export_file(const char *name) { FILE *file = roadmap_file_fopen (roadmap_path_user(), name, "w"); if (file == NULL) return NULL; fprintf (file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); fprintf (file, "<gpx\nversion=\"1.1\"\ncreator=\"RoadMap Editor - http://roadmap.digitalomaha.net/editor.html\"\n"); fprintf (file, "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"); fprintf (file, "xmlns=\"http://www.topografix.com/GPX/1/1\"\n"); fprintf (file, "xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">\n"); add_timestamp (file, time(NULL)); return file; } static void close_export_file(FILE *file) { fprintf (file, "</gpx>\n"); fclose (file); } static void add_trkpts (FILE *file, int trkseg, int line_id, int flags, RoadMapPosition *from, RoadMapPosition *to) { RoadMapPosition trkseg_pos; int from_point; int first_shape; int last_shape; int trkseg_flags; time_t start_time; time_t end_time; editor_trkseg_get (trkseg, &from_point, &first_shape, &last_shape, &trkseg_flags); editor_trkseg_get_time (trkseg, &start_time, &end_time); editor_point_position (from_point, &trkseg_pos); if (first_shape != -1) { int i; for (i=first_shape; i<=last_shape; i++) { editor_shape_position (i, &trkseg_pos); editor_shape_time (i, &start_time); add_trkpt (file, trkseg_pos.longitude, trkseg_pos.latitude, NO_ELEVATION, start_time); } } } static const char *cfcc2type (int cfcc) { char **categories; int count; roadmap_layer_get_categories_names (&categories, &count); return categories[cfcc - ROADMAP_ROAD_FIRST]; } static void add_attribute (FILE *file, const char *name, const char *value) { fprintf (file, "<%s>%s</%s>\n", name, value, name); } static void add_line_data (FILE *file, int line_id, int cfcc, int flags, int trkseg_flags, RoadMapPosition *line_from, RoadMapPosition *line_to, time_t start_time, time_t end_time) { EditorStreetProperties properties; char *trk_type; int from_point_id; int to_point_id; int roadmap_from_id; int roadmap_to_id; fprintf (file, "<extensions>\n"); if (flags & ED_LINE_DELETED) { fprintf (file, "<action trk_type=\"fake\">Delete</action>\n"); } else { if (trkseg_flags & ED_TRKSEG_FAKE) { trk_type = "fake"; } else if (trkseg_flags & ED_TRKSEG_IGNORE) { trk_type = "ignore"; } else { trk_type = "valid"; } fprintf (file, "<action trk_type=\"%s\">Update</action>\n", trk_type); } editor_line_get_points (line_id, &from_point_id, &to_point_id); editor_point_roadmap_id (from_point_id, &roadmap_from_id); editor_point_roadmap_id (to_point_id, &roadmap_to_id); if (roadmap_from_id >= 0) roadmap_from_id = roadmap_point_db_id (roadmap_from_id); if (roadmap_to_id >= 0) roadmap_to_id = roadmap_point_db_id (roadmap_to_id); if (roadmap_from_id == -1) roadmap_from_id = -from_point_id-2; if (roadmap_to_id == -1) roadmap_to_id = -to_point_id-2; fprintf (file, "<line from_id=\"%d\" to_id=\"%d\">\n", roadmap_from_id, roadmap_to_id); add_trkpt (file, line_from->longitude, line_from->latitude, NO_ELEVATION, start_time); add_trkpt (file, line_to->longitude, line_to->latitude, NO_ELEVATION, end_time); fprintf (file, "</line>\n"); if ((line_id != -1) && (flags & ED_LINE_DIRTY)) { fprintf (file, "<attributes>\n"); editor_street_get_properties (line_id, &properties); add_attribute (file, "road_type", cfcc2type (cfcc)); add_attribute (file, "street_name", editor_street_get_street_fename (&properties)); add_attribute (file, "text2speech", editor_street_get_street_t2s (&properties)); add_attribute (file, "city_name", editor_street_get_street_city (&properties, ED_STREET_LEFT_SIDE)); fprintf (file, "</attributes>\n"); editor_line_modify_properties (line_id, cfcc, flags & ~ED_LINE_DIRTY); } fprintf (file, "</extensions>\n"); } static int export_dirty_lines(FILE *file) { int num_lines = editor_line_get_count(); int current_trk_open = 0; int found = 0; int i; for (i=0; i<num_lines; i++) { RoadMapPosition from; RoadMapPosition to; int cfcc; int flags; int trkseg_flags = 0; time_t start_time; time_t end_time; int trkseg; int last_trkseg; editor_line_get (i, &from, &to, NULL, &cfcc, &flags); if (!(flags & ED_LINE_DIRTY)) continue; if (!(flags & ED_LINE_DELETED)) { if (!current_trk_open) { open_trk (file); current_trk_open = 1; } open_trkseg (file); editor_line_get_trksegs (i, &trkseg, &last_trkseg); add_trkpts (file, trkseg, i, flags, &from, &to); editor_trkseg_get_time (trkseg, &start_time, &end_time); editor_trkseg_get (trkseg, NULL, NULL, NULL, &trkseg_flags); if (trkseg_flags & ED_TRKSEG_OPPOSITE_DIR) { add_line_data (file, i, cfcc, flags, trkseg_flags, &to, &from, start_time, end_time); } else { add_line_data (file, i, cfcc, flags, trkseg_flags, &from, &to, start_time, end_time); } close_trkseg (file); found++; } editor_line_modify_properties (i, cfcc, flags & ~ED_LINE_DIRTY); } if (current_trk_open) { close_trk (file); } return found; } int editor_export_data(const char *name) { FILE *file = create_export_file (name); int trkseg; int line_id; int current_trk_open = 0; if (file == NULL) { editor_log (ROADMAP_ERROR, "Can't create file: %s", name); return -1; } trkseg = editor_trkseg_get_next_export (); if (trkseg == -1) { if (!export_dirty_lines (file)) { editor_log (ROADMAP_INFO, "No trksegs are available for export."); } close_export_file (file); return 0; } while (trkseg != -1) { RoadMapPosition from; RoadMapPosition to; int cfcc; int flags; int trkseg_flags = 0; time_t start_time; time_t end_time; line_id = editor_trkseg_get_line (trkseg); if (line_id != -1) { editor_line_get (line_id, &from, &to, NULL, &cfcc, &flags); if (flags & ED_LINE_DELETED) { editor_line_modify_properties (line_id, cfcc, flags & ~ED_LINE_DIRTY); if (current_trk_open) { close_trk (file); current_trk_open = 0; } goto next_trkseg; } } editor_trkseg_get (trkseg, NULL, NULL, NULL, &trkseg_flags); if (trkseg_flags & ED_TRKSEG_NEW_TRACK) { if (current_trk_open) { close_trk (file); current_trk_open = 0; } } if (!current_trk_open) { open_trk (file); current_trk_open = 1; } open_trkseg (file); add_trkpts (file, trkseg, line_id, flags, &from, &to); editor_trkseg_get_time (trkseg, &start_time, &end_time); if (trkseg_flags & ED_TRKSEG_OPPOSITE_DIR) { add_line_data (file, line_id, cfcc, flags, trkseg_flags, &to, &from, start_time, end_time); } else { add_line_data (file, line_id, cfcc, flags, trkseg_flags, &from, &to, start_time, end_time); } close_trkseg (file); next_trkseg: if (trkseg_flags & ED_TRKSEG_END_TRACK) { if (current_trk_open) { close_trk (file); current_trk_open = 0; } } trkseg = editor_trkseg_next_in_global (trkseg); } if (current_trk_open) { close_trk (file); } export_dirty_lines (file); close_export_file (file); editor_trkseg_reset_next_export (); return 0; } void editor_export_reset_dirty () { int count; int i; count = editor_line_get_count (); for (i=0; i<count; i++) { int flags; int cfcc; editor_line_get (i, NULL, NULL, NULL, &cfcc, &flags); editor_line_modify_properties (i, cfcc, flags | ED_LINE_DIRTY); } } |
From: Ehud S. <esh...@us...> - 2005-11-28 19:48:01
|
Update of /cvsroot/roadmap/roadmap_editor/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2745/src Added Files: roadmap_plugin.c roadmap_plugin.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- NEW FILE: roadmap_plugin.h --- /* roadmap_plugin.h - plugin interfaces * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef INCLUDE__ROADMAP_PLUGIN__H #define INCLUDE__ROADMAP_PLUGIN__H #include "roadmap_canvas.h" #define ROADMAP_PLUGIN_ID 0 #define PLUGIN_MAKE_LINE(plugin_id, line_id, cfcc, fips) \ {plugin_id, line_id, cfcc, fips} #define PLUGIN_VALID(plugin) (plugin.plugin_id >= 0) #define INVALIDATE_PLUGIN(plugin) (plugin.plugin_id = -1) /* plugin types */ typedef struct { int plugin_id; int line_id; int cfcc; int fips; } PluginLine; typedef struct { int plugin_id; int street_id; } PluginStreet; typedef struct { const char *address; const char *street; const char *city; } PluginStreetProperties; #define PLUGIN_LINE_NULL {-1, -1, -1, -1} #define PLUGIN_STREET_NULL {-1, -1} struct RoadMapNeighbour_t; int roadmap_plugin_same_line (const PluginLine *line1, const PluginLine *line2); int roadmap_plugin_same_street (const PluginStreet *street1, const PluginStreet *street2); void roadmap_plugin_get_street (const PluginLine *line, PluginStreet *street); void roadmap_plugin_line_from (const PluginLine *line, RoadMapPosition *pos); void roadmap_plugin_line_to (const PluginLine *line, RoadMapPosition *pos); int roadmap_plugin_get_id (const PluginLine *line); int roadmap_plugin_get_fips (const PluginLine *line); int roadmap_plugin_get_line_id (const PluginLine *line); int roadmap_plugin_get_line_cfcc (const PluginLine *line); int roadmap_plugin_get_street_id (const PluginStreet *street); void roadmap_plugin_set_line (PluginLine *line, int plugin_id, int line_id, int cfcc, int fips); void roadmap_plugin_set_street (PluginStreet *street, int plugin_id, int street_id); int roadmap_plugin_activate_db (const PluginLine *line); int roadmap_plugin_get_distance (const RoadMapPosition *point, const PluginLine *line, struct RoadMapNeighbour_t *result); /* hook functions definition */ typedef int (*plugin_override_line_hook) (int line, int cfcc, int fips); typedef int (*plugin_override_pen_hook) (int line, int cfcc, int fips, int pen_type, RoadMapPen *override_pen); typedef void (*plugin_screen_repaint_hook) (int max_pen); typedef int (*plugin_activate_db_func) (const PluginLine *line); typedef void (*plugin_line_pos_func) (const PluginLine *line, RoadMapPosition *pos); typedef int (*plugin_get_distance_func) (const RoadMapPosition *point, const PluginLine *line, struct RoadMapNeighbour_t *result); typedef void (*plugin_get_street_func) (const PluginLine *line, PluginStreet *street); typedef const char *(*plugin_street_full_name_func) (const PluginLine *line); typedef void (*plugin_street_properties_func) (const PluginLine *line, PluginStreetProperties *props); typedef int (*plugin_find_connected_lines_func) (const RoadMapPosition *crossing, PluginLine *plugin_lines, int max); typedef void (*plugin_adjust_layer_hook) (int layer, int thickness, int pen_count); typedef int (*plugin_get_closest_func) (const RoadMapPosition *position, int *categories, int categories_count, struct RoadMapNeighbour_t *neighbours, int count, int max); typedef struct { plugin_line_pos_func line_from; plugin_line_pos_func line_to; plugin_activate_db_func activate_db; plugin_get_distance_func get_distance; plugin_override_line_hook override_line; plugin_override_pen_hook override_pen; plugin_screen_repaint_hook screen_repaint; plugin_get_street_func get_street; plugin_street_full_name_func get_street_full_name; plugin_street_properties_func get_street_properties; plugin_find_connected_lines_func find_connected_lines; plugin_adjust_layer_hook adjust_layer; plugin_get_closest_func get_closest; } RoadMapPluginHooks; /* Interface functions */ int roadmap_plugin_register (RoadMapPluginHooks *hooks); void roadmap_plugin_unregister (int plugin_id); int roadmap_plugin_override_line (int line, int cfcc, int fips); int roadmap_plugin_override_pen (int line, int cfcc, int fips, int pen_type, RoadMapPen *override_pen); void roadmap_plugin_screen_repaint (int max_pen); const char *roadmap_plugin_street_full_name (PluginLine *line); void roadmap_plugin_get_street_properties (PluginLine *line, PluginStreetProperties *props); int roadmap_plugin_find_connected_lines (RoadMapPosition *crossing, PluginLine *plugin_lines, int max); void roadmap_plugin_adjust_layer (int layer, int thickness, int pen_count); int roadmap_plugin_get_closest (const RoadMapPosition *position, int *categories, int categories_count, struct RoadMapNeighbour_t *neighbours, int count, int max); #endif /* INCLUDE__ROADMAP_PLUGIN__H */ --- NEW FILE: roadmap_plugin.c --- /* roadmap_plugin.c - plugin layer * * LICENSE: * * Copyright 2005 Ehud Shabtai * * This file is part of RoadMap. * * RoadMap is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * RoadMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * SYNOPSYS: * * See roadmap_plugin.h. */ #include <assert.h> #include <stdlib.h> #include "roadmap.h" #include "roadmap_line.h" #include "roadmap_locator.h" #include "roadmap_street.h" #include "roadmap_plugin.h" #define MAX_PLUGINS 10 static RoadMapPluginHooks *hooks[MAX_PLUGINS] = {0}; static int PluginCount = 0; static RoadMapPluginHooks *get_hooks (int id) { assert (id < MAX_PLUGINS); return hooks[id]; } int roadmap_plugin_register (RoadMapPluginHooks *hook) { int i; for (i=1; i<MAX_PLUGINS; i++) { if (hooks[i] == NULL) { hooks[i] = hook; PluginCount++; return i; } } return -1; } void roadmap_plugin_unregister (int plugin_id) { hooks[plugin_id] = NULL; PluginCount--; } int roadmap_plugin_same_line (const PluginLine *line1, const PluginLine *line2) { if ((line1 == NULL) || (line2 == NULL)) return 0; return ( (line1->plugin_id == line2->plugin_id) && (line1->line_id == line2->line_id) && (line1->fips == line2->fips) ); } int roadmap_plugin_same_street (const PluginStreet *street1, const PluginStreet *street2) { return ( (street1->plugin_id == street2->plugin_id) && (street1->street_id == street2->street_id) ); } int roadmap_plugin_get_id (const PluginLine *line) { return line->plugin_id; } int roadmap_plugin_get_fips (const PluginLine *line) { return line->fips; } int roadmap_plugin_get_line_id (const PluginLine *line) { return line->line_id; } int roadmap_plugin_get_line_cfcc (const PluginLine *line) { return line->cfcc; } int roadmap_plugin_get_street_id (const PluginStreet *street) { return street->street_id; } void roadmap_plugin_set_line (PluginLine *line, int plugin_id, int line_id, int cfcc, int fips) { line->plugin_id = plugin_id; line->line_id = line_id; line->cfcc = cfcc; line->fips = fips; } void roadmap_plugin_set_street (PluginStreet *street, int plugin_id, int street_id) { street->plugin_id = plugin_id; street->street_id = street_id; } int roadmap_plugin_activate_db (const PluginLine *line) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { if (roadmap_locator_activate (line->fips) != ROADMAP_US_OK) { return -1; } return 0; } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); return -1; } if (hooks->activate_db != NULL) { return (*hooks->activate_db) (line); } return 0; } } int roadmap_plugin_get_distance (const RoadMapPosition *point, const PluginLine *line, RoadMapNeighbour *result) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { return roadmap_street_get_distance (point, line->line_id, line->cfcc, result); } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); return 0; } if (hooks->activate_db != NULL) { return (*hooks->get_distance) (point, line, result); } return 0; } } void roadmap_plugin_line_from (const PluginLine *line, RoadMapPosition *pos) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { roadmap_line_from (line->line_id, pos); } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); pos->longitude = pos->latitude = 0; return; } if (hooks->line_from != NULL) { (*hooks->line_from) (line, pos); } else { pos->longitude = pos->latitude = 0; } return; } } void roadmap_plugin_line_to (const PluginLine *line, RoadMapPosition *pos) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { roadmap_line_to (line->line_id, pos); } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); pos->longitude = pos->latitude = 0; return; } if (hooks->line_to != NULL) { (*hooks->line_to) (line, pos); } else { pos->longitude = pos->latitude = 0; } return; } } int roadmap_plugin_override_line (int line, int cfcc, int fips) { int i; for (i=1; i<=PluginCount; i++) { RoadMapPluginHooks *hooks = get_hooks (i); if (hooks == NULL) continue; if (hooks->override_line != NULL) { int res = hooks->override_line (line, cfcc, fips); if (res) return res; } } return 0; } int roadmap_plugin_override_pen (int line, int cfcc, int fips, int pen_type, RoadMapPen *override_pen) { int i; for (i=1; i<=PluginCount; i++) { RoadMapPluginHooks *hooks = get_hooks (i); if (hooks == NULL) continue; if (hooks->override_pen != NULL) { int res = hooks->override_pen (line, cfcc, fips, pen_type, override_pen); if (res) return res; } } return 0; } void roadmap_plugin_screen_repaint (int max_pen) { int i; for (i=1; i<=PluginCount; i++) { RoadMapPluginHooks *hooks = get_hooks (i); if ((hooks == NULL) || (hooks->screen_repaint == NULL)) continue; hooks->screen_repaint (max_pen); } } void roadmap_plugin_get_street (const PluginLine *line, PluginStreet *street) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { RoadMapStreetProperties properties; roadmap_street_get_properties (line->line_id, &properties); street->plugin_id = ROADMAP_PLUGIN_ID; street->street_id = properties.street; } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); street->plugin_id = line->plugin_id; if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); street->street_id = -1; return; } if (hooks->get_street != NULL) { (*hooks->get_street) (line, street); } else { street->street_id = -1; } return; } } const char *roadmap_plugin_street_full_name (PluginLine *line) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { RoadMapStreetProperties properties; roadmap_street_get_properties (line->line_id, &properties); return roadmap_street_get_full_name (&properties); } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); return ""; } if (hooks->get_street != NULL) { return (*hooks->get_street_full_name) (line); } return ""; } } void roadmap_plugin_get_street_properties (PluginLine *line, PluginStreetProperties *props) { if (line->plugin_id == ROADMAP_PLUGIN_ID) { RoadMapStreetProperties rm_properties; roadmap_street_get_properties (line->line_id, &rm_properties); props->address = roadmap_street_get_street_address (&rm_properties); props->street = roadmap_street_get_street_name (&rm_properties); props->city = roadmap_street_get_city_name (&rm_properties); return; } else { RoadMapPluginHooks *hooks = get_hooks (line->plugin_id); props->address = ""; props->street = ""; props->city = ""; if (hooks == NULL) { roadmap_log (ROADMAP_ERROR, "plugin id:%d is missing.", line->plugin_id); return; } if (hooks->get_street != NULL) { (*hooks->get_street_properties) (line, props); } return; } } int roadmap_plugin_find_connected_lines (RoadMapPosition *crossing, PluginLine *plugin_lines, int max) { int i; int count = 0; for (i=1; i<=PluginCount; i++) { RoadMapPluginHooks *hooks = get_hooks (i); if ((hooks == NULL) || (hooks->find_connected_lines == NULL)) continue; count += hooks->find_connected_lines (crossing, plugin_lines + count, max - count); } return count; } void roadmap_plugin_adjust_layer (int layer, int thickness, int pen_count) { int i; for (i=1; i<=PluginCount; i++) { RoadMapPluginHooks *hooks = get_hooks (i); if ((hooks == NULL) || (hooks->adjust_layer == NULL)) continue; hooks->adjust_layer (layer, thickness, pen_count); } } int roadmap_plugin_get_closest (const RoadMapPosition *position, int *categories, int categories_count, RoadMapNeighbour *neighbours, int count, int max) { int i; for (i=1; i<=PluginCount; i++) { RoadMapPluginHooks *hooks = get_hooks (i); if (hooks == NULL) continue; if (hooks->get_closest != NULL) { count = hooks->get_closest (position, categories, categories_count, neighbours, count, max); } } return count; } |
From: Ehud S. <esh...@us...> - 2005-11-28 19:43:49
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/track In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1959/track Log Message: Directory /cvsroot/roadmap/roadmap_editor/src/editor/track added to the repository |
From: Ehud S. <esh...@us...> - 2005-11-28 19:43:49
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/export In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1959/export Log Message: Directory /cvsroot/roadmap/roadmap_editor/src/editor/export added to the repository |
From: Ehud S. <esh...@us...> - 2005-11-28 19:43:46
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/static In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1959/static Log Message: Directory /cvsroot/roadmap/roadmap_editor/src/editor/static added to the repository |
From: Ehud S. <esh...@us...> - 2005-11-28 19:43:46
|
Update of /cvsroot/roadmap/roadmap_editor/src/editor/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1959/db Log Message: Directory /cvsroot/roadmap/roadmap_editor/src/editor/db added to the repository |
From: Ehud S. <esh...@us...> - 2005-11-28 19:36:52
|
Update of /cvsroot/roadmap/roadmap_editor/src/unix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/src/unix Modified Files: roadmap_file.c roadmap_path.c Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export Index: roadmap_path.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/unix/roadmap_path.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_path.c 15 Oct 2005 22:19:09 -0000 1.1.1.1 --- roadmap_path.c 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 121,126 **** - static char *roadmap_path_expand (const char *item, int length); - static void roadmap_path_list_create(const char *name, const char *items[], --- 121,124 ---- *************** *** 145,151 **** for (i = 0; i < count; ++i) { ! new_path->items[i] = roadmap_path_expand (items[i], strlen(items[i])); } ! new_path->preferred = roadmap_path_expand (preferred, strlen(preferred)); RoadMapPaths = new_path; --- 143,149 ---- for (i = 0; i < count; ++i) { ! new_path->items[i] = strdup(items[i]); } ! new_path->preferred = strdup(preferred); RoadMapPaths = new_path; *************** *** 296,324 **** - char *roadmap_path_expand (const char *item, int length) { - - const char *expand; - int expand_length; - char *res; - - switch (item[0]) { - case '~': expand = roadmap_path_home(); item += 1; break; - case '&': expand = roadmap_path_user(); item += 1; break; - default: expand = ""; - } - expand_length = strlen(expand); - - res = malloc (length + expand_length + 1); - roadmap_check_allocated(res); - - strcpy (res, expand); - strncat (res, item, length); - - res[length+expand_length] = 0; - - return res; - } - - /* Path lists operations. -------------------------------------------------- */ --- 294,297 ---- *************** *** 327,331 **** --- 300,307 ---- int i; int count; + int length; + int expand_length; const char *item; + const char *expand; const char *next_item; *************** *** 371,380 **** next_item = strchr (item, ','); if (next_item == NULL) { ! path_list->items[i] = roadmap_path_expand (item, strlen(item)); } else { ! path_list->items[i] = roadmap_path_expand (item, next_item - item); } if (roadmap_file_exists(NULL, path_list->items[i])) { ++i; --- 347,371 ---- next_item = strchr (item, ','); + switch (item[0]) { + case '~': expand = roadmap_path_home(); item += 1; break; + case '&': expand = roadmap_path_user(); item += 1; break; + default: expand = ""; + } + expand_length = strlen(expand); + if (next_item == NULL) { ! length = strlen(item); } else { ! length = next_item - item; } + path_list->items[i] = malloc (length + expand_length + 1); + roadmap_check_allocated(path_list->items[i]); + + strcpy (path_list->items[i], expand); + strncat (path_list->items[i], item, length); + + (path_list->items[i])[length+expand_length] = 0; + if (roadmap_file_exists(NULL, path_list->items[i])) { ++i; Index: roadmap_file.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/unix/roadmap_file.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_file.c 15 Oct 2005 22:19:09 -0000 1.1.1.1 --- roadmap_file.c 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 271,275 **** if (context->fd >= 0) break; - name_size = errno; sequence = roadmap_path_next(set, sequence); --- 271,274 ---- |
From: Ehud S. <esh...@us...> - 2005-11-28 19:36:52
|
Update of /cvsroot/roadmap/roadmap_editor/src/gtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/src/gtk Modified Files: roadmap_main.c Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export Index: roadmap_main.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/gtk/roadmap_main.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_main.c 15 Oct 2005 22:19:07 -0000 1.1.1.1 --- roadmap_main.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 62,66 **** static GtkWidget *RoadMapMainBox = NULL; static GtkWidget *RoadMapMainMenuBar = NULL; - static GtkWidget *RoadMapCurrentMenu = NULL; static GtkWidget *RoadMapMainToolbar = NULL; static GtkWidget *RoadMapMainStatus = NULL; --- 62,65 ---- *************** *** 178,182 **** ! void roadmap_main_add_menu (const char *label) { GtkWidget *menu_item; --- 177,193 ---- ! RoadMapMenu roadmap_main_new_menu (void) { ! ! return (RoadMapMenu) gtk_menu_new (); ! } ! ! ! void roadmap_main_free_menu (RoadMapMenu menu) { ! ! gtk_widget_destroy ((GtkWidget *)menu); ! } ! ! ! void roadmap_main_add_menu (RoadMapMenu menu, const char *label) { GtkWidget *menu_item; *************** *** 193,202 **** gtk_menu_bar_append (GTK_MENU_BAR(RoadMapMainMenuBar), menu_item); ! RoadMapCurrentMenu = gtk_menu_new (); ! gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), RoadMapCurrentMenu); } ! void roadmap_main_add_menu_item (const char *label, const char *tip, RoadMapCallback callback) { --- 204,213 ---- gtk_menu_bar_append (GTK_MENU_BAR(RoadMapMainMenuBar), menu_item); ! gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), (GtkWidget *) menu); } ! void roadmap_main_add_menu_item (RoadMapMenu menu, ! const char *label, const char *tip, RoadMapCallback callback) { *************** *** 204,208 **** GtkWidget *menu_item; ! if (RoadMapCurrentMenu == NULL) { roadmap_log (ROADMAP_FATAL, "No menu defined for menu item %s", label); } --- 215,219 ---- GtkWidget *menu_item; ! if (menu == NULL) { roadmap_log (ROADMAP_FATAL, "No menu defined for menu item %s", label); } *************** *** 218,222 **** menu_item = gtk_menu_item_new (); } ! gtk_menu_append (GTK_MENU(RoadMapCurrentMenu), menu_item); if (tip != NULL) { --- 229,233 ---- menu_item = gtk_menu_item_new (); } ! gtk_menu_append (GTK_MENU(menu), menu_item); if (tip != NULL) { *************** *** 226,232 **** ! void roadmap_main_add_separator (void) { - roadmap_main_add_menu_item (NULL, NULL, NULL); } --- 237,256 ---- ! void roadmap_main_add_separator (RoadMapMenu menu) { ! ! roadmap_main_add_menu_item (menu, NULL, NULL, NULL); ! } ! ! ! void roadmap_main_popup_menu (RoadMapMenu menu, int x, int y) { ! ! gtk_menu_popup (GTK_MENU(menu), ! NULL, ! NULL, ! NULL, ! NULL, ! 0, ! gtk_get_current_event_time()); } |
From: Ehud S. <esh...@us...> - 2005-11-28 19:36:52
|
Update of /cvsroot/roadmap/roadmap_editor/web In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/web Modified Files: download.html hardware.html index.html Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export Index: hardware.html =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/web/hardware.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** hardware.html 15 Oct 2005 22:19:35 -0000 1.1.1.1 --- hardware.html 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 44,48 **** the <a class="normal" href="http://www.handhelds.org/">Handhelds.org site</a> for more information on supported models. - <LI>HP IPAQ running Microsoft's PocketPC 2002 or less worse (i.e., better). <LI><a class="normal" href="http://www.myzaurus.com/">Sharp Zaurus</a>. <LI><a class="normal" href="http://www.apple.com/">Apple G3</a> (and --- 44,47 ---- Index: download.html =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/web/download.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** download.html 15 Oct 2005 22:19:49 -0000 1.1.1.1 --- download.html 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 30,35 **** developped by Latchesar Ionkov (who wrote the original QT support). The support for the Digital Charts of the World was contributed by Stephen ! Woodbridge. The version of RoadMap for Windows (PocketPC) is developped and ! supported by Ehud Shabtai (eshabtai at gmail dot com). <P> The latest Roadmap sources are also available from <A class=normal --- 30,35 ---- developped by Latchesar Ionkov (who wrote the original QT support). The support for the Digital Charts of the World was contributed by Stephen ! Woodbridge. The version of RoadMap for Windows is developped and supported ! by Ehud Shabtai (eshabtai at gmail dot com). <P> The latest Roadmap sources are also available from <A class=normal *************** *** 67,72 **** href="roadmap/roadmap_1_0_11_armv4l.tar.gz">Linux/ARM binaries</A>, <A class=normal - href="roadmap/roadmap_1_0_11_ppc_arm.zip">Microsoft PocketPC/ARM binaries</A>. - <A class=normal href="roadmap/roadmap_1_0_11_doc.tar.gz">Documentation</A>. --- 67,70 ---- Index: index.html =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/web/index.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** index.html 15 Oct 2005 22:19:41 -0000 1.1.1.1 --- index.html 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 1,4 **** <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ! <HTML><HEAD><TITLE>RoadMap: car navigation system for Linux and UNIX (and PocketPC too)</TITLE> <META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK href="sitestandard.css" type=text/css rel=stylesheet> --- 1,4 ---- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ! <HTML><HEAD><TITLE>RoadMap: car navigation system for Linux and UNIX</TITLE> <META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK href="sitestandard.css" type=text/css rel=stylesheet> *************** *** 8,12 **** <img SRC="roadmap-right.png" align="middle" border="0"> <P> ! <H1>A Car Navigation System for Linux and UNIX (and PocketPC too)</H1> </CENTER> <BR> --- 8,12 ---- <img SRC="roadmap-right.png" align="middle" border="0"> <P> ! <H1>A Car Navigation System for Linux and UNIX</H1> </CENTER> <BR> *************** *** 34,39 **** developped by Latchesar Ionkov (who wrote the original QT support). The support for the Digital Charts of the World was contributed by Stephen ! Woodbridge. The version of RoadMap for Windows (PocketPC) is developped and ! supported by Ehud Shabtai (eshabtai at gmail dot com). <P> The latest Roadmap sources are also available from <A class=normal --- 34,39 ---- developped by Latchesar Ionkov (who wrote the original QT support). The support for the Digital Charts of the World was contributed by Stephen ! Woodbridge. The version of RoadMap for Windows is developped and supported ! by Ehud Shabtai (eshabtai at gmail dot com). <P> The latest Roadmap sources are also available from <A class=normal |
Update of /cvsroot/roadmap/roadmap_editor/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/src Modified Files: Makefile app_a02.txt buildmap.h buildmap_dbwrite.c buildmap_dictionary.c buildmap_line.c buildmap_main.c buildmap_messages.c buildmap_place.c buildmap_point.c buildmap_polygon.c buildmap_range.c buildmap_shape.c buildmap_shapefile.c buildmap_square.c buildmap_street.c buildmap_zip.c buildplace_main.c buildus_county.c buildus_main.c roadmap_address.c roadmap_crossing.c roadmap_display.c roadmap_display.h roadmap_driver.c roadmap_factory.c roadmap_file.h roadmap_fuzzy.c roadmap_fuzzy.h roadmap_gps.h roadmap_layer.c roadmap_layer.h roadmap_line.h roadmap_locator.c roadmap_log.c roadmap_math.c roadmap_math.h roadmap_navigate.c roadmap_navigate.h roadmap_point.c roadmap_point.h roadmap_pointer.c roadmap_screen.c roadmap_shape.c roadmap_square.c roadmap_square.h roadmap_start.c roadmap_street.c roadmap_street.h roadmap_trip.c Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export Index: roadmap_navigate.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_navigate.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_navigate.h 15 Oct 2005 22:19:03 -0000 1.1.1.1 --- roadmap_navigate.h 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 25,30 **** #define INCLUDE__ROADMAP_NAVIGATE__H - #include "roadmap_street.h" #include "roadmap_gps.h" void roadmap_navigate_disable (void); --- 25,57 ---- #define INCLUDE__ROADMAP_NAVIGATE__H #include "roadmap_gps.h" + #include "roadmap_fuzzy.h" + #include "roadmap_plugin.h" + + typedef struct { + RoadMapFuzzy direction; + RoadMapFuzzy distance; + RoadMapFuzzy connected; + } RoadMapDebug; + + typedef struct { + + int valid; + PluginStreet street; + + int direction; + int opposite_street_direction; + + RoadMapFuzzy fuzzyfied; + + PluginLine intersection; + + RoadMapPosition entry; + + RoadMapDebug debug; + + } RoadMapTracking; + + #define ROADMAP_TRACKING_NULL {0, PLUGIN_STREET_NULL, 0, 0, 0, PLUGIN_LINE_NULL, {0, 0}, {0, 0, 0}}; void roadmap_navigate_disable (void); *************** *** 32,37 **** int roadmap_navigate_retrieve_line ! (const RoadMapPosition *position, int accuracy, ! RoadMapNeighbour *closest); void roadmap_navigate_locate (const RoadMapGpsPosition *gps_position); --- 59,66 ---- int roadmap_navigate_retrieve_line ! (const RoadMapPosition *position, ! int accuracy, ! PluginLine *line, ! int *distance); void roadmap_navigate_locate (const RoadMapGpsPosition *gps_position); *************** *** 39,43 **** void roadmap_navigate_initialize (void); ! int roadmap_delta_direction (int direction1, int direction2); #endif // INCLUDE__ROADMAP_NAVIGATE__H --- 68,75 ---- void roadmap_navigate_initialize (void); ! int roadmap_navigate_fuzzify ! (RoadMapTracking *tracked, ! RoadMapNeighbour *previous_line, ! RoadMapNeighbour *line, int direction); #endif // INCLUDE__ROADMAP_NAVIGATE__H Index: roadmap_address.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_address.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_address.c 15 Oct 2005 22:18:50 -0000 1.1.1.1 --- roadmap_address.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 62,66 **** static void roadmap_address_done (RoadMapGeocode *selected) { ! RoadMapNeighbour line = ROADMAP_NEIGHBOUR_NULL; roadmap_locator_activate (selected->fips); --- 62,67 ---- static void roadmap_address_done (RoadMapGeocode *selected) { ! PluginStreet street; ! PluginLine line; roadmap_locator_activate (selected->fips); *************** *** 74,81 **** selected->position.latitude >= 0 ? 'N' : 'S'); ! line.line = selected->line; roadmap_display_activate ! ("Selected Street", &line, &selected->position); roadmap_trip_set_point ("Selection", &selected->position); --- 75,83 ---- selected->position.latitude >= 0 ? 'N' : 'S'); ! roadmap_plugin_set_line ! (&line, ROADMAP_PLUGIN_ID, selected->line, -1, selected->fips); roadmap_display_activate ! ("Selected Street", &line, &selected->position, &street); roadmap_trip_set_point ("Selection", &selected->position); Index: app_a02.txt =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/app_a02.txt,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** app_a02.txt 15 Oct 2005 22:18:58 -0000 1.1.1.1 --- app_a02.txt 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 3232,3236 **** 72 153 Yauco PR 74 300 Midway Islands UM - 77 001 Israel IL 78 010 St. Croix VI 78 020 St. John VI --- 3232,3235 ---- Index: buildplace_main.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/buildplace_main.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** buildplace_main.c 15 Oct 2005 22:19:01 -0000 1.1.1.1 --- buildplace_main.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 41,45 **** #if ROADMAP_USE_SHAPEFILES ! #include <libshp/shapefil.h> /* shapefile column names */ --- 41,45 ---- #if ROADMAP_USE_SHAPEFILES ! #include <shapefil.h> /* shapefile column names */ *************** *** 164,168 **** } ! buildmap_db_open (BuildPlaceResult, db_name); buildmap_square_save (); --- 164,170 ---- } ! if (buildmap_db_open (BuildPlaceResult, db_name) < 0) { ! buildmap_fatal (0, "cannot create database %s", db_name); ! } buildmap_square_save (); Index: roadmap_street.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_street.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** roadmap_street.c 12 Nov 2005 15:46:37 -0000 1.2 --- roadmap_street.c 28 Nov 2005 19:36:34 -0000 1.3 *************** *** 44,51 **** #include "roadmap_line.h" #include "roadmap_dictionary.h" - #include "editor/editor_line.h" - #include "editor/editor_override.h" - #include "editor/editor_street.h" static char *RoadMapStreetType = "RoadMapStreetContext"; --- 44,48 ---- *************** *** 819,827 **** int smallest_distance; RoadMapNeighbour current; ! current.line = line; ! current.plugin_id = 0; ! current.fips = roadmap_locator_active(); ! current.cfcc = cfcc; /* Note: the position of a shape point is relative to the position --- 816,823 ---- int smallest_distance; RoadMapNeighbour current; + int fips = roadmap_locator_active(); ! roadmap_plugin_set_line ! (¤t.line, ROADMAP_PLUGIN_ID, line, cfcc, fips); /* Note: the position of a shape point is relative to the position *************** *** 885,892 **** &neighbour->intersection); ! neighbour->line = line; ! neighbour->plugin_id = 0; ! neighbour->fips = roadmap_locator_active(); ! neighbour->cfcc = cfcc; return 1; --- 881,890 ---- &neighbour->intersection); ! roadmap_plugin_set_line ! (&neighbour->line, ! ROADMAP_PLUGIN_ID, ! line, ! cfcc, ! roadmap_locator_active ()); return 1; *************** *** 910,914 **** neighbours[count] = *this; - neighbours[count].fips = roadmap_locator_active(); return count + 1; --- 908,911 ---- *************** *** 931,935 **** if (farthest >= 0) { neighbours[farthest] = *this; - neighbours[farthest].fips = roadmap_locator_active(); } return max; --- 928,931 ---- *************** *** 971,975 **** (position, line, cfcc, result); } - return found; } --- 967,970 ---- *************** *** 991,994 **** --- 986,991 ---- RoadMapNeighbour this; + int fips = roadmap_locator_active (); + if (roadmap_line_in_square (square, cfcc, &first_line, &last_line) > 0) { *************** *** 998,1004 **** for (line = first_line; line <= last_line; line++) { ! ! if (editor_override_line_get_flags (line) & ! ED_LINE_DELETED) continue; if (roadmap_shape_of_line (line, first_shape_line, --- 995,1000 ---- for (line = first_line; line <= last_line; line++) { ! ! if (roadmap_plugin_override_line (line, cfcc, fips)) continue; if (roadmap_shape_of_line (line, first_shape_line, *************** *** 1054,1057 **** --- 1050,1055 ---- } + if (roadmap_plugin_override_line (line, cfcc, fips)) continue; + if (shape_count > 0 && roadmap_shape_of_line (line, first_shape_line, *************** *** 1089,1096 **** int county; int county_count; ! ! int j; ! int square[4]; ! int square_count; int count = 0; --- 1087,1091 ---- int county; int county_count; ! int square; int count = 0; *************** *** 1111,1139 **** /* -- Look for the square the current location fits in. */ ! square_count = ! roadmap_square_search_near (position, square, 4); ! for (j=0; j<square_count; j++) { ! ! /* The current location fits in one of the county's squares. ! * We might be in that county, search for the closest streets. ! */ ! for (i = 0; i < categories_count; ++i) { ! count = ! roadmap_street_get_closest_in_square ! (position, ! square[j], ! categories[i], ! neighbours, ! count, ! max); ! } } - - count = - editor_street_get_closest - (position, fips[county], categories, - categories_count, neighbours, ED_SQUARE_NEAR, count, max); } --- 1106,1123 ---- /* -- Look for the square the current location fits in. */ ! square = roadmap_square_search (position); ! if (square >= 0) { ! /* The current location fits in one of the county's squares. ! * We might be in that county, search for the closest streets. ! */ ! for (i = 0; i < categories_count; ++i) { ! ! count = ! roadmap_street_get_closest_in_square ! (position, square, categories[i], neighbours, count, max); ! } } } Index: buildmap_polygon.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/buildmap_polygon.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** buildmap_polygon.c 15 Oct 2005 22:19:00 -0000 1.1.1.1 --- buildmap_polygon.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 887,897 **** root = buildmap_db_add_section (NULL, "polygon"); ! head_table = buildmap_db_add_section (root, "head"); ! buildmap_db_add_data (head_table, PolygonCount, sizeof(RoadMapPolygon)); ! point_table = buildmap_db_add_section (root, "point"); ! buildmap_db_add_data (point_table, ! PolygonLineCount, sizeof(RoadMapPolygonPoint)); db_head = (RoadMapPolygon *) buildmap_db_get_data (head_table); --- 887,897 ---- root = buildmap_db_add_section (NULL, "polygon"); + if (root == NULL) buildmap_fatal (0, "Can't add a new section"); ! head_table = buildmap_db_add_child ! (root, "head", PolygonCount, sizeof(RoadMapPolygon)); ! point_table = buildmap_db_add_child ! (root, "point", PolygonLineCount, sizeof(RoadMapPolygonPoint)); db_head = (RoadMapPolygon *) buildmap_db_get_data (head_table); Index: buildus_county.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/buildus_county.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** buildus_county.c 15 Oct 2005 22:19:00 -0000 1.1.1.1 --- buildus_county.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 434,448 **** root = buildmap_db_add_section (NULL, "county"); ! data_table = buildmap_db_add_section (root, "data"); ! buildmap_db_add_data (data_table, CountyCount, sizeof(RoadMapCounty)); ! city_table = buildmap_db_add_section (root, "city2county"); ! buildmap_db_add_data ! (city_table, CountyCityCount, sizeof(RoadMapCountyCity)); ! bystate_table = buildmap_db_add_section (root, "bystate"); ! buildmap_db_add_data (bystate_table, ! state_max + 1, sizeof(RoadMapCountyByState)); db_county = (RoadMapCounty *) buildmap_db_get_data (data_table); --- 434,447 ---- root = buildmap_db_add_section (NULL, "county"); + if (root == NULL) buildmap_fatal (0, "Can't add a new section"); ! data_table = buildmap_db_add_child ! (root, "data", CountyCount, sizeof(RoadMapCounty)); ! city_table = buildmap_db_add_child ! (root, "city2county", CountyCityCount, sizeof(RoadMapCountyCity)); ! bystate_table = buildmap_db_add_child ! (root, "bystate", state_max + 1, sizeof(RoadMapCountyByState)); db_county = (RoadMapCounty *) buildmap_db_get_data (data_table); Index: buildmap_point.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/buildmap_point.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** buildmap_point.c 15 Oct 2005 22:19:01 -0000 1.1.1.1 --- buildmap_point.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 353,363 **** root = buildmap_db_add_section (NULL, "point"); ! table_data = buildmap_db_add_section (root, "data"); ! buildmap_db_add_data (table_data, PointCount, sizeof(RoadMapPoint)); ! table_bysquare = buildmap_db_add_section (root, "bysquare"); ! buildmap_db_add_data ! (table_bysquare, buildmap_square_get_count(), sizeof(RoadMapSortedList)); db_points = (RoadMapPoint *) buildmap_db_get_data (table_data); --- 353,366 ---- root = buildmap_db_add_section (NULL, "point"); + if (root == NULL) buildmap_fatal (0, "Can't add a new section"); ! table_data = buildmap_db_add_child ! (root, "data", PointCount, sizeof(RoadMapPoint)); ! table_bysquare = buildmap_db_add_child ! (root, ! "bysquare", ! buildmap_square_get_count(), ! sizeof(RoadMapSortedList)); db_points = (RoadMapPoint *) buildmap_db_get_data (table_data); Index: buildmap_square.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/buildmap_square.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** buildmap_square.c 15 Oct 2005 22:18:58 -0000 1.1.1.1 --- buildmap_square.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 311,320 **** root = buildmap_db_add_section (NULL, "square"); ! table_global = buildmap_db_add_section (root, "global"); ! buildmap_db_add_data (table_global, 1, sizeof(RoadMapGlobal)); ! table_data = buildmap_db_add_section (root, "data"); ! buildmap_db_add_data (table_data, SquareCount, sizeof(RoadMapSquare)); db_global = (RoadMapGlobal *) buildmap_db_get_data (table_global); --- 311,321 ---- root = buildmap_db_add_section (NULL, "square"); + if (root == NULL) buildmap_fatal (0, "Can't add a new section"); ! table_global = buildmap_db_add_child ! (root, "global", 1, sizeof(RoadMapGlobal)); ! table_data = buildmap_db_add_child ! (root, "data", SquareCount, sizeof(RoadMapSquare)); db_global = (RoadMapGlobal *) buildmap_db_get_data (table_global); Index: buildmap.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/buildmap.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** buildmap.h 15 Oct 2005 22:18:58 -0000 1.1.1.1 --- buildmap.h 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 78,81 **** --- 78,85 ---- char *buildmap_db_get_data (buildmap_db *section); + buildmap_db *buildmap_db_add_child (buildmap_db *parent, + char *name, + int count, + int size); void buildmap_db_close (void); Index: roadmap_fuzzy.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_fuzzy.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_fuzzy.c 15 Oct 2005 22:18:54 -0000 1.1.1.1 --- roadmap_fuzzy.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 35,41 **** #include "roadmap_line.h" #include "roadmap_locator.h" ! ! #include "editor/editor_db.h" ! #include "editor/editor_line.h" #include "roadmap_fuzzy.h" --- 35,39 ---- #include "roadmap_line.h" #include "roadmap_locator.h" ! #include "roadmap_plugin.h" #include "roadmap_fuzzy.h" *************** *** 56,59 **** --- 54,64 ---- + void roadmap_fuzzy_set_cycle_params (int street_accuracy, int confidence) { + + RoadMapAccuracyStreet = street_accuracy; + RoadMapConfidence = confidence; + } + + void roadmap_fuzzy_start_cycle (void) { *************** *** 90,94 **** * properties to fold the delta. */ ! if (delta < 0) delta += 180; if (delta > 90) delta = 180 - delta; --- 95,99 ---- * properties to fold the delta. */ ! while (delta < 0) delta += 180; if (delta > 90) delta = 180 - delta; *************** *** 96,100 **** delta = delta % 360; ! if (delta < 0) delta += 360; if (delta > 180) delta = 360 - delta; } --- 101,105 ---- delta = delta % 360; ! while (delta < 0) delta += 360; if (delta > 180) delta = 360 - delta; } *************** *** 138,185 **** ! if ((street->fips == reference->fips) && ! (street->line == reference->line)) return FUZZY_TRUTH_MAX; ! ! if (!street->plugin_id) { ! if (roadmap_locator_activate (street->fips) != ROADMAP_US_OK) { ! return 0; ! } ! roadmap_line_from (street->line, &(line_point[0])); ! roadmap_line_to (street->line, &(line_point[1])); ! ! } else { ! if (editor_db_activate (street->fips) == -1) { ! return 0; ! } ! editor_line_get ! (street->line, ! &(line_point[0]), ! &(line_point[1]), ! NULL, NULL, NULL); } ! if (!reference->plugin_id) { ! if (roadmap_locator_activate (reference->fips) != ROADMAP_US_OK) { ! return 0; ! } ! roadmap_line_from (reference->line, &(reference_point[0])); ! roadmap_line_to (reference->line, &(reference_point[1])); ! } else { ! if (editor_db_activate (reference->fips) == -1) { ! return 0; ! } ! editor_line_get ! (reference->line, ! &(reference_point[0]), ! &(reference_point[1]), ! NULL, NULL, NULL); } for (i = 0; i <= 1; ++i) { for (j = 0; j <= 1; ++j) { ! if ((line_point[i].latitude == line_point[j].latitude) && ! (line_point[i].longitude == line_point[j].longitude)) { *connection = line_point[i]; return (FUZZY_TRUTH_MAX * 2) / 3; --- 143,167 ---- ! if (roadmap_plugin_same_line (&street->line, &reference->line)) ! return FUZZY_TRUTH_MAX; ! if (roadmap_plugin_activate_db (&street->line) == -1) { ! return 0; } ! roadmap_plugin_line_from (&street->line, &(line_point[0])); ! roadmap_plugin_line_to (&street->line, &(line_point[1])); ! if (roadmap_plugin_activate_db (&reference->line) == -1) { ! return 0; } + roadmap_plugin_line_from (&reference->line, &(reference_point[0])); + roadmap_plugin_line_to (&reference->line, &(reference_point[1])); + for (i = 0; i <= 1; ++i) { for (j = 0; j <= 1; ++j) { ! if ((line_point[i].latitude == reference_point[j].latitude) && ! (line_point[i].longitude == reference_point[j].longitude)) { *connection = line_point[i]; return (FUZZY_TRUTH_MAX * 2) / 3; Index: roadmap_line.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_line.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_line.h 15 Oct 2005 22:18:50 -0000 1.1.1.1 --- roadmap_line.h 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 25,28 **** --- 25,29 ---- #define _ROADMAP_LINE__H_ + #include "roadmap_types.h" #include "roadmap_dbread.h" Index: roadmap_pointer.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_pointer.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_pointer.c 15 Oct 2005 22:19:05 -0000 1.1.1.1 --- roadmap_pointer.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 110,114 **** } - static void roadmap_pointer_moved (RoadMapGuiPoint *point) { if (!is_button_down && !is_dragging) return; --- 110,113 ---- Index: roadmap_layer.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_layer.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_layer.c 15 Oct 2005 22:18:50 -0000 1.1.1.1 --- roadmap_layer.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 34,40 **** #include "roadmap_config.h" #include "roadmap_canvas.h" #include "roadmap_layer.h" - #include "editor/editor_screen.h" --- 34,40 ---- #include "roadmap_config.h" #include "roadmap_canvas.h" + #include "roadmap_plugin.h" #include "roadmap_layer.h" *************** *** 208,217 **** - void roadmap_layer_select (int layer, int pen_type) { - - roadmap_canvas_select_pen (RoadMapCategory[layer].pen[pen_type]); - } - - RoadMapPen roadmap_layer_get_pen (int layer, int pen_type) { --- 208,211 ---- *************** *** 244,249 **** category->pen_count > 1); ! editor_adjust_layer (i, thickness, category->pen_count); ! /* As a matter of taste, I do dislike roads with a filler * of 1 pixel. Lets force at least a filler of 2. --- 238,242 ---- category->pen_count > 1); ! roadmap_plugin_adjust_layer (i, thickness, category->pen_count); /* As a matter of taste, I do dislike roads with a filler * of 1 pixel. Lets force at least a filler of 2. Index: roadmap_navigate.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_navigate.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** roadmap_navigate.c 12 Nov 2005 15:46:37 -0000 1.2 --- roadmap_navigate.c 28 Nov 2005 19:36:34 -0000 1.3 *************** *** 42,60 **** #include "roadmap_adjust.h" - #include "editor/editor_db.h" - #include "editor/editor_line.h" - #include "editor/editor_override.h" - #include "editor/editor_street.h" - #include "roadmap_navigate.h" - - - typedef struct { - RoadMapFuzzy direction; - RoadMapFuzzy distance; - RoadMapFuzzy connected; - } RoadMapDebug; - static RoadMapConfigDescriptor RoadMapNavigateFlag = ROADMAP_CONFIG_ITEM("Navigation", "Enable"); --- 42,47 ---- *************** *** 70,94 **** static RoadMapPosition RoadMapLatestPosition; - typedef struct { - - int valid; - int street; - int street_plugin_id; - - int direction; - - RoadMapFuzzy fuzzyfied; - - int intersection; - int intersection_plugin_id; - - RoadMapPosition entry; - - RoadMapDebug debug; - - } RoadMapTracking; - - #define ROADMAP_TRACKING_NULL {0, -1, 0, 0, 0, 0, 0, {0, 0}, {0, 0, 0}}; - #define ROADMAP_NEIGHBOURHOUD 16 --- 57,60 ---- *************** *** 99,127 **** ! static void roadmap_navigate_trace (const char *format, ! RoadMapNeighbour *line) { char text[1024]; ! RoadMapStreetProperties properties; ! ! if (line->plugin_id) { ! //TODO do we need to support tracing? ! return; ! } if (! roadmap_log_enabled (ROADMAP_DEBUG)) return; ! roadmap_street_get_properties (line->line, &properties); ! roadmap_message_set ! ('#', roadmap_street_get_street_address (&properties)); ! roadmap_message_set ! ('N', roadmap_street_get_street_name (&properties)); ! roadmap_message_set ! ('C', roadmap_street_get_city_name (&properties)); text[0] = 0; if (roadmap_message_format (text, sizeof(text), format)) { ! printf ("%s (line %d, street %d)\n", text, line->line, properties.street); } } --- 65,91 ---- ! static void roadmap_navigate_trace (const char *format, PluginLine *line) { char text[1024]; ! PluginStreet street; ! PluginStreetProperties properties; if (! roadmap_log_enabled (ROADMAP_DEBUG)) return; ! roadmap_plugin_get_street (line, &street); ! ! roadmap_plugin_get_street_properties (line, &properties); ! roadmap_message_set ('#', properties.address); ! roadmap_message_set ('N', properties.street); ! roadmap_message_set ('C', properties.city); text[0] = 0; if (roadmap_message_format (text, sizeof(text), format)) { ! printf ("%s (plugin_id %d, line_id %d, street_id %d)\n", ! text, ! roadmap_plugin_get_id (line), ! roadmap_plugin_get_line_id (line), ! roadmap_plugin_get_street_id (&street)); } } *************** *** 156,159 **** --- 120,124 ---- int count; int layers[128]; + int layer_count; RoadMapArea focus; *************** *** 188,199 **** roadmap_navigate_adjust_focus (&focus, &focus_point); ! count = roadmap_layer_visible_roads (layers, 128); ! if (count > 0) { roadmap_math_set_focus (&focus); count = roadmap_street_get_closest ! (position, layers, count, neighbours, max); roadmap_math_release_focus (); --- 153,167 ---- roadmap_navigate_adjust_focus (&focus, &focus_point); ! layer_count = roadmap_layer_visible_roads (layers, 128); ! if (layer_count > 0) { roadmap_math_set_focus (&focus); count = roadmap_street_get_closest ! (position, layers, layer_count, neighbours, max); ! ! count = roadmap_plugin_get_closest ! (position, layers, layer_count, neighbours, count, max); roadmap_math_release_focus (); *************** *** 225,248 **** int roadmap_navigate_retrieve_line ! (const RoadMapPosition *position, int accuracy, ! RoadMapNeighbour *closest) { if (roadmap_navigate_get_neighbours ! (position, accuracy, closest, 1) <= 0) { return -1; } ! if (roadmap_locator_activate (closest->fips) != ROADMAP_US_OK) { return -1; } return 0; } ! ! static int roadmap_navigate_fuzzify (RoadMapTracking *tracked, RoadMapNeighbour *line, int direction) { --- 193,223 ---- int roadmap_navigate_retrieve_line ! (const RoadMapPosition *position, ! int accuracy, ! PluginLine *line, ! int *distance) { ! ! RoadMapNeighbour closest; if (roadmap_navigate_get_neighbours ! (position, accuracy, &closest, 1) <= 0) { return -1; } ! *distance = closest.distance; ! ! if (roadmap_plugin_activate_db (&closest.line) == -1) { return -1; } + *line = closest.line; return 0; } ! int roadmap_navigate_fuzzify (RoadMapTracking *tracked, + RoadMapNeighbour *previous_line, RoadMapNeighbour *line, int direction) { *************** *** 250,253 **** --- 225,230 ---- RoadMapFuzzy fuzzyfied_direction; RoadMapFuzzy connected; + int line_direction = 0; + int symetric = 0; fuzzyfied_distance = roadmap_fuzzy_distance (line->distance); *************** *** 257,265 **** } ! tracked->direction = roadmap_math_azymuth (&line->from, &line->to); - //FIXME don't assume symetric roads fuzzyfied_direction = ! roadmap_fuzzy_direction (tracked->direction, direction, 1); if (! roadmap_fuzzy_is_acceptable (fuzzyfied_direction)) { --- 234,256 ---- } ! //TODO define CAR const ! #ifndef _WIN32 ! #warning implement ! #endif ! //line_direction = roadmap_plugin_get_direction (line, 0x001); ! line_direction = 1; ! ! if ((line_direction == 0) || (line_direction == 3)) { ! symetric = 1; ! } ! ! if (line_direction <= 1) { ! tracked->direction = roadmap_math_azymuth (&line->from, &line->to); ! } else { ! tracked->direction = roadmap_math_azymuth (&line->to, &line->from); ! } fuzzyfied_direction = ! roadmap_fuzzy_direction (tracked->direction, direction, symetric); if (! roadmap_fuzzy_is_acceptable (fuzzyfied_direction)) { *************** *** 267,274 **** } ! if (RoadMapConfirmedStreet.valid) { connected = roadmap_fuzzy_connected ! (line, &RoadMapConfirmedLine, &tracked->entry); } else { connected = roadmap_fuzzy_not (0); --- 258,265 ---- } ! if (previous_line != NULL) { connected = roadmap_fuzzy_connected ! (line, previous_line, &tracked->entry); } else { connected = roadmap_fuzzy_not (0); *************** *** 285,303 **** - int roadmap_delta_direction (int direction1, int direction2) { - - int delta = direction2 - direction1; - - while (delta > 180) delta -= 360; - while (delta < -180) delta += 360; - - if (delta < 0) delta = 0 - delta; - - while (delta >= 360) delta -= 360; - - return delta; - } - - static int roadmap_navigate_confirm_intersection (const RoadMapGpsPosition *position) { --- 276,279 ---- *************** *** 305,311 **** int delta; ! if (RoadMapConfirmedStreet.intersection < 0) return 0; ! delta = roadmap_delta_direction (position->steering, RoadMapConfirmedStreet.direction); --- 281,287 ---- int delta; ! if (!PLUGIN_VALID(RoadMapConfirmedStreet.intersection)) return 0; ! delta = roadmap_math_delta_direction (position->steering, RoadMapConfirmedStreet.direction); *************** *** 320,325 **** */ static RoadMapFuzzy roadmap_navigate_is_intersection ! (int line, ! int plugin_id, int direction, const RoadMapPosition *crossing) { --- 296,300 ---- */ static RoadMapFuzzy roadmap_navigate_is_intersection ! (PluginLine *line, int direction, const RoadMapPosition *crossing) { *************** *** 328,343 **** RoadMapPosition line_from; ! if ((line == RoadMapConfirmedLine.line) && ! (plugin_id == RoadMapConfirmedLine.plugin_id)) { ! ! return roadmap_fuzzy_false(); ! } ! if (!plugin_id) { ! roadmap_line_to (line, &line_to); ! roadmap_line_from (line, &line_from); ! } else { ! editor_line_get (line, &line_from, &line_to, NULL, NULL, NULL); ! } if ((line_from.latitude != crossing->latitude) || --- 303,311 ---- RoadMapPosition line_from; ! if (roadmap_plugin_same_line (line, &RoadMapConfirmedLine.line)) ! return roadmap_fuzzy_false(); ! roadmap_plugin_line_to (line, &line_to); ! roadmap_plugin_line_from (line, &line_from); if ((line_from.latitude != crossing->latitude) || *************** *** 353,358 **** return roadmap_fuzzy_not (roadmap_fuzzy_direction ! (roadmap_math_azymuth (&line_from, &line_to), ! direction, 1)); } --- 321,325 ---- return roadmap_fuzzy_not (roadmap_fuzzy_direction ! (roadmap_math_azymuth (&line_from, &line_to), direction, 1)); } *************** *** 368,376 **** */ static int roadmap_navigate_find_intersection ! (const RoadMapGpsPosition *position) { int cfcc; int square; - int line; int first_line; int last_line; --- 335,342 ---- */ static int roadmap_navigate_find_intersection ! (const RoadMapGpsPosition *position, PluginLine *found) { int cfcc; int square; int first_line; int last_line; *************** *** 378,384 **** int delta_to; int delta_from; ! RoadMapPosition *crossing; ! RoadMapPosition from_pos; ! RoadMapPosition to_pos; RoadMapFuzzy match; --- 344,348 ---- int delta_to; int delta_from; ! RoadMapPosition crossing; RoadMapFuzzy match; *************** *** 387,398 **** RoadMapStreetProperties properties; ! RoadMapNeighbour found = ROADMAP_NEIGHBOUR_NULL; ! int plugin_lines [100]; int count; int i; delta_from = ! roadmap_delta_direction (position->steering, roadmap_math_azymuth (&RoadMapLatestPosition, --- 351,362 ---- RoadMapStreetProperties properties; ! int fips = roadmap_locator_active (); ! PluginLine plugin_lines[100]; int count; int i; delta_from = ! roadmap_math_delta_direction (position->steering, roadmap_math_azymuth (&RoadMapLatestPosition, *************** *** 400,423 **** delta_to = ! roadmap_delta_direction (position->steering, roadmap_math_azymuth (&RoadMapLatestPosition, &RoadMapConfirmedLine.to)); - if (!RoadMapConfirmedLine.plugin_id) { - roadmap_line_from (RoadMapConfirmedLine.line, &from_pos); - roadmap_line_to (RoadMapConfirmedLine.line, &to_pos); - } else { - editor_line_get - (RoadMapConfirmedLine.line, - &from_pos, - &to_pos, - NULL, NULL, NULL); - } - if (delta_to < delta_from - 30) { ! crossing = &to_pos; } else if (delta_from < delta_to - 30) { ! crossing = &from_pos; } else { return 0; /* Not sure enough. */ --- 364,376 ---- delta_to = ! roadmap_math_delta_direction (position->steering, roadmap_math_azymuth (&RoadMapLatestPosition, &RoadMapConfirmedLine.to)); if (delta_to < delta_from - 30) { ! roadmap_plugin_line_to (&RoadMapConfirmedLine.line, &crossing); } else if (delta_from < delta_to - 30) { ! roadmap_plugin_line_from (&RoadMapConfirmedLine.line, &crossing); } else { return 0; /* Not sure enough. */ *************** *** 433,437 **** */ best_match = roadmap_fuzzy_false(); ! square = roadmap_square_search (crossing); if (square != -1) { --- 386,390 ---- */ best_match = roadmap_fuzzy_false(); ! square = roadmap_square_search (&crossing); if (square != -1) { *************** *** 440,468 **** if (roadmap_line_in_square ! (square, cfcc, &first_line, &last_line) > 0) { ! for (line = first_line; line <= last_line; ++line) { ! if (editor_override_line_get_flags (line) & ! ED_LINE_DELETED) { ! continue; ! } ! match = roadmap_navigate_is_intersection ! (line, 0, position->steering, crossing); ! if (best_match < match) { ! roadmap_street_get_properties (line, &properties); ! if ((properties.street > 0) && ! ((RoadMapConfirmedStreet.street_plugin_id != 0) || ! (properties.street != RoadMapConfirmedStreet.street))) { ! found.line = line; ! found.plugin_id = 0; ! best_match = match; ! } ! } ! } } --- 393,428 ---- if (roadmap_line_in_square ! (square, cfcc, &first_line, &last_line) > 0) { ! int line; ! for (line = first_line; line <= last_line; ++line) { ! PluginLine p_line = ! PLUGIN_MAKE_LINE (ROADMAP_PLUGIN_ID, line, cfcc, fips); ! if (roadmap_plugin_override_line (line, cfcc, fips)) { ! continue; ! } ! match = roadmap_navigate_is_intersection ! (&p_line, position->steering, &crossing); ! if (best_match < match) { ! PluginStreet street; ! roadmap_street_get_properties (line, &properties); ! roadmap_plugin_set_street ! (&street, ROADMAP_PLUGIN_ID, properties.street); ! ! if ((properties.street > 0) && ! !roadmap_plugin_same_street ! (&street, ! &RoadMapConfirmedStreet.street)) { ! ! *found = p_line; ! best_match = match; ! } ! } ! } } *************** *** 470,525 **** (square, cfcc, &first_line, &last_line) > 0) { ! int xline; ! for (xline = first_line; xline <= last_line; ++xline) { ! line = roadmap_line_get_from_index2 (xline); ! if (editor_override_line_get_flags (line) & ! ED_LINE_DELETED) { ! continue; ! } ! match = roadmap_navigate_is_intersection ! (line, 0, position->steering, crossing); ! if (best_match < match) { ! roadmap_street_get_properties (line, &properties); ! if ((properties.street > 0) && ! ((RoadMapConfirmedStreet.street_plugin_id != 0) || ! (properties.street != RoadMapConfirmedStreet.street))) { ! found.line = line; ! found.plugin_id = 0; ! best_match = match; ! } ! } ! } } ! } } ! count = editor_street_get_connected_lines ! (crossing, plugin_lines, sizeof(plugin_lines)/sizeof(*plugin_lines)); for (i=0; i<count; i++) { ! EditorStreetProperties editor_properties; match = roadmap_navigate_is_intersection ! (plugin_lines[i], 1, position->steering, crossing); if (best_match < match) { ! editor_street_get_properties ! (plugin_lines[i], &editor_properties); ! if ((editor_properties.street > 0) && ! (!RoadMapConfirmedStreet.street_plugin_id || ! (editor_properties.street != RoadMapConfirmedStreet.street))) { ! found.line = plugin_lines[i]; ! found.plugin_id = 1; best_match = match; } --- 430,491 ---- (square, cfcc, &first_line, &last_line) > 0) { ! int xline; ! for (xline = first_line; xline <= last_line; ++xline) { ! int line = roadmap_line_get_from_index2 (xline); ! PluginLine p_line = ! PLUGIN_MAKE_LINE (ROADMAP_PLUGIN_ID, line, cfcc, fips); ! if (roadmap_plugin_override_line (line, cfcc, fips)) { ! continue; ! } ! match = roadmap_navigate_is_intersection ! (&p_line, position->steering, &crossing); ! ! if (best_match < match) { ! PluginStreet street; ! roadmap_street_get_properties (line, &properties); ! roadmap_plugin_set_street ! (&street, ROADMAP_PLUGIN_ID, properties.street); ! if ((properties.street > 0) && ! !roadmap_plugin_same_street ! (&street, ! &RoadMapConfirmedStreet.street)) { ! ! *found = p_line; ! best_match = match; ! } ! } ! } } ! } } ! /* search plugin lines */ ! count = roadmap_plugin_find_connected_lines ! (&crossing, plugin_lines, sizeof(plugin_lines)/sizeof(*plugin_lines)); for (i=0; i<count; i++) { ! PluginStreet street; match = roadmap_navigate_is_intersection ! (&plugin_lines[i], position->steering, &crossing); ! if (best_match < match) { ! roadmap_plugin_get_street (&plugin_lines[i], &street); ! if (!roadmap_plugin_same_street ! (&street, ! &RoadMapConfirmedStreet.street)) { ! *found = plugin_lines[i]; best_match = match; } *************** *** 533,544 **** roadmap_navigate_trace ! ("Announce crossing %N, %C|Announce crossing %N", &found); ! if ((found.plugin_id != RoadMapConfirmedStreet.intersection_plugin_id) || ! (found.line != RoadMapConfirmedStreet.intersection)) { ! ! RoadMapConfirmedStreet.intersection = found.line; ! RoadMapConfirmedStreet.intersection_plugin_id = found.plugin_id; ! roadmap_display_activate ("Approach", &found, crossing); } --- 499,509 ---- roadmap_navigate_trace ! ("Announce crossing %N, %C|Announce crossing %N", found); ! if (!roadmap_plugin_same_line ! (found, &RoadMapConfirmedStreet.intersection)) { ! PluginStreet street; ! RoadMapConfirmedStreet.intersection = *found; ! roadmap_display_activate ("Approach", found, &crossing, &street); } *************** *** 588,623 **** RoadMapFuzzy before = RoadMapConfirmedStreet.fuzzyfied; ! if (roadmap_locator_activate ! (RoadMapConfirmedLine.fips) != ROADMAP_US_OK) { ! RoadMapConfirmedStreet.valid = 0; return; } ! if (!RoadMapConfirmedLine.plugin_id) { ! roadmap_street_get_distance ! (&RoadMapLatestPosition, ! RoadMapConfirmedLine.line, ! RoadMapConfirmedLine.cfcc, ! &RoadMapConfirmedLine); ! } else { ! ! if (editor_db_activate (RoadMapConfirmedLine.fips) == -1) { ! RoadMapConfirmedStreet.valid = 0; ! return; ! } ! editor_street_get_distance ! (&RoadMapLatestPosition, ! RoadMapConfirmedLine.line, ! RoadMapConfirmedLine.fips, ! &RoadMapConfirmedLine); ! } ! if (roadmap_navigate_fuzzify (&RoadMapConfirmedStreet, &RoadMapConfirmedLine, gps_position->steering) >= before) { if (! roadmap_navigate_confirm_intersection (gps_position)) { ! roadmap_navigate_find_intersection (gps_position); } --- 553,574 ---- RoadMapFuzzy before = RoadMapConfirmedStreet.fuzzyfied; ! if (roadmap_plugin_activate_db ! (&RoadMapConfirmedLine.line) == -1) { return; } ! roadmap_plugin_get_distance ! (&RoadMapLatestPosition, ! &RoadMapConfirmedLine.line, ! &RoadMapConfirmedLine); if (roadmap_navigate_fuzzify (&RoadMapConfirmedStreet, + &RoadMapConfirmedLine, &RoadMapConfirmedLine, gps_position->steering) >= before) { if (! roadmap_navigate_confirm_intersection (gps_position)) { ! PluginLine p_line; ! roadmap_navigate_find_intersection (gps_position, &p_line); } *************** *** 635,639 **** result = roadmap_navigate_fuzzify ! (&candidate, RoadMapNeighbourhood+i, gps_position->steering); --- 586,593 ---- result = roadmap_navigate_fuzzify ! (&candidate, ! RoadMapConfirmedStreet.valid ? ! &RoadMapConfirmedLine : NULL, ! RoadMapNeighbourhood+i, gps_position->steering); *************** *** 647,666 **** if (roadmap_fuzzy_is_acceptable (best)) { ! if (roadmap_locator_activate ! (RoadMapNeighbourhood[found].fips) != ROADMAP_US_OK) return; ! if ((RoadMapConfirmedLine.plugin_id != ! RoadMapNeighbourhood[found].plugin_id) || ! (RoadMapConfirmedLine.line != ! RoadMapNeighbourhood[found].line)) { ! ! if (RoadMapConfirmedLine.line > 0) { roadmap_navigate_trace ! ("Quit street %N", &RoadMapConfirmedLine); } roadmap_navigate_trace ("Enter street %N, %C|Enter street %N", ! &RoadMapNeighbourhood[found]); roadmap_display_hide ("Approach"); --- 601,618 ---- if (roadmap_fuzzy_is_acceptable (best)) { ! if (roadmap_plugin_activate_db ! (&RoadMapNeighbourhood[found].line) == -1) { return; + } ! if (!roadmap_plugin_same_line ! (&RoadMapConfirmedLine.line, &RoadMapNeighbourhood[found].line)) { ! if (PLUGIN_VALID(RoadMapConfirmedLine.line)) { roadmap_navigate_trace ! ("Quit street %N", &RoadMapConfirmedLine.line); } roadmap_navigate_trace ("Enter street %N, %C|Enter street %N", ! &RoadMapNeighbourhood[found].line); roadmap_display_hide ("Approach"); *************** *** 672,703 **** RoadMapConfirmedStreet.valid = 1; RoadMapConfirmedStreet.fuzzyfied = best; ! RoadMapConfirmedStreet.intersection = -1; ! RoadMapConfirmedStreet.intersection_plugin_id = 0; ! RoadMapConfirmedStreet.street = ! roadmap_display_activate ! ("Current Street", &RoadMapConfirmedLine, NULL); ! RoadMapConfirmedStreet.street_plugin_id = ! RoadMapConfirmedLine.plugin_id; if (gps_position->speed > roadmap_gps_speed_accuracy()) { ! roadmap_navigate_find_intersection (gps_position); } } else { ! if (RoadMapConfirmedLine.line > 0) { ! if (roadmap_locator_activate ! (RoadMapConfirmedLine.fips) != ROADMAP_US_OK) return; roadmap_navigate_trace ("Lost street %N", ! &RoadMapConfirmedLine); roadmap_display_hide ("Current Street"); roadmap_display_hide ("Approach"); } ! RoadMapConfirmedLine.line = -1; RoadMapConfirmedStreet.valid = 0; } --- 624,655 ---- RoadMapConfirmedStreet.valid = 1; RoadMapConfirmedStreet.fuzzyfied = best; ! INVALIDATE_PLUGIN(RoadMapConfirmedStreet.intersection); ! roadmap_display_activate ! ("Current Street", ! &RoadMapConfirmedLine.line, ! NULL, ! &RoadMapConfirmedStreet.street); if (gps_position->speed > roadmap_gps_speed_accuracy()) { ! PluginLine p_line; ! roadmap_navigate_find_intersection (gps_position, &p_line); } } else { ! if (PLUGIN_VALID(RoadMapConfirmedLine.line)) { ! if (roadmap_plugin_activate_db ! (&RoadMapConfirmedLine.line) == -1) return; roadmap_navigate_trace ("Lost street %N", ! &RoadMapConfirmedLine.line); roadmap_display_hide ("Current Street"); roadmap_display_hide ("Approach"); } ! INVALIDATE_PLUGIN(RoadMapConfirmedLine.line); RoadMapConfirmedStreet.valid = 0; } Index: roadmap_layer.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_layer.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_layer.h 15 Oct 2005 22:18:50 -0000 1.1.1.1 --- roadmap_layer.h 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 35,40 **** int roadmap_layer_is_visible (int layer); - void roadmap_layer_select (int layer, int pen_type); - RoadMapPen roadmap_layer_get_pen (int layer, int pen_type); --- 35,38 ---- Index: roadmap_math.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_math.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_math.h 15 Oct 2005 22:18:50 -0000 1.1.1.1 --- roadmap_math.h 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 85,91 **** (const RoadMapPosition *position1, const RoadMapPosition *position2); ! int roadmap_math_to_trip_distance (int distance); ! int roadmap_math_to_speed_unit (int knots); int roadmap_math_to_current_unit (int value, const char *unit); --- 85,91 ---- (const RoadMapPosition *position1, const RoadMapPosition *position2); ! int roadmap_math_to_trip_distance (int distance); ! int roadmap_math_to_speed_unit (int knots); int roadmap_math_to_current_unit (int value, const char *unit); *************** *** 97,101 **** RoadMapPosition *intersection); ! int roadmap_math_intersection (RoadMapPosition *from1, RoadMapPosition *to1, RoadMapPosition *from2, --- 97,101 ---- RoadMapPosition *intersection); ! int roadmap_math_intersection (RoadMapPosition *from1, RoadMapPosition *to1, RoadMapPosition *from2, *************** *** 107,112 **** int roadmap_math_street_address (const char *image, int length); ! int roadmap_math_compare_points (const RoadMapPosition *p1, const RoadMapPosition *p2); #endif // _ROADMAP_MATH__H_ --- 107,116 ---- int roadmap_math_street_address (const char *image, int length); ! int roadmap_math_compare_points (const RoadMapPosition *p1, const RoadMapPosition *p2); + int roadmap_math_delta_direction (int direction1, int direction2); + + int roadmap_math_distance_convert(const char *string, int *explicit); + #endif // _ROADMAP_MATH__H_ Index: roadmap_file.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_file.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_file.h 15 Oct 2005 22:19:03 -0000 1.1.1.1 --- roadmap_file.h 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 81,85 **** const char *sequence, const char *mode, ! RoadMapFileContext *file); void *roadmap_file_base (RoadMapFileContext file); --- 81,85 ---- const char *sequence, const char *mode, ! RoadMapFileContext *file); void *roadmap_file_base (RoadMapFileContext file); Index: roadmap_math.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_math.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_math.c 15 Oct 2005 22:18:50 -0000 1.1.1.1 --- roadmap_math.c 28 Nov 2005 19:36:34 -0000 1.2 *************** *** 33,36 **** --- 33,37 ---- #include <stdlib.h> #include <math.h> + #include <ctype.h> #include "roadmap.h" *************** *** 349,352 **** --- 350,354 ---- roadmap_math_check_point_in_segment (from, to, &point, count, intersections); + if (count == max_intersections) return count; *************** *** 370,373 **** --- 372,376 ---- roadmap_math_check_point_in_segment (from, to, &point, count, intersections); + if (count == max_intersections) return count; *************** *** 623,627 **** a = b = 0; } else { ! a = 1.0 * (from->latitude - to->latitude) / (from->longitude - to->longitude); b = from->latitude - 1.0 * a * from->longitude; } --- 626,631 ---- a = b = 0; } else { ! a = 1.0 * (from->latitude - to->latitude) / ! (from->longitude - to->longitude); b = from->latitude - 1.0 * a * from->longitude; } *************** *** 1235,1236 **** --- 1239,1302 ---- } } + + + int roadmap_math_delta_direction (int direction1, int direction2) { + + int delta = direction2 - direction1; + + while (delta > 180) delta -= 360; + while (delta < -180) delta += 360; + + if (delta < 0) delta = 0 - delta; + + while (delta >= 360) delta -= 360; + + return delta; + } + + + /* Take a number followed by ft/mi/m/km, and converts it to current units. */ + int roadmap_math_distance_convert(const char *string, int *explicit) + { + char *suffix; + double distance; + RoadMapUnits *my_units, *other_units; + int had_units = 1; + + my_units = RoadMapContext.units; + if (my_units == &RoadMapMetricSystem) { + other_units = &RoadMapImperialSystem; + } else { + other_units = &RoadMapMetricSystem; + } + + distance = strtol (string, &suffix, 10); + + while (*suffix && isspace(*suffix)) suffix++; + + if (*suffix) { + if (0 == strcasecmp(suffix, my_units->length)) { + /* Nothing to do, hopefully this is the usual case. */ + } else if (0 == strcasecmp(suffix, my_units->trip_distance)) { + distance *= my_units->to_trip_unit; + } else if (0 == strcasecmp(suffix, other_units->length)) { + distance /= other_units->cm_to_unit; + distance *= my_units->cm_to_unit; + } else if (0 == strcasecmp(suffix, other_units->trip_distance)) { + distance *= other_units->to_trip_unit; + distance /= other_units->cm_to_unit; + distance *= my_units->cm_to_unit; + } else { + roadmap_log (ROADMAP_WARNING, + "dropping unknown units '%s' from '%s'", suffix, string); + had_units = 0; + } + } else { + had_units = 0; + } + + if (explicit) *explicit = had_units; + + return (int)distance; + } + Index: roadmap_start.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/roadmap_start.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** roadmap_start.c 12 Nov 2005 15:46:37 -0000 1.2 --- roadmap_start.c 28 Nov 2005 19:36:34 -0000 1.3 *************** *** 72,76 **** #include "editor/editor_main.h" ! #include "editor/editor_export.h" static const char *RoadMapMainTitle = "RoadMap"; --- 72,76 ---- #include "editor/editor_main.h" ! #include "editor/export/editor_export.h" static const char *RoadMapMainTitle = "RoadMap"; *************** *** 97,122 **** static void roadmap_start_periodic (void); - static void roadmap_start_enable_editor (void) { - - editor_main_set (1); - roadmap_screen_redraw (); - } - - static void roadmap_start_disable_editor (void) { - - editor_main_set (0); - roadmap_screen_redraw (); - } - - static void roadmap_start_editor_export (void) { - - editor_export_data ("test.gpx"); - } - - static void roadmap_start_editor_reset_export (void) { - - editor_export_reset_dirty (); - } - static void roadmap_start_console (void) { --- 97,100 ---- *************** *** 174,177 **** --- 152,160 ---- } + static void roadmap_start_export_data (void) { + + editor_export_data ("test.xml"); + } + static void roadmap_start_create_trip (void) { *************** *** 423,437 **** "Show information about RoadMap", roadmap_start_about}, ! {"editorenable", "Enable editor", NULL, NULL, ! "Enable editor", roadmap_start_enable_editor}, ! ! {"editordisable", "Disable editor", NULL, NULL, ! "Disable editor", roadmap_start_disable_editor}, ! ! {"editorexport", "Export editor data", NULL, NULL, ! "Export editor data", roadmap_start_editor_export}, ! ! {"editorexportreset", "Unset dirty", NULL, NULL, ! "Unset dirty", roadmap_start_editor_reset_export}, {NULL, NULL, NULL, NULL, NULL, NULL} --- 406,411 ---- "Show information about RoadMap", roadmap_start_about}, ! {"exportdata", "Export Data", NULL, NULL, ! "Export editor data", roadmap_start_export_data}, {NULL, NULL, NULL, NULL, NULL, NULL} *************** *** 448,458 **** RoadMapFactorySeparator, ! "editorenable", ! "editordisable", ! "editorexport", ! "editorexportreset", RoadMapFactorySeparator, - "mutevoice", "enablevoice", --- 422,428 ---- RoadMapFactorySeparator, ! "exportdata", RoadMapFactorySeparator, "mutevoice", "enablevoice", *************** *** 575,583 **** "quit", - RoadMapFactorySeparator, - - "editorenable", - "editordisable", - NULL, }; --- 545,548 ---- *************** *** 652,656 **** static void roadmap_gps_update ! (int gps_time, const RoadMapGpsPrecisio... [truncated message content] |
From: Ehud S. <esh...@us...> - 2005-11-28 19:36:51
|
Update of /cvsroot/roadmap/roadmap_editor/src/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/src/win32 Modified Files: install.inf preferences roadmap_canvas.c roadmap_dialog.c roadmap_file.c roadmap_main.cpp roadmap_path.c roadmap_spawn.c roadmap_win32.c roadmap_win32.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export Index: roadmap_win32.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_win32.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_win32.c 15 Oct 2005 22:19:21 -0000 1.1.1.1 --- roadmap_win32.c 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 45,62 **** char* ConvertToMultiByte(const LPWSTR s, UINT nCodePage) ! { int len; int nSize = wcslen(s); ! ! len = WideCharToMultiByte(nCodePage, 0, s, nSize+1, 0, 0, NULL, NULL); ! ! if (len < 0) { ! return ""; ! } else { ! char *pAnsiString = malloc(len+1); ! WideCharToMultiByte(nCodePage, 0, s, nSize+1, pAnsiString, len+1, ! NULL, NULL); ! return pAnsiString; } } --- 45,62 ---- char* ConvertToMultiByte(const LPWSTR s, UINT nCodePage) ! { int len; int nSize = wcslen(s); ! ! len = WideCharToMultiByte(nCodePage, 0, s, nSize+1, 0, 0, NULL, NULL); ! ! if (len < 0) { ! return ""; ! } else { ! char *pAnsiString = malloc(len+1); ! WideCharToMultiByte(nCodePage, 0, s, nSize+1, pAnsiString, len+1, ! NULL, NULL); ! return pAnsiString; } } Index: roadmap_path.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_path.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_path.c 15 Oct 2005 22:19:09 -0000 1.1.1.1 --- roadmap_path.c 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 55,59 **** }; ! static const char *RoadMapPathConfigPreferred = "\\Storage Card\\roadmap"; /* The default path for the map files (the "maps" path): */ --- 55,59 ---- }; ! static const char *RoadMapPathConfigPreferred = "\\Storage Card\\roadmap"; /* The default path for the map files (the "maps" path): */ *************** *** 64,68 **** }; ! static const char *RoadMapPathMapsPreferred = "\\Storage Card\\roadmap\\maps"; /* We don't have a user directory in wince so we'll leave this one empty */ --- 64,68 ---- }; ! static const char *RoadMapPathMapsPreferred = "\\Storage Card\\roadmap\\maps"; /* We don't have a user directory in wince so we'll leave this one empty */ *************** *** 72,77 **** ! static void roadmap_path_list_create(const char *name, ! const char *items[], const char *preferred) { --- 72,77 ---- ! static void roadmap_path_list_create(const char *name, ! const char *items[], const char *preferred) { *************** *** 95,99 **** new_path->items[i] = strdup(items[i]); } ! new_path->preferred = strdup(preferred); RoadMapPaths = new_path; --- 95,99 ---- new_path->items[i] = strdup(items[i]); } ! new_path->preferred = strdup(preferred); RoadMapPaths = new_path; *************** *** 107,113 **** /* Add the hardcoded configuration. */ ! roadmap_path_list_create ("config", RoadMapPathConfig, RoadMapPathConfigPreferred); ! roadmap_path_list_create ("maps", RoadMapPathMaps, RoadMapPathMapsPreferred); roadmap_path_list_create ("user", RoadMapPathUser, roadmap_path_user()); --- 107,113 ---- /* Add the hardcoded configuration. */ ! roadmap_path_list_create ("config", RoadMapPathConfig, RoadMapPathConfigPreferred); ! roadmap_path_list_create ("maps", RoadMapPathMaps, RoadMapPathMapsPreferred); roadmap_path_list_create ("user", RoadMapPathUser, roadmap_path_user()); *************** *** 370,386 **** } ! /* This function always return a hardcoded default location, ! * which is the recommended location for these objects. ! */ ! const char *roadmap_path_preferred (const char *name) ! { ! RoadMapPathList path_list = roadmap_path_find (name); ! ! if (path_list == NULL) { ! roadmap_log (ROADMAP_FATAL, "invalid path set '%s'", name); ! } ! ! return path_list->preferred; ! } void roadmap_path_create (const char *path) --- 370,386 ---- } ! /* This function always return a hardcoded default location, ! * which is the recommended location for these objects. ! */ ! const char *roadmap_path_preferred (const char *name) ! { ! RoadMapPathList path_list = roadmap_path_find (name); ! ! if (path_list == NULL) { ! roadmap_log (ROADMAP_FATAL, "invalid path set '%s'", name); ! } ! ! return path_list->preferred; ! } void roadmap_path_create (const char *path) *************** *** 475,481 **** } ! ! const char *roadmap_path_temporary (void) { ! ! return roadmap_path_user(); ! } --- 475,481 ---- } ! ! const char *roadmap_path_temporary (void) { ! ! return roadmap_path_user(); ! } Index: roadmap_win32.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_win32.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_win32.h 15 Oct 2005 22:19:21 -0000 1.1.1.1 --- roadmap_win32.h 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 1,15 **** ! #ifndef _ROADMAP_WIN32_H_ ! #define _ROADMAP_WIN32_H_ ! ! #include <windows.h> ! #define snprintf _snprintf ! #define strdup _strdup ! #define strcasecmp _stricmp ! #define strncasecmp _strnicmp ! #define vsnprintf _vsnprintf ! #define trunc(X) (X) ! ! LPWSTR ConvertToWideChar(LPCSTR string, UINT nCodePage); ! char* ConvertToMultiByte(const LPWSTR s, UINT nCodePage); ! ! #endif /* _ROADMAP_WIN32_H_ */ --- 1,15 ---- ! #ifndef _ROADMAP_WIN32_H_ ! #define _ROADMAP_WIN32_H_ ! ! #include <windows.h> ! #define snprintf _snprintf ! #define strdup _strdup ! #define strcasecmp _stricmp ! #define strncasecmp _strnicmp ! #define vsnprintf _vsnprintf ! #define trunc(X) (X) ! ! LPWSTR ConvertToWideChar(LPCSTR string, UINT nCodePage); ! char* ConvertToMultiByte(const LPWSTR s, UINT nCodePage); ! ! #endif /* _ROADMAP_WIN32_H_ */ Index: roadmap_canvas.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_canvas.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** roadmap_canvas.c 16 Oct 2005 11:21:49 -0000 1.2 --- roadmap_canvas.c 28 Nov 2005 19:36:35 -0000 1.3 *************** *** 57,63 **** static RoadMapCanvasMouseHandler RoadMapCanvasMouseButtonPressed = roadmap_canvas_ignore_button; ! static RoadMapCanvasMouseHandler RoadMapCanvasMouseButtonReleased = ! roadmap_canvas_ignore_button; ! static RoadMapCanvasMouseHandler RoadMapCanvasMouseMove = roadmap_canvas_ignore_button; --- 57,63 ---- static RoadMapCanvasMouseHandler RoadMapCanvasMouseButtonPressed = roadmap_canvas_ignore_button; ! static RoadMapCanvasMouseHandler RoadMapCanvasMouseButtonReleased = ! roadmap_canvas_ignore_button; ! static RoadMapCanvasMouseHandler RoadMapCanvasMouseMove = roadmap_canvas_ignore_button; *************** *** 98,107 **** void roadmap_canvas_select_pen (RoadMapPen pen) { ! HPEN old; CurrentPen = pen; ! old = SelectObject(RoadMapDrawingBuffer, CreatePen(PS_SOLID, ! CurrentPen->thinkness, CurrentPen->color)); if (OldHPen == NULL) OldHPen = old; --- 98,107 ---- void roadmap_canvas_select_pen (RoadMapPen pen) { ! HPEN old; CurrentPen = pen; ! old = SelectObject(RoadMapDrawingBuffer, CreatePen(PS_SOLID, ! CurrentPen->thinkness, CurrentPen->color)); if (OldHPen == NULL) OldHPen = old; *************** *** 143,151 **** int high, i, low; COLORREF c; ! ! if (*color == '#') { ! int r, g, b; ! sscanf(color, "#%2x%2x%2x", &r, &g, &b); ! c = RGB(r, g, b); } else { /* Do binary search on color table */ --- 143,151 ---- int high, i, low; COLORREF c; ! ! if (*color == '#') { ! int r, g, b; ! sscanf(color, "#%2x%2x%2x", &r, &g, &b); ! c = RGB(r, g, b); } else { /* Do binary search on color table */ *************** *** 161,165 **** } else { c = RGB(0, 0, 0); ! } } --- 161,165 ---- } else { c = RGB(0, 0, 0); ! } } *************** *** 267,291 **** { int i; ! int count_of_points; ! POINT winpoints[1024]; ! ! HBRUSH oldBrush = SelectObject(RoadMapDrawingBuffer, ! CreateSolidBrush(CurrentPen->color)); ! for (i = 0; i < count; ++i) { ! ! RoadMapGuiPoint end_points[2]; int first = 1; count_of_points = *lines; ! ! if (count_of_points < 2) continue; ! while (count_of_points > 1024) { ! ! if (first) { ! first = 0; ! end_points[0] = *points; } roadmap_canvas_convert_points (winpoints, points, 1024); --- 267,291 ---- { int i; ! int count_of_points; ! POINT winpoints[1024]; ! ! HBRUSH oldBrush = SelectObject(RoadMapDrawingBuffer, ! CreateSolidBrush(CurrentPen->color)); ! for (i = 0; i < count; ++i) { ! ! RoadMapGuiPoint end_points[2]; int first = 1; count_of_points = *lines; ! ! if (count_of_points < 2) continue; ! while (count_of_points > 1024) { ! ! if (first) { ! first = 0; ! end_points[0] = *points; } roadmap_canvas_convert_points (winpoints, points, 1024); *************** *** 294,332 **** points += 1023; count_of_points -= 1023; ! } - if (first) { - first = 0; - end_points[0] = *points; - } - end_points[1] = points[count_of_points - 1]; roadmap_canvas_convert_points (winpoints, points, count_of_points); ! Polyline(RoadMapDrawingBuffer, winpoints, count_of_points); ! ! if (CurrentPen->thinkness > 5) { ! ! HPEN oldPen = SelectObject(RoadMapDrawingBuffer, ! GetStockObject(NULL_PEN)); ! ! int radius = CurrentPen->thinkness / 2; ! ! Ellipse(RoadMapDrawingBuffer, ! end_points[0].x - radius, end_points[0].y - radius, ! radius + end_points[0].x + 1, ! radius + end_points[0].y + 1); ! ! Ellipse(RoadMapDrawingBuffer, ! end_points[1].x - radius, end_points[1].y - radius, ! radius + end_points[1].x + 1, ! radius + end_points[1].y + 1); ! ! SelectObject(RoadMapDrawingBuffer, oldPen); ! } points += count_of_points; lines += 1; } ! DeleteObject(SelectObject(RoadMapDrawingBuffer, oldBrush)); } --- 294,332 ---- points += 1023; count_of_points -= 1023; ! } ! ! if (first) { ! first = 0; ! end_points[0] = *points; ! } end_points[1] = points[count_of_points - 1]; roadmap_canvas_convert_points (winpoints, points, count_of_points); ! Polyline(RoadMapDrawingBuffer, winpoints, count_of_points); ! ! if (CurrentPen->thinkness > 5) { ! ! HPEN oldPen = SelectObject(RoadMapDrawingBuffer, ! GetStockObject(NULL_PEN)); ! ! int radius = CurrentPen->thinkness / 2; ! ! Ellipse(RoadMapDrawingBuffer, ! end_points[0].x - radius, end_points[0].y - radius, ! radius + end_points[0].x + 1, ! radius + end_points[0].y + 1); ! ! Ellipse(RoadMapDrawingBuffer, ! end_points[1].x - radius, end_points[1].y - radius, ! radius + end_points[1].x + 1, ! radius + end_points[1].y + 1); ! ! SelectObject(RoadMapDrawingBuffer, oldPen); ! } points += count_of_points; lines += 1; } ! DeleteObject(SelectObject(RoadMapDrawingBuffer, oldBrush)); } *************** *** 340,344 **** POINT winpoints[1024]; HBRUSH oldBrush; ! if (filled) { oldBrush = SelectObject(RoadMapDrawingBuffer, --- 340,344 ---- POINT winpoints[1024]; HBRUSH oldBrush; ! if (filled) { oldBrush = SelectObject(RoadMapDrawingBuffer, *************** *** 375,383 **** { int i; ! HBRUSH oldBrush; if (filled) { oldBrush = SelectObject(RoadMapDrawingBuffer, ! CreateSolidBrush(CurrentPen->color)); } else { oldBrush = SelectObject(RoadMapDrawingBuffer, --- 375,383 ---- { int i; ! HBRUSH oldBrush; if (filled) { oldBrush = SelectObject(RoadMapDrawingBuffer, ! CreateSolidBrush(CurrentPen->color)); } else { oldBrush = SelectObject(RoadMapDrawingBuffer, *************** *** 391,395 **** int x = centers[i].x - r; int y = centers[i].y - r; ! Ellipse(RoadMapDrawingBuffer, x, y, --- 391,395 ---- int x = centers[i].x - r; int y = centers[i].y - r; ! Ellipse(RoadMapDrawingBuffer, x, y, *************** *** 419,461 **** } - ! void roadmap_canvas_button_released(POINT *data) ! { ! RoadMapGuiPoint point; ! ! point.x = (short)data->x; ! point.y = (short)data->y; ! ! (*RoadMapCanvasMouseButtonReleased) (&point); ! ! } ! ! ! void roadmap_canvas_mouse_move(POINT *data) ! { ! RoadMapGuiPoint point; ! ! point.x = (short)data->x; ! point.y = (short)data->y; ! ! (*RoadMapCanvasMouseMove) (&point); } ! void roadmap_canvas_register_button_pressed_handler ( ! RoadMapCanvasMouseHandler handler) ! { ! RoadMapCanvasMouseButtonPressed = handler; ! } ! ! ! void roadmap_canvas_register_button_released_handler ( ! RoadMapCanvasMouseHandler handler) ! { ! RoadMapCanvasMouseButtonReleased = handler; ! } ! void roadmap_canvas_register_mouse_move_handler ( --- 419,461 ---- } ! ! void roadmap_canvas_button_released(POINT *data) ! { ! RoadMapGuiPoint point; ! ! point.x = (short)data->x; ! point.y = (short)data->y; ! ! (*RoadMapCanvasMouseButtonReleased) (&point); } ! void roadmap_canvas_mouse_move(POINT *data) ! { ! RoadMapGuiPoint point; ! ! point.x = (short)data->x; ! point.y = (short)data->y; ! ! (*RoadMapCanvasMouseMove) (&point); ! ! } ! ! ! void roadmap_canvas_register_button_pressed_handler ( ! RoadMapCanvasMouseHandler handler) ! { ! RoadMapCanvasMouseButtonPressed = handler; ! } ! ! ! void roadmap_canvas_register_button_released_handler ( ! RoadMapCanvasMouseHandler handler) ! { ! RoadMapCanvasMouseButtonReleased = handler; ! } ! void roadmap_canvas_register_mouse_move_handler ( Index: preferences =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/preferences,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** preferences 16 Oct 2005 16:47:34 -0000 1.2 --- preferences 28 Nov 2005 19:36:35 -0000 1.3 *************** *** 1,68 **** ! Destination.Color: red ! GPS.Background: LightYellow ! GPS.Color: red ! GPS.Foreground: black ! Help.Arguments: %s ! Help.Browser: \windows\iexplore ! Highlight.Background: yellow ! Highlight.Duration: 10 ! Highlight.Thickness: 4 ! Location.Color: red ! Polygons.Declutter: 1300 ! Shapes.Declutter: 1300 ! Style.Use Pretty Lines: yes ! Drivers.Trace: Disabled ! Drivers.Kismet: Disabled ! Drivers.Friends: Disabled ! Drivers.Ghost2: Disabled ! Drivers.Ghost1: Disabled ! Drivers.Port: 2007 ! Map.GPS map offset longitude: 0 ! Map.GPS map offset latitude: 0 ! Download.Destination: \Storage Card\Roadmap\maps ! Download.Source: /usr/local/share/roadmap/usc%05d.rdm ! History.Depth: 100 ! GPS.Timeout: 10 ! GPS.Baud Rate: 4800 ! GPS.Source: com7: ! Accuracy.GPS Position: 30 ! Accuracy.GPS Speed: 4 ! Voice.Selected Street: flite -t 'Selected %N' ! Voice.Next Intersection: flite -t 'Next intersection: %N' ! Voice.Current Street: flite -t 'On %N' ! Voice.Approach: flite -t 'Approaching %N' ! Error.Foreground: white ! Error.Background: red ! Info.Foreground: black ! Info.Background: yellow ! Selected Street.Foreground: black ! Selected Street.Background: yellow ! Selected Street.Text: %F ! Approach.Foreground: white ! Approach.Background: DarkSeaGreen4 ! Approach.Text: Approaching %N, %C|Approaching %N ! Current Street.Foreground: white ! Current Street.Background: DarkSeaGreen4 ! Current Street.Text: %N, %C|%N ! Console.Foreground: black ! Console.Background: yellow ! Display.Top Right: ETA: %A|%T ! Display.Bottom Left: %S ! Display.Bottom Right: %D (%W)|%D ! Display.Duration: 10 ! Accuracy.Confidence: 25 ! Accuracy.Street: 35 ! Style.Show Objects when Dragging: yes ! Style.Pretty Lines when Dragging: yes ! Map.Refresh: normal ! Map.Signs: yes ! Map.Background: LightYellow ! Accuracy.Mouse: 20 ! Display.Rotate: yes ! General.Default Zoom: 20 ! Map.Cache: 8 ! General.Icons: yes ! General.Toolbar: yes ! Geometry.Main: 800x600 ! General.Keyboard: no ! General.Unit: metric --- 1,24 ---- ! Destination.Color: red ! Download.Destination: \Storage Card\Roadmap\maps ! Map.Cache: 8 ! Map.Background: LightYellow ! General.Default Zoom: 20 ! General.Keyboard: no ! General.Icons: yes ! General.Toolbar: yes ! General.Unit: imperial ! GPS.Background: LightYellow ! GPS.Baud Rate: 4800 ! GPS.Color: red ! GPS.Foreground: black ! GPS.Source: com1: ! GPS.Timeout: 10 ! Help.Arguments: %s ! Help.Browser: \windows\iexplore ! Highlight.Background: yellow ! Highlight.Duration: 10 ! Highlight.Thickness: 4 ! Location.Color: red ! Polygons.Declutter: 1300 ! Shapes.Declutter: 1300 ! Display.Rotate: yes Index: roadmap_main.cpp =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_main.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_main.cpp 15 Oct 2005 22:19:21 -0000 1.1.1.1 --- roadmap_main.cpp 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 325,334 **** case WM_DESTROY: ! if (RoadMapMainMenuBar != NULL) { ! DestroyWindow(RoadMapMainMenuBar); ! } ! if (RoadMapMainToolbar != NULL) { ! CommandBar_Destroy(RoadMapMainToolbar); } PostQuitMessage(0); --- 325,334 ---- case WM_DESTROY: ! if (RoadMapMainMenuBar != NULL) { ! DestroyWindow(RoadMapMainMenuBar); ! } ! if (RoadMapMainToolbar != NULL) { ! CommandBar_Destroy(RoadMapMainToolbar); } PostQuitMessage(0); *************** *** 346,373 **** } break; ! ! case WM_LBUTTONUP: ! { ! POINT point; ! point.x = LOWORD(lParam); ! point.y = HIWORD(lParam); ! if (RoadMapMainToolbar != NULL) { ! point.y -= 26; ! } ! roadmap_canvas_button_released(&point); ! } ! break; ! ! case WM_MOUSEMOVE: ! { ! POINT point; ! point.x = LOWORD(lParam); ! point.y = HIWORD(lParam); ! if (RoadMapMainToolbar != NULL) { ! point.y -= 26; ! } ! roadmap_canvas_mouse_move(&point); ! } ! break; case WM_KEYDOWN: --- 346,373 ---- } break; ! ! case WM_LBUTTONUP: ! { ! POINT point; ! point.x = LOWORD(lParam); ! point.y = HIWORD(lParam); ! if (RoadMapMainToolbar != NULL) { ! point.y -= 26; ! } ! roadmap_canvas_button_released(&point); ! } ! break; ! ! case WM_MOUSEMOVE: ! { ! POINT point; ! point.x = LOWORD(lParam); ! point.y = HIWORD(lParam); ! if (RoadMapMainToolbar != NULL) { ! point.y -= 26; ! } ! roadmap_canvas_mouse_move(&point); ! } ! break; case WM_KEYDOWN: *************** *** 484,494 **** RoadMapMainInput = callback; } ! ! ! RoadMapMenu roadmap_main_new_menu (void) ! { ! return CreatePopupMenu(); } ! void roadmap_main_add_menu (RoadMapMenu menu, const char *label) --- 484,494 ---- RoadMapMainInput = callback; } ! ! ! RoadMapMenu roadmap_main_new_menu (void) ! { ! return CreatePopupMenu(); } ! void roadmap_main_add_menu (RoadMapMenu menu, const char *label) *************** *** 518,522 **** ! void roadmap_main_add_menu_item (RoadMapMenu menu, const char *label, const char *tip, RoadMapCallback callback) { --- 518,522 ---- ! void roadmap_main_add_menu_item (RoadMapMenu menu, const char *label, const char *tip, RoadMapCallback callback) { *************** *** 543,551 **** } } ! ! void roadmap_main_popup_menu (RoadMapMenu menu, int x, int y) { ! ! TrackPopupMenuEx( (HMENU)menu, 0, x, y, RoadMapMainWindow, NULL); ! } void roadmap_main_add_separator (RoadMapMenu menu) --- 543,551 ---- } } ! ! void roadmap_main_popup_menu (RoadMapMenu menu, int x, int y) { ! ! TrackPopupMenuEx( (HMENU)menu, 0, x, y, RoadMapMainWindow, NULL); ! } void roadmap_main_add_separator (RoadMapMenu menu) Index: roadmap_dialog.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_dialog.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_dialog.c 15 Oct 2005 22:19:21 -0000 1.1.1.1 --- roadmap_dialog.c 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 101,105 **** char *value; char *ansi_value; ! RoadMapDialogSelection *choice; int num_choices; }; --- 101,105 ---- char *value; char *ansi_value; ! RoadMapDialogSelection *choice; int num_choices; }; *************** *** 112,116 **** const char *name) { ! RoadMapDialogItem child; RoadMapDialogItem last_child = NULL; --- 112,116 ---- const char *name) { ! RoadMapDialogItem child; RoadMapDialogItem last_child = NULL; *************** *** 124,128 **** if (strcmp (child->name, name) == 0) { return child; ! } last_child = child; child = child->next; --- 124,128 ---- if (strcmp (child->name, name) == 0) { return child; ! } last_child = child; child = child->next; *************** *** 149,165 **** child->value = ""; child->ansi_value = NULL; ! child->choice = NULL; child->num_choices = 0; if (parent != NULL) { ! ! child->rank = parent->count; ! child->next = NULL; ! ! if (last_child == NULL) { ! parent->children = child; ! } else { ! last_child->next = child; ! } parent->count += 1; --- 149,165 ---- child->value = ""; child->ansi_value = NULL; ! child->choice = NULL; child->num_choices = 0; if (parent != NULL) { ! ! child->rank = parent->count; ! child->next = NULL; ! ! if (last_child == NULL) { ! parent->children = child; ! } else { ! last_child->next = child; ! } parent->count += 1; *************** *** 336,340 **** child->choice = choice; child->callback = callback; ! child->value = choice[0].value; child->num_choices = count; } --- 336,340 ---- child->choice = choice; child->callback = callback; ! child->value = choice[0].value; child->num_choices = count; } *************** *** 399,403 **** } child->choice = choice; ! child->value = choice[0].value; child->num_choices = count; --- 399,403 ---- } child->choice = choice; ! child->value = choice[0].value; child->num_choices = count; *************** *** 552,568 **** free(str); } ! break; ! case ROADMAP_WIDGET_CHOICE: ! { ! int i; ! for (i=0; i<this_item->num_choices; i++) { ! if (data == this_item->choice[i].value) { ! SendMessage ! (this_item->w, (UINT) CB_SETCURSEL, (WPARAM) i, (LPARAM) 0); ! break; ! } ! } ! } ! break; } --- 552,568 ---- free(str); } ! break; ! case ROADMAP_WIDGET_CHOICE: ! { ! int i; ! for (i=0; i<this_item->num_choices; i++) { ! if (data == this_item->choice[i].value) { ! SendMessage ! (this_item->w, (UINT) CB_SETCURSEL, (WPARAM) i, (LPARAM) 0); ! break; ! } ! } ! } ! break; } *************** *** 799,805 **** SetWindowLong(hDlg, GWL_USERDATA, (LONG)dialog); ! SetWindowLong(hDlg, GWL_STYLE, ! GetWindowLong(hDlg, GWL_STYLE) | WS_NONAVDONEBUTTON); ! SHDoneButton(hDlg, SHDB_HIDE); --- 799,805 ---- SetWindowLong(hDlg, GWL_USERDATA, (LONG)dialog); ! SetWindowLong(hDlg, GWL_STYLE, ! GetWindowLong(hDlg, GWL_STYLE) | WS_NONAVDONEBUTTON); ! SHDoneButton(hDlg, SHDB_HIDE); Index: roadmap_spawn.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_spawn.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_spawn.c 15 Oct 2005 22:19:11 -0000 1.1.1.1 --- roadmap_spawn.c 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 48,58 **** memset(&pi, 0, sizeof(pi)); ! if (*name != '\\') { snprintf(full_name, MAX_PATH, "%s\\%s", RoadMapSpawnPath, name); ! full_path_unicode = ConvertToWideChar(full_name, CP_UTF8); ! } else { ! full_path_unicode = ConvertToWideChar(name, CP_UTF8); ! } if (command_line != NULL) { --- 48,58 ---- memset(&pi, 0, sizeof(pi)); ! if (*name != '\\') { snprintf(full_name, MAX_PATH, "%s\\%s", RoadMapSpawnPath, name); ! full_path_unicode = ConvertToWideChar(full_name, CP_UTF8); ! } else { ! full_path_unicode = ConvertToWideChar(name, CP_UTF8); ! } if (command_line != NULL) { Index: install.inf =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/install.inf,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** install.inf 16 Oct 2005 16:47:33 -0000 1.2 --- install.inf 28 Nov 2005 19:36:35 -0000 1.3 *************** *** 1,71 **** ! [CEStrings] ! AppName = "Roadmap" ! InstallDir = %CE1%\%AppName% ! ! [Strings] ! CompanyName = "RoadMap" ! ! [Version] ! Signature = "$Chicago$" ! CESignature = "$Windows CE$" ! Provider = %CompanyName% ! ! [DefaultInstall] ! CEShortcuts = Shortcuts.All ! ! [DefaultInstall.ARM] ! CopyFiles = Files.Config, Files.Maps , Files.ARM ! ! [SourceDisksNames] ! 1 = ,"Common config files",,L:\shared\roadmap_editor\src ! 2 = ,"Common map files",,L:\shared\roadmap_editor\maps ! 5 = ,"WinCE preferences",,L:\shared\roadmap_editor\src\win32 ! 6 = ,"Manual",,L:\shared\roadmap_editor\manual ! ! [SourceDisksNames.ARM] ! 3 = ,"ARM files",,L:\shared\roadmap_editor\src\win32\wince_env\Roadmap\ARMV4Rel ! 4 = ,"ARM files",,L:\shared\roadmap_editor\src\win32\wince_env\RoadGPS\ARMV4Rel ! ! [SourceDisksFiles] ! drivers = 1 ! preferences = 5 ! roadmap.toolbar = 5 ! schema = 1 ! sprites = 1 ! usc77001.rdm = 2 ! usdir.rdm = 2 ! apt_toc.gif = 6 ! manual.html = 6 ! ! [SourceDisksFiles.ARM] ! Roadmap.exe = 3 ! RoadGPS.exe = 4 ! ! [DestinationDirs] ! Shortcuts.All = 0,%CE11% ! Files.Config = 0,%InstallDir% ! Files.Maps = 0,%InstallDir%\Maps ! Files.ARM = 0,%InstallDir% ! DefaultDestDir = 0,%InstallDir% ! ! [Shortcuts.All] ! %AppName%,0,Roadmap.exe ! RoadGPS,0,RoadGPS.exe ! ! [Files.Config] ! drivers,,,0x00000010 ! preferences,,,0x00000010 ! roadmap.toolbar,,,0x00000010 ! schema,,,0x00000010 ! sprites,,,0x00000010 ! apt_toc.gif,,,0 ! manual.html,,,0 ! ! [Files.Maps] ! usc77001.rdm,,,0x00000010 ! usdir.rdm,,,0x00000010 ! ! [Files.ARM] ! Roadmap.exe,,,0 ! RoadGPS.exe,,,0 ! --- 1,71 ---- ! [CEStrings] ! AppName = "Roadmap" ! InstallDir = %CE1%\%AppName% ! ! [Strings] ! CompanyName = "RoadMap" ! ! [Version] ! Signature = "$Chicago$" ! CESignature = "$Windows CE$" ! Provider = %CompanyName% ! ! [DefaultInstall] ! CEShortcuts = Shortcuts.All ! ! [DefaultInstall.ARM] ! CopyFiles = Files.Config, Files.Maps , Files.ARM ! ! [SourceDisksNames] ! 1 = ,"Common config files",,L:\shared\roadmap_editor\src ! 2 = ,"Common map files",,L:\shared\roadmap_editor\maps ! 5 = ,"WinCE preferences",,L:\shared\roadmap_editor\src\win32 ! 6 = ,"Manual",,L:\shared\roadmap_editor\manual ! ! [SourceDisksNames.ARM] ! 3 = ,"ARM files",,L:\shared\roadmap_editor\src\win32\wince_env\Roadmap\ARMV4Rel ! 4 = ,"ARM files",,L:\shared\roadmap_editor\src\win32\wince_env\RoadGPS\ARMV4Rel ! ! [SourceDisksFiles] ! drivers = 1 ! preferences = 5 ! roadmap.toolbar = 5 ! schema = 1 ! sprites = 1 ! usc77001.rdm = 2 ! usdir.rdm = 2 ! apt_toc.gif = 6 ! manual.html = 6 ! ! [SourceDisksFiles.ARM] ! Roadmap.exe = 3 ! RoadGPS.exe = 4 ! ! [DestinationDirs] ! Shortcuts.All = 0,%CE11% ! Files.Config = 0,%InstallDir% ! Files.Maps = 0,%InstallDir%\Maps ! Files.ARM = 0,%InstallDir% ! DefaultDestDir = 0,%InstallDir% ! ! [Shortcuts.All] ! %AppName%,0,Roadmap.exe ! RoadGPS,0,RoadGPS.exe ! ! [Files.Config] ! drivers,,,0x00000010 ! preferences,,,0x00000010 ! roadmap.toolbar,,,0x00000010 ! schema,,,0x00000010 ! sprites,,,0x00000010 ! apt_toc.gif,,,0 ! manual.html,,,0 ! ! [Files.Maps] ! usc77001.rdm,,,0x00000010 ! usdir.rdm,,,0x00000010 ! ! [Files.ARM] ! Roadmap.exe,,,0 ! RoadGPS.exe,,,0 ! Index: roadmap_file.c =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/roadmap_file.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_file.c 15 Oct 2005 22:19:21 -0000 1.1.1.1 --- roadmap_file.c 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 187,244 **** free(full_name_unicode); ! if (file != INVALID_HANDLE_VALUE) { ! DWORD res; ! res = SetFilePointer (file, 0, NULL, FILE_END); ! ! if (res != INVALID_SET_FILE_POINTER) { ! WriteFile(file, data, length, &res, NULL); } CloseHandle(file); } } - ! int roadmap_file_truncate (const char *path, const char *name, ! int length) { ! ! HANDLE file; ! const char *full_name = roadmap_path_join (path, name); ! DWORD res = -1; ! ! LPWSTR full_name_unicode = ConvertToWideChar(full_name, CP_UTF8); ! ! file = CreateFile (full_name_unicode, ! GENERIC_WRITE, ! 0, ! NULL, ! OPEN_ALWAYS, ! 0, ! NULL); ! ! roadmap_path_free (full_name); ! free(full_name_unicode); ! ! if (file != INVALID_HANDLE_VALUE) { ! ! res = SetFilePointer (file, length, NULL, FILE_BEGIN); ! ! if (res != INVALID_SET_FILE_POINTER) { ! res = SetEndOfFile(file); ! if (res == 0) { ! res = -1; ! } else { ! res = 0; ! } ! } else { ! res = -1; ! } ! ! CloseHandle(file); ! } ! ! return res; ! } ! const char *roadmap_file_unique (const char *base) --- 187,244 ---- free(full_name_unicode); ! if (file != INVALID_HANDLE_VALUE) { ! DWORD res; ! res = SetFilePointer (file, 0, NULL, FILE_END); ! ! if (res != INVALID_SET_FILE_POINTER) { ! WriteFile(file, data, length, &res, NULL); } CloseHandle(file); } } ! ! int roadmap_file_truncate (const char *path, const char *name, ! int length) { ! ! HANDLE file; ! const char *full_name = roadmap_path_join (path, name); ! DWORD res = -1; ! ! LPWSTR full_name_unicode = ConvertToWideChar(full_name, CP_UTF8); ! ! file = CreateFile (full_name_unicode, ! GENERIC_WRITE, ! 0, ! NULL, ! OPEN_ALWAYS, ! 0, ! NULL); ! ! roadmap_path_free (full_name); ! free(full_name_unicode); ! ! if (file != INVALID_HANDLE_VALUE) { ! ! res = SetFilePointer (file, length, NULL, FILE_BEGIN); ! ! if (res != INVALID_SET_FILE_POINTER) { ! res = SetEndOfFile(file); ! if (res == 0) { ! res = -1; ! } else { ! res = 0; ! } ! } else { ! res = -1; ! } ! ! CloseHandle(file); ! } ! ! return res; ! } ! const char *roadmap_file_unique (const char *base) *************** *** 278,288 **** const char *roadmap_file_map (const char *set, const char *name, ! const char *sequence, const char *mode, RoadMapFileContext *file) { RoadMapFileContext context; ! DWORD file_size; ! int map_mode; int open_mode; --- 278,288 ---- const char *roadmap_file_map (const char *set, const char *name, ! const char *sequence, const char *mode, RoadMapFileContext *file) { RoadMapFileContext context; ! DWORD file_size; ! int map_mode; int open_mode; *************** *** 293,308 **** context->base = NULL; context->size = 0; ! ! if (strcmp(mode, "r") == 0) { ! open_mode = GENERIC_READ; ! map_mode = PAGE_READONLY; ! } else if (strchr (mode, 'w') != NULL) { ! open_mode = GENERIC_READ | GENERIC_WRITE; ! map_mode = PAGE_READWRITE; ! } else { ! roadmap_log (ROADMAP_ERROR, ! "%s: invalid file access mode %s", name, mode); ! return NULL; ! } if ((name[0] == '\\') || (name[0] == '/')) { --- 293,308 ---- context->base = NULL; context->size = 0; ! ! if (strcmp(mode, "r") == 0) { ! open_mode = GENERIC_READ; ! map_mode = PAGE_READONLY; ! } else if (strchr (mode, 'w') != NULL) { ! open_mode = GENERIC_READ | GENERIC_WRITE; ! map_mode = PAGE_READWRITE; ! } else { ! roadmap_log (ROADMAP_ERROR, ! "%s: invalid file access mode %s", name, mode); ! return NULL; ! } if ((name[0] == '\\') || (name[0] == '/')) { |
From: Ehud S. <esh...@us...> - 2005-11-28 19:36:51
|
Update of /cvsroot/roadmap/roadmap_editor/src/win32/wince_env/libroadmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/src/win32/wince_env/libroadmap Modified Files: libroadmap.vcp Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export Index: libroadmap.vcp =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/win32/wince_env/libroadmap/libroadmap.vcp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** libroadmap.vcp 15 Oct 2005 22:19:23 -0000 1.1.1.1 --- libroadmap.vcp 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 105,109 **** CPP=cl.exe # ADD BASE CPP /nologo /W3 /Oxs /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_LIB" /YX /Gs8192 /GF /c ! # ADD CPP /nologo /W3 /Oxs /I "./wince_os" /I "../../wince_os/" /I "../../" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_LIB" /YX /Gs8192 /GF /c LIB32=link.exe -lib # ADD BASE LIB32 /nologo --- 105,109 ---- CPP=cl.exe # ADD BASE CPP /nologo /W3 /Oxs /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_LIB" /YX /Gs8192 /GF /c ! # ADD CPP /nologo /W3 /Oxs /I "./wince_os" /I "../../wince_os/" /I "../../" /I "l:\shared\roadmap_merged\src" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_LIB" /YX /Gs8192 /GF /c LIB32=link.exe -lib [...3963 lines suppressed...] - "..\..\..\editor\editor_square.h"\ - "..\..\..\editor\editor_street.h"\ "..\..\..\roadmap.h"\ "..\..\..\roadmap_db.h"\ --- 6261,6264 ---- *************** *** 5055,5058 **** --- 6277,6288 ---- "..\..\roadmap_win32.h"\ + NODEP_CPP_ROADMAP_ST=\ + "..\..\..\editor\editor_db.h"\ + "..\..\..\editor\editor_dictionary.h"\ + "..\..\..\editor\editor_line.h"\ + "..\..\..\editor\editor_override.h"\ + "..\..\..\editor\editor_square.h"\ + "..\..\..\editor\editor_street.h"\ + !ENDIF |
From: Ehud S. <esh...@us...> - 2005-11-28 19:36:50
|
Update of /cvsroot/roadmap/roadmap_editor/src/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/src/qt Modified Files: Makefile qt_main.cc qt_main.h roadmap_main.cc Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export Index: qt_main.cc =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/qt/qt_main.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** qt_main.cc 15 Oct 2005 22:19:07 -0000 1.1.1.1 --- qt_main.cc 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 65,69 **** // Implementation of RMapMainWindow class RMapMainWindow::RMapMainWindow(const char* name) : QMainWindow(0, name) { - currentMenu = 0; spacePressed = false; for (int i = 0 ; i < ROADMAP_MAX_TIMER; ++i) { --- 65,68 ---- *************** *** 92,118 **** } ! void RMapMainWindow::addMenu(const char* label) { ! currentMenu = new QPopupMenu(this); ! menuBar()->insertItem(label, currentMenu); } ! void RMapMainWindow::addMenuItem(const char* label, const char* tip, ! RoadMapCallback callback) { ! if (currentMenu == 0) { roadmap_log (ROADMAP_FATAL, "No menu defined for menu item %s", label); } RMapCallback* cb = new RMapCallback(callback); ! currentMenu->insertItem(label, cb, SLOT(fire())); } ! void RMapMainWindow::addMenuSeparator() { ! if (currentMenu == 0) { roadmap_log (ROADMAP_FATAL, "No menu defined for menu separator"); } ! currentMenu->insertSeparator(); } --- 91,136 ---- } ! QPopupMenu *RMapMainWindow::newMenu() { ! ! return new QPopupMenu(this); ! } ! void RMapMainWindow::freeMenu(QPopupMenu *menu) { ! ! delete (menu); } ! void RMapMainWindow::addMenu(QPopupMenu *menu, const char* label) { ! menuBar()->insertItem(label, menu); ! } ! ! void RMapMainWindow::addMenuItem(QPopupMenu *menu, const char* label, ! const char* tip, RoadMapCallback callback) { ! ! if (menu == 0) { roadmap_log (ROADMAP_FATAL, "No menu defined for menu item %s", label); } RMapCallback* cb = new RMapCallback(callback); ! menu->insertItem(label, cb, SLOT(fire())); } ! void RMapMainWindow::popupMenu(QPopupMenu *menu, int x, int y) { ! ! if (menu == 0) { ! roadmap_log (ROADMAP_FATAL, "No menu defined for menu popup"); ! } ! ! menu->popup (QPoint (x, y)); ! } ! ! void RMapMainWindow::addMenuSeparator(QPopupMenu *menu) { ! ! if (menu == 0) { roadmap_log (ROADMAP_FATAL, "No menu defined for menu separator"); } ! menu->insertSeparator(); } Index: Makefile =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/qt/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile 15 Oct 2005 22:19:05 -0000 1.1.1.1 --- Makefile 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 15,21 **** WARNFLAGS=-W -Wall -Wno-unused-parameter ! GUICFLAGS=-I/usr/include/qt3 -I/usr/local/include/qt3 ! GUILDFLAGS=-lqt ! MOC=/usr/bin/moc --- 15,22 ---- WARNFLAGS=-W -Wall -Wno-unused-parameter ! QTDIR=/usr/qt/3 ! GUICFLAGS=-I/usr/include/qt3 -I/usr/local/include/qt3 -I$(QTDIR)/include ! GUILDFLAGS=-L $(QTDIR)/lib -lqt ! MOC=moc Index: qt_main.h =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/qt/qt_main.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** qt_main.h 15 Oct 2005 22:19:05 -0000 1.1.1.1 --- qt_main.h 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 92,100 **** void setKeyboardCallback(RoadMapKeyInput c); ! void addMenu(const char* label); ! void addMenuItem(const char* label, const char* tip, RoadMapCallback callback); ! void addMenuSeparator(); void addTool(const char* label, const char *icon, const char* tip, --- 92,103 ---- void setKeyboardCallback(RoadMapKeyInput c); ! QPopupMenu *newMenu(); ! void freeMenu(QPopupMenu *menu); ! void addMenu(QPopupMenu *menu, const char* label); ! void addMenuItem(QPopupMenu *menu, const char* label, const char* tip, RoadMapCallback callback); + void popupMenu(QPopupMenu *menu, int x, int y); ! void addMenuSeparator(QPopupMenu *menu); void addTool(const char* label, const char *icon, const char* tip, *************** *** 112,116 **** protected: RoadMapKeyInput keyCallback; - QPopupMenu* currentMenu; QMap<int, RMapInput*> inputMap; QToolBar* toolBar; --- 115,118 ---- Index: roadmap_main.cc =================================================================== RCS file: /cvsroot/roadmap/roadmap_editor/src/qt/roadmap_main.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** roadmap_main.cc 15 Oct 2005 22:19:05 -0000 1.1.1.1 --- roadmap_main.cc 28 Nov 2005 19:36:35 -0000 1.2 *************** *** 91,111 **** } ! void roadmap_main_add_menu(const char* label) { if (mainWindow) { ! mainWindow->addMenu(label); } } ! void roadmap_main_add_menu_item(const char* label, const char* tip, ! RoadMapCallback callback) { if (mainWindow) { ! mainWindow->addMenuItem(label, tip, callback); } } ! void roadmap_main_add_separator(void) { if (mainWindow) { ! mainWindow->addMenuSeparator(); } } --- 91,136 ---- } ! RoadMapMenu roadmap_main_new_menu (void) { ! if (mainWindow) { ! return mainWindow->newMenu(); ! } else { ! return (RoadMapMenu) NULL; ! } ! } ! ! void roadmap_main_free_menu (RoadMapMenu menu) { ! ! if (mainWindow) { ! mainWindow->freeMenu((QPopupMenu *)menu); } } ! void roadmap_main_popup_menu (RoadMapMenu menu, int x, int y) { if (mainWindow) { ! mainWindow->popupMenu((QPopupMenu *)menu, x, y); } } ! void roadmap_main_add_menu (RoadMapMenu menu, const char *label) { if (mainWindow) { ! mainWindow->addMenu((QPopupMenu *)menu, label); ! } ! } ! ! void roadmap_main_add_menu_item (RoadMapMenu menu, ! const char *label, ! const char *tip, ! RoadMapCallback callback) { ! ! if (mainWindow) { ! mainWindow->addMenuItem((QPopupMenu *)menu, label, tip, callback); ! } ! } ! ! void roadmap_main_add_separator(RoadMapMenu menu) { ! if (mainWindow) { ! mainWindow->addMenuSeparator((QPopupMenu *)menu); } } |
Update of /cvsroot/roadmap/roadmap_editor/src/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv592/src/editor Removed Files: .editor_main.c.swp editor_db.c editor_db.h editor_dialog.c editor_dialog.h editor_dictionary.c editor_dictionary.h editor_export.c editor_export.h editor_line.c editor_line.h editor_log.h editor_main.c editor_main.h editor_override.c editor_override.h editor_point.c editor_point.h editor_route.c editor_route.h editor_screen.c editor_screen.h editor_shape.c editor_shape.h editor_square.c editor_square.h editor_street.c editor_street.h editor_track.c editor_track.h editor_trkseg.c editor_trkseg.h Log Message: Merged with 1.0.12 Reorganized editor code into subdirectories Implemented export --- editor_main.c DELETED --- --- editor_screen.h DELETED --- --- editor_main.h DELETED --- --- editor_screen.c DELETED --- --- editor_trkseg.c DELETED --- --- editor_override.h DELETED --- --- editor_trkseg.h DELETED --- --- editor_override.c DELETED --- --- editor_dictionary.h DELETED --- --- editor_square.c DELETED --- --- editor_dictionary.c DELETED --- --- editor_route.h DELETED --- --- editor_route.c DELETED --- --- editor_point.c DELETED --- --- editor_line.c DELETED --- --- editor_point.h DELETED --- --- editor_line.h DELETED --- --- editor_street.c DELETED --- --- editor_log.h DELETED --- --- editor_street.h DELETED --- --- editor_square.h DELETED --- --- editor_track.c DELETED --- --- editor_db.c DELETED --- --- editor_export.c DELETED --- --- editor_db.h DELETED --- --- editor_track.h DELETED --- --- editor_export.h DELETED --- --- editor_dialog.h DELETED --- --- .editor_main.c.swp DELETED --- --- editor_shape.h DELETED --- --- editor_dialog.c DELETED --- --- editor_shape.c DELETED --- |