diff --git a/shared/src/map/layers/tiled/vector/geojson/GeoJsonParser.h b/shared/src/map/layers/tiled/vector/geojson/GeoJsonParser.h index 1c2a73132..d974cfaf0 100644 --- a/shared/src/map/layers/tiled/vector/geojson/GeoJsonParser.h +++ b/shared/src/map/layers/tiled/vector/geojson/GeoJsonParser.h @@ -111,35 +111,30 @@ class GeoJsonParser { return points; } - UUIDGenerator generator; - - std::shared_ptr geoJson = std::make_shared(); for (const auto &feature: geojson["features"]) { - if (!feature["geometry"].is_object() || - !feature["geometry"]["type"].is_string() || - !feature["geometry"]["coordinates"].is_array()) { + const auto &geometry = feature["geometry"]; + + if (!geometry.is_object()) { LogError <<= "Geojson feature is not valid"; continue; } - const auto &geometryType = feature["geometry"]["type"]; - const auto &coordinates = feature["geometry"]["coordinates"]; - std::shared_ptr geometry; - vtzero::GeomType geomType; - if (geometryType == "Point") { - geometry = parsePoint(coordinates); - geomType = vtzero::GeomType::POINT; + const auto &geometryType = geometry["type"]; + if (!geometryType.is_string() || geometryType != "Point") { + continue; } - if(!geometry || geometry->coordinates.size() != 1 || geometry->coordinates.front().size() != 1) { + if(!feature["id"].is_string()) { continue; } - if(!feature["id"].is_string()) { + const auto &coordinates = geometry["coordinates"]; + + if(!coordinates.is_array()) { continue; } - points.emplace_back(geometry->coordinates.front().front(), GeoJsonParser::getFeatureInfo(feature["properties"], feature["id"].get())); + points.emplace_back(getPoint(coordinates), GeoJsonParser::getFeatureInfo(feature["properties"], feature["id"].get())); } return points; @@ -222,6 +217,10 @@ class GeoJsonParser { return geometry; } + static Coord getPoint(const nlohmann::json &coordinates) { + return parseCoordinate(coordinates); + } + static std::shared_ptr parseMultiPoint(const nlohmann::json &coordinates) { auto geometry = std::make_shared(); for (const auto &coord : coordinates) {