Make PolylineFormatter's encodedAsJSON and unencodedAsJSON free standing functions

This commit is contained in:
Daniel J. Hofmann
2016-01-08 13:15:09 +01:00
committed by Patrick Niklaus
parent c65dd16460
commit 0627c3443d
3 changed files with 10 additions and 18 deletions
+2 -2
View File
@@ -243,9 +243,9 @@ util::json::Value ApiResponseGenerator<DataFacadeT>::GetGeometry(const bool retu
const Segments &segments) const
{
if (return_encoded)
return PolylineFormatter().printEncodedString(segments.Get());
return polylineEncodeAsJSON(segments.Get());
else
return PolylineFormatter().printUnencodedString(segments.Get());
return polylineUnencodedAsJSON(segments.Get());
}
template <typename DataFacadeT>
+6 -7
View File
@@ -1,6 +1,7 @@
#ifndef POLYLINE_FORMATTER_HPP
#define POLYLINE_FORMATTER_HPP
#include "engine/segment_information.hpp"
#include "osrm/json_container.hpp"
#include <string>
@@ -11,14 +12,12 @@ namespace osrm
namespace engine
{
struct SegmentInformation;
// Encodes geometry into polyline format, returning an encoded JSON object
// See: https://developers.google.com/maps/documentation/utilities/polylinealgorithm
util::json::String polylineEncodeAsJSON(const std::vector<SegmentInformation> &geometry);
struct PolylineFormatter
{
util::json::String printEncodedString(const std::vector<SegmentInformation> &polyline) const;
util::json::Array printUnencodedString(const std::vector<SegmentInformation> &polyline) const;
};
// Does not encode the geometry in polyline format, instead returning an unencoded JSON object
util::json::Array polylineUnencodedAsJSON(const std::vector<SegmentInformation> &geometry);
}
}