| 58 | |
| 59 | template <typename ForwardIter> |
| 60 | util::json::Object makeGeoJSONGeometry(ForwardIter begin, ForwardIter end) |
| 61 | { |
| 62 | auto num_coordinates = std::distance(begin, end); |
| 63 | BOOST_ASSERT(num_coordinates != 0); |
| 64 | util::json::Object geojson; |
| 65 | geojson.values["type"] = "LineString"; |
| 66 | util::json::Array coordinates; |
| 67 | if (num_coordinates > 1) |
| 68 | { |
| 69 | coordinates.values.reserve(num_coordinates); |
| 70 | auto into = std::back_inserter(coordinates.values); |
| 71 | std::transform(begin, end, into, &detail::coordinateToLonLat); |
| 72 | } |
| 73 | else if (num_coordinates > 0) |
| 74 | { |
| 75 | // For a single location we create a [location, location] LineString |
| 76 | // instead of a single Point making the GeoJSON output consistent. |
| 77 | coordinates.values.reserve(2); |
| 78 | auto location = detail::coordinateToLonLat(*begin); |
| 79 | coordinates.values.push_back(location); |
| 80 | coordinates.values.push_back(location); |
| 81 | } |
| 82 | geojson.values["coordinates"] = util::json::Value{std::move(coordinates)}; |
| 83 | |
| 84 | return geojson; |
| 85 | } |
| 86 | |
| 87 | util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver); |
| 88 |
no test coverage detected