Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tagging #13

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ add_executable(${PROJECT_NAME} ${MAIN_CPP_FILES} ${CPP_FILES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${ICU_LIBRARY}
PRIVATE Boost::boost Boost::log Boost::program_options
PRIVATE GEOS::geos
PRIVATE ${OSMIUM_INCLUDE_DIRS}
PRIVATE GDAL::GDAL
PRIVATE expat bz2
)
2 changes: 1 addition & 1 deletion plugins/navteq/converter/LanduseConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void LanduseConverter::build_landuse_taglist(
// FEAT_TYPE 'PARK (STATE)'
// In many cases this is meant to be a national park or
// protected area but this is not guaranteed
tl_builder.add_tag("leisure", "park");
tl_builder.add_tag("boundary", "national_park");
} else if (featureCode == "900140") {
// FEAT_TYPE 'PARK IN WATER'
tl_builder.add_tag("boundary", "national_park");
Expand Down
4 changes: 2 additions & 2 deletions plugins/navteq/converter/RailwayConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ void RailwayConverter::process_railways(
tl_builder.add_tag("railway", "rail");
tl_builder.add_tag("usage", "main");

if (parse_bool(feat->GetFieldAsString(BRIDGE.data())))
if (get_bool_from_feature(feat, BRIDGE))
tl_builder.add_tag("bridge", YES.data());

if (parse_bool(feat->GetFieldAsString(TUNNEL.data())))
if (get_bool_from_feature(feat, TUNNEL))
tl_builder.add_tag("tunnel", YES.data());
}
{
Expand Down
12 changes: 5 additions & 7 deletions plugins/navteq/converter/StreetConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ StreetConverter::read_junction_names(const std::filesystem::path &dbf_file) {
std::map<uint64_t, std::string> junctionNames;

for (auto &feat : *layer) {
if (parse_bool(get_field_from_feature(feat, JUNCTIONNM))) {
if (get_bool_from_feature(feat, JUNCTIONNM)) {
uint64_t link_id = get_uint_from_feature(feat, LINK_ID);
junctionNames[link_id] = get_field_from_feature(feat, ST_NM_BASE);
}
Expand All @@ -444,15 +444,13 @@ void StreetConverter::parse_ramp_names(
if (layer == nullptr)
throw(shp_empty_error(shp_file.string()));

int exitNameField = layer->FindFieldIndex(EXITNAME.data(), true);
int linkIdField = layer->FindFieldIndex(LINK_ID.data(), true);
int baseNameField = layer->FindFieldIndex(ST_NM_BASE.data(), true);
int directionField = layer->FindFieldIndex(DIR_TRAVEL.data(), true);
int rampField = layer->FindFieldIndex(RAMP.data(), true);

for (auto &feat : *layer) {

if (!parse_bool(feat->GetFieldAsString(rampField))) {
if (!get_bool_from_feature(feat, RAMP)) {
continue;
}

Expand All @@ -463,7 +461,7 @@ void StreetConverter::parse_ramp_names(
location = osmium::Location(ogr_ls->getX(ogr_ls->getNumPoints() - 1),
ogr_ls->getY(ogr_ls->getNumPoints() - 1));

if (parse_bool(feat->GetFieldAsString(exitNameField))) {
if (get_bool_from_feature(feat, EXITNAME)) {
std::string exitName = feat->GetFieldAsString(baseNameField);

// add junction name
Expand Down Expand Up @@ -847,12 +845,12 @@ void StreetConverter::set_ferry_z_lvls_to_zero(
if (z_lvl_vec.size() > 2)
z_lvl_vec.erase(z_lvl_vec.begin() + 1, z_lvl_vec.end() - 1);
// erase first z_lvl if first index references first node
if (!z_lvl_vec.empty() && z_lvl_vec.begin()->index != 0)
if (!z_lvl_vec.empty() && z_lvl_vec.front().index != 0)
z_lvl_vec.erase(z_lvl_vec.begin());
// erase last z_lvl if last index references last node
OGRLineString *ogr_ls = static_cast<OGRLineString *>(feat->GetGeometryRef());
if (!z_lvl_vec.empty() &&
(z_lvl_vec.end() - 1)->index != ogr_ls->getNumPoints() - 1)
z_lvl_vec.back().index != ogr_ls->getNumPoints() - 1)
z_lvl_vec.erase(z_lvl_vec.end());
}

Expand Down
59 changes: 29 additions & 30 deletions plugins/navteq/converter/StreetConverterOSMTagger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ uint64_t StreetConverter::parse_street_tags(
const char *link_id_s = get_field_from_feature(f, LINK_ID);
uint64_t link_id = std::stoul(link_id_s);

bool ramp = parse_bool(get_field_from_feature(f, RAMP));
bool ramp = get_bool_from_feature(f, RAMP);

ushort route_type = 0;
if (!(std::string(get_field_from_feature(f, ROUTE)).empty()))
Expand Down Expand Up @@ -153,11 +153,11 @@ uint64_t StreetConverter::parse_street_tags(
if (debugMode) {
builder.add_tag(LINK_ID.data(), link_id_s);
add_here_speed_cat_tag(builder, f);
if (parse_bool(get_field_from_feature(f, TOLLWAY)))
if (get_bool_from_feature(f, TOLLWAY))
builder.add_tag("here:tollway", YES.data());
if (parse_bool(get_field_from_feature(f, URBAN)))
if (get_bool_from_feature(f, URBAN))
builder.add_tag("here:urban", YES.data());
if (parse_bool(get_field_from_feature(f, CONTRACC)))
if (get_bool_from_feature(f, CONTRACC))
builder.add_tag("here:controll_access", YES.data());
if (route_type)
add_uint_tag(builder, "here:route_type", route_type);
Expand Down Expand Up @@ -273,11 +273,10 @@ void StreetConverter::add_ferry_tag(osmium::builder::TagListBuilder &builder,
if (only_pedestrians(f)) {
builder.add_tag("foot", YES.data());
} else {
builder.add_tag("foot",
parse_bool(get_field_from_feature(f, AR_PEDESTRIANS))
? YES.data()
: NO.data());
builder.add_tag("motorcar", parse_bool(get_field_from_feature(f, AR_AUTO))
builder.add_tag("foot", get_bool_from_feature(f, AR_PEDESTRIANS)
? YES.data()
: NO.data());
builder.add_tag("motorcar", get_bool_from_feature(f, AR_AUTO)
? YES.data()
: NO.data());
}
Expand Down Expand Up @@ -310,17 +309,17 @@ void StreetConverter::add_highway_tags(osmium::builder::TagListBuilder &builder,
add_lanes_tag(builder, f);
add_postcode_tag(builder, f);

if (parse_bool(get_field_from_feature(f, PAVED)))
if (get_bool_from_feature(f, PAVED))
builder.add_tag("surface", "paved");
if (parse_bool(get_field_from_feature(f, BRIDGE)))
if (get_bool_from_feature(f, BRIDGE))
builder.add_tag("bridge", YES.data());
if (parse_bool(get_field_from_feature(f, TUNNEL)))
if (get_bool_from_feature(f, TUNNEL))
builder.add_tag("tunnel", YES.data());
if (parse_bool(get_field_from_feature(f, TOLLWAY)))
if (get_bool_from_feature(f, TOLLWAY))
builder.add_tag("toll", YES.data());
if (parse_bool(get_field_from_feature(f, ROUNDABOUT)))
if (get_bool_from_feature(f, ROUNDABOUT))
builder.add_tag("junction", "roundabout");
if (parse_bool(get_field_from_feature(f, FOURWHLDR)))
if (get_bool_from_feature(f, FOURWHLDR))
builder.add_tag("4wd_only", YES.data());
}

Expand All @@ -339,20 +338,20 @@ void StreetConverter::add_one_way_tag(osmium::builder::TagListBuilder &builder,

void StreetConverter::add_access_tags(osmium::builder::TagListBuilder &builder,
const OGRFeatureUniquePtr &f) {
bool automobile_allowed = parse_bool(get_field_from_feature(f, AR_AUTO));
bool automobile_allowed = get_bool_from_feature(f, AR_AUTO);
if (!automobile_allowed)
builder.add_tag("motorcar", NO.data());
if (!parse_bool(get_field_from_feature(f, AR_BUS)))
if (!get_bool_from_feature(f, AR_BUS))
builder.add_tag("bus", NO.data());
if (!parse_bool(get_field_from_feature(f, AR_TAXIS)))
if (!get_bool_from_feature(f, AR_TAXIS))
builder.add_tag("taxi", NO.data());
// if (! parse_bool(get_field_from_feature(f, AR_CARPOOL)))
// builder->add_tag("hov", NO);
if (!parse_bool(get_field_from_feature(f, AR_PEDESTRIANS)))
if (!get_bool_from_feature(f, AR_PEDESTRIANS))
builder.add_tag("foot", NO.data());
if (!parse_bool(get_field_from_feature(f, AR_TRUCKS))) {
if (!get_bool_from_feature(f, AR_TRUCKS)) {
// truck access handling:
if (!parse_bool(get_field_from_feature(f, AR_DELIV)))
if (!get_bool_from_feature(f, AR_DELIV))
builder.add_tag(
"hgv",
NO.data()); // no truck + no delivery => hgv not allowed at all
Expand All @@ -364,14 +363,14 @@ void StreetConverter::add_access_tags(osmium::builder::TagListBuilder &builder,
builder.add_tag("hgv", "delivery"); // automobile generally allowed =>
// only truck is 'delivery'
}
if (!parse_bool(get_field_from_feature(f, AR_EMERVEH)))
if (!get_bool_from_feature(f, AR_EMERVEH))
builder.add_tag("emergency", NO.data());
if (!parse_bool(get_field_from_feature(f, AR_MOTORCYCLES)))
if (!get_bool_from_feature(f, AR_MOTORCYCLES))
builder.add_tag("motorcycle", NO.data());
if (!parse_bool(get_field_from_feature(f, PUB_ACCESS)) ||
parse_bool(get_field_from_feature(f, PRIVATE))) {
if (!get_bool_from_feature(f, PUB_ACCESS) ||
get_bool_from_feature(f, PRIVATE)) {
builder.add_tag("access", "private");
} else if (!parse_bool(get_field_from_feature(f, AR_THROUGH_TRAFFIC))) {
} else if (!get_bool_from_feature(f, AR_THROUGH_TRAFFIC)) {
builder.add_tag("access", "destination");
}
}
Expand Down Expand Up @@ -511,7 +510,7 @@ void StreetConverter::add_highway_tag(osmium::builder::TagListBuilder &builder,
const std::string &ref_name,
bool underConstruction) {

bool paved = parse_bool(get_field_from_feature(f, PAVED));
bool paved = get_bool_from_feature(f, PAVED);
bool motorized_allowed = is_motorized_allowed(f);

std::string highwayTagName = HIGHWAY.data();
Expand All @@ -537,9 +536,9 @@ void StreetConverter::add_highway_tag(osmium::builder::TagListBuilder &builder,
builder.add_tag(highwayTagName, FOOTWAY.data());
} else {
// paved + motorized allowed
bool controlled_access = parse_bool(get_field_from_feature(f, CONTRACC));
bool urban = parse_bool(get_field_from_feature(f, URBAN));
bool ramp = parse_bool(get_field_from_feature(f, RAMP));
bool controlled_access = get_bool_from_feature(f, CONTRACC);
bool urban = get_bool_from_feature(f, URBAN);
bool ramp = get_bool_from_feature(f, RAMP);

if (controlled_access) {
// controlled_access => motorway
Expand Down
Loading