Skip to content

Commit c3647a2

Browse files
committed
Refactoring: Change a bunch of int variables/parameters to bool
They are only used as boolean values anyway.
1 parent 2e0d830 commit c3647a2

File tree

6 files changed

+50
-50
lines changed

6 files changed

+50
-50
lines changed

src/output-pgsql.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ void output_pgsql_t::pending_way(osmid_t id)
8484
pgsql_delete_way_from_output(id);
8585

8686
taglist_t outtags;
87-
int polygon = 0;
88-
int roads = 0;
87+
bool polygon = false;
88+
bool roads = false;
8989
auto &way = buffer.get<osmium::Way>(0);
9090
if (!m_tagtransform->filter_tags(way, &polygon, &roads, outtags)) {
9191
auto nnodes = m_mid->nodes_get_list(&(way.nodes()));
@@ -149,8 +149,8 @@ void output_pgsql_t::node_add(osmium::Node const &node)
149149

150150
void output_pgsql_t::way_add(osmium::Way *way)
151151
{
152-
int polygon = 0;
153-
int roads = 0;
152+
bool polygon = false;
153+
bool roads = false;
154154
taglist_t outtags;
155155

156156
/* Check whether the way is: (1) Exportable, (2) Maybe a polygon */
@@ -181,9 +181,9 @@ void output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel)
181181
return;
182182
}
183183

184-
int roads = 0;
185-
int make_polygon = 0;
186-
int make_boundary = 0;
184+
bool roads = false;
185+
bool make_polygon = false;
186+
bool make_boundary = false;
187187
taglist_t outtags;
188188

189189
// If it's a route relation make_boundary and make_polygon will be false

src/tagtransform-c.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {
@@ -145,8 +145,8 @@ bool c_tagtransform_t::check_key(std::vector<taginfo> const &infos,
145145
return false;
146146
}
147147

148-
bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
149-
int *roads, taglist_t &out_tags)
148+
bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, bool *polygon,
149+
bool *roads, taglist_t &out_tags)
150150
{
151151
//assume we dont like this set of tags
152152
bool filter = true;
@@ -196,7 +196,7 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
196196
if (add_area_tag) {
197197
/* If we need to force this as a polygon, append an area tag */
198198
out_tags.add_tag_if_not_exists("area", "yes");
199-
*polygon = 1;
199+
*polygon = true;
200200
} else {
201201
auto const *area = o.tags()["area"];
202202
if (area) {
@@ -216,7 +216,7 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
216216

217217
bool c_tagtransform_t::filter_rel_member_tags(
218218
taglist_t const &rel_tags, osmium::memory::Buffer const &,
219-
rolelist_t const &, int *make_boundary, int *make_polygon, int *roads,
219+
rolelist_t const &, bool *make_boundary, bool *make_polygon, bool *roads,
220220
taglist_t &out_tags)
221221
{
222222
std::string const *type = rel_tags.get("type");
@@ -323,12 +323,12 @@ bool c_tagtransform_t::filter_rel_member_tags(
323323
- Linear features will end up in the line and roads tables (useful for admin boundaries)
324324
- Polygon features also go into the polygon table (useful for national_forests)
325325
The edges of the polygon also get treated as linear fetaures allowing these to be rendered seperately. */
326-
*make_boundary = 1;
326+
*make_boundary = true;
327327
} else if (is_multipolygon && out_tags.contains("boundary")) {
328328
/* Treat type=multipolygon exactly like type=boundary if it has a boundary tag. */
329-
*make_boundary = 1;
329+
*make_boundary = true;
330330
} else if (is_multipolygon) {
331-
*make_polygon = 1;
331+
*make_polygon = true;
332332
}
333333

334334
add_z_order(out_tags, roads);

src/tagtransform-c.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class c_tagtransform_t : public tagtransform_t
2020

2121
std::unique_ptr<tagtransform_t> clone() const override;
2222

23-
bool filter_tags(osmium::OSMObject const &o, int *polygon, int *roads,
23+
bool filter_tags(osmium::OSMObject const &o, bool *polygon, bool *roads,
2424
taglist_t &out_tags) override;
2525

2626
bool filter_rel_member_tags(taglist_t const &rel_tags,
2727
osmium::memory::Buffer const &members,
2828
rolelist_t const &member_roles,
29-
int *make_boundary, int *make_polygon,
30-
int *roads, taglist_t &out_tags) override;
29+
bool *make_boundary, bool *make_polygon,
30+
bool *roads, taglist_t &out_tags) override;
3131

3232
private:
3333
bool check_key(std::vector<taginfo> const &infos, char const *k,

src/tagtransform-lua.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ void lua_tagtransform_t::check_lua_function_exists(std::string const &func_name)
6363
lua_pop(L, 1);
6464
}
6565

66-
bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
67-
int *roads, taglist_t &out_tags)
66+
bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, bool *polygon,
67+
bool *roads, taglist_t &out_tags)
6868
{
6969
switch (o.type()) {
7070
case osmium::item_type::node:
@@ -150,8 +150,8 @@ bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
150150

151151
bool lua_tagtransform_t::filter_rel_member_tags(
152152
taglist_t const &rel_tags, osmium::memory::Buffer const &members,
153-
rolelist_t const &member_roles, int *make_boundary, int *make_polygon,
154-
int *roads, taglist_t &out_tags)
153+
rolelist_t const &member_roles, bool *make_boundary, bool *make_polygon,
154+
bool *roads, taglist_t &out_tags)
155155
{
156156
size_t const num_members = member_roles.size();
157157
lua_getglobal(L, m_rel_mem_func.c_str());

src/tagtransform-lua.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class lua_tagtransform_t : public tagtransform_t
2929

3030
std::unique_ptr<tagtransform_t> clone() const override;
3131

32-
bool filter_tags(osmium::OSMObject const &o, int *polygon, int *roads,
32+
bool filter_tags(osmium::OSMObject const &o, bool *polygon, bool *roads,
3333
taglist_t &out_tags) override;
3434

3535
bool filter_rel_member_tags(taglist_t const &rel_tags,
3636
osmium::memory::Buffer const &members,
3737
rolelist_t const &member_roles,
38-
int *make_boundary, int *make_polygon,
39-
int *roads, taglist_t &out_tags) override;
38+
bool *make_boundary, bool *make_polygon,
39+
bool *roads, taglist_t &out_tags) override;
4040

4141
private:
4242
void open_style();

src/tagtransform.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class tagtransform_t
2929

3030
virtual std::unique_ptr<tagtransform_t> clone() const = 0;
3131

32-
virtual bool filter_tags(osmium::OSMObject const &o, int *polygon,
33-
int *roads, taglist_t &out_tags) = 0;
32+
virtual bool filter_tags(osmium::OSMObject const &o, bool *polygon,
33+
bool *roads, taglist_t &out_tags) = 0;
3434

3535
virtual bool filter_rel_member_tags(taglist_t const &rel_tags,
3636
osmium::memory::Buffer const &members,
3737
rolelist_t const &member_roles,
38-
int *make_boundary, int *make_polygon,
39-
int *roads, taglist_t &out_tags) = 0;
38+
bool *make_boundary, bool *make_polygon,
39+
bool *roads, taglist_t &out_tags) = 0;
4040
};
4141

4242
#endif // OSM2PGSQL_TAGTRANSFORM_HPP

0 commit comments

Comments
 (0)