[libchamplain] Add high-contrast rules, add zoom-to-data button



commit 2a0d885342856f5ba5f3050adeb6f0106fe8b4e4
Author: Simon Wenner <simon wenner ch>
Date:   Thu Jun 25 15:23:05 2009 +0200

    Add high-contrast rules, add zoom-to-data button

 demos/high-contrast.xml |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 demos/local-rendering.c |   47 ++++++++++++++++++++++----
 2 files changed, 125 insertions(+), 7 deletions(-)
---
diff --git a/demos/high-contrast.xml b/demos/high-contrast.xml
new file mode 100644
index 0000000..3fbfe1f
--- /dev/null
+++ b/demos/high-contrast.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rules version="0.1" autor="SimonWenner" background="#ffffff">
+
+    <!-- Draw landuse/natural first -->
+    <rule e="way" k="landuse|natural" v="*">
+       <rule e="way" k="natural" v="water|coastline">
+            <polygone color="#1997FF"/>
+        </rule>
+       <rule e="way" k="landuse|natural" v="wood|forest">
+            <polygone color="#00A520"/>
+            <line color="#6fc18e" width="0.5"/>
+       </rule>
+        <rule e="way" k="landuse" v="landfill|quarry">
+            <polygone color="#00A520"/>
+            <line color="#5A6332" width="0.2"/>
+        </rule>
+    </rule>
+    
+    <!-- Waterways -->
+    <rule e="way" k="waterway" v="*">
+        <rule e="way" k="waterway" v="riverbank">
+            <polygone color="#1997FF"/>
+        </rule>
+        <rule e="way" k="waterway" v="river">
+            <line color="#1997FF" width="2"/>
+        </rule>
+        <rule e="way" k="waterway" v="stream">
+            <line color="#1997FF" width=".2"/>
+        </rule>
+        <rule e="way" k="waterway" v="canal">
+            <line color="#1997FF" width="2"/>
+        </rule>
+        <rule e="way" k="waterway" v="drain">
+            <line color="#1997FF" width="1"/>
+        </rule>
+        <rule e="way" k="waterway" v="dock">
+            <polygone color="#1997FF"/>
+        </rule>
+        <rule e="way" k="natural|landuse" v="water|pond|lake">
+            <polygone color="#1997FF"/>
+        </rule>
+        <rule e="way" k="landuse" v="reservoir">
+            <polygone color="#1997FF"/>
+        </rule>
+        <rule e="way" k="landuse" v="basin">
+            <polygone color="#1997FF"/>
+        </rule>
+    </rule>
+<!--
+    <rule e="way" k="building" v="*">
+        <polygone color="#dddddd" zoom="15:17"/>
+        <line color="#cccccc" width="0.1" zoom="15:18"/>
+    </rule>
+-->
+    <!-- Railway -->
+    <rule e="way" k="railway" v="monorail|preserved|narrow_gauge|rail">
+            <!-- <line color="#000000" width="1.5"/> -->
+            <line color="#151515" width="1"/>
+    </rule>
+
+    <!-- Draw highways -->
+    <rule e="way" k="highway" v="*">
+        <rule e="way" k="highway" v="footway|track|steps|bridleway|cycleway|track">
+            <line color="#FF4D00" width="0.5" zoom="14:18"/>
+        </rule>
+        <rule e="way" k="highway" v="living_street|service">
+            <line color="#3A3A3A" width="2.5" zoom="13:18"/>
+            <text color="#ffffff" width="2" zoom="17:18"/>
+        </rule>
+        <rule e="way" k="highway" v="residential|unclassified|pedestrian">
+            <line color="#3A3A3A" width="2.5" zoom="12:18"/>
+            <text color="#ffffff" width="2" zoom="17:18"/>
+        </rule>
+        <rule e="way" k="highway" v="tertiary|secondary|primary">
+            <!-- <line color="#FFEF00" width="3.5"/> -->
+            <line color="#AE0700" width="3.2"/> <!-- red -->
+            <text color="#ffffff" width="3" zoom="16:18"/>
+        </rule>
+        <rule e="way" k="highway" v="trunk|motorway|trunk_link">
+            <line color="#FF0011" width="5"/>
+            <line color="#FFEF00" width="4.5"/> <!-- yellow -->
+            <text color="#000000" width="4" zoom="16:18"/>
+        </rule>
+    </rule>
+</rules>
diff --git a/demos/local-rendering.c b/demos/local-rendering.c
index bd0ed96..6bbefbf 100644
--- a/demos/local-rendering.c
+++ b/demos/local-rendering.c
@@ -31,8 +31,7 @@ static const char *maps[] = { "schaffhausen.osm", "las_palmas.osm" };
 static const double coords[][3] = { {47.696303, 8.634481, 14},
                                     {28.13476, -15.43814, 15} };
 
