WIP: Tests, comments and minor fixes to housenumbers/names handling #5965
13 changed files with 95 additions and 15 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
/// If a string holds an uint value then stores it as a varint, otherwise as a string.
|
||||
class StringNumericOptimal
|
||||
{
|
||||
public:
|
||||
|
|
Binary file not shown.
|
@ -15338,7 +15338,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 6381914
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
@ -15381,7 +15382,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 6381914
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
@ -15424,7 +15426,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 6381914
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
|
Binary file not shown.
|
@ -15196,7 +15196,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 6381914
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
@ -15239,7 +15240,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 6381914
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
@ -15282,7 +15284,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 6381914
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
|
Binary file not shown.
|
@ -15196,7 +15196,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 5592405
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
@ -15239,7 +15240,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 5592405
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
@ -15282,7 +15284,8 @@ cont {
|
|||
is_optional: true
|
||||
}
|
||||
secondary {
|
||||
height: 12
|
||||
height: 10
|
||||
color: 5592405
|
||||
offset_y: 10
|
||||
text: "addr:flats"
|
||||
is_optional: true
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
# - type name: "highway|bus_stop" ("|" is converted to "-" internally)
|
||||
# - mapcss selectors for tags: "[highway=bus_stop]", multiple selectors are separated with commas
|
||||
# - "x" for a deprecated type or an empty cell otherwise
|
||||
# - primary title tag (usually "name")
|
||||
# - secondary title tag (usually "int_name")
|
||||
# - primary title tag (usually "name"), IGNORED at the moment
|
||||
# - secondary title tag (usually "int_name"), IGNORED at the moment
|
||||
# - type id, sequential starting from 1
|
||||
# - optional: a replacement type for a deprecated one
|
||||
# A "mandatory" mapcss selector like [fee?] or [fee] matches all tag values except [fee=no],
|
||||
|
|
Can't render this file because it contains an unexpected character in line 7 and column 16.
|
|
@ -618,6 +618,10 @@ node|z18-[entrance=main],
|
|||
node|z18-[entrance=exit],
|
||||
node|z18-[amenity=loading_dock],
|
||||
{text-color: @building_label;}
|
||||
node|z19-[entrance]::flats,
|
||||
node|z18-[entrance=main]::flats,
|
||||
node|z18-[entrance=exit]::flats,
|
||||
{text-color: @building_label;}
|
||||
|
||||
/* 8.1 Pier */
|
||||
area|z15-[waterway=dam],
|
||||
|
@ -669,7 +673,7 @@ node|z18-[entrance=exit],
|
|||
node|z18-[entrance=main],
|
||||
{icon-image: main_entrance-s.svg;font-size: 10;text: ref;text-offset-x: 1;}
|
||||
node|z19-[entrance]::flats
|
||||
{text: "addr:flats";font-size: 12;text-offset-y: 10;}
|
||||
{text: "addr:flats";font-size: 10;text-offset-y: 10;}
|
||||
|
||||
/* 8.3 Airports */
|
||||
area|z14-[aeroway=terminal]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "types_helper.hpp"
|
||||
|
||||
#include "coding/string_utf8_multilang.hpp"
|
||||
|
||||
#include "generator/feature_builder.hpp"
|
||||
#include "generator/generator_tests_support/test_with_classificator.hpp"
|
||||
#include "generator/geometry_holder.hpp"
|
||||
|
@ -218,6 +220,54 @@ UNIT_CLASS_TEST(TestWithClassificator, FBuilder_ParamsParsing)
|
|||
TEST_EQUAL(params.house.Get(), "0", ());
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(TestWithClassificator, FBuilder_Housenumbers)
|
||||
{
|
||||
FeatureBuilderParams params;
|
||||
std::string_view name;
|
||||
|
||||
params.MakeZero();
|
||||
name = {};
|
||||
params.AddHouseName("75a"); // addr:housenumber
|
||||
params.AddHouseName("Sandpiper"); // addr:housename
|
||||
TEST_EQUAL(params.house.Get(), "75a", ());
|
||||
TEST(params.name.GetString(StringUtf8Multilang::kDefaultCode, name), ());
|
||||
TEST_EQUAL(name, "Sandpiper", ());
|
||||
|
||||
params.MakeZero();
|
||||
name = {};
|
||||
params.AddHouseName("75"); // addr:housenumber
|
||||
params.AddHouseName("Bld 2"); // addr:housename
|
||||
TEST_EQUAL(params.house.Get(), "75", ());
|
||||
TEST(params.name.GetString(StringUtf8Multilang::kDefaultCode, name), ());
|
||||
TEST_EQUAL(name, "Bld 2", ());
|
||||
|
||||
params.MakeZero();
|
||||
name = {};
|
||||
params.AddHouseName("75"); // addr:housenumber
|
||||
params.AddHouseName("2"); // addr:housename
|
||||
pastk
commented
both housenumbers and housenames are added via AddHouseName() always in the generator both housenumbers and housenames are added via AddHouseName() always in the generator
|
||||
TEST_EQUAL(params.house.Get(), "2", ());
|
||||
TEST(params.name.GetString(StringUtf8Multilang::kDefaultCode, name), ());
|
||||
TEST_EQUAL(name, "75", ());
|
||||
|
||||
params.MakeZero();
|
||||
name = {};
|
||||
params.name.AddString(StringUtf8Multilang::kDefaultCode, "The Mansion");
|
||||
params.AddHouseName("75a"); // addr:housenumber
|
||||
params.AddHouseName("Sandpiper"); // addr:housename
|
||||
TEST_EQUAL(params.house.Get(), "75a", ());
|
||||
TEST(params.name.GetString(StringUtf8Multilang::kDefaultCode, name), ());
|
||||
TEST_EQUAL(name, "The Mansion", ());
|
||||
|
||||
params.MakeZero();
|
||||
name = {};
|
||||
params.AddHouseName("75a"); // addr:housenumber
|
||||
params.AddHouseName("2"); // addr:housename
|
||||
params.name.AddString(StringUtf8Multilang::kDefaultCode, "The Mansion");
|
||||
TEST_EQUAL(params.house.Get(), "2", ());
|
||||
TEST(params.name.GetString(StringUtf8Multilang::kDefaultCode, name), ());
|
||||
TEST_EQUAL(name, "The Mansion", ());
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(TestWithClassificator, FBuilder_SerializeLocalityObjectForBuildingPoint)
|
||||
{
|
||||
FeatureBuilder fb;
|
||||
|
|
|
@ -922,6 +922,14 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params,
|
|||
|
||||
// Stage3: Process base feature tags.
|
||||
TagProcessor(p).ApplyRules<void(string &, string &)>({
|
||||
// Store a housenumber or a housename.
|
||||
// - values having at least 1 digit go into the "house" addinfo;
|
||||
// - a fully numeric housename will replace a housenumber, which will be stored in the empty "name";
|
||||
// - values w/o digits are stored in the empty "name" only.
|
||||
// E.g. if the "name" was empty before then
|
||||
// housename=2, housenumber=34a --> "house" == 2 and "name" == 34a,
|
||||
// housename=Bld 2, housenumber=34a --> "house" == 34a and "name" == Bld 2,
|
||||
// housename=Sandpiper, housenumber=12 --> "house" == 12 and "name" == Sandpiper.
|
||||
{"addr:housenumber", "*",
|
||||
[¶ms](string & k, string & v) {
|
||||
params.AddHouseName(v);
|
||||
|
@ -934,6 +942,7 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params,
|
|||
k.clear();
|
||||
v.clear();
|
||||
}},
|
||||
|
||||
{"addr:street", "*",
|
||||
[¶ms](string & k, string & v) {
|
||||
params.AddStreet(v);
|
||||
|
|
|
@ -38,7 +38,8 @@ int32_t constexpr kOverlaysMaxPriority = 10000;
|
|||
/// drawing type of rule - can be one of ...
|
||||
enum rule_type_t { line, area, symbol, caption, circle, pathtext, waymarker, shield, count_of_rules };
|
||||
|
||||
/// text field type - can be one of ...
|
||||
/// Text field type ("text: *"). Only "addr:housenumber" and "addr:housename" are recognised,
|
||||
/// all other values like "int_name", "ref", etc. are ignored.
|
||||
enum text_type_t { text_type_name = 0, text_type_housename, text_type_housenumber };
|
||||
|
||||
typedef buffer_vector<Key, 16> KeysT;
|
||||
|
|
|
@ -301,6 +301,10 @@ bool FeatureParams::AddName(string_view lang, string_view s)
|
|||
return true;
|
||||
}
|
||||
|
||||
/// Store a housenumber or a housename.
|
||||
/// - strings having at least 1 digit go into the "house" addinfo;
|
||||
/// - strings w/o digits are stored in the empty "name";
|
||||
/// - if the "house" is set already then a new all-numeric value will replace it and push it into the empty "name".
|
||||
bool FeatureParams::AddHouseName(string const & s)
|
||||
{
|
||||
if (IsDummyName(s) || name.FindString(s) != StringUtf8Multilang::kUnsupportedLanguageCode)
|
||||
|
@ -310,8 +314,8 @@ bool FeatureParams::AddHouseName(string const & s)
|
|||
if (house.IsEmpty() && AddHouseNumber(s))
|
||||
return true;
|
||||
|
||||
// If we got a clear number, replace the house number with it.
|
||||
// Example: housename=16th Street, housenumber=34
|
||||
// If we got a true number, replace the previous housenumber with it
|
||||
// and put the previous one into the empty name.
|
||||
if (strings::IsASCIINumeric(s))
|
||||
{
|
||||
string housename(house.Get());
|
||||
|
@ -336,6 +340,7 @@ bool FeatureParams::AddHouseName(string const & s)
|
|||
return false;
|
||||
}
|
||||
|
||||
/// Store a new housenumber (must have at least one digit) into the "house" addinfo.
|
||||
bool FeatureParams::AddHouseNumber(string houseNumber)
|
||||
{
|
||||
ASSERT(!houseNumber.empty(), ("This check should be done by the caller."));
|
||||
|
@ -355,6 +360,7 @@ bool FeatureParams::AddHouseNumber(string houseNumber)
|
|||
++i;
|
||||
houseNumber.erase(0, i);
|
||||
|
||||
// The housenumber must have one digit at least.
|
||||
if (any_of(houseNumber.cbegin(), houseNumber.cend(), &strings::IsASCIIDigit))
|
||||
{
|
||||
house.Set(houseNumber);
|
||||
|
|
Reference in a new issue
Should we have
AddHouseNumber("75")
here?