{"id":15735356,"url":"https://github.com/vahancho/polylineencoder","last_synced_at":"2025-05-12T20:41:22.833Z","repository":{"id":48664779,"uuid":"113848285","full_name":"vahancho/polylineencoder","owner":"vahancho","description":"A C++ implementation of Google Encoded Polyline Algorithm Format (encoder/decoder)","archived":false,"fork":false,"pushed_at":"2023-12-04T16:09:23.000Z","size":79,"stargazers_count":22,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T17:02:46.013Z","etag":null,"topics":["coordinates","cpp","cpp11","geospacial","gis","google","google-maps","maps","polyline-decoder","polyline-encoder","stl"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vahancho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-11T10:59:53.000Z","updated_at":"2025-01-09T02:00:45.000Z","dependencies_parsed_at":"2023-02-08T19:00:53.748Z","dependency_job_id":"89739c1b-1c44-42ae-bee1-a8e17464c4fe","html_url":"https://github.com/vahancho/polylineencoder","commit_stats":{"total_commits":102,"total_committers":5,"mean_commits":20.4,"dds":"0.10784313725490191","last_synced_commit":"9bed987f811406c9b1b4c4a85a593572f5aee687"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vahancho%2Fpolylineencoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vahancho%2Fpolylineencoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vahancho%2Fpolylineencoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vahancho%2Fpolylineencoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vahancho","download_url":"https://codeload.github.com/vahancho/polylineencoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253817837,"owners_count":21969050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coordinates","cpp","cpp11","geospacial","gis","google","google-maps","maps","polyline-decoder","polyline-encoder","stl"],"created_at":"2024-10-04T01:12:45.895Z","updated_at":"2025-05-12T20:41:22.784Z","avatar_url":"https://github.com/vahancho.png","language":"C++","readme":"# A C++ header-only Polyline Encoder/Decoder\nC++ implementation of [Google Encoded Polyline Algorithm Format.](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)\u003cbr\u003e\nThe implementation guarantees to conform with the results of the [Google Interactive Polyline Encoder Utility.](https://developers.google.com/maps/documentation/utilities/polylineutility)\n\n[![Latest release](https://img.shields.io/github/v/release/vahancho/polylineencoder?include_prereleases)](https://github.com/vahancho/polylineencoder/releases)\n[![Build and test (CMake)](https://github.com/vahancho/polylineencoder/actions/workflows/cmake.yml/badge.svg)](https://github.com/vahancho/polylineencoder/actions/workflows/cmake.yml)\n[![Build status](https://ci.appveyor.com/api/projects/status/6tg1kkp5fgk3x2fd?svg=true)](https://ci.appveyor.com/project/vahancho/polylineencoder)\n[![Code coverage](https://codecov.io/gh/vahancho/polylineencoder/branch/master/graph/badge.svg)](https://codecov.io/gh/vahancho/polylineencoder)\n\n## Prerequisites\n\nNo special requirements except *C++11* compliant compiler. The class is tested with\n*gcc* and *MSVC* compilers. In order to build and run unit tests\nfor this project you are required to have Google Test library installed on the system.\nFor more details see the CI badges or [GitHub Actions](https://github.com/vahancho/polylineencoder/actions).\n\n## Installation\n\nAs `Polylineencoder` is a single header library no installation required in general. Just include\n*polylineencoder.h* in your project and instantiate `gepaf::PolylineEncoder` class template.\n\n### Integration with `CMake` projects\n\nHowever, if you use `CMake` and want to integrate the library into your project\nyou might want to install it first by invoking a `CMake` command from the build directory:\n\n```\ncmake --install . --prefix=\u003cinstall_path\u003e\n```\n\nOnce the library is installed you can use it from in your project by adjusting its\n`CMake` script. For example:\n\n```\n[..]\nfind_package(polylineencoder REQUIRED)\n\nadd_executable(example main.cpp)\ntarget_link_libraries(example gepaf::polylineencoder)\n[..]\n```\n\n## Usage Example:\n\nAll code is in `gepaf` namespace. `gepaf` stands for *Google Encoded Polyline Algorithm Format*.\n\n```cpp\n#include \u003cpolylineencoder.h\u003e\n\n// Create an encoder with precision of five decimal places (default)\n// In order to create objects with other precision use template parameter\n// like: gepaf::PolylineEncoder\u003c6\u003e\ngepaf::PolylineEncoder\u003c\u003e encoder;\n\n// Poles and equator.\nencoder.addPoint(-90.0, -180.0);\nencoder.addPoint(.0, .0);\nencoder.addPoint(90.0, 180.0);\n\nauto res = encoder.encode(); // \"~bidP~fsia@_cidP_gsia@_cidP_gsia@\"\nencoder.clear(); // Clear the list of points.\n\n// Decode a string using static function.\nauto polyline = gepaf::PolylineEncoder\u003c\u003e::decode(\"~bidP~fsia@_cidP_gsia@_cidP_gsia@\");\n\n// Iterate over all points and print coordinates of each.\nfor (const auto \u0026point : polyline) {\n    printf(\"(%f, %f)\\n\", point.latitude(), point.longitude());\n}\n```\n\nYou can also use custom data structures and containers including C-style arrays.\n\n```cpp\nclass Point\n{\npublic:\n    Point(double t_x, double t_y) : x(t_x), y(t_y) {}\n\n    double getX() const { return x; }\n    double getY() const { return y; }\n\n    double x;\n    double y;\n};\n\ngepaf::PolylineEncoder\u003c\u003e encoder;\n\n// List of DummyPoint for testing purpose\nDummyPoint dp[] = {\n    Point{-90.0, -180.0},\n    Point{.0, .0},\n    Point{90.0, 180.0}\n};\n\n// Using member functions.\nauto result1 = encoder.encode(dp, dp + sizeof dp / sizeof dp[0], \u0026DummyPoint::getX, \u0026DummyPoint::getY);\n\n// Using member variables.\nauto result2 = encoder.encode(dp, dp + sizeof dp / sizeof dp[0], \u0026DummyPoint::x, \u0026DummyPoint::y);\n```\n\n## Building and Testing\n\nThere are unit tests provided for `PolylineEncoder` class template. You can find them in the *test/* directory.\nTo run them you have to build and run the test application (linking with Google\nTest library is required). For doing that you can invoke the following commands\nfrom the terminal, assuming that compiler and environment are already configured:\n\n##### Linux (gcc)\n```\ncd test\ng++ -std=c++11 -I..\\src main.cpp -o test\n./test\n```\n\nor with `CMake`\n\n```\nmkdir build \u0026\u0026 cd build\ncmake .. -DENABLE_TESTING=True\nmake\nmake test\n```\n\n##### Windows\n```\ncd test\ncl /W4 /EHsc /I..\\src main.cpp /link /out:test.exe\ntest\n```\n\nor with CMake\n\n```\nmkdir build \u0026\u0026 cd build\ncmake .. -G \"NMake Makefiles\" -DENABLE_TESTING=True\ncmake --build . --config Release\nctest -C Release\n```\n\n## See Also\n\n* [Encoded Polyline Algorithm](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvahancho%2Fpolylineencoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvahancho%2Fpolylineencoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvahancho%2Fpolylineencoder/lists"}