| 23 | } |
| 24 | |
| 25 | void BoundaryPostcodeCollector::Collect(OsmElement const & el) |
| 26 | { |
| 27 | /// @todo Add postal_code for highways processing (along a street). |
| 28 | |
| 29 | // https://wiki.openstreetmap.org/wiki/Key:postal_code |
| 30 | if (el.m_type != OsmElement::EntityType::Relation || el.GetTag("type") != "boundary") |
| 31 | return; |
| 32 | |
| 33 | auto postcode = el.GetTag("postal_code"); |
| 34 | if (postcode.empty()) |
| 35 | postcode = el.GetTag("addr:postcode"); |
| 36 | |
| 37 | // Filter dummy tags like here: https://www.openstreetmap.org/relation/7444 |
| 38 | if (postcode.empty() || postcode.find_first_of(";,") != std::string::npos) |
| 39 | return; |
| 40 | |
| 41 | /// @todo We don't override CollectFeature instead, because of FeatureMakerSimple? |
| 42 | auto osmElementCopy = el; |
| 43 | feature::FeatureBuilder feature; |
| 44 | m_featureMakerSimple.Add(osmElementCopy); |
| 45 | |
| 46 | while (m_featureMakerSimple.GetNextFeature(feature)) |
| 47 | { |
| 48 | /// @todo Make move geometry? |
| 49 | if (feature.IsGeometryClosed()) |
| 50 | m_data.emplace_back(postcode, feature.GetOuterGeometry()); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | void BoundaryPostcodeCollector::Save() |
| 55 | { |
nothing calls this directly
no test coverage detected