MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / decodePolyline

Function decodePolyline

include/engine/polyline_compressor.hpp:55–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54template <unsigned POLYLINE_PRECISION = 100000>
55std::vector<util::Coordinate> decodePolyline(const std::string &polyline)
56{
57 double polyline_to_coordinate = COORDINATE_PRECISION / POLYLINE_PRECISION;
58 std::vector<util::Coordinate> coordinates;
59 std::int32_t latitude = 0, longitude = 0;
60
61 std::string::const_iterator first = polyline.begin();
62 const std::string::const_iterator last = polyline.end();
63 while (first != last)
64 {
65 const auto dlat = detail::decode_polyline_integer(first, last);
66 const auto dlon = detail::decode_polyline_integer(first, last);
67
68 latitude += dlat;
69 longitude += dlon;
70
71 coordinates.emplace_back(util::Coordinate{
72 util::FixedLongitude{static_cast<std::int32_t>(longitude * polyline_to_coordinate)},
73 util::FixedLatitude{static_cast<std::int32_t>(latitude * polyline_to_coordinate)}});
74 }
75 return coordinates;
76}
77} // namespace osrm::engine
78
79#endif /* POLYLINECOMPRESSOR_H_ */

Callers 3

BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 4

decode_polyline_integerFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected