openFrameworks addon for decoding Google encoded polylines into sketch-friendly longitude/latitude coordinates.
README
ofxGooglePolyline
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.Usage
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.Compatibility
Tested with openFrameworks 0.12.1 on macOS.
The example includes the standard openFrameworks Makefile flow:
cd example
make Debug
make RunDebug Get this addon
Latest release
Maintenance release for current openFrameworks projects.
- Adds
decodePolyline()as a value-returning API that avoids ownership leaks. - Keeps the original pointer-returning
decode()wrapper for older sketches. - Modernizes the example window setup and Makefile build.
- Refreshes the README with clearer coordinate-order notes.
make Debug using openFrameworks 0.12.1 on macOS.
ofxAddons