@placemarkio/polyline 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ window.searchData = JSON.parse(
2
+ '{"kinds":{"64":"Function"},"rows":[{"kind":64,"name":"decode","url":"functions/decode.html","classes":"tsd-kind-function"},{"kind":64,"name":"encode","url":"functions/encode.html","classes":"tsd-kind-function"},{"kind":64,"name":"geoJSONToPolyline","url":"functions/geoJSONToPolyline.html","classes":"tsd-kind-function"},{"kind":64,"name":"polylineToGeoJSON","url":"functions/polylineToGeoJSON.html","classes":"tsd-kind-function"}],"index":{"version":"2.3.9","fields":["name","comment"],"fieldVectors":[["name/0",[0,12.04]],["comment/0",[]],["name/1",[1,12.04]],["comment/1",[]],["name/2",[2,12.04]],["comment/2",[]],["name/3",[3,12.04]],["comment/3",[]]],"invertedIndex":[["decode",{"_index":0,"name":{"0":{}},"comment":{}}],["encode",{"_index":1,"name":{"1":{}},"comment":{}}],["geojsontopolyline",{"_index":2,"name":{"2":{}},"comment":{}}],["polylinetogeojson",{"_index":3,"name":{"3":{}},"comment":{}}]],"pipeline":[]}}',
3
+ );
package/package.json CHANGED
@@ -1,30 +1,8 @@
1
1
  {
2
2
  "name": "@placemarkio/polyline",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "encode and decode polylines",
5
- "source": "lib/index.ts",
6
- "umd:main": "dist/polyline.umd.js",
7
- "unpkg": "dist/polyline.umd.js",
8
- "types": "dist/index.d.ts",
9
- "browser": "dist/polyline.umd.js",
10
- "jsdelivr": "dist/polyline.umd.js",
11
- "module": "dist/polyline.es.mjs",
12
- "main": "dist/polyline.cjs",
13
- "exports": {
14
- "require": "./dist/polyline.cjs",
15
- "default": "./dist/polyline.es.mjs"
16
- },
17
- "files": [
18
- "dist"
19
- ],
20
- "scripts": {
21
- "test": "vitest run",
22
- "test:ci": "vitest run",
23
- "lint": "eslint",
24
- "doc": "typedoc --options ./typedoc.json",
25
- "prepare": "rollup -c rollup.config.js && npm run doc",
26
- "release": "standard-version"
27
- },
5
+ "zshy": "./src/index.ts",
28
6
  "peerDependencies": {
29
7
  "@types/geojson": "*"
30
8
  },
@@ -35,24 +13,50 @@
35
13
  "author": "Tom MacWright",
36
14
  "license": "MIT",
37
15
  "dependencies": {
16
+ "@biomejs/biome": "^2.3.5",
38
17
  "@types/geojson": "*"
39
18
  },
40
19
  "devDependencies": {
41
- "@rollup/plugin-typescript": "^8.5.0",
42
- "eslint": "^8.24.0",
20
+ "@changesets/cli": "^2.29.7",
43
21
  "husky": "^8.0.1",
44
22
  "prettier": "^2.7.1",
45
- "rollup": "^2.79.1",
46
- "rollup-plugin-dts": "^4.2.2",
47
- "rollup-plugin-terser": "^7.0.2",
48
23
  "standard-version": "^9.5.0",
49
24
  "tslib": "^2.4.0",
50
25
  "typedoc": "^0.23.15",
51
- "typescript": "^4.8.4",
52
- "vitest": "^0.24.4"
26
+ "typescript": "^5.9.3",
27
+ "vitest": "^4.0.9",
28
+ "zshy": "^0.4.4"
53
29
  },
54
30
  "keywords": [
55
31
  "polyline",
56
32
  "geojson"
57
- ]
58
- }
33
+ ],
34
+ "files": [
35
+ "**/*.js",
36
+ "**/*.mjs",
37
+ "**/*.cjs",
38
+ "**/*.d.ts",
39
+ "**/*.d.mts",
40
+ "**/*.d.cts"
41
+ ],
42
+ "type": "module",
43
+ "main": "./dist/index.cjs",
44
+ "module": "./dist/index.js",
45
+ "types": "./dist/index.d.cts",
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "exports": {
50
+ ".": {
51
+ "types": "./dist/index.d.cts",
52
+ "import": "./dist/index.js",
53
+ "require": "./dist/index.cjs"
54
+ }
55
+ },
56
+ "scripts": {
57
+ "test": "vitest run",
58
+ "test:ci": "vitest run",
59
+ "lint": "biome check",
60
+ "doc": "typedoc --options ./typedoc.json"
61
+ }
62
+ }
package/CHANGELOG.md DELETED
@@ -1,17 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### [1.1.1](https://github.com/placemark/polyline/compare/v1.1.0...v1.1.1) (2022-10-06)
6
-
7
- ## 1.1.0 (2022-10-06)
8
-
9
-
10
- ### Features
11
-
12
- * Consistent order ([2a6fe45](https://github.com/placemark/polyline/commit/2a6fe45936c9c64018c07485515c2ac4200f0f2a))
13
-
14
-
15
- ### Bug Fixes
16
-
17
- * Improve docs ([03fcd10](https://github.com/placemark/polyline/commit/03fcd10f5353174d03ef6221e2b5889f24136c6b))
@@ -1 +0,0 @@
1
- {"version":3,"file":"polyline.cjs","sources":["../lib/lib/index.ts"],"sourcesContent":["import type { LineString, Position } from \"geojson\";\n\n// https://github.com/mapbox/polyline/blob/master/src/polyline.js\n\n// Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)\n//\n// Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)\n// by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)\n\nfunction py2_round(value: number) {\n // Google's polyline algorithm uses the same rounding strategy as Python 2,\n // which is different from JS for negative values\n return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);\n}\n\nfunction encodeNumber(current: number, previous: number, factor: number) {\n current = py2_round(current * factor);\n previous = py2_round(previous * factor);\n let coordinate = current - previous;\n coordinate <<= 1;\n if (current - previous < 0) {\n coordinate = ~coordinate;\n }\n let output = \"\";\n while (coordinate >= 0x20) {\n output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);\n coordinate >>= 5;\n }\n output += String.fromCharCode(coordinate + 63);\n return output;\n}\n\nfunction resultChange(result: number) {\n return result & 1 ? ~(result >> 1) : result >> 1;\n}\n\n/**\n * Decodes any string into a [longitude, latitude] coordinates array.\n *\n * Any string is a valid polyline, but if you provide this\n * with an arbitrary string, it'll produce coordinates well\n * outside of the normal range.\n */\nexport function decode(str: string, precision: number = 5): Position[] {\n const factor = Math.pow(10, precision);\n let index = 0;\n let lat = 0;\n let lng = 0;\n const coordinates = [];\n let shift = 0;\n let result = 0;\n let byte = null;\n\n let latitude_change: number;\n let longitude_change: number;\n\n // Coordinates have variable length when encoded, so just keep\n // track of whether we've hit the end of the string. In each\n // loop iteration, a single coordinate is decoded.\n while (index < str.length) {\n // Reset shift, result, and byte\n byte = null;\n shift = 0;\n result = 0;\n\n do {\n byte = str.charCodeAt(index++) - 63;\n result |= (byte & 0x1f) << shift;\n shift += 5;\n } while (byte >= 0x20);\n\n latitude_change = resultChange(result);\n\n shift = result = 0;\n\n do {\n byte = str.charCodeAt(index++) - 63;\n result |= (byte & 0x1f) << shift;\n shift += 5;\n } while (byte >= 0x20);\n\n longitude_change = resultChange(result);\n\n lat += latitude_change;\n lng += longitude_change;\n\n coordinates.push([lng / factor, lat / factor]);\n }\n\n return coordinates;\n}\n\n/**\n * Encodes the given [latitude, longitude] coordinates array.\n *\n * @param coordinates Coordinates, in longitude, latitude order\n * @returns encoded polyline\n */\nexport function encode(coordinates: number[][], precision: number = 5) {\n if (!coordinates.length) {\n return \"\";\n }\n const factor = Math.pow(10, precision);\n\n let output =\n encodeNumber(coordinates[0][1], 0, factor) +\n encodeNumber(coordinates[0][0], 0, factor);\n\n for (let i = 1; i < coordinates.length; i++) {\n const a = coordinates[i];\n const b = coordinates[i - 1];\n output += encodeNumber(a[1], b[1], factor);\n output += encodeNumber(a[0], b[0], factor);\n }\n\n return output;\n}\n\n/**\n * Encodes a GeoJSON LineString feature/geometry.\n *\n * @param geojson A LineString\n */\nexport function geoJSONToPolyline(geojson: LineString, precision: number = 5) {\n return encode(geojson.coordinates, precision);\n}\n\n/**\n * Decodes to a GeoJSON LineString geometry.\n *\n * @param str An encoded polyline as a string.\n */\nexport function polylineToGeoJSON(str: string, precision: number = 5): LineString {\n const coords = decode(str, precision);\n return {\n type: \"LineString\",\n coordinates: coords,\n };\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BAAiB,CAAC,GAAW,EAAE,YAAoB,CAAC,EAAA;IAClE,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACtC,OAAO;AACL,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,WAAW,EAAE,MAAM;KACpB,CAAC;AACJ;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"polyline.es.mjs","sources":["../lib/lib/index.ts"],"sourcesContent":["import type { LineString, Position } from \"geojson\";\n\n// https://github.com/mapbox/polyline/blob/master/src/polyline.js\n\n// Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)\n//\n// Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)\n// by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)\n\nfunction py2_round(value: number) {\n // Google's polyline algorithm uses the same rounding strategy as Python 2,\n // which is different from JS for negative values\n return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);\n}\n\nfunction encodeNumber(current: number, previous: number, factor: number) {\n current = py2_round(current * factor);\n previous = py2_round(previous * factor);\n let coordinate = current - previous;\n coordinate <<= 1;\n if (current - previous < 0) {\n coordinate = ~coordinate;\n }\n let output = \"\";\n while (coordinate >= 0x20) {\n output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);\n coordinate >>= 5;\n }\n output += String.fromCharCode(coordinate + 63);\n return output;\n}\n\nfunction resultChange(result: number) {\n return result & 1 ? ~(result >> 1) : result >> 1;\n}\n\n/**\n * Decodes any string into a [longitude, latitude] coordinates array.\n *\n * Any string is a valid polyline, but if you provide this\n * with an arbitrary string, it'll produce coordinates well\n * outside of the normal range.\n */\nexport function decode(str: string, precision: number = 5): Position[] {\n const factor = Math.pow(10, precision);\n let index = 0;\n let lat = 0;\n let lng = 0;\n const coordinates = [];\n let shift = 0;\n let result = 0;\n let byte = null;\n\n let latitude_change: number;\n let longitude_change: number;\n\n // Coordinates have variable length when encoded, so just keep\n // track of whether we've hit the end of the string. In each\n // loop iteration, a single coordinate is decoded.\n while (index < str.length) {\n // Reset shift, result, and byte\n byte = null;\n shift = 0;\n result = 0;\n\n do {\n byte = str.charCodeAt(index++) - 63;\n result |= (byte & 0x1f) << shift;\n shift += 5;\n } while (byte >= 0x20);\n\n latitude_change = resultChange(result);\n\n shift = result = 0;\n\n do {\n byte = str.charCodeAt(index++) - 63;\n result |= (byte & 0x1f) << shift;\n shift += 5;\n } while (byte >= 0x20);\n\n longitude_change = resultChange(result);\n\n lat += latitude_change;\n lng += longitude_change;\n\n coordinates.push([lng / factor, lat / factor]);\n }\n\n return coordinates;\n}\n\n/**\n * Encodes the given [latitude, longitude] coordinates array.\n *\n * @param coordinates Coordinates, in longitude, latitude order\n * @returns encoded polyline\n */\nexport function encode(coordinates: number[][], precision: number = 5) {\n if (!coordinates.length) {\n return \"\";\n }\n const factor = Math.pow(10, precision);\n\n let output =\n encodeNumber(coordinates[0][1], 0, factor) +\n encodeNumber(coordinates[0][0], 0, factor);\n\n for (let i = 1; i < coordinates.length; i++) {\n const a = coordinates[i];\n const b = coordinates[i - 1];\n output += encodeNumber(a[1], b[1], factor);\n output += encodeNumber(a[0], b[0], factor);\n }\n\n return output;\n}\n\n/**\n * Encodes a GeoJSON LineString feature/geometry.\n *\n * @param geojson A LineString\n */\nexport function geoJSONToPolyline(geojson: LineString, precision: number = 5) {\n return encode(geojson.coordinates, precision);\n}\n\n/**\n * Decodes to a GeoJSON LineString geometry.\n *\n * @param str An encoded polyline as a string.\n */\nexport function polylineToGeoJSON(str: string, precision: number = 5): LineString {\n const coords = decode(str, precision);\n return {\n type: \"LineString\",\n coordinates: coords,\n };\n}\n"],"names":[],"mappings":"AAEA;AAEA;AACA;AACA;AACA;AAEA,SAAS,SAAS,CAAC,KAAa,EAAA;;;AAG9B,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,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;KACpB,CAAC;AACJ;;;;"}
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).toGeoJSON={})}(this,(function(e){"use strict";function t(e){return Math.floor(Math.abs(e)+.5)*(e>=0?1:-1)}function o(e,o,n){let r=(e=t(e*n))-(o=t(o*n));r<<=1,e-o<0&&(r=~r);let i="";for(;r>=32;)i+=String.fromCharCode(63+(32|31&r)),r>>=5;return i+=String.fromCharCode(r+63),i}function n(e){return 1&e?~(e>>1):e>>1}function r(e,t=5){const o=Math.pow(10,t);let r=0,i=0,f=0;const l=[];let u,c,d=0,s=0,h=null;for(;r<e.length;){h=null,d=0,s=0;do{h=e.charCodeAt(r++)-63,s|=(31&h)<<d,d+=5}while(h>=32);u=n(s),d=s=0;do{h=e.charCodeAt(r++)-63,s|=(31&h)<<d,d+=5}while(h>=32);c=n(s),i+=u,f+=c,l.push([f/o,i/o])}return l}function i(e,t=5){if(!e.length)return"";const n=Math.pow(10,t);let r=o(e[0][1],0,n)+o(e[0][0],0,n);for(let t=1;t<e.length;t++){const i=e[t],f=e[t-1];r+=o(i[1],f[1],n),r+=o(i[0],f[0],n)}return r}e.decode=r,e.encode=i,e.geoJSONToPolyline=function(e,t=5){return i(e.coordinates,t)},e.polylineToGeoJSON=function(e,t=5){return{type:"LineString",coordinates:r(e,t)}},Object.defineProperty(e,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=polyline.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"polyline.umd.js","sources":["../lib/lib/index.ts"],"sourcesContent":["import type { LineString, Position } from \"geojson\";\n\n// https://github.com/mapbox/polyline/blob/master/src/polyline.js\n\n// Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)\n//\n// Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)\n// by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)\n\nfunction py2_round(value: number) {\n // Google's polyline algorithm uses the same rounding strategy as Python 2,\n // which is different from JS for negative values\n return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);\n}\n\nfunction encodeNumber(current: number, previous: number, factor: number) {\n current = py2_round(current * factor);\n previous = py2_round(previous * factor);\n let coordinate = current - previous;\n coordinate <<= 1;\n if (current - previous < 0) {\n coordinate = ~coordinate;\n }\n let output = \"\";\n while (coordinate >= 0x20) {\n output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);\n coordinate >>= 5;\n }\n output += String.fromCharCode(coordinate + 63);\n return output;\n}\n\nfunction resultChange(result: number) {\n return result & 1 ? ~(result >> 1) : result >> 1;\n}\n\n/**\n * Decodes any string into a [longitude, latitude] coordinates array.\n *\n * Any string is a valid polyline, but if you provide this\n * with an arbitrary string, it'll produce coordinates well\n * outside of the normal range.\n */\nexport function decode(str: string, precision: number = 5): Position[] {\n const factor = Math.pow(10, precision);\n let index = 0;\n let lat = 0;\n let lng = 0;\n const coordinates = [];\n let shift = 0;\n let result = 0;\n let byte = null;\n\n let latitude_change: number;\n let longitude_change: number;\n\n // Coordinates have variable length when encoded, so just keep\n // track of whether we've hit the end of the string. In each\n // loop iteration, a single coordinate is decoded.\n while (index < str.length) {\n // Reset shift, result, and byte\n byte = null;\n shift = 0;\n result = 0;\n\n do {\n byte = str.charCodeAt(index++) - 63;\n result |= (byte & 0x1f) << shift;\n shift += 5;\n } while (byte >= 0x20);\n\n latitude_change = resultChange(result);\n\n shift = result = 0;\n\n do {\n byte = str.charCodeAt(index++) - 63;\n result |= (byte & 0x1f) << shift;\n shift += 5;\n } while (byte >= 0x20);\n\n longitude_change = resultChange(result);\n\n lat += latitude_change;\n lng += longitude_change;\n\n coordinates.push([lng / factor, lat / factor]);\n }\n\n return coordinates;\n}\n\n/**\n * Encodes the given [latitude, longitude] coordinates array.\n *\n * @param coordinates Coordinates, in longitude, latitude order\n * @returns encoded polyline\n */\nexport function encode(coordinates: number[][], precision: number = 5) {\n if (!coordinates.length) {\n return \"\";\n }\n const factor = Math.pow(10, precision);\n\n let output =\n encodeNumber(coordinates[0][1], 0, factor) +\n encodeNumber(coordinates[0][0], 0, factor);\n\n for (let i = 1; i < coordinates.length; i++) {\n const a = coordinates[i];\n const b = coordinates[i - 1];\n output += encodeNumber(a[1], b[1], factor);\n output += encodeNumber(a[0], b[0], factor);\n }\n\n return output;\n}\n\n/**\n * Encodes a GeoJSON LineString feature/geometry.\n *\n * @param geojson A LineString\n */\nexport function geoJSONToPolyline(geojson: LineString, precision: number = 5) {\n return encode(geojson.coordinates, precision);\n}\n\n/**\n * Decodes to a GeoJSON LineString geometry.\n *\n * @param str An encoded polyline as a string.\n */\nexport function polylineToGeoJSON(str: string, precision: number = 5): LineString {\n const coords = decode(str, precision);\n return {\n type: \"LineString\",\n coordinates: coords,\n };\n}\n"],"names":["py2_round","value","Math","floor","abs","encodeNumber","current","previous","factor","coordinate","output","String","fromCharCode","resultChange","result","decode","str","precision","pow","index","lat","lng","coordinates","latitude_change","longitude_change","shift","byte","length","charCodeAt","push","encode","i","a","b","geojson","type"],"mappings":"iPASA,SAASA,EAAUC,GAGjB,OAAOC,KAAKC,MAAMD,KAAKE,IAAIH,GAAS,KAAQA,GAAS,EAAI,GAAK,EAChE,CAEA,SAASI,EAAaC,EAAiBC,EAAkBC,GAGvD,IAAIC,GAFJH,EAAUN,EAAUM,EAAUE,KAC9BD,EAAWP,EAAUO,EAAWC,IAEhCC,IAAe,EACXH,EAAUC,EAAW,IACvBE,GAAcA,GAEhB,IAAIC,EAAS,GACb,KAAOD,GAAc,IACnBC,GAAUC,OAAOC,aAA4C,IAA9B,GAAqB,GAAbH,IACvCA,IAAe,EAGjB,OADAC,GAAUC,OAAOC,aAAaH,EAAa,IACpCC,CACT,CAEA,SAASG,EAAaC,GACpB,OAAgB,EAATA,IAAeA,GAAU,GAAKA,GAAU,CACjD,UASgBC,EAAO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