| 844 | } |
| 845 | |
| 846 | void PreprocessElement(OsmElement * p, CalculateOriginFnT const & calcOrg) |
| 847 | { |
| 848 | bool hasLayer = false; |
| 849 | char const * layer = nullptr; |
| 850 | |
| 851 | bool isSubway = false; |
| 852 | bool isLightRail = false; |
| 853 | bool isPlatform = false; |
| 854 | bool isStopPosition = false; |
| 855 | bool isBus = false; |
| 856 | bool isTram = false; |
| 857 | bool isFunicular = false; |
| 858 | |
| 859 | bool isCapital = false; |
| 860 | |
| 861 | bool isMultipolygon = false; |
| 862 | |
| 863 | /// @todo Rearrange processing code with accumulating tags for: PT, Surface, Cuisine, Artwork, Memorial, ... |
| 864 | /// Process in separate components (with unit-tests), like DetermineSurface. |
| 865 | TagProcessor(p).ApplyRules({ |
| 866 | {"bridge", "yes", [&layer] { layer = "1"; }}, |
| 867 | {"tunnel", "yes", [&layer] { layer = "-1"; }}, |
| 868 | {"layer", "*", [&hasLayer] { hasLayer = true; }}, |
| 869 | |
| 870 | {"railway", "subway_entrance", [&isSubway] { isSubway = true; }}, |
| 871 | {"public_transport", "platform", [&isPlatform] { isPlatform = true; }}, |
| 872 | {"public_transport", "stop_position", [&isStopPosition] { isStopPosition = true; }}, |
| 873 | {"bus", "yes", [&isBus] { isBus = true; }}, |
| 874 | {"trolleybus", "yes", [&isBus] { isBus = true; }}, |
| 875 | {"tram", "yes", [&isTram] { isTram = true; }}, |
| 876 | {"funicular", "yes", [&isFunicular] { isFunicular = true; }}, |
| 877 | |
| 878 | /// @todo Unfortunately, it's not working in many cases (route=subway, transport=subway). |
| 879 | /// Actually, it's better to process subways after feature types assignment. |
| 880 | {"station", "subway", [&isSubway] { isSubway = true; }}, |
| 881 | {"station", "light_rail", [&isLightRail] { isLightRail = true; }}, |
| 882 | |
| 883 | {"capital", "yes", [&isCapital] { isCapital = true; }}, |
| 884 | |
| 885 | {"type", "multipolygon", [&isMultipolygon] { isMultipolygon = true; }}, |
| 886 | }); |
| 887 | |
| 888 | if (!hasLayer && layer) |
| 889 | p->AddTag("layer", layer); |
| 890 | |
| 891 | // Append tags for Node or Way. Relation logic may be too complex to make such a straightforward tagging. |
| 892 | if (p->m_type != OsmElement::EntityType::Relation) |
| 893 | { |
| 894 | // Tag 'city' is needed for correct selection of metro icons. |
| 895 | if ((isSubway || isLightRail) && calcOrg) |
| 896 | { |
| 897 | auto const org = calcOrg(p); |
| 898 | if (org) |
| 899 | { |
| 900 | string const city = MatchCity(mercator::ToLatLon(*org)); |
| 901 | if (!city.empty()) |
| 902 | p->AddTag("city", city); |
| 903 | } |
no test coverage detected