Skip to content

Commit

Permalink
use get_bool_from_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Jäger committed Jul 29, 2024
1 parent e27aeed commit 82bebc2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 39 deletions.
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

0 comments on commit 82bebc2

Please sign in to comment.