Parent Directory | Revision Log
Add support for variable-width dashes, make "Mapnik" style steps distinct
1 | /* |
2 | * Copyright (C) 2008 Till Harbaum <till@harbaum.org>. |
3 | * |
4 | * This file is part of OSM2Go. |
5 | * |
6 | * OSM2Go is free software: you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation, either version 3 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * OSM2Go is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with OSM2Go. If not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | |
20 | #ifndef JOSM_ELEMSTYLES_H |
21 | #define JOSM_ELEMSTYLES_H |
22 | |
23 | // Ratio conversions |
24 | |
25 | float scaledn_to_zoom(const float scaledn); |
26 | float zoom_to_scaledn(const float zoom); |
27 | |
28 | |
29 | typedef enum { |
30 | ES_TYPE_NONE = 0, |
31 | ES_TYPE_LINE, |
32 | ES_TYPE_AREA, |
33 | ES_TYPE_LINE_MOD |
34 | } elemstyle_type_t; |
35 | |
36 | #define DEFAULT_DASH_LENGTH 0 |
37 | |
38 | typedef gulong elemstyle_color_t; |
39 | |
40 | /* from elemstyles.xml: |
41 | * line attributes |
42 | * - width absolute width in pixel in every zoom level |
43 | * - realwidth relative width which will be scaled in meters, integer |
44 | * - colour |
45 | */ |
46 | |
47 | typedef struct { |
48 | gint width; |
49 | elemstyle_color_t color; |
50 | gboolean dashed; |
51 | gint dash_length; // <= 0 means dash length is based on the width |
52 | |
53 | struct { |
54 | gboolean valid; |
55 | gint width; |
56 | } real; |
57 | |
58 | struct { |
59 | gboolean valid; |
60 | gint width; |
61 | elemstyle_color_t color; |
62 | } bg; |
63 | |
64 | float zoom_max; // XXX probably belongs in elemstyle_s |
65 | } elemstyle_line_t; |
66 | |
67 | /* attribute modifiers */ |
68 | typedef enum { |
69 | ES_MOD_NONE = 0, // don't change attribute |
70 | ES_MOD_ADD, // add constant value |
71 | ES_MOD_SUB, // subtract constant value |
72 | ES_MOD_PERCENT // scale by x percent |
73 | } elemstyle_mod_mode_t; |
74 | |
75 | /* a width with modifier */ |
76 | typedef struct { |
77 | elemstyle_mod_mode_t mod; |
78 | gint width; |
79 | } elemstyle_width_mod_t; |
80 | |
81 | |
82 | typedef struct { |
83 | elemstyle_width_mod_t line, bg; |
84 | } elemstyle_line_mod_t; |
85 | |
86 | typedef struct { |
87 | elemstyle_color_t color; |
88 | float zoom_max; // XXX probably belongs in elemstyle_s |
89 | } elemstyle_area_t; |
90 | |
91 | typedef struct { |
92 | gboolean annotate; |
93 | char *filename; |
94 | float zoom_max; // XXX probably belongs in elemstyle_s |
95 | } elemstyle_icon_t; |
96 | |
97 | typedef struct elemstyle_s { |
98 | struct { |
99 | char *key; |
100 | char *value; |
101 | } condition; |
102 | |
103 | elemstyle_type_t type; |
104 | |
105 | union { |
106 | elemstyle_line_mod_t *line_mod; |
107 | elemstyle_line_t *line; |
108 | elemstyle_area_t *area; |
109 | }; |
110 | |
111 | elemstyle_icon_t *icon; |
112 | |
113 | struct elemstyle_s *next; |
114 | } elemstyle_t; |
115 | |
116 | elemstyle_t *josm_elemstyles_load(char *name); |
117 | void josm_elemstyles_free(elemstyle_t *elemstyles); |
118 | gboolean parse_color(xmlNode *a_node, char *name, elemstyle_color_t *color); |
119 | |
120 | void josm_elemstyles_colorize_node(struct style_s *style, node_t *node); |
121 | void josm_elemstyles_colorize_way(struct style_s *style, way_t *way); |
122 | void josm_elemstyles_colorize_world(struct style_s *style, osm_t *osm); |
123 | |
124 | #endif // JOSM_ELEMSTYLES_H |
125 | |
126 | // vim:et:ts=8:sw=2:sts=2:ai |