Skip to content

Commit 4c91bed

Browse files
committed
remove support for old-style MPs
Also removes support for superseding ways from polygons. The lua bindings still expect that the supersede table is present but will simply drop it.
1 parent c9030bb commit 4c91bed

12 files changed

+25
-110
lines changed

geometry-processor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ size_t relation_helper::set(osmium::Relation const &rel, middle_t const *mid)
9090
// get the nodes and roles of the ways
9191
auto num_ways = mid->rel_way_members_get(rel, &roles, data);
9292

93-
// mark the ends of each so whoever uses them will know where they end..
94-
superseded.resize(num_ways);
95-
9693
return num_ways;
9794
}
9895

geometry-processor.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class relation_helper
9090
void add_way_locations(middle_t const *mid);
9191

9292
rolelist_t roles;
93-
std::vector<int> superseded;
9493
osmium::memory::Buffer data;
9594
};
9695

output-multi.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -368,19 +368,19 @@ int output_multi_t::process_relation(osmium::Relation const &rel,
368368
if (m_relation_helper.set(rel, (middle_t *)m_mid) < 1)
369369
return 0;
370370

371-
//NOTE: make_polygon is preset here this is to force the tag matching/superseded stuff
371+
//NOTE: make_polygon is preset here this is to force the tag matching
372372
//normally this wouldnt work but we tell the tag transform to allow typeless relations
373373
//this is needed because the type can get stripped off by the rel_tag filter above
374374
//if the export list did not include the type tag.
375-
//TODO: find a less hacky way to do the matching/superseded and tag copying stuff without
375+
//TODO: find a less hacky way to do the matching and tag copying stuff without
376376
//all this trickery
377377
int roads;
378378
int make_boundary, make_polygon;
379379
taglist_t outtags;
380380
filter = m_tagtransform->filter_rel_member_tags(
381381
rel_outtags, m_relation_helper.data, m_relation_helper.roles,
382-
&m_relation_helper.superseded.front(), &make_boundary,
383-
&make_polygon, &roads, *m_export_list.get(), outtags, true);
382+
&make_boundary, &make_polygon, &roads, *m_export_list.get(),
383+
outtags, true);
384384
if (!filter)
385385
{
386386
m_relation_helper.add_way_locations((middle_t *)m_mid);
@@ -389,23 +389,6 @@ int output_multi_t::process_relation(osmium::Relation const &rel,
389389
for (const auto geom : geoms) {
390390
copy_to_table(-rel.id(), geom, outtags);
391391
}
392-
393-
//TODO: should this loop be inside the if above just in case?
394-
//take a look at each member to see if its superseded (tags on it matched the tags on the relation)
395-
size_t i = 0;
396-
for (auto const &w : m_relation_helper.data.select<osmium::Way>()) {
397-
//tags matched so we are keeping this one with this relation
398-
if (m_relation_helper.superseded[i]) {
399-
//just in case it wasnt previously with this relation we get rid of them
400-
way_delete(w.id());
401-
//the other option is that we marked them pending in the way processing so here we mark them
402-
//done so when we go back over the pendings we can just skip it because its in the done list
403-
//TODO: dont do this when working with pending relations to avoid thread races
404-
if(!pending)
405-
ways_done_tracker->mark(w.id());
406-
}
407-
++i;
408-
}
409392
}
410393
}
411394
return 0;

output-pgsql.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,7 @@ int output_pgsql_t::way_add(osmium::Way *way)
276276
auto filter = m_tagtransform->filter_tags(*way, &polygon, &roads,
277277
*m_export_list.get(), outtags);
278278

279-
/* If this isn't a polygon then it can not be part of a multipolygon
280-
Hence only polygons are "pending" */
281-
if (!filter && polygon) { ways_pending_tracker.mark(way->id()); }
282-
283-
if( !polygon && !filter )
284-
{
279+
if (!filter) {
285280
/* Get actual node data and generate output */
286281
auto nnodes = m_mid->nodes_get_list(&(way->nodes()));
287282
if (nnodes > 1) {
@@ -320,15 +315,13 @@ int output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel,
320315
int roads = 0;
321316
int make_polygon = 0;
322317
int make_boundary = 0;
323-
std::vector<int> members_superseded(num_ways, 0);
324318
taglist_t outtags;
325319

326320
// If it's a route relation make_boundary and make_polygon will be false
327321
// otherwise one or the other will be true.
328322
if (m_tagtransform->filter_rel_member_tags(
329-
prefiltered_tags, buffer, xrole, &(members_superseded[0]),
330-
&make_boundary, &make_polygon, &roads, *m_export_list.get(),
331-
outtags)) {
323+
prefiltered_tags, buffer, xrole, &make_boundary, &make_polygon,
324+
&roads, *m_export_list.get(), outtags)) {
332325
return 0;
333326
}
334327

@@ -369,24 +362,6 @@ int output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel,
369362
}
370363
m_tables[t_poly]->write_row(-rel.id(), outtags, wkb);
371364
}
372-
373-
/* Tagtransform will have marked those member ways of the relation that
374-
* have fully been dealt with as part of the multi-polygon entry.
375-
* Set them in the database as done and delete their entry to not
376-
* have duplicates */
377-
if (make_polygon) {
378-
size_t j = 0;
379-
for (auto &w : buffer.select<osmium::Way>()) {
380-
if (members_superseded[j]) {
381-
pgsql_delete_way_from_output(w.id());
382-
// When working with pending relations this is not needed.
383-
if (!pending) {
384-
ways_done_tracker->mark(w.id());
385-
}
386-
}
387-
++j;
388-
}
389-
}
390365
}
391366

392367
return 0;

tagtransform-c.cpp

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
206206