-guint rules_index = 0;
-static const char *rules[] = { "default-rules.xml" };
+static const char *rules[] = { "default-rules.xml", "high-contrast.xml" };
 
 /*
  * Terminate the main loop.
@@ -56,6 +55,11 @@ load_map_data (ChamplainMapSource *source, ChamplainView *view)
   champlain_local_map_data_source_load_map_data (data, tmp);
   g_free (tmp);
   g_object_set (G_OBJECT (view), "map-source", source, NULL);
+}
+
+static void
+zoom_to_map_data (GtkWidget *widget, ChamplainView *view)
+{
   champlain_view_center_on (CHAMPLAIN_VIEW(view), coords[map_index][0],
       coords[map_index][1]);
   champlain_view_set_zoom_level (CHAMPLAIN_VIEW(view), coords[map_index][2]);
@@ -115,6 +119,27 @@ map_data_changed (GtkWidget *widget, ChamplainView *view)
 }
 
 static void
+rules_changed (GtkWidget *widget, ChamplainView *view)
+{
+  gchar* file;
+  ChamplainMapSource *source;
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+
+  if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+    return;
+
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+  gtk_tree_model_get (model, &iter, 0, &file, -1);
+
+  g_object_get (G_OBJECT (view), "map-source", &source, NULL);
+  if (g_strcmp0 (champlain_map_source_get_id (source), "memphis-local") == 0)
+    champlain_memphis_map_source_load_rules (
+        CHAMPLAIN_MEMPHIS_MAP_SOURCE(source),
+        file);
+}
+
+static void
 zoom_changed (GtkSpinButton *spinbutton,
               ChamplainView *view)
 {
@@ -223,10 +248,10 @@ build_rules_combo_box (GtkComboBox *box)
 
   store = gtk_tree_store_new (1, G_TYPE_STRING, /* file name */ -1);
   gtk_tree_store_append (store, &parent, NULL);
-  gtk_tree_store_set (store, &parent, 0, "default-rules.xml", -1);
+  gtk_tree_store_set (store, &parent, 0, rules[0], -1);
 
-  //gtk_tree_store_append (store, &parent, NULL);
-  //gtk_tree_store_set (store, &parent, 0, "low-contrast.xml", -1);
+  gtk_tree_store_append (store, &parent, NULL);
+  gtk_tree_store_set (store, &parent, 0, rules[1], -1);
 
   gtk_combo_box_set_model (box, GTK_TREE_MODEL (store));
 
@@ -313,16 +338,24 @@ main (int argc,
   gtk_label_set_markup (GTK_LABEL (label), "<b>Memphis Rendering Options</b>");
   gtk_box_pack_start (GTK_BOX (menubox), label, FALSE, FALSE, 0);
 
+  bbox =  gtk_hbox_new (FALSE, 10);
+
   button = gtk_combo_box_new ();
   build_data_combo_box (GTK_COMBO_BOX (button));
   gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0);
   g_signal_connect (button, "changed", G_CALLBACK (map_data_changed), view);
-  gtk_box_pack_start (GTK_BOX (menubox), button, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
+
+  button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
+  g_signal_connect (button, "clicked", G_CALLBACK (zoom_to_map_data), view);
+  gtk_container_add (GTK_CONTAINER (bbox), button);
+
+  gtk_box_pack_start (GTK_BOX (menubox), bbox, FALSE, FALSE, 0);
 
   button = gtk_combo_box_new ();
   build_rules_combo_box (GTK_COMBO_BOX (button));
   gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0);
-  //g_signal_connect (button, "changed", G_CALLBACK (rules_changed), view);
+  g_signal_connect (button, "changed", G_CALLBACK (rules_changed), view);
   gtk_box_pack_start (GTK_BOX (menubox), button, FALSE, FALSE, 0);
   
   /* viewport */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]