Skip to content

Commit

Permalink
fis weight conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Jäger authored and Venator2013 committed Aug 30, 2024
1 parent 39f91c7 commit aab211f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
16 changes: 12 additions & 4 deletions plugins/navteq/converter/HouseNumberConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ void HouseNumberConverter::create_premium_house_numbers(
{
// scope tl_builder
osmium::builder::TagListBuilder tl_builder(node_buffer, &node_builder);
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
if (debugMode) {
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
}
tl_builder.add_tag("addr:housenumber", houseNo);
tl_builder.add_tag(
"addr:street",
Expand Down Expand Up @@ -205,7 +207,9 @@ void HouseNumberConverter::create_house_numbers(
{
// scope tl_builder
osmium::builder::TagListBuilder tl_builder(node_builder);
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
if (debugMode) {
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
}
tl_builder.add_tag("addr:housenumber", startNumber);
tl_builder.add_tag(
"addr:street",
Expand Down Expand Up @@ -240,7 +244,9 @@ void HouseNumberConverter::create_house_numbers(
tl_builder.add_tag("addr:street",
to_camel_case_with_spaces(
get_field_from_feature(feat, ST_NAME)));
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
if (debugMode) {
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
}
}
}

Expand All @@ -254,7 +260,9 @@ void HouseNumberConverter::create_house_numbers(
const char *schema =
parse_house_number_schema(get_field_from_feature(feat, addr_schema));
tl_builder.add_tag("addr:interpolation", schema);
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
if (debugMode) {
tl_builder.add_tag(LINK_ID.data(), std::to_string(linkId));
}
}
}
node_buffer.commit();
Expand Down
3 changes: 2 additions & 1 deletion plugins/navteq/converter/StreetConverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ class StreetConverter : public Converter {

void addRestrictionTag(osmium::builder::TagListBuilder &builder,
const std::string &restriction, int direction,
bool is_imperial_units, uint64_t max_value);
bool is_imperial_units, bool isWeight,
uint64_t max_value);

void manipulate_cdms_map(std::multimap<uint64_t, cond_type> &cdms_map,
const std::filesystem::path &dir);
Expand Down
24 changes: 15 additions & 9 deletions plugins/navteq/converter/StreetConverterOSMTagger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,28 +776,34 @@ void StreetConverter::addTransportAccessRestriction(
}

if (max_height > 0)
addRestrictionTag(builder, "maxheight", direction, imperial_units,
addRestrictionTag(builder, "maxheight", direction, imperial_units, false,
max_height);
if (max_width > 0)
addRestrictionTag(builder, "maxwidth", direction, imperial_units,
addRestrictionTag(builder, "maxwidth", direction, imperial_units, false,
max_width);
if (max_length > 0)
addRestrictionTag(builder, "maxlength", direction, imperial_units,
addRestrictionTag(builder, "maxlength", direction, imperial_units, false,
max_length);
if (max_weight > 0)
addRestrictionTag(builder, "maxweight", direction, imperial_units,
addRestrictionTag(builder, "maxweight", direction, imperial_units, true,
max_weight);
if (max_axleload > 0)
addRestrictionTag(builder, "maxaxleload", direction, imperial_units,
max_weight);
addRestrictionTag(builder, "maxaxleload", direction, imperial_units, true,
max_axleload);
}

void StreetConverter::addRestrictionTag(
osmium::builder::TagListBuilder &builder, const std::string &restriction,
int direction, bool is_imperial_units, uint64_t max_value) {
int direction, bool is_imperial_units, bool isWeight, uint64_t max_value) {
{
std::string convertedValue =
is_imperial_units ? inch_to_feet(max_value) : cm_to_m(max_value);

std::string convertedValue = "";
if (isWeight)
convertedValue =
is_imperial_units ? lbs_to_metric_ton(max_value) : kg_to_t(max_value);
else
convertedValue =
is_imperial_units ? inch_to_feet(max_value) : cm_to_m(max_value);

if (direction == 2)
builder.add_tag(restriction + ":forward", convertedValue);
Expand Down
3 changes: 2 additions & 1 deletion plugins/navteq/navteq_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <osmium/io/any_input.hpp>
#include <osmium/io/any_output.hpp>
#include <osmium/io/output_iterator.hpp>
#include <osmium/io/reader_with_progress_bar.hpp>
#include <osmium/object_pointer_collection.hpp>
#include <osmium/osm/object_comparisons.hpp>
#include <ranges>
Expand Down Expand Up @@ -272,7 +273,7 @@ void navteq_plugin::copyType(osmium::io::Writer &writer, osmium::io::File &file,
std::vector<osmium::memory::Buffer> data;
osmium::ObjectPointerCollection objects;

osmium::io::Reader reader{file, bits};
osmium::io::ReaderWithProgressBar reader(true, file, bits);
while (osmium::memory::Buffer buffer = reader.read()) {
osmium::apply(buffer, objects);
data.push_back(std::move(buffer));
Expand Down

0 comments on commit aab211f

Please sign in to comment.