Contents of /trunk/src/josm_elemstyles.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations)
Tue Dec 16 17:00:20 2008 UTC (15 years, 4 months ago) by harbaum
File MIME type: text/plain
File size: 2966 byte(s)
initial line mod support and some small fixes
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 typedef gulong elemstyle_color_t;
37
38 /* from elemstyles.xml:
39 * line attributes
40 * - width absolute width in pixel in every zoom level
41 * - realwidth relative width which will be scaled in meters, integer
42 * - colour
43 */
44
45 typedef struct {
46 gint width;
47 elemstyle_color_t color;
48 gboolean dashed;
49
50 struct {
51 gboolean valid;
52 gint width;
53 } real;
54
55 struct {
56 gboolean valid;
57 gint width;
58 elemstyle_color_t color;
59 } bg;
60
61 float zoom_max; // XXX probably belongs in elemstyle_s
62 } elemstyle_line_t;
63
64 /* attribute modifiers */
65 typedef enum {
66 ES_MOD_NONE = 0, // don't change attribute
67 ES_MOD_ADD, // add constant value
68 ES_MOD_SUB, // subtract constant value
69 ES_MOD_PERCENT // scale by x percent
70 } elemstyle_mod_mode_t;
71
72 /* a width with modifier */
73 typedef struct {
74 elemstyle_mod_mode_t mod;
75 gint width;
76 } elemstyle_width_mod_t;
77
78
79 typedef struct {
80 elemstyle_width_mod_t line, bg;
81 } elemstyle_line_mod_t;
82
83 typedef struct {
84 elemstyle_color_t color;
85 float zoom_max; // XXX probably belongs in elemstyle_s
86 } elemstyle_area_t;
87
88 typedef struct {
89 gboolean annotate;
90 char *filename;
91 float zoom_max; // XXX probably belongs in elemstyle_s
92 } elemstyle_icon_t;
93
94 typedef struct elemstyle_s {
95 struct {
96 char *key;
97 char *value;
98 } condition;
99
100 elemstyle_type_t type;
101
102 union {
103 elemstyle_line_mod_t *line_mod;
104 elemstyle_line_t *line;
105 elemstyle_area_t *area;
106 };
107
108 elemstyle_icon_t *icon;
109
110 struct elemstyle_s *next;
111 } elemstyle_t;
112
113 elemstyle_t *josm_elemstyles_load(char *name);
114 void josm_elemstyles_free(elemstyle_t *elemstyles);
115 gboolean parse_color(xmlNode *a_node, char *name, elemstyle_color_t *color);
116
117 void josm_elemstyles_colorize_node(struct style_s *style, node_t *node);
118 void josm_elemstyles_colorize_way(struct style_s *style, way_t *way);
119 void josm_elemstyles_colorize_world(struct style_s *style, osm_t *osm);
120
121 #endif // JOSM_ELEMSTYLES_H
122
123 // vim:et:ts=8:sw=2:sts=2:ai