207207
bool c_tagtransform_t::filter_rel_member_tags(
208208
taglist_t const &rel_tags, osmium::memory::Buffer const &members,
209-
rolelist_t const &member_roles, int *member_superseded, int *make_boundary,
210-
int *make_polygon, int *roads, export_list const &exlist,
211-
taglist_t &out_tags, bool allow_typeless)
209+
rolelist_t const &member_roles, int *make_boundary, int *make_polygon,
210+
int *roads, export_list const &exlist, taglist_t &out_tags,
211+
bool allow_typeless)
212212
{
213213
auto const &infos = exlist.get(osmium::item_type::way);
214214
//if it has a relation figure out what kind it is
@@ -386,35 +386,6 @@ bool c_tagtransform_t::filter_rel_member_tags(
386386
return true;
387387
}
388388

389-
/* If we are creating a multipolygon then we
390-
mark each member so that we can skip them during iterate_ways
391-
but only if the polygon-tags look the same as the outer ring */
392-
if (make_polygon) {
393-
size_t i = 0;
394-
for (auto const &w : members.select<osmium::Way>()) {
395-
member_superseded[i] = 1;
396-
for (const auto &member_tag : w.tags()) {
397-
auto const *v = out_tags.get(member_tag.key());
398-
bool filt;
399-
int flag;
400-
if ((!v && check_key(infos, member_tag.key(), &filt, &flag, false))
401-
|| (v && *v != member_tag.value())) {
402-
/* z_order and osm_ are automatically generated tags, so ignore them */
403-
if (strcmp(member_tag.key(), "z_order") &&
404-
strcmp(member_tag.key(), "osm_user") &&
405-
strcmp(member_tag.key(), "osm_version") &&
406-
strcmp(member_tag.key(), "osm_uid") &&
407-
strcmp(member_tag.key(), "osm_changeset") &&
408-
strcmp(member_tag.key(), "osm_timestamp")) {
409-
member_superseded[i] = 0;
410-
break;
411-
}
412-
}
413-
}
414-
++i;
415-
}
416-
}
417-
418389
add_z_order(out_tags, roads);
419390

420391
return 0;

tagtransform-c.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class c_tagtransform_t : public tagtransform_t
1616
bool filter_rel_member_tags(taglist_t const &rel_tags,
1717
osmium::memory::Buffer const &members,
1818
rolelist_t const &member_roles,
19-
int *member_superseded, int *make_boundary,
20-
int *make_polygon, int *roads,
21-
export_list const &exlist, taglist_t &out_tags,
19+
int *make_boundary, int *make_polygon,
20+
int *roads, export_list const &exlist,
21+
taglist_t &out_tags,
2222
bool allow_typeless = false) override;
2323

2424
private:

tagtransform-lua.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
140140

141141
bool lua_tagtransform_t::filter_rel_member_tags(
142142
taglist_t const &rel_tags, osmium::memory::Buffer const &members,
143-
rolelist_t const &member_roles, int *member_superseded, int *make_boundary,
144-
int *make_polygon, int *roads, export_list const &, taglist_t &out_tags,
145-
bool)
143+
rolelist_t const &member_roles, int *make_boundary, int *make_polygon,
144+
int *roads, export_list const &, taglist_t &out_tags, bool)
146145
{
147146
size_t num_members = member_roles.size();
148147
lua_getglobal(L, m_rel_mem_func.c_str());
@@ -195,16 +194,8 @@ bool lua_tagtransform_t::filter_rel_member_tags(
195194
*make_boundary = (int)lua_tointeger(L, -1);
196195
lua_pop(L, 1);
197196

198-
lua_pushnil(L);
199-
for (size_t i = 0; i < num_members; ++i) {
200-
if (lua_next(L, -2)) {
201-
member_superseded[i] = (int)lua_tointeger(L, -1);
202-
lua_pop(L, 1);
203-
} else {
204-
throw std::runtime_error("Failed to read member_superseded from lua function");
205-
}
206-
}
207-
lua_pop(L, 2);
197+
// obsolete member superseded is ignored.
198+
lua_pop(L, 1);
208199

209200
lua_pushnil(L);
210201
while (lua_next(L, -2) != 0) {

tagtransform-lua.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class lua_tagtransform_t : public tagtransform_t
2222
bool filter_rel_member_tags(taglist_t const &rel_tags,
2323
osmium::memory::Buffer const &members,
2424
rolelist_t const &member_roles,
25-
int *member_superseded, int *make_boundary,
26-
int *make_polygon, int *roads,
27-
export_list const &exlist, taglist_t &out_tags,
25+
int *make_boundary, int *make_polygon,
26+
int *roads, export_list const &exlist,
27+
taglist_t &out_tags,
2828
bool allow_typeless = false) override;
2929

3030
private:

tagtransform.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class tagtransform_t
2525
virtual bool filter_rel_member_tags(taglist_t const &rel_tags,
2626
osmium::memory::Buffer const &members,
2727
rolelist_t const &member_roles,
28-
int *member_superseded,
2928
int *make_boundary, int *make_polygon,
3029
int *roads, export_list const &exlist,
3130
taglist_t &out_tags,

tests/test-output-pgsql-tablespace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void test_regression_simple() {
9191
db->check_count(1342, "SELECT count(*) FROM osm2pgsql_test_point");
9292
db->check_count(3231, "SELECT count(*) FROM osm2pgsql_test_line");
9393
db->check_count( 375, "SELECT count(*) FROM osm2pgsql_test_roads");
94-
db->check_count(4127, "SELECT count(*) FROM osm2pgsql_test_polygon");
94+
db->check_count(4136, "SELECT count(*) FROM osm2pgsql_test_polygon");
9595
}
9696

9797
} // anonymous namespace

0 commit comments

Comments
 (0)