{"id":21579735,"url":"https://github.com/hieuunguyeen/polyline-extended","last_synced_at":"2025-07-25T16:37:18.535Z","repository":{"id":57327116,"uuid":"68699262","full_name":"hieuunguyeen/polyline-extended","owner":"hieuunguyeen","description":"Implementation for Google polyline algorithm with **extra** salt and sugar. :sparkles::sparkles:","archived":false,"fork":false,"pushed_at":"2019-10-05T15:45:29.000Z","size":348,"stargazers_count":8,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T15:21:56.886Z","etag":null,"topics":["haversine","polyline","polyline-algorithm","utilities"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/hieuunguyeen.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}},"created_at":"2016-09-20T10:03:44.000Z","updated_at":"2020-04-10T10:42:51.000Z","dependencies_parsed_at":"2022-09-13T19:00:51.850Z","dependency_job_id":null,"html_url":"https://github.com/hieuunguyeen/polyline-extended","commit_stats":null,"previous_names":["blackevil245/polyline-extended"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fpolyline-extended","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fpolyline-extended/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fpolyline-extended/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fpolyline-extended/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hieuunguyeen","download_url":"https://codeload.github.com/hieuunguyeen/polyline-extended/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262207,"owners_count":21074263,"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":["haversine","polyline","polyline-algorithm","utilities"],"created_at":"2024-11-24T13:14:14.933Z","updated_at":"2025-04-10T17:43:02.007Z","avatar_url":"https://github.com/hieuunguyeen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polyline Extended\n\nImplementation for Google polyline algorithm with **extra** salt and sugar.\n\n![Demo image](/demo.png)\n\nDocumentation for polyline algorithm\n\n\u003e https://developers.google.com/maps/documentation/utilities/polylinealgorithm\n\n## Example\n\n```javascript\nconst lib = require(\"polyline-extended\");\n\nlib.decode(\"ecfnJ_cgwCDnG??{BN?Aq@n@??eEhH@?CYEkCA?gNb@u@??K[CcDXFpE\");\nlib.encode([[60.123, 24.12312], [60.13123, 25.21312], ...[lat, lon]]);\n\nlib.length(\"ecfnJ_cgwCDnG??{BN?Aq@n@??eEhH@?CYEkCA?gNb@u@??K[CcDXFpE\", \"meter\");\n\nlib.mergeTwoPolylines(\"ecfnJ_cgwCDnG??\", \"{BN?Aq@n@??eEhH@?CYEkCA\");\n\nlib.mergePolylines([\n  \"ecfnJ_cgwCDnG??\",\n  \"{BN?Aq@n@??eEhH@?CYEkCA\",\n  \"?gNb@u@??K[CcDXFpE\"\n]);\n```\n\n## API\n\n### Core\n\n```\n✓ Encoding\n✓ Decoding\n✓ Length\n✓ Merging\n  ✓ Merge two polylines\n  ✓ Merge multiple polylines\n```\n\n### Supporting functions\n\n```\n✓ Haversine\n✓ Haversine distance\n```\n\n### Documentation\n\n##### Encoding\n\n```javascript\n/**\n * Encode pairs of lat and lon into a polyline encoded string\n * @param points {Array.Array[lat, lon]}\n * @return encoded polyline {String}\n */\nfunction encode(points)\n```\n\n##### Decoding\n\n```javascript\n/**\n * Decode a polyline string into an array of coordinates.\n * @see This is adapted from the implementation in Project-OSRM\n * https://github.com/DennisOSRM/Project-OSRM-Web/blob/master/WebContent/routing/OSRM.RoutingGeometry.js\n *\n * @param {string} polyline - polyline string\n * @param {integer} precision - coordinates precision (number of decimal)\n *\n * @return {Array[Array[Number]]} coordinates\n */\nfunction decode(polyline, precision)\n```\n\n##### Length\n\n```javascript\n/**\n * Calculate the distance of the polyline. If radius is not provided, distance is flat, else distance is haversine distance\n * NOTE: Support flat surface and sphere\n *\n * @param {string} polyline - The polyline to calculate from\n * @param {enum={meter, kilometer}]} [unit=kilometer] - The unit of the response.\n *\n * @return {Float} length - unit based on options.radius unit\n */\nfunction length(polyline, unit)\n```\n\n##### Merge two polylines\n\n```javascript\n/**\n * Merge two polylines into one single polyline\n * @param {string} poly1 - origin polyline\n * @param {string} poly2 - connected polyline\n *\n * @return {string} finalPolyline - merged polyline\n */\nfunction mergeTwoPolylines(poly1, poly2)\n```\n\n##### Merge multiple polylines\n\n```javascript\n/**\n * Merge multiple polylines into a connected one\n * @param  {Array[string]} polylines - Array of multi polylines\n *\n * @return {string} one single merged polyline\n */\nfunction mergePolylines(polylines)\n```\n\n##### Haversine\n\n```javascript\n/**\n * Calculate haversine of a number\n *\n * @param {float} number - input number\n * @return {float} haversine\n */\nfunction haversine(number)\n```\n\n##### Haversine Distance\n\n```javascript\n/**\n * Calculate the haversine distance between 2 points\n * on the Earth, using radius of 6371 km\n *\n * @param {Array[{ lat,lon }]} point1 - lat, lon are mandatory\n * @param {Array[{ lat,lon }]} point2 - lat, lon are mandatory\n * @return {float} distance\n */\nfunction haversineDistance(_point1, _point2)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhieuunguyeen%2Fpolyline-extended","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhieuunguyeen%2Fpolyline-extended","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhieuunguyeen%2Fpolyline-extended/lists"}