Skip to content

paulobarcelos/ofxGooglePolyline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

openFrameworks addon for decoding Google encoded polylines into sketch-friendly longitude/latitude coordinates.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors