From 02fe28ec79e864f678fba1b877bb06aea6b24979 Mon Sep 17 00:00:00 2001 From: vng Date: Thu, 1 Oct 2015 18:15:48 +0300 Subject: [PATCH] [classificator] Added new hospital types. Renamed entrance->building-entrance. Added barrier-entrance type. --- data/categories.txt | 2 +- data/mapcss-mapping.csv | 3 ++ data/styles/clear/include/POI.mapcss | 33 +++++++++--- data/styles/legacy/include/base_other.mapcss | 4 +- generator/generator_tests/osm_type_test.cpp | 55 ++++++++++++++++++++ generator/osm2type.cpp | 23 ++++---- 6 files changed, 102 insertions(+), 18 deletions(-) diff --git a/data/categories.txt b/data/categories.txt index 7b5a8e780e..5aeed492f3 100644 --- a/data/categories.txt +++ b/data/categories.txt @@ -1477,7 +1477,7 @@ ro:cimitir nb:gravplass fi:hautausmaa -amenity-hospital|amenity-doctors +amenity-hospital|amenity-doctors|amenity-dentist|amenity-clinic en:3hospital|clinic|3doctor|U+1F691|U+1F3E5|U+1F489|U+1F48A ru:3больница|3госпиталь|врач|доктор uk:3лікарня|клініка|лікар|травмпункт diff --git a/data/mapcss-mapping.csv b/data/mapcss-mapping.csv index 52749c8664..94d82f9aae 100644 --- a/data/mapcss-mapping.csv +++ b/data/mapcss-mapping.csv @@ -1033,3 +1033,6 @@ railway|subway_entrance|madrid;[railway=subway_entrance][city=madrid];;name;int_ railway|subway_entrance|roma;[railway=subway_entrance][city=roma];;name;int_name;1033; railway|subway_entrance|spb;[railway=subway_entrance][city=spb];;name;int_name;1034; aerialway|drag_lift;[aerialway=drag_lift];;name;int_name;1035; +amenity|dentist;[amenity=dentist];;name;int_name;1037; +amenity|clinic;[amenity=clinic];;name;int_name;1038; +barrier|entrance;[barrier=entrance];;name;int_name;1040; diff --git a/data/styles/clear/include/POI.mapcss b/data/styles/clear/include/POI.mapcss index 78bccd0e9c..04efa7450a 100644 --- a/data/styles/clear/include/POI.mapcss +++ b/data/styles/clear/include/POI.mapcss @@ -81,7 +81,15 @@ node|z16[amenity=theatre], area|z16[amenity=theatre] { icon-image: theatre-m.svg node|z16[amenity=kindergarten], area|z16[amenity=kindergarten] { icon-image: kindergarten-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z16[amenity=school], area|z16[amenity=school] { icon-image: school-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z16[amenity=college], area|z16[amenity=college] { icon-image: college-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } -node|z16[amenity=hospital], area|z16[amenity=hospital] { icon-image: hospital-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } + +node|z16[amenity=hospital], area|z16[amenity=hospital], +node|z16[amenity=doctors], area|z16[amenity=doctors], +node|z16[amenity=dentist], area|z16[amenity=dentist], +node|z16[amenity=clinic], area|z16[amenity=clinic], +{ + icon-image: hospital-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; +} + node|z16[amenity=university], area|z16[amenity=university] { icon-image: college-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; z-index: 4; } node|z16[amenity=fuel], area|z16[amenity=fuel] { icon-image: fuel-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z16-[natural=spring],area|z16-[natural=spring]{ icon-image: drinking-water-m.svg; z-index: 1000; text-offset:8; font-size: 10; text: name; text-color: @poi_label; z-index: 100; } @@ -92,7 +100,15 @@ node|z17[amenity=theatre], area|z17[amenity=theatre] { icon-image: theatre-l.svg node|z17[amenity=kindergarten], area|z17[amenity=kindergarten] { icon-image: kindergarten-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z17[amenity=school], area|z17[amenity=school] { icon-image: school-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z17[amenity=college], area|z17[amenity=college] { icon-image: college-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } -node|z17[amenity=hospital], area|z17[amenity=hospital] { icon-image: hospital-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } + +node|z17[amenity=hospital], area|z17[amenity=hospital], +node|z17[amenity=doctors], area|z17[amenity=doctors], +node|z17[amenity=dentist], area|z17[amenity=dentist], +node|z17[amenity=clinic], area|z17[amenity=clinic], +{ + icon-image: hospital-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; +} + node|z17[amenity=university], area|z17[amenity=university] { icon-image: college-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; z-index: 4; } node|z17[amenity=cinema], area|z17[amenity=cinema] { icon-image: cinema-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } @@ -114,7 +130,15 @@ node|z18-[amenity=theatre], area|z18-[amenity=theatre] { icon-image: theatre-l.s node|z18-[amenity=kindergarten], area|z18-[amenity=kindergarten] { icon-image: kindergarten-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z18-[amenity=school], area|z18-[amenity=school] { icon-image: school-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z18-[amenity=college], area|z18-[amenity=college] { icon-image: college-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } -node|z18-[amenity=hospital], area|z18-[amenity=hospital] { icon-image: hospital-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } + +node|z18-[amenity=hospital], area|z18-[amenity=hospital], +node|z18-[amenity=doctors], area|z18-[amenity=doctors], +node|z18-[amenity=dentist], area|z18-[amenity=dentist], +node|z18-[amenity=clinic], area|z18-[amenity=clinic], +{ + icon-image: hospital-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; +} + node|z18-[amenity=university], area|z18-[amenity=university] { icon-image: college-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; z-index: 5; } node|z18-[amenity=cinema], area|z18-[amenity=cinema] { icon-image: cinema-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } node|z18-[amenity=bank], area|z18-[amenity=bank] { z-index: 4500; icon-image: bank-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } @@ -179,9 +203,6 @@ node|z18-[sport=gymnastics] { icon-image: pitch-l.svg; text-offset: 8; font-size node|z16-[highway=speed_camera] { icon-image: speedcam-m.svg; z-index: 7000; } -node|z16[building=hospital], area|z16[building=hospital] { icon-image: hospital-m.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } -node|z17-[building=hospital], area|z17-[building=hospital] { icon-image: hospital-l.svg; text-offset: 8; font-size: 10; text: name; text-color: @poi_label; } - /* PARKINGS */ area|z16-[amenity=parking] {fill-color: @parking;fill-oppacity:1;z-index: 0;} diff --git a/data/styles/legacy/include/base_other.mapcss b/data/styles/legacy/include/base_other.mapcss index 16159749f8..02268a5f27 100644 --- a/data/styles/legacy/include/base_other.mapcss +++ b/data/styles/legacy/include/base_other.mapcss @@ -1213,7 +1213,9 @@ node|z17-[tourism=information][office] icon-image: information-office.svg; } area|z17-[barrier=gate], -node|z17-[barrier=gate] +node|z17-[barrier=gate], +area|z17-[barrier=entrance], +node|z17-[barrier=entrance], { icon-image: gate.svg; } diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index 35e0c58190..1054ad0ca0 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -728,3 +728,58 @@ UNIT_TEST(OsmType_Subway) TEST(params.IsTypeExist(GetType({"railway", "station", "subway", "london"})), (params)); } } + +UNIT_TEST(OsmType_Hospital) +{ + { + char const * arr[][2] = { + { "building", "hospital" }, + }; + + OsmElement e; + FillXmlElement(arr, ARRAY_SIZE(arr), &e); + + FeatureParams params; + ftype::GetNameAndType(&e, params); + + TEST_EQUAL(params.m_Types.size(), 1, (params)); + TEST(params.IsTypeExist(GetType({"building"})), (params)); + } + + { + char const * arr[][2] = { + { "building", "yes" }, + { "amenity", "hospital" }, + }; + + OsmElement e; + FillXmlElement(arr, ARRAY_SIZE(arr), &e); + + FeatureParams params; + ftype::GetNameAndType(&e, params); + + TEST_EQUAL(params.m_Types.size(), 2, (params)); + TEST(params.IsTypeExist(GetType({"building"})), (params)); + TEST(params.IsTypeExist(GetType({"amenity", "hospital"})), (params)); + } +} + +UNIT_TEST(OsmType_Entrance) +{ + { + char const * arr[][2] = { + { "building", "entrance" }, + { "barrier", "entrance" }, + }; + + OsmElement e; + FillXmlElement(arr, ARRAY_SIZE(arr), &e); + + FeatureParams params; + ftype::GetNameAndType(&e, params); + + TEST_EQUAL(params.m_Types.size(), 2, (params)); + TEST(params.IsTypeExist(GetType({"entrance"})), (params)); + TEST(params.IsTypeExist(GetType({"barrier", "entrance"})), (params)); + } +} diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index e0f1e299aa..e9679306ba 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -302,10 +302,10 @@ namespace ftype // Next objects trying to find by value first. ClassifObjectPtr pObj = - ForEachTagEx(p, skipRows, [&](string const & k, string const & v) + ForEachTagEx(p, skipRows, [¤t](string const & k, string const & v) { if (!NeedMatchValue(k, v)) - return ClassifObjectPtr(0, 0); + return ClassifObjectPtr(); return current->BinaryFind(v); }); @@ -389,7 +389,7 @@ namespace ftype return string(); } - void PreprocessElement(OsmElement * p, FeatureParams & params) + void PreprocessElement(OsmElement * p) { bool hasLayer = false; char const * layer = nullptr; @@ -404,6 +404,9 @@ namespace ftype { "layer", "*", [&hasLayer] { hasLayer = true; }}, { "railway", "subway_entrance", [&isSubwayEntrance] { isSubwayEntrance = true; }}, + + /// @todo Unfortunatelly, it's not working in many cases (route=subway, transport=subway). + /// Actually, it's better to process subways after feature types assignment. { "station", "subway", [&isSubwayStation] { isSubwayStation = true; }}, }); @@ -507,7 +510,7 @@ namespace ftype void GetNameAndType(OsmElement * p, FeatureParams & params) { // Stage1: Preprocess tags. - PreprocessElement(p, params); + PreprocessElement(p); // Stage2: Process feature name on all languages. ForEachTag(p, NamesExtractor(params)); @@ -518,9 +521,10 @@ namespace ftype { "atm", "yes", [](string & k, string & v) { k.swap(v); k = "amenity"; }}, { "restaurant", "yes", [](string & k, string & v) { k.swap(v); k = "amenity"; }}, { "hotel", "yes", [](string & k, string & v) { k.swap(v); k = "tourism"; }}, - { "addr:housename", "*", [¶ms](string & k, string & v) { params.AddHouseName(v); k.clear(); v.clear();}}, - { "addr:street", "*", [¶ms](string & k, string & v) { params.AddStreetAddress(v); k.clear(); v.clear();}}, - { "addr:flats", "*", [¶ms](string & k, string & v) { params.flats = v; k.clear(); v.clear();}}, + { "building", "entrance", [](string & k, string & v) { k.swap(v); v = "yes"; }}, + { "addr:housename", "*", [¶ms](string & k, string & v) { params.AddHouseName(v); k.clear(); v.clear(); }}, + { "addr:street", "*", [¶ms](string & k, string & v) { params.AddStreetAddress(v); k.clear(); v.clear(); }}, + { "addr:flats", "*", [¶ms](string & k, string & v) { params.flats = v; k.clear(); v.clear(); }}, { "addr:housenumber", "*", [¶ms](string & k, string & v) { // Treat "numbers" like names if it's not an actual number. @@ -535,8 +539,7 @@ namespace ftype uint64_t n; if (strings::to_uint64(v, n)) params.rank = static_cast(log(double(n)) / log(1.1)); - k.clear(); - v.clear(); + k.clear(); v.clear(); }}, { "ref", "*", [¶ms](string & k, string & v) { @@ -556,7 +559,7 @@ namespace ftype }}, }); - // Stage4: Match tags to classificator for find feature types. + // Stage4: Match tags in classificator to find feature types. MatchTypes(p, params); // Stage5: Postprocess feature types.