diff --git a/CHANGELOG.md b/CHANGELOG.md index 4430ff05c..a06893ae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 5.0.0 + - API: + - if `geometry=geojson` is passed the resulting geometry can be a LineString or Point + depending on how many coordinates are present. + # 5.0.0 RC2 - Profiles: - `properties.allow_uturns_at_via` -> `properties.continue_straight_at_waypoint` (value is inverted!) diff --git a/include/engine/api/json_factory.hpp b/include/engine/api/json_factory.hpp index 15a49f07e..398fb684b 100644 --- a/include/engine/api/json_factory.hpp +++ b/include/engine/api/json_factory.hpp @@ -50,16 +50,17 @@ template util::json::String makePolyline(ForwardIter begi template util::json::Object makeGeoJSONGeometry(ForwardIter begin, ForwardIter end) { - auto distance = std::distance(begin, end); + auto num_coordinates = std::distance(begin, end); + BOOST_ASSERT(num_coordinates != 0); util::json::Object geojson; - if (distance > 1) + if (num_coordinates > 1) { geojson.values["type"] = "LineString"; util::json::Array coordinates; std::transform(begin, end, std::back_inserter(coordinates.values), &detail::coordinateToLonLat); geojson.values["coordinates"] = std::move(coordinates); } - else if (distance > 0) + else if (num_coordinates > 0) { geojson.values["type"] = "Point"; util::json::Array coordinates;