Patch:Core:Patch from Helge to add offset to dashed polylines. Thank you
authorkazer_ <kazer_@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 1 Sep 2008 09:45:27 +0000 (09:45 +0000)
committerkazer_ <kazer_@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 1 Sep 2008 09:45:27 +0000 (09:45 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1354 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/graphics.c
navit/navit/item_def.h
navit/navit/layout.c
navit/navit/layout.h
navit/navit/navit.xml
navit/navit/osm2navit.c
navit/navit/xmlconfig.c

index a32ab0d..d5f0e28 100644 (file)
@@ -673,7 +673,8 @@ static void xdisplay_draw_elements(struct graphics *gra, GHashTable *display_lis
                                        if (e->u.polyline.width > 1) 
                                                gc->meth.gc_set_linewidth(gc->priv, e->u.polyline.width);
                                        if (e->u.polyline.width > 0 && e->u.polyline.dash_num > 0)
-                                               graphics_gc_set_dashes(gc, e->u.polyline.width, 0,
+                                               graphics_gc_set_dashes(gc, e->u.polyline.width, 
+                                                                      e->u.polyline.dash_offset,
                                                                       e->u.polyline.dash_table,
                                                                       e->u.polyline.dash_num);
                                        gra->meth.draw_lines(gra->priv, gc->priv, di->pnt, di->count);
index e7a02a3..648327c 100644 (file)
@@ -364,6 +364,7 @@ ITEM(piste_downhill_intermediate)
 ITEM(piste_downhill_advanced)
 ITEM(piste_downhill_expert)
 ITEM(piste_downhill_freeride)
+ITEM(footway_and_piste_nordic)
 /* Area */
 ITEM2(0xc0000000,area)
 ITEM2(0xc0000001,area_unspecified)
index e4f5571..eb124df 100644 (file)
@@ -100,7 +100,7 @@ polygon_new(struct color *color)
 
 struct element *
 polyline_new(struct color *color, int width, int directed,
-             int *dash_table, int dash_num)
+             int dash_offset, int *dash_table, int dash_num)
 {
        struct element *e;
        int i;
@@ -110,6 +110,7 @@ polyline_new(struct color *color, int width, int directed,
        e->color=*color;
        e->u.polyline.width=width;
        e->u.polyline.directed=directed;
+       e->u.polyline.dash_offset = dash_offset;
        e->u.polyline.dash_num=dash_num;
        for (i=0; i<dash_num; i++)
                e->u.polyline.dash_table[i] = dash_table[i];
index e6417d8..dda9834 100644 (file)
@@ -37,6 +37,7 @@ struct element {
                        int width;
                        int directed;
                        int dash_num;
+                       int dash_offset;
                        unsigned char dash_table[4];
                } polyline;
                struct element_polygon {
@@ -79,7 +80,7 @@ void layer_add_itemtype(struct layer *layer, struct itemtype *itemtype);
 void itemtype_add_element(struct itemtype *itemtype, struct element *element);
 struct element *polygon_new(struct color *color);
 struct element *polyline_new(struct color *color, int width, int directed,
-                             int *dash_table, int dash_num);
+                             int dash_offset, int *dash_table, int dash_num);
 struct element *circle_new(struct color *color, int radius, int width, int label_size);
 struct element *label_new(int label_size);
 struct element *icon_new(const char *src);
index e682aa1..ac7c1aa 100644 (file)
@@ -481,16 +481,38 @@ It's always the top left corner of the icon, so you need to consider the icon's
                                <polyline color="#696969" width="1" dash="5" />
                        </item>
                        <item type="piste_nordic"  order="10-12">
-                               <polyline color="#0000ff" width="1" dash="3,6" />
+                               <polyline color="#0000ff" width="1" dash="3,6" offset="4" />
                        </item>
                        <item type="piste_nordic"  order="13-14">
-                               <polyline color="#0000ff" width="2" dash="4,8" />
+                               <polyline color="#ffffff" width="4" dash="4,8" offset="6" />
+                               <polyline color="#0000ff" width="2" dash="4,8" offset="6" />
                        </item>
                        <item type="piste_nordic"  order="15-16">
-                               <polyline color="#0000ff" width="3" dash="5,10" />
+                               <polyline color="#ffffff" width="5" dash="5,10" offset="7" />
+                               <polyline color="#0000ff" width="3" dash="5,10" offset="7" />
                        </item>
                        <item type="piste_nordic"  order="17-">
-                               <polyline color="#0000ff" width="5" dash="7,15" />
+                               <polyline color="#ffffff" width="7" dash="7,15" offset="10" />
+                               <polyline color="#0000ff" width="5" dash="7,15" offset="10" />
+                       </item>
+                       <item type="footway_and_piste_nordic" order="10-12">
+                               <polyline color="#ff0000" width="1" dash="3,15" />
+                               <polyline color="#0000ff" width="1" dash="3,15" offset="9" />
+                       </item>
+                       <item type="footway_and_piste_nordic" order="13-14">
+                               <polyline color="#ffffff" width="4" dash="4,8" />
+                               <polyline color="#ff0000" width="2" dash="4,20" />
+                               <polyline color="#0000ff" width="2" dash="4,20" offset="12" />
+                       </item>
+                       <item type="footway_and_piste_nordic" order="15-16">
+                               <polyline color="#ffffff" width="5" dash="5,10" />
+                               <polyline color="#ff0000" width="3" dash="5,25" />
+                               <polyline color="#0000ff" width="3" dash="5,25" offset="15" />
+                       </item>
+                       <item type="footway_and_piste_nordic" order="17-">
+                               <polyline color="#ffffff" width="7" dash="7,15" />
+                               <polyline color="#ff0000" width="5" dash="7,37" />
+                               <polyline color="#0000ff" width="5" dash="7,37" offset="22" />
                        </item>
                        <item type="footway" order="10-12">
                                <polyline color="#ff0000" width="1" dash="3,6" />
index 21525d1..26873b9 100644 (file)
@@ -172,6 +172,7 @@ static char *attrmap={
        "w      highway=path,bicycle=designated cycleway\n"
        "w      highway=footway         footway\n"
        "w      piste:type=nordic       piste_nordic\n"
+       "w      highway=footway,piste:type=nordic       footway_and_piste_nordic\n"
        "w      route=ski       piste_nordic\n"
        "w      piste:type=downhill,piste:difficulty=novice     piste_downhill_novice\n"
        "w      piste:type=downhill,piste:difficulty=easy       piste_downhill_easy\n"
index c8da7f1..69541d9 100644 (file)
@@ -522,8 +522,8 @@ static int
 xmlconfig_polyline(struct xmlstate *state)
 {
        struct color color;
-       const char *width, *dash, *directed;
-       int w=0, d=0, dt[4], ds=0;
+       const char *width, *dash, *directed, *dash_offset;
+       int w=0, d=0, doff=0, dt[4], ds=0;
 
        if (! find_color(state, 1, &color))
                return 0;
@@ -533,11 +533,14 @@ xmlconfig_polyline(struct xmlstate *state)
        dash=find_attribute(state, "dash", 0);
        if (dash)
                ds=convert_number_list(dash, dt, sizeof(dt)/sizeof(*dt));
+       dash_offset=find_attribute(state, "offset", 0);
+       if (dash_offset)
+               doff=convert_number(dash_offset);
        directed=find_attribute(state, "directed", 0);
        if (directed) 
                d=convert_number(directed);
        
-       state->element_attr.u.data=polyline_new(&color, w, d, dt, ds);
+       state->element_attr.u.data=polyline_new(&color, w, d, doff, dt, ds);
        if (! state->element_attr.u.data)
                return 0;
        itemtype_add_element(state->parent->element_attr.u.data, state->element_attr.u.data);