mirror of
https://github.com/osm2pgsql-dev/osm2pgsql.git
synced 2025-08-18 08:18:25 +00:00
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.
This commit is contained in:
@ -90,9 +90,6 @@ size_t relation_helper::set(osmium::Relation const &rel, middle_t const *mid)
|
||||
// get the nodes and roles of the ways
|
||||
auto num_ways = mid->rel_way_members_get(rel, &roles, data);
|
||||
|
||||
// mark the ends of each so whoever uses them will know where they end..
|
||||
superseded.resize(num_ways);
|
||||
|
||||
return num_ways;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,6 @@ public:
|
||||
void add_way_locations(middle_t const *mid);
|
||||
|
||||
rolelist_t roles;
|
||||
std::vector<int> superseded;
|
||||
osmium::memory::Buffer data;
|
||||
};
|
||||
|
||||
|
@ -368,19 +368,19 @@ int output_multi_t::process_relation(osmium::Relation const &rel,
|
||||
if (m_relation_helper.set(rel, (middle_t *)m_mid) < 1)
|
||||
return 0;
|
||||
|
||||
//NOTE: make_polygon is preset here this is to force the tag matching/superseded stuff
|
||||
//NOTE: make_polygon is preset here this is to force the tag matching
|
||||
//normally this wouldnt work but we tell the tag transform to allow typeless relations
|
||||
//this is needed because the type can get stripped off by the rel_tag filter above
|
||||
//if the export list did not include the type tag.
|
||||
//TODO: find a less hacky way to do the matching/superseded and tag copying stuff without
|
||||
//TODO: find a less hacky way to do the matching and tag copying stuff without
|
||||
//all this trickery
|
||||
int roads;
|
||||
int make_boundary, make_polygon;
|
||||
taglist_t outtags;
|
||||
filter = m_tagtransform->filter_rel_member_tags(
|
||||
rel_outtags, m_relation_helper.data, m_relation_helper.roles,
|
||||
&m_relation_helper.superseded.front(), &make_boundary,
|
||||
&make_polygon, &roads, *m_export_list.get(), outtags, true);
|
||||
&make_boundary, &make_polygon, &roads, *m_export_list.get(),
|
||||
outtags, true);
|
||||
if (!filter)
|
||||
{
|
||||
m_relation_helper.add_way_locations((middle_t *)m_mid);
|
||||
@ -389,23 +389,6 @@ int output_multi_t::process_relation(osmium::Relation const &rel,
|
||||
for (const auto geom : geoms) {
|
||||
copy_to_table(-rel.id(), geom, outtags);
|
||||
}
|
||||
|
||||
//TODO: should this loop be inside the if above just in case?
|
||||
//take a look at each member to see if its superseded (tags on it matched the tags on the relation)
|
||||
size_t i = 0;
|
||||
for (auto const &w : m_relation_helper.data.select<osmium::Way>()) {
|
||||
//tags matched so we are keeping this one with this relation
|
||||
if (m_relation_helper.superseded[i]) {
|
||||
//just in case it wasnt previously with this relation we get rid of them
|
||||
way_delete(w.id());
|
||||
//the other option is that we marked them pending in the way processing so here we mark them
|
||||
//done so when we go back over the pendings we can just skip it because its in the done list
|
||||
//TODO: dont do this when working with pending relations to avoid thread races
|
||||
if(!pending)
|
||||
ways_done_tracker->mark(w.id());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -276,12 +276,7 @@ int output_pgsql_t::way_add(osmium::Way *way)
|
||||
auto filter = m_tagtransform->filter_tags(*way, &polygon, &roads,
|
||||
*m_export_list.get(), outtags);
|
||||
|
||||
/* If this isn't a polygon then it can not be part of a multipolygon
|
||||
Hence only polygons are "pending" */
|
||||
if (!filter && polygon) { ways_pending_tracker.mark(way->id()); }
|
||||
|
||||
if( !polygon && !filter )
|
||||
{
|
||||
if (!filter) {
|
||||
/* Get actual node data and generate output */
|
||||
auto nnodes = m_mid->nodes_get_list(&(way->nodes()));
|
||||
if (nnodes > 1) {
|
||||
@ -320,15 +315,13 @@ int output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel,
|
||||
int roads = 0;
|
||||
int make_polygon = 0;
|
||||
int make_boundary = 0;
|
||||
std::vector<int> members_superseded(num_ways, 0);
|
||||
taglist_t outtags;
|
||||
|
||||
// If it's a route relation make_boundary and make_polygon will be false
|
||||
// otherwise one or the other will be true.
|
||||
if (m_tagtransform->filter_rel_member_tags(
|
||||
prefiltered_tags, buffer, xrole, &(members_superseded[0]),
|
||||
&make_boundary, &make_polygon, &roads, *m_export_list.get(),
|
||||
outtags)) {
|
||||
prefiltered_tags, buffer, xrole, &make_boundary, &make_polygon,
|
||||
&roads, *m_export_list.get(), outtags)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -369,24 +362,6 @@ int output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel,
|
||||
}
|
||||
m_tables[t_poly]->write_row(-rel.id(), outtags, wkb);
|
||||
}
|
||||
|
||||
/* Tagtransform will have marked those member ways of the relation that
|
||||
* have fully been dealt with as part of the multi-polygon entry.
|
||||
* Set them in the database as done and delete their entry to not
|
||||
* have duplicates */
|
||||
if (make_polygon) {
|
||||
size_t j = 0;
|
||||
for (auto &w : buffer.select<osmium::Way>()) {
|
||||
if (members_superseded[j]) {
|
||||
pgsql_delete_way_from_output(w.id());
|
||||
// When working with pending relations this is not needed.
|
||||
if (!pending) {
|
||||
ways_done_tracker->mark(w.id());
|
||||
}
|
||||
}
|
||||
++j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -206,9 +206,9 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
|
||||
|
||||
bool c_tagtransform_t::filter_rel_member_tags(
|
||||
taglist_t const &rel_tags, osmium::memory::Buffer const &members,
|
||||
rolelist_t const &member_roles, int *member_superseded, int *make_boundary,
|
||||
int *make_polygon, int *roads, export_list const &exlist,
|
||||
taglist_t &out_tags, bool allow_typeless)
|
||||
rolelist_t const &member_roles, int *make_boundary, int *make_polygon,
|
||||
int *roads, export_list const &exlist, taglist_t &out_tags,
|
||||
bool allow_typeless)
|
||||
{
|
||||
auto const &infos = exlist.get(osmium::item_type::way);
|
||||
//if it has a relation figure out what kind it is
|
||||
@ -386,35 +386,6 @@ bool c_tagtransform_t::filter_rel_member_tags(
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If we are creating a multipolygon then we
|
||||
mark each member so that we can skip them during iterate_ways
|
||||
but only if the polygon-tags look the same as the outer ring */
|
||||
if (make_polygon) {
|
||||
size_t i = 0;
|
||||
for (auto const &w : members.select<osmium::Way>()) {
|
||||
member_superseded[i] = 1;
|
||||
for (const auto &member_tag : w.tags()) {
|
||||
auto const *v = out_tags.get(member_tag.key());
|
||||
bool filt;
|
||||
int flag;
|
||||
if ((!v && check_key(infos, member_tag.key(), &filt, &flag, false))
|
||||
|| (v && *v != member_tag.value())) {
|
||||
/* z_order and osm_ are automatically generated tags, so ignore them */
|
||||
if (strcmp(member_tag.key(), "z_order") &&
|
||||
strcmp(member_tag.key(), "osm_user") &&
|
||||
strcmp(member_tag.key(), "osm_version") &&
|
||||
strcmp(member_tag.key(), "osm_uid") &&
|
||||
strcmp(member_tag.key(), "osm_changeset") &&
|
||||
strcmp(member_tag.key(), "osm_timestamp")) {
|
||||
member_superseded[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
add_z_order(out_tags, roads);
|
||||
|
||||
return 0;
|
||||
|
@ -16,9 +16,9 @@ public:
|
||||
bool filter_rel_member_tags(taglist_t const &rel_tags,
|
||||
osmium::memory::Buffer const &members,
|
||||
rolelist_t const &member_roles,
|
||||
int *member_superseded, int *make_boundary,
|
||||
int *make_polygon, int *roads,
|
||||
export_list const &exlist, taglist_t &out_tags,
|
||||
int *make_boundary, int *make_polygon,
|
||||
int *roads, export_list const &exlist,
|
||||
taglist_t &out_tags,
|
||||
bool allow_typeless = false) override;
|
||||
|
||||
private:
|
||||
|
@ -140,9 +140,8 @@ bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
|
||||
|
||||
bool lua_tagtransform_t::filter_rel_member_tags(
|
||||
taglist_t const &rel_tags, osmium::memory::Buffer const &members,
|
||||
rolelist_t const &member_roles, int *member_superseded, int *make_boundary,
|
||||
int *make_polygon, int *roads, export_list const &, taglist_t &out_tags,
|
||||
bool)
|
||||
rolelist_t const &member_roles, int *make_boundary, int *make_polygon,
|
||||
int *roads, export_list const &, taglist_t &out_tags, bool)
|
||||
{
|
||||
size_t num_members = member_roles.size();
|
||||
lua_getglobal(L, m_rel_mem_func.c_str());
|
||||
@ -195,16 +194,8 @@ bool lua_tagtransform_t::filter_rel_member_tags(
|
||||
*make_boundary = (int)lua_tointeger(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushnil(L);
|
||||
for (size_t i = 0; i < num_members; ++i) {
|
||||
if (lua_next(L, -2)) {
|
||||
member_superseded[i] = (int)lua_tointeger(L, -1);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
throw std::runtime_error("Failed to read member_superseded from lua function");
|
||||
}
|
||||
}
|
||||
lua_pop(L, 2);
|
||||
// obsolete member superseded is ignored.
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, -2) != 0) {
|
||||
|
@ -22,9 +22,9 @@ public:
|
||||
bool filter_rel_member_tags(taglist_t const &rel_tags,
|
||||
osmium::memory::Buffer const &members,
|
||||
rolelist_t const &member_roles,
|
||||
int *member_superseded, int *make_boundary,
|
||||
int *make_polygon, int *roads,
|
||||
export_list const &exlist, taglist_t &out_tags,
|
||||
int *make_boundary, int *make_polygon,
|
||||
int *roads, export_list const &exlist,
|
||||
taglist_t &out_tags,
|
||||
bool allow_typeless = false) override;
|
||||
|
||||
private:
|
||||
|
@ -25,7 +25,6 @@ public:
|
||||
virtual bool filter_rel_member_tags(taglist_t const &rel_tags,
|
||||
osmium::memory::Buffer const &members,
|
||||
rolelist_t const &member_roles,
|
||||
int *member_superseded,
|
||||
int *make_boundary, int *make_polygon,
|
||||
int *roads, export_list const &exlist,
|
||||
taglist_t &out_tags,
|
||||
|
@ -91,7 +91,7 @@ void test_regression_simple() {
|
||||
db->check_count(1342, "SELECT count(*) FROM osm2pgsql_test_point");
|
||||
db->check_count(3231, "SELECT count(*) FROM osm2pgsql_test_line");
|
||||
db->check_count( 375, "SELECT count(*) FROM osm2pgsql_test_roads");
|
||||
db->check_count(4127, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
db->check_count(4136, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -83,7 +83,7 @@ void test_z_order() {
|
||||
db->assert_has_table("osm2pgsql_test_polygon");
|
||||
db->assert_has_table("osm2pgsql_test_roads");
|
||||
|
||||
db->check_count(10, "SELECT COUNT(*) FROM osm2pgsql_test_polygon");
|
||||
db->check_count(12, "SELECT COUNT(*) FROM osm2pgsql_test_polygon");
|
||||
db->check_count(0, "SELECT COUNT(*) FROM osm2pgsql_test_polygon WHERE NOT ST_IsValid(way)");
|
||||
db->check_count(0, "SELECT COUNT(*) FROM osm2pgsql_test_polygon WHERE ST_IsEmpty(way)");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void test_regression_simple() {
|
||||
db->check_count(1342, "SELECT count(*) FROM osm2pgsql_test_point");
|
||||
db->check_count(3231, "SELECT count(*) FROM osm2pgsql_test_line");
|
||||
db->check_count( 375, "SELECT count(*) FROM osm2pgsql_test_roads");
|
||||
db->check_count(4127, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
db->check_count(4136, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
|
||||
// Check size of lines
|
||||
db->check_number(1696.04, "SELECT ST_Length(way) FROM osm2pgsql_test_line WHERE osm_id = 1101");
|
||||
@ -142,7 +142,7 @@ void test_latlong() {
|
||||
db->check_count(1342, "SELECT count(*) FROM osm2pgsql_test_point");
|
||||
db->check_count(3229, "SELECT count(*) FROM osm2pgsql_test_line");
|
||||
db->check_count(374, "SELECT count(*) FROM osm2pgsql_test_roads");
|
||||
db->check_count(4127, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
db->check_count(4136, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
|
||||
// Check size of lines
|
||||
db->check_number(0.0105343, "SELECT ST_Length(way) FROM osm2pgsql_test_line WHERE osm_id = 1101");
|
||||
@ -279,7 +279,7 @@ void test_clone() {
|
||||
db->check_count(1342, "SELECT count(*) FROM osm2pgsql_test_point");
|
||||
db->check_count(3231, "SELECT count(*) FROM osm2pgsql_test_line");
|
||||
db->check_count( 375, "SELECT count(*) FROM osm2pgsql_test_roads");
|
||||
db->check_count(4127, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
db->check_count(4136, "SELECT count(*) FROM osm2pgsql_test_polygon");
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
Reference in New Issue
Block a user