Skip to content

Commit

Permalink
fix way end node lookup for differnet z_level
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Jäger committed Sep 20, 2024
1 parent aab211f commit 9638a77
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
17 changes: 2 additions & 15 deletions plugins/navteq/converter/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ Converter::create_open_way_nodes(
osmium::memory::Buffer &node_buffer) {
std::vector<std::pair<osmium::Location, osmium::unsigned_object_id_type>>
osm_way_node_ids;

for (auto &point : *line) {
osmium::Location location(point.getX(), point.getY());
auto it = g_way_end_points_map.find(location);
Expand Down Expand Up @@ -175,20 +174,8 @@ Converter::create_closed_way_nodes(
std::map<osmium::Location, osmium::unsigned_object_id_type>
&g_way_end_points_map,
osmium::memory::Buffer &node_buffer) {
std::vector<std::pair<osmium::Location, osmium::unsigned_object_id_type>>
osm_way_node_ids;
for (auto &point : *ring) {
osmium::Location location(point.getX(), point.getY());
auto it = g_way_end_points_map.find(location);

if (it != g_way_end_points_map.end()) {
osm_way_node_ids.emplace_back(location, it->second);
} else {
auto osm_id = build_node(location, node_buffer);
osm_way_node_ids.emplace_back(location, osm_id);
g_way_end_points_map.emplace(location, osm_id);
}
}
auto osm_way_node_ids =
create_open_way_nodes(ring, g_way_end_points_map, node_buffer);

// first and last node are the same in rings, hence add first node_id and
// skip last node.
Expand Down
29 changes: 23 additions & 6 deletions plugins/navteq/converter/StreetConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,18 +432,18 @@ void StreetConverter::process_way_end_nodes(
auto ogr_ls = static_cast<const OGRLineString *>(feat->GetGeometryRef());

process_way_end_node(osmium::Location(ogr_ls->getX(0), ogr_ls->getY(0)), data,
way_end_points_map, node_buffer);
way_end_points_map, false, node_buffer);
process_way_end_node(
osmium::Location(ogr_ls->getX(ogr_ls->getNumPoints() - 1),
ogr_ls->getY(ogr_ls->getNumPoints() - 1)),
data, way_end_points_map, node_buffer);
data, way_end_points_map, false, node_buffer);
}

void StreetConverter::process_way_end_node(
const osmium::Location &location, const StreetConverter::TagData &data,
std::map<osmium::Location, osmium::unsigned_object_id_type>
&way_end_points_map,
osmium::memory::Buffer &node_buffer) {
bool gloablEndPoints, osmium::memory::Buffer &node_buffer) {

auto it = way_end_points_map.find(location);
if (it != way_end_points_map.end())
Expand All @@ -461,6 +461,12 @@ void StreetConverter::process_way_end_node(
if (!junctionName.empty())
tglBuilder.add_tag("name", junctionName);
}

if (gloablEndPoints && debugMode) {
osmium::builder::TagListBuilder tglBuilder(builder);
tglBuilder.add_tag("region_end", "yes");
}

way_end_points_map.emplace(location, osm_id);
}

Expand Down Expand Up @@ -753,12 +759,23 @@ void StreetConverter::process_end_point(
if (it != z_lvl_nodes_map.end()) {
node_ref_map.emplace(location, it->second);
} else {
osmium::unsigned_object_id_type osm_id =
build_node(location, node_buffer);

osmium::unsigned_object_id_type osm_id;
auto it = way_end_points_map.find(location);
if (it != way_end_points_map.end()) {
osm_id = it->second;
} else {
osm_id = build_node(location, node_buffer);
}

node_ref_map.emplace(location, osm_id);
z_lvl_nodes_map.emplace(node_id, osm_id);
}
} else {

if (way_end_points_map.find(location) != way_end_points_map.end())
return;

// adds all zero z-level end points to g_way_end_points_map
way_end_points_map.emplace(location, build_node(location, node_buffer));
}
Expand Down Expand Up @@ -1009,7 +1026,7 @@ void StreetConverter::update_region_connecting_points(

// process the region connecting points
process_way_end_node(osmium::Location(point->getX(), point->getY()), data,
regionConnectingPoints, node_buffer);
regionConnectingPoints, true, node_buffer);
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/navteq/converter/StreetConverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class StreetConverter : public Converter {
const osmium::Location &location, const StreetConverter::TagData &data,
std::map<osmium::Location, osmium::unsigned_object_id_type>
&way_end_points_map,
osmium::memory::Buffer &node_buffer);
bool gloablEndPoints, osmium::memory::Buffer &node_buffer);

void
process_way(const std::filesystem::path &dir,
Expand Down

0 comments on commit 9638a77

Please sign in to comment.