Skip to content

A C++ implementation of Google Encoded Polyline Algorithm Format (encoder/decoder)

License

Notifications You must be signed in to change notification settings

AlexisRiksman-TomTom/polylineencoder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polyline Encoder/Decoder

C++ implementation of Google Encoded Polyline Algorithm Format

Build Status Build status Coverage Status

Installation

No installation required. Just compile polylineencoder.h(.cpp) in your project and use PolylineEncoder class.

Prerequisites

No special requirements except C++11 compliant compiler. The class is tested with gcc 4.8.4 and MSVC 12.0 (Visual Studio 2013). For more details see the CI badges (Travis CI & AppVeyor CI).

Usage Example:

PolylineEncoder encoder;

// Poles and equator.
encoder.addPoint(-90.0, -180.0);
encoder.addPoint(.0, .0);
encoder.addPoint(90.0, 180.0);

auto res = encoder.encode(); // "~bidP~fsia@_cidP_gsia@_cidP_gsia@"
encoder.clear(); // Clear the list of points.

// Decode a string using static function.
auto polyline = PolylineEncoder::decode("~bidP~fsia@_cidP_gsia@_cidP_gsia@");

// Iterate over all points and print coordinates of each.
for (const auto &point : polyline) {
    printf("(%f, %f)\n", std::get<0>(point), std::get<1>(point));
}

Test

There are unit tests provided for PolylineEncoder class. You can find them in the test/ directory. To run them you have to build and run the test application. For doing that you must invoke the following commands from the terminal, assuming that compiler and environment are already configured:

Linux (gcc)
cd test
g++ -std=c++11 main.cpp -o test
./test
Windows
cd test
cl /W4 /EHsc main.cpp /link /out:test.exe
test

See Also

About

A C++ implementation of Google Encoded Polyline Algorithm Format (encoder/decoder)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%