Tiny openFrameworks addon for decoding strings that use the Google Encoded Polyline Algorithm Format.
This is handy when you are sketching with route data from mapping APIs and want the encoded path back as openFrameworks-friendly coordinates. Points are returned as ofVec2f, with x = longitude and y = latitude, which maps naturally to screen coordinates after projection/scaling.
std::string encoded = "_p~iF~ps|U_ulLnnqC_mqNvxq`@";
std::vector<ofVec2f> points = ofxGooglePolyline::decodePolyline(encoded);
for(const auto& point : points){
ofLogNotice() << "lng: " << point.x << ", lat: " << point.y;
}The original pointer-returning ofxGooglePolyline::decode() function is still available for older projects, but new code should use decodePolyline() so ownership is clear and nothing leaks.
Tested with openFrameworks 0.12.1 on macOS.
The example includes the standard openFrameworks Makefile flow:
cd example
make Debug
make RunDebug