Skip to content

Commit 9c4d7f6

Browse files
authored
Merge pull request #1910 from joto/no-tags-no-processing
Don't process objects without tags in pgsql/flex output in append mode
2 parents b6ab0c6 + 4ebd470 commit 9c4d7f6

File tree

3 files changed

+37
-82
lines changed

3 files changed

+37
-82
lines changed

src/osmdata.cpp

Lines changed: 35 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,20 @@ void osmdata_t::node(osmium::Node const &node)
5757
m_mid->node(node);
5858

5959
if (node.deleted()) {
60-
node_delete(node.id());
61-
} else {
62-
if (m_append) {
63-
node_modify(node);
60+
m_output->node_delete(node.id());
61+
return;
62+
}
63+
64+
bool const has_tags_or_attrs = m_with_extra_attrs || !node.tags().empty();
65+
if (m_append) {
66+
if (has_tags_or_attrs) {
67+
m_output->node_modify(node);
6468
} else {
65-
node_add(node);
69+
m_output->node_delete(node.id());
6670
}
71+
m_dependency_manager->node_changed(node.id());
72+
} else if (has_tags_or_attrs) {
73+
m_output->node_add(node);
6774
}
6875
}
6976

@@ -78,13 +85,20 @@ void osmdata_t::way(osmium::Way &way)
7885
m_mid->way(way);
7986

8087
if (way.deleted()) {
81-
way_delete(way.id());
82-
} else {
83-
if (m_append) {
84-
way_modify(&way);
88+
m_output->way_delete(way.id());
89+
return;
90+
}
91+
92+
bool const has_tags_or_attrs = m_with_extra_attrs || !way.tags().empty();
93+
if (m_append) {
94+
if (has_tags_or_attrs) {
95+
m_output->way_modify(&way);
8596
} else {
86-
way_add(&way);
97+
m_output->way_delete(way.id());
8798
}
99+
m_dependency_manager->way_changed(way.id());
100+
} else if (has_tags_or_attrs) {
101+
m_output->way_add(&way);
88102
}
89103
}
90104

@@ -110,70 +124,23 @@ void osmdata_t::relation(osmium::Relation const &rel)
110124
m_mid->relation(rel);
111125

112126
if (rel.deleted()) {
113-
relation_delete(rel.id());
114-
} else {
115-
if (m_append) {
116-
relation_modify(rel);
117-
} else {
118-
relation_add(rel);
119-
}
120-
}
121-
}
122-
123-
void osmdata_t::after_relations() { m_mid->after_relations(); }
124-
125-
void osmdata_t::node_add(osmium::Node const &node) const
126-
{
127-
if (m_with_extra_attrs || !node.tags().empty()) {
128-
m_output->node_add(node);
129-
}
130-
}
131-
132-
void osmdata_t::way_add(osmium::Way *way) const
133-
{
134-
if (m_with_extra_attrs || !way->tags().empty()) {
135-
m_output->way_add(way);
127+
m_output->relation_delete(rel.id());
128+
return;
136129
}
137-
}
138130

139-
void osmdata_t::relation_add(osmium::Relation const &rel) const
140-
{
141-
if (m_with_extra_attrs || !rel.tags().empty()) {
131+
bool const has_tags_or_attrs = m_with_extra_attrs || !rel.tags().empty();
132+
if (m_append) {
133+
if (has_tags_or_attrs) {
134+
m_output->relation_modify(rel);
135+
} else {
136+
m_output->relation_delete(rel.id());
137+
}
138+
} else if (has_tags_or_attrs) {
142139
m_output->relation_add(rel);
143140
}
144141
}
145142

146-
void osmdata_t::node_modify(osmium::Node const &node) const
147-
{
148-
m_output->node_modify(node);
149-
m_dependency_manager->node_changed(node.id());
150-
}
151-
152-
void osmdata_t::way_modify(osmium::Way *way) const
153-
{
154-
m_output->way_modify(way);
155-
m_dependency_manager->way_changed(way->id());
156-
}
157-
158-
void osmdata_t::relation_modify(osmium::Relation const &rel) const
159-
{
160-
m_output->relation_modify(rel);
161-
}
162-
163-
void osmdata_t::node_delete(osmid_t id) const
164-
{
165-
m_output->node_delete(id);
166-
}
167-
168-
void osmdata_t::way_delete(osmid_t id) const
169-
{
170-
m_output->way_delete(id);
171-
}
172-
173-
void osmdata_t::relation_delete(osmid_t id) const
174-
{
175-
m_output->relation_delete(id);
176-
}
143+
void osmdata_t::after_relations() { m_mid->after_relations(); }
177144

178145
void osmdata_t::start() const
179146
{

src/osmdata.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,6 @@ class osmdata_t : public osmium::handler::Handler
6161
void stop() const;
6262

6363
private:
64-
void node_add(osmium::Node const &node) const;
65-
void way_add(osmium::Way *way) const;
66-
void relation_add(osmium::Relation const &rel) const;
67-
68-
void node_modify(osmium::Node const &node) const;
69-
void way_modify(osmium::Way *way) const;
70-
void relation_modify(osmium::Relation const &rel) const;
71-
72-
void node_delete(osmid_t id) const;
73-
void way_delete(osmid_t id) const;
74-
void relation_delete(osmid_t id) const;
75-
7664
/**
7765
* Run stage 1b and stage 1c processing: Process dependent objects in
7866
* append mode.

tests/test-parse-osmium.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ TEST_CASE("parse diff file")
205205
output, "008-ch.osc.gz", false);
206206

207207
REQUIRE(output->node.added == 0);
208-
REQUIRE(output->node.modified == 1176);
209-
REQUIRE(output->node.deleted == 16773);
208+
REQUIRE(output->node.modified == 153);
209+
REQUIRE(output->node.deleted == 17796);
210210
REQUIRE(output->way.added == 0);
211211
REQUIRE(output->way.modified == 161);
212212
REQUIRE(output->way.deleted == 4);

0 commit comments

Comments
 (0)