@@ -23,25 +23,25 @@ static const struct
2323{
2424 int offset;
2525 char const *highway;
26- int roads;
27- } layers[] = {{1 , " proposed" , 0 }, {2 , " construction" , 0 },
28- {10 , " steps" , 0 }, {10 , " cycleway" , 0 },
29- {10 , " bridleway" , 0 }, {10 , " footway" , 0 },
30- {10 , " path" , 0 }, {11 , " track" , 0 },
31- {15 , " service" , 0 },
32-
33- {24 , " tertiary_link" , 0 }, {25 , " secondary_link" , 1 },
34- {27 , " primary_link" , 1 }, {28 , " trunk_link" , 1 },
35- {29 , " motorway_link" , 1 },
36-
37- {30 , " raceway" , 0 }, {31 , " pedestrian" , 0 },
38- {32 , " living_street" , 0 }, {33 , " road" , 0 },
39- {33 , " unclassified" , 0 }, {33 , " residential" , 0 },
40- {34 , " tertiary" , 0 }, {36 , " secondary" , 1 },
41- {37 , " primary" , 1 }, {38 , " trunk" , 1 },
42- {39 , " motorway" , 1 }};
43-
44- void add_z_order (taglist_t &tags, int *roads)
26+ bool roads;
27+ } layers[] = {{1 , " proposed" , false }, {2 , " construction" , false },
28+ {10 , " steps" , false }, {10 , " cycleway" , false },
29+ {10 , " bridleway" , false }, {10 , " footway" , false },
30+ {10 , " path" , false }, {11 , " track" , false },
31+ {15 , " service" , false },
32+
33+ {24 , " tertiary_link" , false }, {25 , " secondary_link" , true },
34+ {27 , " primary_link" , true }, {28 , " trunk_link" , true },
35+ {29 , " motorway_link" , true },
36+
37+ {30 , " raceway" , false }, {31 , " pedestrian" , false },
38+ {32 , " living_street" , false }, {33 , " road" , false },
39+ {33 , " unclassified" , false }, {33 , " residential" , false },
40+ {34 , " tertiary" , false }, {36 , " secondary" , true },
41+ {37 , " primary" , true }, {38 , " trunk" , true },
42+ {39 , " motorway" , true }};
43+
44+ void add_z_order (taglist_t &tags, bool *roads)
4545{
4646 std::string const *const layer = tags.get (" layer" );
4747 std::string const *const highway = tags.get (" highway" );
@@ -54,7 +54,7 @@ void add_z_order(taglist_t &tags, int *roads)
5454
5555 int l = layer ? (int )strtol (layer->c_str (), nullptr , 10 ) : 0 ;
5656 z_order = 100 * l;
57- *roads = 0 ;
57+ *roads = false ;
5858
5959 if (highway) {
6060 for (const auto &layer : layers) {
@@ -68,11 +68,11 @@ void add_z_order(taglist_t &tags, int *roads)
6868
6969 if (railway && !railway->empty ()) {
7070 z_order += 35 ;
71- *roads = 1 ;
71+ *roads = true ;
7272 }
7373 /* Administrative boundaries are rendered at low zooms so we prefer to use the roads table */
7474 if (boundary && *boundary == " administrative" ) {
75- *roads = 1 ;
75+ *roads = true ;
7676 }
7777
7878 if (bridge) {
@@ -101,8 +101,7 @@ std::unique_ptr<tagtransform_t> c_tagtransform_t::clone() const
101101}
102102
103103bool c_tagtransform_t::check_key (std::vector<taginfo> const &infos,
104- char const *k, bool *filter, int *flags,
105- bool strict)
104+ char const *k, bool *filter, int *flags)
106105{
107106 // go through the actual tags found on the item and keep the ones in the export list
108107 for (auto const &info : infos) {
@@ -119,38 +118,35 @@ bool c_tagtransform_t::check_key(std::vector<taginfo> const &infos,
119118 }
120119
121120 // if we didn't find any tags that we wanted to export
122- // and we aren't strictly adhering to the list
123- if (!strict) {
124- if (m_options->hstore_mode != hstore_column::none) {
125- /* ... but if hstore_match_only is set then don't take this
121+ if (m_options->hstore_mode != hstore_column::none) {
122+ /* ... but if hstore_match_only is set then don't take this
126123 as a reason for keeping the object */
127- if (!m_options->hstore_match_only ) {
128- *filter = false ;
129- }
130- /* with hstore, copy all tags... */
131- return true ;
124+ if (!m_options->hstore_match_only ) {
125+ *filter = false ;
132126 }
127+ /* with hstore, copy all tags... */
128+ return true ;
129+ }
133130
134- if (!m_options->hstore_columns .empty ()) {
135- /* does this column match any of the hstore column prefixes? */
136- for (auto const &column : m_options->hstore_columns ) {
137- if (boost::starts_with (k, column)) {
138- /* ... but if hstore_match_only is set then don't take this
131+ if (!m_options->hstore_columns .empty ()) {
132+ /* does this column match any of the hstore column prefixes? */
133+ for (auto const &column : m_options->hstore_columns ) {
134+ if (boost::starts_with (k, column)) {
135+ /* ... but if hstore_match_only is set then don't take this
139136 as a reason for keeping the object */
140- if (!m_options->hstore_match_only ) {
141- *filter = false ;
142- }
143- return true ;
137+ if (!m_options->hstore_match_only ) {
138+ *filter = false ;
144139 }
140+ return true ;
145141 }
146142 }
147143 }
148144
149145 return false ;
150146}
151147
152- bool c_tagtransform_t::filter_tags (osmium::OSMObject const &o, int *polygon,
153- int *roads, taglist_t &out_tags, bool strict )
148+ bool c_tagtransform_t::filter_tags (osmium::OSMObject const &o, bool *polygon,
149+ bool *roads, taglist_t &out_tags)
154150{
155151 // assume we dont like this set of tags
156152 bool filter = true ;
@@ -170,27 +166,25 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
170166 for (auto const &item : o.tags ()) {
171167 char const *const k = item.key ();
172168 char const *const v = item.value ();
173- // if we want to do more than the export list says
174- if (!strict) {
175- if (o.type () == osmium::item_type::relation &&
176- std::strcmp (" type" , k) == 0 ) {
177- out_tags.add_tag (k, v);
169+
170+ if (o.type () == osmium::item_type::relation &&
171+ std::strcmp (" type" , k) == 0 ) {
172+ out_tags.add_tag (k, v);
173+ continue ;
174+ }
175+ /* Allow named islands to appear as polygons */
176+ if (std::strcmp (" natural" , k) == 0 &&
177+ std::strcmp (" coastline" , v) == 0 ) {
178+ add_area_tag = 1 ;
179+
180+ /* Discard natural=coastline tags (we render these from a shapefile instead) */
181+ if (!m_options->keep_coastlines ) {
178182 continue ;
179183 }
180- /* Allow named islands to appear as polygons */
181- if (std::strcmp (" natural" , k) == 0 &&
182- std::strcmp (" coastline" , v) == 0 ) {
183- add_area_tag = 1 ;
184-
185- /* Discard natural=coastline tags (we render these from a shapefile instead) */
186- if (!m_options->keep_coastlines ) {
187- continue ;
188- }
189- }
190184 }
191185
192186 // go through the actual tags found on the item and keep the ones in the export list
193- if (check_key (infos, k, &filter, &flags, strict )) {
187+ if (check_key (infos, k, &filter, &flags)) {
194188 out_tags.add_tag (k, v);
195189 }
196190 }
@@ -202,7 +196,7 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
202196 if (add_area_tag) {
203197 /* If we need to force this as a polygon, append an area tag */
204198 out_tags.add_tag_if_not_exists (" area" , " yes" );
205- *polygon = 1 ;
199+ *polygon = true ;
206200 } else {
207201 auto const *area = o.tags ()[" area" ];
208202 if (area) {
@@ -222,27 +216,25 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
222216
223217bool c_tagtransform_t::filter_rel_member_tags (
224218 taglist_t const &rel_tags, osmium::memory::Buffer const &,
225- rolelist_t const &, int *make_boundary, int *make_polygon, int *roads,
226- taglist_t &out_tags, bool allow_typeless )
219+ rolelist_t const &, bool *make_boundary, bool *make_polygon, bool *roads,
220+ taglist_t &out_tags)
227221{
228- // if it has a relation figure out what kind it is
229222 std::string const *type = rel_tags.get (" type" );
223+ if (!type) {
224+ return true ;
225+ }
226+
230227 bool is_route = false ;
231228 bool is_boundary = false ;
232229 bool is_multipolygon = false ;
233- if (type) {
234- // what kind of relation is it
235- if (*type == " route" ) {
236- is_route = true ;
237- } else if (*type == " boundary" ) {
238- is_boundary = true ;
239- } else if (*type == " multipolygon" ) {
240- is_multipolygon = true ;
241- } else if (!allow_typeless) {
242- return true ;
243- }
244- } // you didnt have a type and it was required
245- else if (!allow_typeless) {
230+
231+ if (*type == " route" ) {
232+ is_route = true ;
233+ } else if (*type == " boundary" ) {
234+ is_boundary = true ;
235+ } else if (*type == " multipolygon" ) {
236+ is_multipolygon = true ;
237+ } else {
246238 return true ;
247239 }
248240
@@ -331,12 +323,12 @@ bool c_tagtransform_t::filter_rel_member_tags(
331323 - Linear features will end up in the line and roads tables (useful for admin boundaries)
332324 - Polygon features also go into the polygon table (useful for national_forests)
333325 The edges of the polygon also get treated as linear fetaures allowing these to be rendered seperately. */
334- *make_boundary = 1 ;
326+ *make_boundary = true ;
335327 } else if (is_multipolygon && out_tags.contains (" boundary" )) {
336328 /* Treat type=multipolygon exactly like type=boundary if it has a boundary tag. */
337- *make_boundary = 1 ;
329+ *make_boundary = true ;
338330 } else if (is_multipolygon) {
339- *make_polygon = 1 ;
331+ *make_polygon = true ;
340332 }
341333
342334 add_z_order (out_tags, roads);
0 commit comments