diff options
author | Ian McIntosh <ian_mcintosh@linuxadvocate.org> | 2005-03-28 12:49:50 +0000 |
---|---|---|
committer | Ian McIntosh <ian_mcintosh@linuxadvocate.org> | 2005-03-28 12:49:50 +0000 |
commit | f8f00fdfc32900138a44b81190e9869f24acbc57 (patch) | |
tree | 6b24a6b4e6630ffcf8253fea351d462b2622c1b8 | |
parent | 360a03476f7c3bf748c9c050253aaf37d097e410 (diff) |
Added this file for global flags.
Added #include for main.h. Change from using pointstring_t to road_t for
map geometry objects.
Add map_side_test_line() to test which side of a line a point is.
Tooltip now reports the address range of that part of the street.
Removed GPS tab temporarily.
Minor style changes.
41 files changed, 720 insertions, 527 deletions
@@ -1,3 +1,13 @@ +2005-03-28 Ian McIntosh <ian_mcintosh@linuxadvocate.org> + + * src/main.h: Added this file for global flags. + * src/*: Added #include for main.h. Change from using pointstring_t to road_t for map geometry objects. + * src/map.c: Add map_side_test_line() to test which side of a line a point is. + * src/mainwindow.c: Tooltip now reports the address range of that part of the street. + + * data/roadster.glade: Removed GPS tab temporarily. + * data/layers.xml: Minor style changes. + 2005-03-26 Ian McIntosh <ian_mcintosh@linuxadvocate.org> * src/mainwindow.c: Made zoom and history buttons (and menuitems) go insentitive when clicking them would do nothing. Changed single-click on border to always scroll half of window width/height/diagonal. diff --git a/data/layers.xml b/data/layers.xml index bddf124..52bdbfa 100644 --- a/data/layers.xml +++ b/data/layers.xml @@ -35,7 +35,7 @@ <layer name="major-roads"> <sublayer> <property name="width" level="5" value="8.0" /> - <property name="width" level="6" value="11.0" /> + <property name="width" level="6" value="9.0" /> <property name="width" level="7" value="13.0" /> <property name="width" level="8" value="15.0" /> <property name="width" level="9" value="24.0" /> @@ -48,7 +48,7 @@ <property name="width" level="3" value="1.8" /> <property name="width" level="4" value="2.5" /> <property name="width" level="5" value="6.0" /> - <property name="width" level="6" value="9.0" /> + <property name="width" level="6" value="7.0" /> <property name="width" level="7" value="11.0" /> <property name="width" level="8" value="13.0" /> <property name="width" level="9" value="21.0" /> @@ -187,17 +187,18 @@ <layer name="railroads"> <sublayer> - <property name="width" level="7" value="0.6" /> - <property name="width" level="10" value="1.2" /> - <property name="color" value="#50506eff" /> + <property name="width" level="6" value="0.5" /> + <property name="width" level="7" value="2.2" /> + <property name="color" value="#808080ff" /> <property name="join-style" value="miter" /> <property name="cap-style" value="butt" /> </sublayer> <sublayer> - <property name="width" level="7" value="3.0" /> + <property name="width" level="6" value="1.0" /> + <property name="width" level="7" value="4.0" /> <property name="width" level="9" value="4.0" /> <property name="width" level="10" value="7.0" /> - <property name="color" value="#50506eff" /> + <property name="color" value="#404040ff" /> <property name="join-style" value="miter" /> <property name="cap-style" value="butt" /> <property name="dash-style" value="1" /> @@ -217,7 +218,7 @@ <property name="cap-style" value="butt" /> </sublayer> <label> - <property name="color" value="#202020ff" /> + <property name="color" value="#338833FF" /> <property name="font-size" level="6" value="10" /> <property name="font-size" level="8" value="12" /> <property name="font-size" level="10" value="14" /> @@ -234,7 +235,7 @@ <property name="width" level="8" value="3.0" /> <property name="width" level="9" value="6.0" /> <property name="width" level="10" value="8.0" /> - <property name="color" value="#C2C0F8ff" /> + <property name="color" value="#B9B9F8FF" /> <property name="join-style" value="round" /> <property name="cap-style" value="round" /> </sublayer> @@ -248,7 +249,7 @@ <property name="cap-style" value="butt" /> </sublayer> <label> - <property name="color" value="#202020ff" /> + <property name="color" value="#5250F8FF" /> <property name="font-size" level="6" value="10" /> <property name="font-size" level="8" value="12" /> <property name="font-size" level="10" value="14" /> diff --git a/data/roadster.glade b/data/roadster.glade index 34a376d..4b0509c 100644 --- a/data/roadster.glade +++ b/data/roadster.glade @@ -2031,7 +2031,7 @@ Restaurants</property> <child> <widget class="GtkLabel" id="label92260"> <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small">_Label all results on map</span></property> + <property name="label" translatable="yes"><span size="small">_Limit to visible map and POI</span></property> <property name="use_underline">True</property> <property name="use_markup">True</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -2084,368 +2084,6 @@ Restaurants</property> </child> <child> - <widget class="GtkVBox" id="gpstabvbox"> - <property name="border_width">4</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkHBox" id="gpsstatushbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">4</property> - - <child> - <widget class="GtkLabel" id="speedlabel"> - <property name="width_request">89</property> - <property name="visible">True</property> - <property name="label" translatable="yes"><span font_desc='32'>199</span></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_RIGHT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">1</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="speedunitslabel"> - <property name="visible">True</property> - <property name="label" translatable="yes"><span font_desc="12">MPH</span></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.9</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label92242"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkEventBox" id="eventbox11"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">GPS signal strength (higher is better)</property> - <property name="visible_window">True</property> - <property name="above_child">False</property> - - <child> - <widget class="GtkProgressBar" id="gpssignalprogressbar"> - <property name="visible">True</property> - <property name="orientation">GTK_PROGRESS_BOTTOM_TO_TOP</property> - <property name="fraction">0</property> - <property name="pulse_step">0</property> - <property name="text" translatable="yes"></property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame30"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkAlignment" id="alignment62"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">4</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkVBox" id="gpsoptionsvbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkCheckButton" id="gpsshowpositioncheckbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="mainwindow_on_gps_show_position_toggled" last_modification_time="Sun, 20 Mar 2005 06:20:04 GMT"/> - - <child> - <widget class="GtkLabel" id="label92256"> - <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small">_Show position on map</span></property> - <property name="use_underline">True</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame31"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkAlignment" id="alignment63"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">8</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkVBox" id="vbox8864"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">4</property> - - <child> - <widget class="GtkCheckButton" id="gpskeeppositioncenteredcheckbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="mainwindow_on_gps_keep_position_centered_toggled" last_modification_time="Sun, 20 Mar 2005 06:23:34 GMT"/> - - <child> - <widget class="GtkLabel" id="label92257"> - <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small">Keep position _centered</span></property> - <property name="use_underline">True</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkCheckButton" id="gpsshowtrailcheckbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="mainwindow_on_gps_show_trail_toggled" last_modification_time="Sun, 20 Mar 2005 06:20:50 GMT"/> - - <child> - <widget class="GtkLabel" id="label92258"> - <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small">Show GPS _trail</span></property> - <property name="use_underline">True</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkCheckButton" id="gpssticktoroadscheckbutton"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="mainwindow_on_gps_stick_to_roads_toggled" last_modification_time="Sun, 20 Mar 2005 06:21:05 GMT"/> - - <child> - <widget class="GtkLabel" id="label92259"> - <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small">Stick to Roads</span></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label92240"> - <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small"><b>GPS Options</b></span></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label92238"> - <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small">_2. GPS</span></property> - <property name="use_underline">True</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> <widget class="GtkVBox" id="drawtabvbox"> <property name="visible">True</property> <property name="homogeneous">False</property> @@ -2559,7 +2197,7 @@ Restaurants</property> <child> <widget class="GtkLabel" id="sideboxnotebookdrawlabel"> <property name="visible">True</property> - <property name="label" translatable="yes"><span size="small">_3. POI</span></property> + <property name="label" translatable="yes"><span size="small">_2. POI</span></property> <property name="use_underline">True</property> <property name="use_markup">True</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -2585,7 +2223,6 @@ Restaurants</property> <child> <widget class="GtkFrame" id="frame32"> <property name="height_request">135</property> - <property name="visible">True</property> <property name="label_xalign">0</property> <property name="label_yalign">0.5</property> <property name="shadow_type">GTK_SHADOW_IN</property> @@ -3491,4 +3128,357 @@ Below, enter any MySQL user account that has rights to create a database, probab </child> </widget> +<widget class="GtkWindow" id="___gps_tab"> + <property name="title" translatable="yes">window1</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + + <child> + <widget class="GtkVBox" id="gpstabvbox"> + <property name="border_width">4</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">8</property> + + <child> + <widget class="GtkHBox" id="gpsstatushbox"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">4</property> + + <child> + <widget class="GtkLabel" id="speedlabel"> + <property name="width_request">89</property> + <property name="visible">True</property> + <property name="label" translatable="yes"><span font_desc='32'>199</span></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_RIGHT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">1</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="speedunitslabel"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span font_desc="12">MPH</span></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.9</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label92242"> + <property name="visible">True</property> + <property name="label" translatable="yes"></property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkEventBox" id="eventbox11"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">GPS signal strength (higher is better)</property> + <property name="visible_window">True</property> + <property name="above_child">False</property> + + <child> + <widget class="GtkProgressBar" id="gpssignalprogressbar"> + <property name="visible">True</property> + <property name="orientation">GTK_PROGRESS_BOTTOM_TO_TOP</property> + <property name="fraction">0</property> + <property name="pulse_step">0</property> + <property name="text" translatable="yes"></property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="frame30"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + + <child> + <widget class="GtkAlignment" id="alignment62"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">4</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="gpsoptionsvbox"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkCheckButton" id="gpsshowpositioncheckbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="mainwindow_on_gps_show_position_toggled" last_modification_time="Sun, 20 Mar 2005 06:20:04 GMT"/> + + <child> + <widget class="GtkLabel" id="label92256"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span size="small">_Show position on map</span></property> + <property name="use_underline">True</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="frame31"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + + <child> + <widget class="GtkAlignment" id="alignment63"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">8</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox8864"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">4</property> + + <child> + <widget class="GtkCheckButton" id="gpskeeppositioncenteredcheckbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="mainwindow_on_gps_keep_position_centered_toggled" last_modification_time="Sun, 20 Mar 2005 06:23:34 GMT"/> + + <child> + <widget class="GtkLabel" id="label92257"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span size="small">Keep position _centered</span></property> + <property name="use_underline">True</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="gpsshowtrailcheckbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="mainwindow_on_gps_show_trail_toggled" last_modification_time="Sun, 20 Mar 2005 06:20:50 GMT"/> + + <child> + <widget class="GtkLabel" id="label92258"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span size="small">Show GPS _trail</span></property> + <property name="use_underline">True</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="gpssticktoroadscheckbutton"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="mainwindow_on_gps_stick_to_roads_toggled" last_modification_time="Sun, 20 Mar 2005 06:21:05 GMT"/> + + <child> + <widget class="GtkLabel" id="label92259"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span size="small">Stick to Roads</span></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label92240"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span size="small"><b>GPS Options</b></span></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface> diff --git a/src/animator.c b/src/animator.c index b090c65..d3d7116 100644 --- a/src/animator.c +++ b/src/animator.c @@ -27,6 +27,7 @@ #include <gtk/gtk.h> +#include "main.h" #include "animator.h" #include "util.h" diff --git a/src/databasewindow.c b/src/databasewindow.c index 1bb5cac..d76af5f 100644 --- a/src/databasewindow.c +++ b/src/databasewindow.c @@ -26,6 +26,7 @@ #include <gtk/gtk.h> #include <glade/glade.h> +#include "main.h" #include "db.h" #include "gui.h" #include "databasewindow.h" diff --git a/src/datasetwindow.c b/src/datasetwindow.c index 4b90988..6834ac4 100644 --- a/src/datasetwindow.c +++ b/src/datasetwindow.c @@ -29,6 +29,7 @@ #include <gtk/gtk.h> +#include "main.h" #include "util.h" #include "datasetwindow.h" #include "mainwindow.h" @@ -21,8 +21,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define USE_GNOME_VFS - #include <mysql.h> #define HAVE_MYSQL_EMBED @@ -36,16 +34,17 @@ #include <stdio.h> #include <string.h> -#ifdef USE_GNOME_VFS -#include <gnome-vfs-2.0/libgnomevfs/gnome-vfs.h> -#endif - +#include "main.h" #include "db.h" #include "mainwindow.h" #include "util.h" #include "layers.h" #include "locationset.h" +#ifdef USE_GNOME_VFS +#include <gnome-vfs-2.0/libgnomevfs/gnome-vfs.h> +#endif + #define MYSQL_RESULT_SUCCESS (0) // for clearer code #define MAX_SQLBUFFER_LEN (132000) // must be big for lists of coordinates @@ -488,7 +487,7 @@ gboolean db_insert_state(const gchar* pszName, const gchar* pszCode, gint nCount #define WKB_POINT 1 // only two we care about #define WKB_LINESTRING 2 -void db_parse_wkb_pointstring(const gint8* data, pointstring_t* pPointString, gboolean (*callback_get_point)(mappoint_t**)) +void db_parse_wkb_linestring(const gint8* data, GPtrArray* pPointsArray, gboolean (*callback_alloc_point)(mappoint_t**)) { g_assert(sizeof(double) == 8); // mysql gives us 8 bytes per point @@ -502,12 +501,12 @@ void db_parse_wkb_pointstring(const gint8* data, pointstring_t* pPointString, gb while(nNumPoints > 0) { mappoint_t* pPoint = NULL; - if(!callback_get_point(&pPoint)) return; + if(!callback_alloc_point(&pPoint)) return; pPoint->m_fLatitude = *((double*)data)++; pPoint->m_fLongitude = *((double*)data)++; - g_ptr_array_add(pPointString->m_pPointsArray, pPoint); + g_ptr_array_add(pPointsArray, pPoint); nNumPoints--; } @@ -79,9 +79,7 @@ void db_end_thread(void); gchar* db_make_escaped_string(const gchar* pszString); void db_free_escaped_string(gchar* pszString); -void db_parse_point(const gchar* pszText, mappoint_t* pPoint); -//void db_parse_pointstring(const gchar* pszText, pointstring_t* pPointString, gboolean (*callback_get_point)(mappoint_t**)); -void db_parse_wkb_pointstring(const gint8* data, pointstring_t* pPointString, gboolean (*callback_get_point)(mappoint_t**)); +void db_parse_wkb_linestring(const gint8* data, GPtrArray* pPointsArray, gboolean (*callback_alloc_point)(mappoint_t**)); void db_enable_keys(void); void db_disable_keys(void); diff --git a/src/glyph.c b/src/glyph.c index 5b90c4e..62e4934 100644 --- a/src/glyph.c +++ b/src/glyph.c @@ -22,7 +22,6 @@ */ #include <gtk/gtk.h> - #include <cairo.h> #ifdef HAVE_LIBSVG diff --git a/src/gotowindow.c b/src/gotowindow.c index 863d728..6e97c52 100644 --- a/src/gotowindow.c +++ b/src/gotowindow.c @@ -23,6 +23,7 @@ #include <glade/glade.h> #include <gtk/gtk.h> +#include "main.h" #include "mainwindow.h" #include "gotowindow.h" diff --git a/src/gpsclient.c b/src/gpsclient.c index 02aca52..d3372e8 100644 --- a/src/gpsclient.c +++ b/src/gpsclient.c @@ -23,6 +23,7 @@ #include <gtk/gtk.h> #include <gps.h> // gpslib +#include "main.h" #include "gpsclient.h" struct { @@ -28,9 +28,9 @@ #include <glade/glade.h> #include <gtk/gtk.h> +#include "main.h" #include "gui.h" #include "db.h" - #include "mainwindow.h" #include "gotowindow.h" #include "importwindow.h" diff --git a/src/history.c b/src/history.c index 05dba78..3d19bcc 100644 --- a/src/history.c +++ b/src/history.c @@ -22,6 +22,7 @@ */ #include <gtk/gtk.h> +#include "main.h" #include "history.h" #include "map.h" diff --git a/src/import.c b/src/import.c index 7c3bb25..dcfe742 100644 --- a/src/import.c +++ b/src/import.c @@ -21,13 +21,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define USE_GNOME_VFS - #include <stdlib.h> #include <stdio.h> #include <string.h> #include <gtk/gtk.h> +#include "main.h" #include "import.h" #include "importwindow.h" #include "import_tiger.h" diff --git a/src/import_tiger.c b/src/import_tiger.c index 8be3a30..348a78e 100644 --- a/src/import_tiger.c +++ b/src/import_tiger.c @@ -22,21 +22,20 @@ */ // See TGR2003.PDF page 208 for county list -#define USE_GNOME_VFS - #include <stdlib.h> // for strtod #include <string.h> -#ifdef USE_GNOME_VFS -#include <gnome-vfs-2.0/libgnomevfs/gnome-vfs.h> -#endif - +#include "main.h" #include "util.h" #include "import_tiger.h" #include "importwindow.h" #include "road.h" +#ifdef USE_GNOME_VFS +#include <gnome-vfs-2.0/libgnomevfs/gnome-vfs.h> +#endif + #define TIGER_RT1_LINE_LENGTH (230) #define TIGER_RT2_LINE_LENGTH (210) #define TIGER_RT7_LINE_LENGTH (76) diff --git a/src/importwindow.c b/src/importwindow.c index f10f537..a0fdab4 100644 --- a/src/importwindow.c +++ b/src/importwindow.c @@ -23,6 +23,7 @@ #include <glade/glade.h> #include <gtk/gtk.h> +#include "main.h" #include "db.h" #include "import.h" #include "mainwindow.h" diff --git a/src/layers.c b/src/layers.c index 8aff6ad..b11daf0 100644 --- a/src/layers.c +++ b/src/layers.c @@ -27,6 +27,7 @@ #include <cairo.h> #include <libxml/parser.h> #include <libxml/tree.h> +#include "main.h" #include "layers.h" layer_t * g_aLayers[NUM_LAYERS+1]; diff --git a/src/location.c b/src/location.c index 4491b2e..2547d42 100644 --- a/src/location.c +++ b/src/location.c @@ -22,6 +22,7 @@ */ #include <gtk/gtk.h> +#include "main.h" #include "map.h" #include "location.h" diff --git a/src/locationset.c b/src/locationset.c index 34d1732..3a37f14 100644 --- a/src/locationset.c +++ b/src/locationset.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <gtk/gtk.h> +#include "main.h" #include "location.h" #include "locationset.h" #include "db.h" @@ -20,13 +20,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define USE_GNOME_VFS #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <gtk/gtk.h> +#include "main.h" #include "gui.h" #include "db.h" #include "map.h" @@ -34,6 +34,7 @@ #include "scenemanager.h" #include "prefs.h" #include "animator.h" +#include "road.h" static gboolean main_init(void); static void main_deinit(void); @@ -80,6 +81,10 @@ gboolean main_init(void) point_init(); g_print("initializing pointstrings\n"); pointstring_init(); + + g_print("initializing roads\n"); + road_init(); + g_print("initializing tracks\n"); track_init(); g_print("initializing layers\n"); diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..eac362f --- /dev/null +++ b/src/main.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * main.h + * + * Copyright 2005 Ian McIntosh + * ian_mcintosh@linuxadvocate.org + ****************************************************************************/ + +/* + * This program 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. + * + * This program 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 Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#define USE_GNOME_VFS +//#define ENABLE_TIMING +#define USE_GFREELIST + diff --git a/src/mainwindow.c b/src/mainwindow.c index c72c06c..dbf2e39 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -28,6 +28,7 @@ #include <gtk/gtk.h> #include <gtk/gtksignal.h> +#include "main.h" #include "search_road.h" #include "gui.h" #include "util.h" @@ -66,7 +67,7 @@ #define DRAW_PRETTY_RESIZE_TIMEOUT_MS (180) #define SCROLL_TIMEOUT_MS (80) // how often (in MS) to move -#define SCROLL_DISTANCE_IN_PIXELS (120) // how far to move every (above) MS +#define SCROLL_DISTANCE_IN_PIXELS (100) // how far to move every (above) MS #define BORDER_SCROLL_CLICK_TARGET_SIZE (20) // the size of the click target (distance from edge of map view) to begin scrolling #define SLIDE_TIMEOUT_MS (50) // time between frames (in MS) for smooth-sliding (on double click?) @@ -81,7 +82,7 @@ #define MAX_SEARCH_TEXT_LENGTH (100) #define SPEED_LABEL_FORMAT ("<span font_desc='32'>%.0f</span>") -#define TOOLTIP_FORMAT (" %s ") +#define TOOLTIP_FORMAT ("%s") // Settings #define TIMER_GPS_REDRAW_INTERVAL_MS (2500) // lower this (to 1000?) when it's faster to redraw track @@ -26,15 +26,7 @@ #include <gtk/gtk.h> #include <math.h> -//#define THREADED_RENDERING -//#define SCENEMANAGER_DEBUG_TEST - -#ifdef THREADED_RENDERING -#define RENDERING_THREAD_YIELD g_thread_yield() -#else -#define RENDERING_THREAD_YIELD -#endif - +#include "main.h" #include "gui.h" #include "map.h" #include "mainwindow.h" @@ -46,6 +38,12 @@ #include "locationset.h" #include "scenemanager.h" +#ifdef THREADED_RENDERING +#define RENDERING_THREAD_YIELD g_thread_yield() +#else +#define RENDERING_THREAD_YIELD +#endif + #define RENDERMODE_FAST 1 // Use 'fast' until Cairo catches up. :) #define RENDERMODE_PRETTY 2 @@ -70,8 +68,10 @@ static gboolean map_data_load_tiles(map_t* pMap, maprect_t* pRect); // ensure ti static gboolean map_data_load(map_t* pMap, maprect_t* pRect); // hit testing -static gboolean map_hit_test_layer_lines(GPtrArray* pPointStringsArray, gdouble fMaxDistance, mappoint_t* pHitPoint, gchar** ppReturnString); -static gboolean map_hit_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mappoint_t* pHitPoint, gdouble fDistance); +static gboolean map_hit_test_layer_roads(GPtrArray* pPointStringsArray, gdouble fMaxDistance, mappoint_t* pHitPoint, gchar** ppReturnString); +static gboolean map_hit_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mappoint_t* pHitPoint, gdouble fDistance, mappoint_t* pReturnClosestPoint); + +static ESide map_side_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mappoint_t* pClosestPointOnLine, mappoint_t* pHitPoint); static void map_data_clear(map_t* pMap); void map_get_render_metrics(map_t* pMap, rendermetrics_t* pMetrics); @@ -165,7 +165,7 @@ gboolean map_new(map_t** ppMap, GtkWidget* pTargetWidget) gint i; for(i=0 ; i<NUM_ELEMS(pMap->m_apLayerData) ; i++) { maplayer_data_t* pLayer = g_new0(maplayer_data_t, 1); - pLayer->m_pPointStringsArray = g_ptr_array_new(); + pLayer->m_pRoadsArray = g_ptr_array_new(); pMap->m_apLayerData[i] = pLayer; } @@ -492,7 +492,7 @@ static gboolean map_data_load(map_t* pMap, maprect_t* pRect) // generate SQL gchar* pszSQL; pszSQL = g_strdup_printf( - "SELECT Road.ID, Road.TypeID, AsBinary(Road.Coordinates), RoadName.Name, RoadName.SuffixID" + "SELECT Road.ID, Road.TypeID, AsBinary(Road.Coordinates), RoadName.Name, RoadName.SuffixID, AddressLeftStart, AddressLeftEnd, AddressRightStart, AddressRightEnd" " FROM Road " " LEFT JOIN RoadName ON (Road.RoadNameID=RoadName.ID)" " WHERE" @@ -523,6 +523,10 @@ static gboolean map_data_load(map_t* pMap, maprect_t* pRect) // aRow[2] is Coordinates in mysql's text format // aRow[3] is road name // aRow[4] is road name suffix id + // aRow[5] is road address left start + // aRow[6] is road address left end + // aRow[7] is road address right start + // aRow[8] is road address right end // g_print("data: %s, %s, %s, %s, %s\n", aRow[0], aRow[1], aRow[2], aRow[3], aRow[4]); // Get layer type that this belongs on @@ -533,12 +537,15 @@ static gboolean map_data_load(map_t* pMap, maprect_t* pRect) } // Extract points - pointstring_t* pNewPointString = NULL; - if(!pointstring_alloc(&pNewPointString)) { - g_warning("out of memory loading pointstrings\n"); - continue; - } - db_parse_wkb_pointstring(aRow[2], pNewPointString, point_alloc); + road_t* pNewRoad = NULL; + road_alloc(&pNewRoad); + + //pointstring_t* pNewPointString = NULL; + //if(!pointstring_alloc(&pNewPointString)) { + // g_warning("out of memory loading pointstrings\n"); + // continue; + //} + db_parse_wkb_linestring(aRow[2], pNewRoad->m_pPointsArray, point_alloc); // Build name by adding suffix, if one is present gchar azFullName[100] = ""; @@ -550,11 +557,15 @@ static gboolean map_data_load(map_t* pMap, maprect_t* pRect) g_snprintf(azFullName, 100, "%s%s%s", aRow[3], (pszSuffix[0] != '\0') ? " " : "", pszSuffix); } - pNewPointString->m_pszName = g_strdup(azFullName); + pNewRoad->m_nAddressLeftStart = atoi(aRow[5]); + pNewRoad->m_nAddressLeftEnd = atoi(aRow[6]); + pNewRoad->m_nAddressRightStart = atoi(aRow[7]); + pNewRoad->m_nAddressRightEnd = atoi(aRow[8]); + + pNewRoad->m_pszName = g_strdup(azFullName); // Add this item to layer's list of pointstrings - g_ptr_array_add( - pMap->m_apLayerData[nTypeID]->m_pPointStringsArray, pNewPointString); + g_ptr_array_add(pMap->m_apLayerData[nTypeID]->m_pRoadsArray, pNewRoad); } // end while loop on rows //g_print("[%d rows]\n", uRowCount); TIMER_SHOW(mytimer, "after rows retrieved"); @@ -577,12 +588,12 @@ static void map_data_clear(map_t* pMap) for(i=0 ; i<NUM_ELEMS(pMap->m_apLayerData) ; i++) { maplayer_data_t* pLayerData = pMap->m_apLayerData[i]; - // Free each pointstring - for(j = (pLayerData->m_pPointStringsArray->len - 1) ; j>=0 ; j--) { - pointstring_t* pPointString = g_ptr_array_remove_index_fast(pLayerData->m_pPointStringsArray, j); - pointstring_free(pPointString); + // Free each + for(j = (pLayerData->m_pRoadsArray->len - 1) ; j>=0 ; j--) { + road_t* pRoad = g_ptr_array_remove_index_fast(pLayerData->m_pRoadsArray, j); + road_free(pRoad); } - g_assert(pLayerData->m_pPointStringsArray->len == 0); + g_assert(pLayerData->m_pRoadsArray->len == 0); } } @@ -654,20 +665,22 @@ gboolean map_hit_test(map_t* pMap, mappoint_t* pMapPoint, gchar** ppReturnString gdouble fLineWidth = max(g_aLayers[nLayer]->m_Style.m_aSubLayers[0].m_afLineWidths[pMap->m_uZoomLevel-1], g_aLayers[nLayer]->m_Style.m_aSubLayers[1].m_afLineWidths[pMap->m_uZoomLevel-1]); +#define EXTRA_CLICKABLE_ROAD_IN_PIXELS (8) + // make thin roads a little easier to hit fLineWidth = max(fLineWidth, MIN_ROAD_HIT_TARGET_WIDTH); // XXX: hack, map_pixels should really take a floating point instead. - gdouble fMaxDistance = map_pixels_to_degrees(pMap, 1, pMap->m_uZoomLevel) * (fLineWidth/2); // half width on each side + gdouble fMaxDistance = map_pixels_to_degrees(pMap, 1, pMap->m_uZoomLevel) * ((fLineWidth/2) + EXTRA_CLICKABLE_ROAD_IN_PIXELS); // half width on each side - if(map_hit_test_layer_lines(pMap->m_apLayerData[nLayer]->m_pPointStringsArray, fMaxDistance, pMapPoint, ppReturnString)) { + if(map_hit_test_layer_roads(pMap->m_apLayerData[nLayer]->m_pRoadsArray, fMaxDistance, pMapPoint, ppReturnString)) { return TRUE; } } return FALSE; } -static gboolean map_hit_test_layer_lines(GPtrArray* pPointStringsArray, gdouble fMaxDistance, mappoint_t* pHitPoint, gchar** ppReturnString) +static gboolean map_hit_test_layer_roads(GPtrArray* pRoadsArray, gdouble fMaxDistance, mappoint_t* pHitPoint, gchar** ppReturnString) { g_assert(ppReturnString != NULL); g_assert(*ppReturnString == NULL); // pointer to null pointer @@ -681,24 +694,47 @@ static gboolean map_hit_test_layer_lines(GPtrArray* pPointStringsArray, gdouble // Loop through line strings, order doesn't matter here since they're all on the same level. gint iString; - for(iString=0 ; iString<pPointStringsArray->len ; iString++) { - pointstring_t* pPointString = g_ptr_array_index(pPointStringsArray, iString); - if(pPointString->m_pPointsArray->len < 2) continue; + for(iString=0 ; iString<pRoadsArray->len ; iString++) { + road_t* pRoad = g_ptr_array_index(pRoadsArray, iString); + if(pRoad->m_pPointsArray->len < 2) continue; // start on 1 so we can do -1 trick below gint iPoint; - for(iPoint=1 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) { - mappoint_t* pPoint1 = g_ptr_array_index(pPointString->m_pPointsArray, iPoint-1); - mappoint_t* pPoint2 = g_ptr_array_index(pPointString->m_pPointsArray, iPoint); + for(iPoint=1 ; iPoint<pRoad->m_pPointsArray->len ; iPoint++) { + mappoint_t* pPoint1 = g_ptr_array_index(pRoad->m_pPointsArray, iPoint-1); + mappoint_t* pPoint2 = g_ptr_array_index(pRoad->m_pPointsArray, iPoint); + + mappoint_t pointClosest; // hit test this line - if(map_hit_test_line(pPoint1, pPoint2, pHitPoint, fMaxDistance)) { + if(map_hit_test_line(pPoint1, pPoint2, pHitPoint, fMaxDistance, &pointClosest)) { // got a hit - if(pPointString->m_pszName[0] == '\0') { + if(pRoad->m_pszName[0] == '\0') { *ppReturnString = g_strdup("<i>unnamed road</i>"); } else { - *ppReturnString = g_strdup(pPointString->m_pszName); + ESide eSide = map_side_test_line(pPoint1, pPoint2, &pointClosest, pHitPoint); + + gint nAddressStart; + gint nAddressEnd; + if(eSide == SIDE_LEFT) { + nAddressStart = pRoad->m_nAddressLeftStart; + nAddressEnd = pRoad->m_nAddressLeftEnd; + } + else { + nAddressStart = pRoad->m_nAddressRightStart; + nAddressEnd = pRoad->m_nAddressRightEnd; + } + + if(nAddressStart == 0 || nAddressEnd == 0) { + *ppReturnString = g_strdup_printf("%s", pRoad->m_pszName); + } + else { + gint nMinAddres = min(nAddressStart, nAddressEnd); + gint nMaxAddres = max(nAddressStart, nAddressEnd); + + *ppReturnString = g_strdup_printf("%s <b>#%d-%d</b>", pRoad->m_pszName, nMinAddres, nMaxAddres); + } } return TRUE; } @@ -708,7 +744,7 @@ static gboolean map_hit_test_layer_lines(GPtrArray* pPointStringsArray, gdouble } // Does the given point come close enough to the line segment to be considered a hit? -static gboolean map_hit_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mappoint_t* pHitPoint, gdouble fMaxDistance) +static gboolean map_hit_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mappoint_t* pHitPoint, gdouble fMaxDistance, mappoint_t* pReturnClosestPoint) { // Some bad ASCII art demonstrating the situation: // @@ -728,7 +764,7 @@ static gboolean map_hit_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mapp v.m_fLatitude = pPoint2->m_fLatitude - pPoint1->m_fLatitude; // 10->90 becomes 0->80 (just store 80) v.m_fLongitude = pPoint2->m_fLongitude - pPoint1->m_fLongitude; - gdouble fLengthV = sqrt((v.m_fLatitude*v.m_fLatitude) + (v.m_fLongitude*v.m_fLongitude)); + gdouble fLengthV = sqrt((v.m_fLatitude*v.m_fLatitude) + (v.m_fLongitude*v.m_fLongitude)); if(fLengthV == 0.0) return FALSE; // bad data: a line segment with no length? // @@ -776,12 +812,52 @@ static gboolean map_hit_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mapp /* g_print("fDotProduct = %f\n", fDotProduct); */ /* g_print("a (%f,%f)\n", a.m_fLatitude, a.m_fLongitude); */ /* g_print("fDistance = %f\n", sqrt(fDistanceSquared)); */ + if(pReturnClosestPoint) { + pReturnClosestPoint->m_fLatitude = a.m_fLatitude + pPoint1->m_fLatitude; + pReturnClosestPoint->m_fLongitude = a.m_fLongitude + pPoint1->m_fLongitude; + } + return TRUE; } } return FALSE; } +static ESide map_side_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mappoint_t* pClosestPointOnLine, mappoint_t* pHitPoint) +{ + // make a translated-to-origin *perpendicular* vector of the line (points to the "left" of the line when walking from point 1 to 2) + mappoint_t v; + v.m_fLatitude = (pPoint2->m_fLongitude - pPoint1->m_fLongitude); // NOTE: swapping lat and lon to make perpendicular + v.m_fLongitude = -(pPoint2->m_fLatitude - pPoint1->m_fLatitude); + + // make a translated-to-origin vector of the line from closest point to hitpoint + mappoint_t u; + u.m_fLatitude = pHitPoint->m_fLatitude - pClosestPointOnLine->m_fLatitude; + u.m_fLongitude = pHitPoint->m_fLongitude - pClosestPointOnLine->m_fLongitude; + + // figure out the signs of the elements of the vectors + gboolean bULatPositive = (u.m_fLatitude >= 0); + gboolean bULonPositive = (u.m_fLongitude >= 0); + gboolean bVLatPositive = (v.m_fLatitude >= 0); + gboolean bVLonPositive = (v.m_fLongitude >= 0); + + //g_print("%s,%s %s,%s\n", bVLonPositive?"Y":"N", bVLatPositive?"Y":"N", bULonPositive?"Y":"N", bULatPositive?"Y":"N"); + + // if the signs agree, it's to the left, otherwise to the right + if(bULatPositive == bVLatPositive && bULonPositive == bVLonPositive) { + return SIDE_LEFT; + } + else { + // let's check our algorithm: if the signs aren't both the same, they should be both opposite + // ...unless the vector from hitpoint to line center is 0, which doesn't have sign + + //g_print("%f,%f %f,%f\n", u.m_fLatitude, u.m_fLongitude, v.m_fLatitude, v.m_fLongitude); + g_assert(bULatPositive != bVLatPositive || u.m_fLatitude == 0.0); + g_assert(bULonPositive != bVLonPositive || u.m_fLongitude == 0.0); + return SIDE_RIGHT; + } +} + gboolean map_can_zoom_in(map_t* pMap) { // can we increase zoom level? @@ -121,6 +121,11 @@ typedef enum { UNIT_LAST=3, } EDistanceUnits; +typedef enum { + SIDE_LEFT=1, + SIDE_RIGHT=2, +} ESide; + #define DEFAULT_UNIT (UNIT_MILES) extern gchar* g_aDistanceUnitNames[]; @@ -137,7 +142,7 @@ typedef struct { #define SCALE_Y(p, y) ((p)->m_nWindowHeight - ((((y) - (p)->m_rWorldBoundingBox.m_A.m_fLatitude) / (p)->m_fScreenLatitude) * (p)->m_nWindowHeight)) typedef struct { - GPtrArray* m_pPointStringsArray; // this should probably change to an array of 'roads' + GPtrArray* m_pRoadsArray; } maplayer_data_t; typedef struct { diff --git a/src/map_draw_cairo.c b/src/map_draw_cairo.c index a0ed801..bcd763b 100644 --- a/src/map_draw_cairo.c +++ b/src/map_draw_cairo.c @@ -37,6 +37,7 @@ #include <gtk/gtk.h> #include <math.h> +#include "main.h" #include "gui.h" #include "map.h" #include "mainwindow.h" @@ -50,10 +51,10 @@ #include "scenemanager.h" // Draw whole layers -static void map_draw_cairo_layer_polygons(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); -static void map_draw_cairo_layer_lines(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); -static void map_draw_cairo_layer_line_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); -static void map_draw_cairo_layer_polygon_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); +static void map_draw_cairo_layer_polygons(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); +static void map_draw_cairo_layer_roads(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); +static void map_draw_cairo_layer_road_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); +static void map_draw_cairo_layer_polygon_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); static void map_draw_cairo_locations(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics); // Draw a single line/polygon/point @@ -61,8 +62,8 @@ static void map_draw_cairo_background(map_t* pMap, cairo_t *pCairo); static void map_draw_cairo_layer_points(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pLocationsArray); // Draw a single line/polygon label -static void map_draw_cairo_line_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, pointstring_t* pPointString, gdouble fLineWidth, const gchar* pszLabel); -static void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, pointstring_t* pPointString, const gchar* pszLabel); +static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, gdouble fLineWidth, const gchar* pszLabel); +static void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, const gchar* pszLabel); // static void map_draw_cairo_crosshair(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics); @@ -98,9 +99,9 @@ void map_draw_cairo(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPi gint nRenderType = layerdraworder[i].eSubLayerRenderType; if(nRenderType == SUBLAYER_RENDERTYPE_LINES) { if(nDrawFlags & DRAWFLAG_GEOMETRY) { - map_draw_cairo_layer_lines(pMap, pCairo, + map_draw_cairo_layer_roads(pMap, pCairo, pRenderMetrics, - /* geometry */ pMap->m_apLayerData[nLayer]->m_pPointStringsArray, + /* geometry */ pMap->m_apLayerData[nLayer]->m_pRoadsArray, /* style */ &(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]), &(g_aLayers[nLayer]->m_TextLabelStyle)); } @@ -109,16 +110,16 @@ void map_draw_cairo(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPi if(nDrawFlags & DRAWFLAG_GEOMETRY) { map_draw_cairo_layer_polygons(pMap, pCairo, pRenderMetrics, - /* geometry */ pMap->m_apLayerData[nLayer]->m_pPointStringsArray, + /* geometry */ pMap->m_apLayerData[nLayer]->m_pRoadsArray, /* style */ &(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]), &(g_aLayers[nLayer]->m_TextLabelStyle)); } } else if(nRenderType == SUBLAYER_RENDERTYPE_LINE_LABELS) { if(nDrawFlags & DRAWFLAG_LABELS) { - map_draw_cairo_layer_line_labels(pMap, pCairo, + map_draw_cairo_layer_road_labels(pMap, pCairo, pRenderMetrics, - /* geometry */ pMap->m_apLayerData[nLayer]->m_pPointStringsArray, + /* geometry */ pMap->m_apLayerData[nLayer]->m_pRoadsArray, /* style */ &(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]), &(g_aLayers[nLayer]->m_TextLabelStyle)); } @@ -127,7 +128,7 @@ void map_draw_cairo(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPi if(nDrawFlags & DRAWFLAG_LABELS) { map_draw_cairo_layer_polygon_labels(pMap, pCairo, pRenderMetrics, - /* geometry */ pMap->m_apLayerData[nLayer]->m_pPointStringsArray, + /* geometry */ pMap->m_apLayerData[nLayer]->m_pRoadsArray, /* style */ &(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]), &(g_aLayers[nLayer]->m_TextLabelStyle)); } @@ -159,7 +160,7 @@ static void map_draw_cairo_background(map_t* pMap, cairo_t *pCairo) // // Draw a whole layer of line strings // -void map_draw_cairo_layer_line_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) +void map_draw_cairo_layer_road_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) { gint i; gdouble fLineWidth = pSubLayerStyle->m_afLineWidths[pRenderMetrics->m_nZoomLevel-1]; @@ -175,10 +176,10 @@ void map_draw_cairo_layer_line_labels(map_t* pMap, cairo_t* pCairo, rendermetric cairo_select_font(pCairo, pszFontFamily, CAIRO_FONT_SLANT_NORMAL, pLabelStyle->m_abBoldAtZoomLevel[pRenderMetrics->m_nZoomLevel-1] ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL); cairo_scale_font(pCairo, fFontSize); - for(i=0 ; i<pPointStringsArray->len ; i++) { - pointstring_t* pPointString = g_ptr_array_index(pPointStringsArray, i); - if(pPointString->m_pszName[0] != '\0') { - map_draw_cairo_line_label(pMap, pCairo, pLabelStyle, pRenderMetrics, pPointString, fLineWidth, pPointString->m_pszName); + for(i=0 ; i<pRoadsArray->len ; i++) { + road_t* pRoad = g_ptr_array_index(pRoadsArray, i); + if(pRoad->m_pszName[0] != '\0') { + map_draw_cairo_road_label(pMap, pCairo, pLabelStyle, pRenderMetrics, pRoad->m_pPointsArray, fLineWidth, pRoad->m_pszName); } } cairo_restore(pCairo); @@ -187,7 +188,7 @@ void map_draw_cairo_layer_line_labels(map_t* pMap, cairo_t* pCairo, rendermetric // // Draw a whole layer of polygons // -void map_draw_cairo_layer_polygon_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) +void map_draw_cairo_layer_polygon_labels(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) { gdouble fFontSize = pLabelStyle->m_afFontSizeAtZoomLevel[pRenderMetrics->m_nZoomLevel-1]; if(fFontSize == 0) return; @@ -199,17 +200,19 @@ void map_draw_cairo_layer_polygon_labels(map_t* pMap, cairo_t* pCairo, rendermet cairo_select_font(pCairo, pszFontFamily, CAIRO_FONT_SLANT_NORMAL, pLabelStyle->m_abBoldAtZoomLevel[pRenderMetrics->m_nZoomLevel-1] ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL); cairo_scale_font(pCairo, fFontSize); + cairo_set_rgb_color(pCairo, pLabelStyle->m_clrColor.m_fRed, pLabelStyle->m_clrColor.m_fGreen, pLabelStyle->m_clrColor.m_fBlue); + gint i; - for(i=0 ; i<pPointStringsArray->len ; i++) { - pointstring_t* pPointString = g_ptr_array_index(pPointStringsArray, i); - if(pPointString->m_pszName[0] != '\0') { - map_draw_cairo_polygon_label(pMap, pCairo, pLabelStyle, pRenderMetrics, pPointString, pPointString->m_pszName); + for(i=0 ; i<pRoadsArray->len ; i++) { + road_t* pRoad = g_ptr_array_index(pRoadsArray, i); + if(pRoad->m_pszName[0] != '\0') { + map_draw_cairo_polygon_label(pMap, pCairo, pLabelStyle, pRenderMetrics, pRoad->m_pPointsArray, pRoad->m_pszName); } } cairo_restore(pCairo); } -void map_draw_cairo_layer_lines(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) +void map_draw_cairo_layer_roads(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) { mappoint_t* pPoint; pointstring_t* pPointString; @@ -260,10 +263,10 @@ void map_draw_cairo_layer_lines(map_t* pMap, cairo_t* pCairo, rendermetrics_t* p cairo_set_alpha(pCairo, pSubLayerStyle->m_clrColor.m_fAlpha); cairo_set_line_width(pCairo, fLineWidth); - for(iString=0 ; iString<pPointStringsArray->len ; iString++) { + for(iString=0 ; iString<pRoadsArray->len ; iString++) { RENDERING_THREAD_YIELD; - pPointString = g_ptr_array_index(pPointStringsArray, iString); + pPointString = g_ptr_array_index(pRoadsArray, iString); if(pPointString->m_pPointsArray->len >= 2) { pPoint = g_ptr_array_index(pPointString->m_pPointsArray, 0); @@ -291,10 +294,10 @@ void map_draw_cairo_layer_lines(map_t* pMap, cairo_t* pCairo, rendermetrics_t* p cairo_restore(pCairo); } -void map_draw_cairo_layer_polygons(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) +void map_draw_cairo_layer_polygons(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) { + road_t* pRoad; mappoint_t* pPoint; - pointstring_t* pPointString; gdouble fLineWidth = pSubLayerStyle->m_afLineWidths[pRenderMetrics->m_nZoomLevel-1]; if(fLineWidth == 0.0) return; // Don't both drawing with line width 0 @@ -311,21 +314,21 @@ void map_draw_cairo_layer_polygons(map_t* pMap, cairo_t* pCairo, rendermetrics_t // cairo_set_dash(pCairo, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_pfList, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount, 0.0); gint iString; - for(iString=0 ; iString<pPointStringsArray->len ; iString++) { + for(iString=0 ; iString<pRoadsArray->len ; iString++) { RENDERING_THREAD_YIELD; - pPointString = g_ptr_array_index(pPointStringsArray, iString); + pRoad = g_ptr_array_index(pRoadsArray, iString); - if(pPointString->m_pPointsArray->len >= 3) { - pPoint = g_ptr_array_index(pPointString->m_pPointsArray, 0); + if(pRoad->m_pPointsArray->len >= 3) { + pPoint = g_ptr_array_index(pRoad->m_pPointsArray, 0); // move to index 0 cairo_move_to(pCairo, SCALE_X(pRenderMetrics, pPoint->m_fLongitude), SCALE_Y(pRenderMetrics, pPoint->m_fLatitude)); // start at index 1 (0 was used above) gint iPoint; - for(iPoint=1 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) { - pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint); + for(iPoint=1 ; iPoint<pRoad->m_pPointsArray->len ; iPoint++) { + pPoint = g_ptr_array_index(pRoad->m_pPointsArray, iPoint); cairo_line_to(pCairo, SCALE_X(pRenderMetrics, pPoint->m_fLongitude), SCALE_Y(pRenderMetrics, pPoint->m_fLatitude)); } //cairo_close_path(pCairo); @@ -459,15 +462,15 @@ typedef struct labelposition { // // Draw a label along a 2-point line // -static void map_draw_cairo_line_label_one_segment(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, pointstring_t* pPointString, gdouble fLineWidth, const gchar* pszLabel) +static void map_draw_cairo_road_label_one_segment(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, gdouble fLineWidth, const gchar* pszLabel) { // get permission to draw this label if(FALSE == scenemanager_can_draw_label_at(pMap->m_pSceneManager, pszLabel, NULL)) { return; } - mappoint_t* pMapPoint1 = g_ptr_array_index(pPointString->m_pPointsArray, 0); - mappoint_t* pMapPoint2 = g_ptr_array_index(pPointString->m_pPointsArray, 1); + mappoint_t* pMapPoint1 = g_ptr_array_index(pPointsArray, 0); + mappoint_t* pMapPoint2 = g_ptr_array_index(pPointsArray, 1); // swap first and second points such that the line goes left-to-right if(pMapPoint2->m_fLongitude < pMapPoint1->m_fLongitude) { @@ -605,7 +608,7 @@ static void map_draw_cairo_line_label_one_segment(map_t* pMap, cairo_t *pCairo, // // Draw a label along a multi-point line // -static gint map_draw_cairo_line_label_position_sort(gconstpointer pA, gconstpointer pB) +static gint map_draw_cairo_road_label_position_sort(gconstpointer pA, gconstpointer pB) { labelposition_t *pPosA = *(labelposition_t **)pA; labelposition_t *pPosB = *(labelposition_t **)pB; @@ -614,20 +617,20 @@ static gint map_draw_cairo_line_label_position_sort(gconstpointer pA, gconstpoin return 1; } -static void map_draw_cairo_line_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, pointstring_t* pPointString, gdouble fLineWidth, const gchar* pszLabel) +static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, gdouble fLineWidth, const gchar* pszLabel) { - if(pPointString->m_pPointsArray->len < 2) return; + if(pPointsArray->len < 2) return; // pass off single segments to a specialized function - if(pPointString->m_pPointsArray->len == 2) { - map_draw_cairo_line_label_one_segment(pMap, pCairo, pLabelStyle, pRenderMetrics, pPointString, fLineWidth, pszLabel); + if(pPointsArray->len == 2) { + map_draw_cairo_road_label_one_segment(pMap, pCairo, pLabelStyle, pRenderMetrics, pPointsArray, fLineWidth, pszLabel); return; } // XXX return; - if(pPointString->m_pPointsArray->len > ROAD_MAX_SEGMENTS) { + if(pPointsArray->len > ROAD_MAX_SEGMENTS) { g_warning("not drawing label for road '%s' with > %d segments.\n", pszLabel, ROAD_MAX_SEGMENTS); return; } @@ -654,7 +657,7 @@ static void map_draw_cairo_line_label(map_t* pMap, cairo_t *pCairo, textlabelsty gdouble aSlopes[ROAD_MAX_SEGMENTS]; mappoint_t* apPoints[ROAD_MAX_SEGMENTS]; - gint nNumPoints = pPointString->m_pPointsArray->len; + gint nNumPoints = pPointsArray->len; mappoint_t* pMapPoint1; mappoint_t* pMapPoint2; @@ -662,7 +665,7 @@ static void map_draw_cairo_line_label(map_t* pMap, cairo_t *pCairo, textlabelsty // load point string into an array gint iRead; for(iRead=0 ; iRead<nNumPoints ; iRead++) { - apPoints[iRead] = g_ptr_array_index(pPointString->m_pPointsArray, iRead); + apPoints[iRead] = g_ptr_array_index(pPointsArray, iRead); } // measure total line length @@ -755,7 +758,7 @@ static void map_draw_cairo_line_label(map_t* pMap, cairo_t *pCairo, textlabelsty // sort postions by score //if(nPositions > 1) - // g_ptr_array_sort(pPositionsPtrArray, map_draw_cairo_line_label_position_sort); + // g_ptr_array_sort(pPositionsPtrArray, map_draw_cairo_road_label_position_sort); /* for(iPosition = 1 ; iPosition < nPositions ; iPosition++) { @@ -795,7 +798,7 @@ static void map_draw_cairo_line_label(map_t* pMap, cairo_t *pCairo, textlabelsty // reverse the array gint iRead,iWrite; for(iWrite=0, iRead=nNumPoints-1 ; iRead>= 0 ; iWrite++, iRead--) { - apPoints[iWrite] = g_ptr_array_index(pPointString->m_pPointsArray, iRead); + apPoints[iWrite] = g_ptr_array_index(pPointsArray, iRead); } } @@ -1120,9 +1123,9 @@ static void map_draw_cairo_line_label(map_t* pMap, cairo_t *pCairo, textlabelsty // // Draw a single polygon label // -void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, pointstring_t* pPointString, const gchar* pszLabel) +void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t* pLabelStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, const gchar* pszLabel) { - if(pPointString->m_pPointsArray->len < 3) return; + if(pPointsArray->len < 3) return; if(FALSE == scenemanager_can_draw_label_at(pMap->m_pSceneManager, pszLabel, NULL)) { return; // duplicate label or whatever other rule scenemanager uses @@ -1140,8 +1143,8 @@ void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, textlabelstyle_t gdouble fX; gdouble fY; gint i; - for(i=0 ; i<pPointString->m_pPointsArray->len ; i++) { - pMapPoint = g_ptr_array_index(pPointString->m_pPointsArray, i); + for(i=0 ; i<pPointsArray->len ; i++) { + pMapPoint = g_ptr_array_index(pPointsArray, i); // find extents fMaxLat = max(pMapPoint->m_fLatitude,fMaxLat); diff --git a/src/map_draw_gdk.c b/src/map_draw_gdk.c index ab68666..d01ae8e 100644 --- a/src/map_draw_gdk.c +++ b/src/map_draw_gdk.c @@ -28,6 +28,7 @@ #include <gtk/gtk.h> #include <math.h> +#include "main.h" #include "gui.h" #include "map.h" #include "mainwindow.h" @@ -36,12 +37,13 @@ #include "road.h" #include "point.h" #include "layers.h" +#include "track.h" #include "locationset.h" #include "scenemanager.h" static void map_draw_gdk_background(map_t* pMap, GdkPixmap* pPixmap); -static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); -static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); +static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); +static void map_draw_gdk_layer_roads(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle); static void map_draw_gdk_tracks(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics); void map_draw_gdk(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPixmap, gint nDrawFlags) @@ -67,16 +69,16 @@ void map_draw_gdk(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPixm gint nSubLayer = layerdraworder[i].nSubLayer; if(layerdraworder[i].eSubLayerRenderType == SUBLAYER_RENDERTYPE_LINES) { - map_draw_gdk_layer_lines(pMap, pPixmap, + map_draw_gdk_layer_roads(pMap, pPixmap, pRenderMetrics, - /* geometry */ pMap->m_apLayerData[nLayer]->m_pPointStringsArray, + /* geometry */ pMap->m_apLayerData[nLayer]->m_pRoadsArray, /* style */ &(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]), &(g_aLayers[nLayer]->m_TextLabelStyle)); } else if(layerdraworder[i].eSubLayerRenderType == SUBLAYER_RENDERTYPE_POLYGONS) { map_draw_gdk_layer_polygons(pMap, pPixmap, pRenderMetrics, - /* geometry */ pMap->m_apLayerData[nLayer]->m_pPointStringsArray, + /* geometry */ pMap->m_apLayerData[nLayer]->m_pRoadsArray, /* style */ &(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]), &(g_aLayers[nLayer]->m_TextLabelStyle)); } @@ -105,10 +107,10 @@ static void map_draw_gdk_background(map_t* pMap, GdkPixmap* pPixmap) TRUE, 0,0, pMap->m_MapDimensions.m_uWidth, pMap->m_MapDimensions.m_uHeight); } -static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) +static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) { mappoint_t* pPoint; - pointstring_t* pPointString; + road_t* pRoad; gint iString; gint iPoint; @@ -131,24 +133,24 @@ static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, renderm clr.blue = pSubLayerStyle->m_clrColor.m_fBlue * 65535; gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr); - for(iString=0 ; iString<pPointStringsArray->len ; iString++) { - pPointString = g_ptr_array_index(pPointStringsArray, iString); + for(iString=0 ; iString<pRoadsArray->len ; iString++) { + pRoad = g_ptr_array_index(pRoadsArray, iString); gdouble fMaxLat = MIN_LATITUDE; // init to the worst possible value so first point will override gdouble fMinLat = MAX_LATITUDE; gdouble fMaxLon = MIN_LONGITUDE; gdouble fMinLon = MAX_LONGITUDE; - if(pPointString->m_pPointsArray->len >= 2) { + if(pRoad->m_pPointsArray->len >= 2) { GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS]; - if(pPointString->m_pPointsArray->len > MAX_GDK_LINE_SEGMENTS) { - g_warning("not drawing line with > %d segments\n", MAX_GDK_LINE_SEGMENTS); + if(pRoad->m_pPointsArray->len > MAX_GDK_LINE_SEGMENTS) { + //g_warning("not drawing line with > %d segments\n", MAX_GDK_LINE_SEGMENTS); continue; } - for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) { - pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint); + for(iPoint=0 ; iPoint<pRoad->m_pPointsArray->len ; iPoint++) { + pPoint = g_ptr_array_index(pRoad->m_pPointsArray, iPoint); // find extents fMaxLat = max(pPoint->m_fLatitude,fMaxLat); @@ -169,15 +171,15 @@ static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, renderm continue; // not visible } gdk_draw_polygon(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], - TRUE, aPoints, pPointString->m_pPointsArray->len); + TRUE, aPoints, pRoad->m_pPointsArray->len); } } } -static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pPointStringsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) +static void map_draw_gdk_layer_roads(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, sublayerstyle_t* pSubLayerStyle, textlabelstyle_t* pLabelStyle) { + road_t* pRoad; mappoint_t* pPoint; - pointstring_t* pPointString; gint iString; gint iPoint; @@ -215,24 +217,24 @@ static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetr clr.blue = pSubLayerStyle->m_clrColor.m_fBlue * 65535; gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr); - for(iString=0 ; iString<pPointStringsArray->len ; iString++) { - pPointString = g_ptr_array_index(pPointStringsArray, iString); + for(iString=0 ; iString<pRoadsArray->len ; iString++) { + pRoad = g_ptr_array_index(pRoadsArray, iString); gdouble fMaxLat = MIN_LATITUDE; // init to the worst possible value so first point will override gdouble fMinLat = MAX_LATITUDE; gdouble fMaxLon = MIN_LONGITUDE; gdouble fMinLon = MAX_LONGITUDE; - if(pPointString->m_pPointsArray->len >= 2) { + if(pRoad->m_pPointsArray->len >= 2) { GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS]; - if(pPointString->m_pPointsArray->len > MAX_GDK_LINE_SEGMENTS) { - g_warning("not drawing line with > %d segments\n", MAX_GDK_LINE_SEGMENTS); + if(pRoad->m_pPointsArray->len > MAX_GDK_LINE_SEGMENTS) { + //g_warning("not drawing line with > %d segments\n", MAX_GDK_LINE_SEGMENTS); continue; } - for(iPoint=0 ; iPoint<pPointString->m_pPointsArray->len ; iPoint++) { - pPoint = g_ptr_array_index(pPointString->m_pPointsArray, iPoint); + for(iPoint=0 ; iPoint<pRoad->m_pPointsArray->len ; iPoint++) { + pPoint = g_ptr_array_index(pRoad->m_pPointsArray, iPoint); // find extents fMaxLat = max(pPoint->m_fLatitude,fMaxLat); @@ -253,7 +255,7 @@ static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetr continue; // not visible } - gdk_draw_lines(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], aPoints, pPointString->m_pPointsArray->len); + gdk_draw_lines(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], aPoints, pRoad->m_pPointsArray->len); } } } @@ -276,7 +278,7 @@ static void map_draw_gdk_tracks(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t if(pPointString->m_pPointsArray->len >= 2) { if(pPointString->m_pPointsArray->len > MAX_GDK_LINE_SEGMENTS) { - g_warning("not drawing track with > %d segments\n", MAX_GDK_LINE_SEGMENTS); + //g_warning("not drawing track with > %d segments\n", MAX_GDK_LINE_SEGMENTS); continue; } diff --git a/src/point.c b/src/point.c index 451e077..19f3b1b 100644 --- a/src/point.c +++ b/src/point.c @@ -22,11 +22,10 @@ */ #include <gtk/gtk.h> +#include "main.h" #include "map.h" #include "point.h" -#define USE_GFREELIST - #ifdef USE_GFREELIST #include "gfreelist.h" GFreeList* g_pPointFreeList; diff --git a/src/pointstring.c b/src/pointstring.c index f236927..583c0e8 100644 --- a/src/pointstring.c +++ b/src/pointstring.c @@ -22,12 +22,11 @@ */ #include <gtk/gtk.h> +#include "main.h" #include "map.h" #include "point.h" #include "pointstring.h" -#define USE_GFREELIST - #ifdef USE_GFREELIST #include "gfreelist.h" GFreeList* g_pPointStringFreeList = NULL; diff --git a/src/prefs.c b/src/prefs.c index 7d3f638..b73063d 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -21,6 +21,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "main.h" + void prefs_init() {} void pref_deinit() {} void prefs_read() {} @@ -22,8 +22,50 @@ */ #include <gtk/gtk.h> +#include "main.h" #include "road.h" #include "util.h" +#include "map.h" +#include "gfreelist.h" + +GFreeList* g_pRoadFreeList = NULL; + +void road_init(void) +{ + g_pRoadFreeList = g_free_list_new(sizeof(road_t), 1000); +} + +gboolean road_alloc(road_t** ppReturnRoad) +{ + g_return_val_if_fail(ppReturnRoad != NULL, FALSE); + g_return_val_if_fail(*ppReturnRoad == NULL, FALSE); // must be a pointer to a NULL pointer + + road_t* pNew = g_free_list_alloc(g_pRoadFreeList); + memset(pNew, 0, sizeof(road_t)); + + pNew->m_pPointsArray = g_ptr_array_new(); + + // return it + *ppReturnRoad = pNew; + return TRUE; +} + +void road_free(road_t* pRoad) +{ + g_return_if_fail(pRoad != NULL); + + int i; + for(i = (pRoad->m_pPointsArray->len - 1) ; i>=0 ; i--) { + mappoint_t* pPoint = g_ptr_array_remove_index_fast(pRoad->m_pPointsArray, i); + point_free(pPoint); + } + g_assert(pRoad->m_pPointsArray->len == 0); + + g_ptr_array_free(pRoad->m_pPointsArray, TRUE); + + // give back to allocator + g_free_list_free(g_pRoadFreeList, pRoad); +} struct { gchar* m_pszLong; @@ -24,6 +24,20 @@ #ifndef _ROAD_H_ #define _ROAD_H_ +typedef struct { + GPtrArray* m_pPointsArray; + gchar* m_pszName; + gint m_nAddressLeftStart; + gint m_nAddressLeftEnd; + gint m_nAddressRightStart; + gint m_nAddressRightEnd; +} road_t; + +void road_init(void); +gboolean road_alloc(road_t** ppReturnRoad); +void road_free(road_t* pRoad); + + // ESuffixLength typedef enum { ROAD_SUFFIX_LENGTH_SHORT, diff --git a/src/scenemanager.c b/src/scenemanager.c index dfaaa9a..0c61dc5 100644 --- a/src/scenemanager.c +++ b/src/scenemanager.c @@ -22,6 +22,8 @@ */ #include <gtk/gtk.h> + +#include "main.h" #include "scenemanager.h" /* diff --git a/src/search.c b/src/search.c index c943baf..b73b0d0 100644 --- a/src/search.c +++ b/src/search.c @@ -22,6 +22,8 @@ */ #include <gtk/gtk.h> + +#include "main.h" #include "search.h" // functions common to all searches diff --git a/src/search_location.c b/src/search_location.c index 2af21ce..d45e29a 100644 --- a/src/search_location.c +++ b/src/search_location.c @@ -23,6 +23,8 @@ #include <stdlib.h> #include <gtk/gtk.h> + +#include "main.h" #include "db.h" #include "util.h" #include "search.h" diff --git a/src/search_road.c b/src/search_road.c index 0efc0ee..3320fbb 100644 --- a/src/search_road.c +++ b/src/search_road.c @@ -25,6 +25,7 @@ #include <math.h> #include <stdlib.h> +#include "main.h" #include "db.h" #include "util.h" #include "pointstring.h" @@ -392,8 +393,8 @@ void search_road_on_roadsearch_struct(const roadsearch_t* pRoadSearch) if(nCount <= SEARCH_RESULT_COUNT_LIMIT) { pointstring_t* pPointString = NULL; pointstring_alloc(&pPointString); - - db_parse_wkb_pointstring(aRow[3], pPointString, point_alloc); + + db_parse_wkb_linestring(aRow[3], pPointString->m_pPointsArray, point_alloc); // g_print("raw: %s\n", aRow[3]); search_road_filter_result(aRow[1], pRoadSearch->m_nNumber, atoi(aRow[2]), atoi(aRow[4]), atoi(aRow[5]), atoi(aRow[6]), atoi(aRow[7]), aRow[8], aRow[9], aRow[10], aRow[11], aRow[12], aRow[13], pPointString); diff --git a/src/searchwindow.c b/src/searchwindow.c index c4ec63e..166f1ce 100644 --- a/src/searchwindow.c +++ b/src/searchwindow.c @@ -28,6 +28,7 @@ # include <config.h> #endif +#include "main.h" #include "search_road.h" #include "search_location.h" #include "mainwindow.h" @@ -110,7 +111,7 @@ void searchwindow_on_findbutton_clicked(GtkWidget *pWidget, gpointer* p) if(g_SearchWindow.m_nNumResults == 0) { // insert a "no results" message - gchar* pszBuffer = g_strdup_printf("<span size='small'><i>Your search did not match any\nstreets or Points of Interest.</i></span>", pszSearch); + gchar* pszBuffer = g_strdup_printf("<span size='small'><i>No results.</i></span>", pszSearch); GtkTreeIter iter; gtk_list_store_append(g_SearchWindow.m_pResultsListStore, &iter); gtk_list_store_set(g_SearchWindow.m_pResultsListStore, &iter, @@ -174,7 +175,7 @@ static void searchwindow_go_to_selected_result(void) if(!bClickable) return; // XXX: is this the right way to make a treeview item not clickable? mainwindow_map_slide_to_mappoint(&pt); - mainwindow_set_zoomlevel(nZoomLevel); + //mainwindow_set_zoomlevel(nZoomLevel); mainwindow_draw_map(DRAWFLAG_ALL); } } diff --git a/src/tooltip.c b/src/tooltip.c index db325c7..c3d4954 100644 --- a/src/tooltip.c +++ b/src/tooltip.c @@ -22,6 +22,8 @@ */ #include <gtk/gtk.h> + +#include "main.h" #include "tooltip.h" void tooltip_init() diff --git a/src/track.c b/src/track.c index c4141e2..b2785bd 100644 --- a/src/track.c +++ b/src/track.c @@ -22,6 +22,7 @@ */ #include <gtk/gtk.h> +#include "main.h" #include "map.h" #include "pointstring.h" #include "point.h" @@ -21,6 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "main.h" #include "util.h" void util_close_parent_window(GtkWidget* pWidget, gpointer data) @@ -34,7 +34,6 @@ void util_random_color(void* pColor); -//#define ENABLE_TIMING #ifdef ENABLE_TIMING #define TIMER_BEGIN(name, str) GTimer* name = g_timer_new(); g_print("\n%s (%f)\n", str, g_timer_elapsed(name, NULL)) diff --git a/src/welcomewindow.c b/src/welcomewindow.c index 859284b..ac3b5dc 100644 --- a/src/welcomewindow.c +++ b/src/welcomewindow.c @@ -28,6 +28,8 @@ #endif #include <gtk/gtk.h> + +#include "main.h" #include "mainwindow.h" #include "welcomewindow.h" |