34 |
} |
} |
35 |
} |
} |
36 |
|
|
|
static int xml_get_prop_opaque(xmlNode *node, char *prop) { |
|
|
float opaque = 100; |
|
|
xml_get_prop_float(node, prop, &opaque); |
|
|
if(opaque > 255) opaque = 255; |
|
|
return(0xff & (int)(0.5 + opaque * 2.55)); |
|
|
} |
|
|
|
|
37 |
static gboolean xml_prop_is(xmlNode *node, char *prop, char *str) { |
static gboolean xml_prop_is(xmlNode *node, char *prop, char *str) { |
38 |
char *prop_str = (char*)xmlGetProp(node, BAD_CAST prop); |
char *prop_str = (char*)xmlGetProp(node, BAD_CAST prop); |
39 |
if(!prop_str) return FALSE; |
if(!prop_str) return FALSE; |
51 |
|
|
52 |
/* -------------- setup defaults -------------------- */ |
/* -------------- setup defaults -------------------- */ |
53 |
/* (the defaults are pretty much the potlatch style) */ |
/* (the defaults are pretty much the potlatch style) */ |
54 |
style->background.color = 0xffffff; // white |
style->background.color = 0xffffffff; // white |
55 |
|
|
56 |
style->area.border_width = 2.0; |
style->area.border_width = 2.0; |
57 |
style->area.opaque = 0x60; // 37.5% |
style->area.color = 0x00000060; // 37.5% |
58 |
style->area.zoom_max = 0.1111; // zoom factor above which an area is visible & selectable |
style->area.zoom_max = 0.1111; // zoom factor above which an area is visible & selectable |
59 |
|
|
60 |
style->node.radius = 4.0; |
style->node.radius = 4.0; |
61 |
style->node.border_radius = 2.0; |
style->node.border_radius = 2.0; |
62 |
style->node.color = 0x000000; // black |
style->node.color = 0x000000ff; // black with filling ... |
63 |
style->node.has_fill_color = TRUE; // is filled ... |
style->node.fill_color = 0x008800ff; // ... in dark green |
|
style->node.fill_color = 0x008800; // ... in dark green |
|
64 |
style->node.show_untagged = FALSE; |
style->node.show_untagged = FALSE; |
65 |
style->node.zoom_max = 0.4444; // zoom factor above which a node is visible & selectable |
style->node.zoom_max = 0.4444; // zoom factor above which a node is visible & selectable |
66 |
|
|
67 |
style->track.width = 6.0; |
style->track.width = 6.0; |
68 |
style->track.color = 0x0000ff40; // blue |
style->track.color = 0x0000ff40; // blue |
69 |
style->track.gps_color = 0x000080; |
style->track.gps_color = 0x000080ff; |
70 |
|
|
71 |
style->way.width = 3.0; |
style->way.width = 3.0; |
72 |
style->way.color = 0x606060; // grey |
style->way.color = 0x606060ff; // grey |
73 |
style->way.zoom_max = 0.2222; // zoom above which it's visible & selectable |
style->way.zoom_max = 0.2222; // zoom above which it's visible & selectable |
74 |
|
|
75 |
style->highlight.width = 3.0; |
style->highlight.width = 3.0; |
76 |
style->highlight.color = 0xffff0080; |
style->highlight.color = 0xffff0080; |
80 |
style->highlight.arrow_limit = 4.0; |
style->highlight.arrow_limit = 4.0; |
81 |
|
|
82 |
style->frisket.mult = 3.0; |
style->frisket.mult = 3.0; |
83 |
style->frisket.opaque = 0xff; |
style->frisket.color = 0xffffffff; |
84 |
style->frisket.border.present = TRUE; |
style->frisket.border.present = TRUE; |
85 |
style->frisket.border.width = 6.0; |
style->frisket.border.width = 6.0; |
86 |
style->frisket.border.color = 0x00000099; |
style->frisket.border.color = 0x00000099; |
98 |
/* ---------- node ------------------------------------- */ |
/* ---------- node ------------------------------------- */ |
99 |
} else if(strcasecmp((char*)cur_node->name, "node") == 0) { |
} else if(strcasecmp((char*)cur_node->name, "node") == 0) { |
100 |
parse_color(cur_node, "color", &style->node.color); |
parse_color(cur_node, "color", &style->node.color); |
101 |
style->node.has_fill_color = |
parse_color(cur_node, "fill-color", &style->node.fill_color); |
|
parse_color(cur_node, "fill-color", &style->node.fill_color); |
|
102 |
xml_get_prop_float(cur_node, "radius", &style->node.radius); |
xml_get_prop_float(cur_node, "radius", &style->node.radius); |
103 |
xml_get_prop_float(cur_node, "border-radius", |
xml_get_prop_float(cur_node, "border-radius", |
104 |
&style->node.border_radius); |
&style->node.border_radius); |
115 |
/* ---------- icon ------------------------------------- */ |
/* ---------- icon ------------------------------------- */ |
116 |
} else if(strcasecmp((char*)cur_node->name, "icon") == 0) { |
} else if(strcasecmp((char*)cur_node->name, "icon") == 0) { |
117 |
xml_get_prop_float(cur_node, "scale", &style->icon.scale); |
xml_get_prop_float(cur_node, "scale", &style->icon.scale); |
118 |
style->icon.path_prefix = (char*)xmlGetProp(cur_node, BAD_CAST "path-prefix"); |
style->icon.path_prefix = |
119 |
|
(char*)xmlGetProp(cur_node, BAD_CAST "path-prefix"); |
120 |
style->icon.enable = xml_prop_is(cur_node, "enable", "true"); |
style->icon.enable = xml_prop_is(cur_node, "enable", "true"); |
121 |
|
|
122 |
/* ---------- way ------------------------------------- */ |
/* ---------- way ------------------------------------- */ |
133 |
/* ---------- frisket --------------------------------- */ |
/* ---------- frisket --------------------------------- */ |
134 |
} else if(strcasecmp((char*)cur_node->name, "frisket") == 0) { |
} else if(strcasecmp((char*)cur_node->name, "frisket") == 0) { |
135 |
xml_get_prop_float(cur_node, "mult", &style->frisket.mult); |
xml_get_prop_float(cur_node, "mult", &style->frisket.mult); |
136 |
style->frisket.opaque = xml_get_prop_opaque(cur_node, "opaque"); |
parse_color(cur_node, "arrow-color", &style->frisket.color); |
137 |
style->frisket.border.present = FALSE; |
style->frisket.border.present = FALSE; |
138 |
|
|
139 |
for(sub_node = cur_node->children; sub_node; sub_node=sub_node->next) { |
for(sub_node = cur_node->children; sub_node; sub_node=sub_node->next) { |
143 |
xml_get_prop_float(sub_node, "width", |
xml_get_prop_float(sub_node, "width", |
144 |
&style->frisket.border.width); |
&style->frisket.border.width); |
145 |
|
|
146 |
gboolean color_set = |
parse_color(sub_node, "color", &style->frisket.border.color); |
|
parse_color(sub_node, "color", &style->frisket.border.color); |
|
|
int opaque = xml_get_prop_opaque(sub_node, "opaque"); |
|
|
if(color_set) |
|
|
style->frisket.border.color = |
|
|
(style->frisket.border.color<<8) | opaque; |
|
147 |
} |
} |
148 |
} |
} |
149 |
} |
} |
150 |
|
|
151 |
/* ---------- highlight ------------------------------- */ |
/* ---------- highlight ------------------------------- */ |
152 |
} else if(strcasecmp((char*)cur_node->name, "highlight") == 0) { |
} else if(strcasecmp((char*)cur_node->name, "highlight") == 0) { |
153 |
gboolean color_set = |
parse_color(cur_node, "color", &style->highlight.color); |
154 |
parse_color(cur_node, "color", &style->highlight.color); |
parse_color(cur_node, "node-color", &style->highlight.node_color); |
155 |
gboolean node_color_set = |
parse_color(cur_node, "touch-color", &style->highlight.touch_color); |
156 |
parse_color(cur_node, "node-color", &style->highlight.node_color); |
parse_color(cur_node, "arrow-color", &style->highlight.arrow_color); |
|
gboolean touch_color_set = |
|
|
parse_color(cur_node, "touch-color", &style->highlight.touch_color); |
|
|
gboolean arrow_color_set = |
|
|
parse_color(cur_node, "arrow-color", &style->highlight.arrow_color); |
|
157 |
xml_get_prop_float(cur_node, "width", &style->highlight.width); |
xml_get_prop_float(cur_node, "width", &style->highlight.width); |
158 |
xml_get_prop_float(cur_node, "arrow-limit", |
xml_get_prop_float(cur_node, "arrow-limit", |
159 |
&style->highlight.arrow_limit); |
&style->highlight.arrow_limit); |
160 |
|
|
|
int op = xml_get_prop_opaque(cur_node, "opaque"); |
|
|
if(color_set) |
|
|
style->highlight.color = (style->highlight.color << 8) | op; |
|
|
if(node_color_set) |
|
|
style->highlight.node_color =(style->highlight.node_color << 8)|op; |
|
|
if(touch_color_set) |
|
|
style->highlight.touch_color =(style->highlight.touch_color << 8)|op; |
|
|
if(arrow_color_set) |
|
|
style->highlight.arrow_color =(style->highlight.arrow_color << 8)|op; |
|
|
|
|
161 |
/* ---------- track ------------------------------------ */ |
/* ---------- track ------------------------------------ */ |
162 |
} else if(strcasecmp((char*)cur_node->name, "track") == 0) { |
} else if(strcasecmp((char*)cur_node->name, "track") == 0) { |
163 |
gboolean color_set = |
parse_color(cur_node, "color", &style->track.color); |
|
parse_color(cur_node, "color", &style->track.color); |
|
164 |
parse_color(cur_node, "gps-color", &style->track.gps_color); |
parse_color(cur_node, "gps-color", &style->track.gps_color); |
165 |
xml_get_prop_float(cur_node, "width", &style->track.width); |
xml_get_prop_float(cur_node, "width", &style->track.width); |
166 |
|
|
|
int opaque = xml_get_prop_opaque(cur_node, "opaque"); |
|
|
if(color_set) style->track.color = (style->track.color<<8) | opaque; |
|
|
|
|
167 |
/* ---------- area ------------------------------------- */ |
/* ---------- area ------------------------------------- */ |
168 |
} else if(strcasecmp((char*)cur_node->name, "area") == 0) { |
} else if(strcasecmp((char*)cur_node->name, "area") == 0) { |
169 |
style->area.has_border_color = |
style->area.has_border_color = |
170 |
parse_color(cur_node, "border-color", &style->area.border_color); |
parse_color(cur_node, "border-color", &style->area.border_color); |
171 |
xml_get_prop_float(cur_node,"border-width", &style->area.border_width); |
xml_get_prop_float(cur_node,"border-width", &style->area.border_width); |
172 |
float scale_max = 0; |
float scale_max = 0; |
173 |
xml_get_prop_float(cur_node, "scale-max", &scale_max); |
xml_get_prop_float(cur_node, "scale-max", &scale_max); |
174 |
if (scale_max > 0) |
if (scale_max > 0) |
175 |
style->area.zoom_max = scaledn_to_zoom(scale_max); |
style->area.zoom_max = scaledn_to_zoom(scale_max); |
176 |
else |
else |
177 |
style->area.zoom_max = 0; |
style->area.zoom_max = 0; |
178 |
|
|
179 |
style->area.opaque = xml_get_prop_opaque(cur_node, "opaque"); |
parse_color(cur_node, "color", &style->area.color); |
180 |
|
|
181 |
/* ---------- background ------------------------------- */ |
/* ---------- background ------------------------------- */ |
182 |
} else if(strcasecmp((char*)cur_node->name, "background") == 0) { |
} else if(strcasecmp((char*)cur_node->name, "background") == 0) { |