@placemarkio/polyline 1.1.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.
- package/README.md +15 -0
- package/dist/index.d.ts +28 -0
- package/dist/polyline.cjs +124 -0
- package/dist/polyline.cjs.map +1 -0
- package/dist/polyline.es.mjs +117 -0
- package/dist/polyline.es.mjs.map +1 -0
- package/dist/polyline.umd.js +2 -0
- package/dist/polyline.umd.js.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# polyline
|
|
2
|
+
|
|
3
|
+
_polyline development is supported by 🌎 [placemark.io](https://placemark.io/)_
|
|
4
|
+
|
|
5
|
+
A maintained fork of the [Mapbox module](https://github.com/mapbox/polyline).
|
|
6
|
+
|
|
7
|
+
Differences:
|
|
8
|
+
|
|
9
|
+
- Written in TypeScript, with types provided.
|
|
10
|
+
- No dependencies.
|
|
11
|
+
- Always follows longitude, latitude order in all API endpoints.
|
|
12
|
+
polylines are, internally, latitude, longitude, but that is not
|
|
13
|
+
exposed to the user.
|
|
14
|
+
|
|
15
|
+
## [📕 API Documentation](https://placemark.github.io/polyline/)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LineString, Position } from "geojson";
|
|
2
|
+
/**
|
|
3
|
+
* Decodes any string into a [longitude, latitude] coordinates array.
|
|
4
|
+
*
|
|
5
|
+
* Any string is a valid polyline, but if you provide this
|
|
6
|
+
* with an arbitrary string, it'll produce coordinates well
|
|
7
|
+
* outside of the normal range.
|
|
8
|
+
*/
|
|
9
|
+
export declare function decode(str: string): Position[];
|
|
10
|
+
/**
|
|
11
|
+
* Encodes the given [latitude, longitude] coordinates array.
|
|
12
|
+
*
|
|
13
|
+
* @param coordinates Coordinates, in longitude, latitude order
|
|
14
|
+
* @returns encoded polyline
|
|
15
|
+
*/
|
|
16
|
+
export declare function encode(coordinates: number[][]): string;
|
|
17
|
+
/**
|
|
18
|
+
* Encodes a GeoJSON LineString feature/geometry.
|
|
19
|
+
*
|
|
20
|
+
* @param geojson A LineString
|
|
21
|
+
*/
|
|
22
|
+
export declare function geoJSONToPolyline(geojson: LineString): string;
|
|
23
|
+
/**
|
|
24
|
+
* Decodes to a GeoJSON LineString geometry.
|
|
25
|
+
*
|
|
26
|
+
* @param str An encoded polyline as a string.
|
|
27
|
+
*/
|
|
28
|
+
export declare function polylineToGeoJSON(str: string): LineString;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const factor = 100000; // Math.pow(10, 5);
|
|
6
|
+
// https://github.com/mapbox/polyline/blob/master/src/polyline.js
|
|
7
|
+
// Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
|
|
8
|
+
//
|
|
9
|
+
// Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)
|
|
10
|
+
// by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)
|
|
11
|
+
function py2_round(value) {
|
|
12
|
+
// Google's polyline algorithm uses the same rounding strategy as Python 2,
|
|
13
|
+
// which is different from JS for negative values
|
|
14
|
+
return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);
|
|
15
|
+
}
|
|
16
|
+
function encodeNumber(current, previous, factor) {
|
|
17
|
+
current = py2_round(current * factor);
|
|
18
|
+
previous = py2_round(previous * factor);
|
|
19
|
+
let coordinate = current - previous;
|
|
20
|
+
coordinate <<= 1;
|
|
21
|
+
if (current - previous < 0) {
|
|
22
|
+
coordinate = ~coordinate;
|
|
23
|
+
}
|
|
24
|
+
let output = "";
|
|
25
|
+
while (coordinate >= 0x20) {
|
|
26
|
+
output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);
|
|
27
|
+
coordinate >>= 5;
|
|
28
|
+
}
|
|
29
|
+
output += String.fromCharCode(coordinate + 63);
|
|
30
|
+
return output;
|
|
31
|
+
}
|
|
32
|
+
function resultChange(result) {
|
|
33
|
+
return result & 1 ? ~(result >> 1) : result >> 1;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Decodes any string into a [longitude, latitude] coordinates array.
|
|
37
|
+
*
|
|
38
|
+
* Any string is a valid polyline, but if you provide this
|
|
39
|
+
* with an arbitrary string, it'll produce coordinates well
|
|
40
|
+
* outside of the normal range.
|
|
41
|
+
*/
|
|
42
|
+
function decode(str) {
|
|
43
|
+
let index = 0;
|
|
44
|
+
let lat = 0;
|
|
45
|
+
let lng = 0;
|
|
46
|
+
const coordinates = [];
|
|
47
|
+
let shift = 0;
|
|
48
|
+
let result = 0;
|
|
49
|
+
let byte = null;
|
|
50
|
+
let latitude_change;
|
|
51
|
+
let longitude_change;
|
|
52
|
+
// Coordinates have variable length when encoded, so just keep
|
|
53
|
+
// track of whether we've hit the end of the string. In each
|
|
54
|
+
// loop iteration, a single coordinate is decoded.
|
|
55
|
+
while (index < str.length) {
|
|
56
|
+
// Reset shift, result, and byte
|
|
57
|
+
byte = null;
|
|
58
|
+
shift = 0;
|
|
59
|
+
result = 0;
|
|
60
|
+
do {
|
|
61
|
+
byte = str.charCodeAt(index++) - 63;
|
|
62
|
+
result |= (byte & 0x1f) << shift;
|
|
63
|
+
shift += 5;
|
|
64
|
+
} while (byte >= 0x20);
|
|
65
|
+
latitude_change = resultChange(result);
|
|
66
|
+
shift = result = 0;
|
|
67
|
+
do {
|
|
68
|
+
byte = str.charCodeAt(index++) - 63;
|
|
69
|
+
result |= (byte & 0x1f) << shift;
|
|
70
|
+
shift += 5;
|
|
71
|
+
} while (byte >= 0x20);
|
|
72
|
+
longitude_change = resultChange(result);
|
|
73
|
+
lat += latitude_change;
|
|
74
|
+
lng += longitude_change;
|
|
75
|
+
coordinates.push([lng / factor, lat / factor]);
|
|
76
|
+
}
|
|
77
|
+
return coordinates;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Encodes the given [latitude, longitude] coordinates array.
|
|
81
|
+
*
|
|
82
|
+
* @param coordinates Coordinates, in longitude, latitude order
|
|
83
|
+
* @returns encoded polyline
|
|
84
|
+
*/
|
|
85
|
+
function encode(coordinates) {
|
|
86
|
+
if (!coordinates.length) {
|
|
87
|
+
return "";
|
|
88
|
+
}
|
|
89
|
+
let output = encodeNumber(coordinates[0][1], 0, factor) +
|
|
90
|
+
encodeNumber(coordinates[0][0], 0, factor);
|
|
91
|
+
for (let i = 1; i < coordinates.length; i++) {
|
|
92
|
+
const a = coordinates[i];
|
|
93
|
+
const b = coordinates[i - 1];
|
|
94
|
+
output += encodeNumber(a[1], b[1], factor);
|
|
95
|
+
output += encodeNumber(a[0], b[0], factor);
|
|
96
|
+
}
|
|
97
|
+
return output;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Encodes a GeoJSON LineString feature/geometry.
|
|
101
|
+
*
|
|
102
|
+
* @param geojson A LineString
|
|
103
|
+
*/
|
|
104
|
+
function geoJSONToPolyline(geojson) {
|
|
105
|
+
return encode(geojson.coordinates);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Decodes to a GeoJSON LineString geometry.
|
|
109
|
+
*
|
|
110
|
+
* @param str An encoded polyline as a string.
|
|
111
|
+
*/
|
|
112
|
+
function polylineToGeoJSON(str) {
|
|
113
|
+
const coords = decode(str);
|
|
114
|
+
return {
|
|
115
|
+
type: "LineString",
|
|
116
|
+
coordinates: coords,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exports.decode = decode;
|
|
121
|
+
exports.encode = encode;
|
|
122
|
+
exports.geoJSONToPolyline = geoJSONToPolyline;
|
|
123
|
+
exports.polylineToGeoJSON = polylineToGeoJSON;
|
|
124
|
+
//# sourceMappingURL=polyline.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyline.cjs","sources":["../lib/lib/index.ts"],"sourcesContent":["import type { LineString, Position } from \"geojson\";\n\nconst factor = 100000; // Math.pow(10, 5);\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): Position[] {\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[][]) {\n if (!coordinates.length) {\n return \"\";\n }\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) {\n return encode(geojson.coordinates);\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): LineString {\n const coords = decode(str);\n return {\n type: \"LineString\",\n coordinates: coords,\n };\n}\n"],"names":[],"mappings":";;;;AAEA,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB;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,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,OAAe,EAAE,QAAgB,EAAE,MAAc,EAAA;AACrE,IAAA,OAAO,GAAG,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;AACtC,IAAA,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC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EAAE,EAAE;AAC3C,QAAA,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7B,QAAA,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3C,QAAA,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC5C,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,OAAmB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC;AAED;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,GAAW,EAAA;AAC3C,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO;AACL,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,WAAW,EAAE,MAAM;KACpB,CAAC;AACJ;;;;;;;"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const factor = 100000; // Math.pow(10, 5);
|
|
2
|
+
// https://github.com/mapbox/polyline/blob/master/src/polyline.js
|
|
3
|
+
// Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
|
|
4
|
+
//
|
|
5
|
+
// Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)
|
|
6
|
+
// by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)
|
|
7
|
+
function py2_round(value) {
|
|
8
|
+
// Google's polyline algorithm uses the same rounding strategy as Python 2,
|
|
9
|
+
// which is different from JS for negative values
|
|
10
|
+
return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);
|
|
11
|
+
}
|
|
12
|
+
function encodeNumber(current, previous, factor) {
|
|
13
|
+
current = py2_round(current * factor);
|
|
14
|
+
previous = py2_round(previous * factor);
|
|
15
|
+
let coordinate = current - previous;
|
|
16
|
+
coordinate <<= 1;
|
|
17
|
+
if (current - previous < 0) {
|
|
18
|
+
coordinate = ~coordinate;
|
|
19
|
+
}
|
|
20
|
+
let output = "";
|
|
21
|
+
while (coordinate >= 0x20) {
|
|
22
|
+
output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);
|
|
23
|
+
coordinate >>= 5;
|
|
24
|
+
}
|
|
25
|
+
output += String.fromCharCode(coordinate + 63);
|
|
26
|
+
return output;
|
|
27
|
+
}
|
|
28
|
+
function resultChange(result) {
|
|
29
|
+
return result & 1 ? ~(result >> 1) : result >> 1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Decodes any string into a [longitude, latitude] coordinates array.
|
|
33
|
+
*
|
|
34
|
+
* Any string is a valid polyline, but if you provide this
|
|
35
|
+
* with an arbitrary string, it'll produce coordinates well
|
|
36
|
+
* outside of the normal range.
|
|
37
|
+
*/
|
|
38
|
+
function decode(str) {
|
|
39
|
+
let index = 0;
|
|
40
|
+
let lat = 0;
|
|
41
|
+
let lng = 0;
|
|
42
|
+
const coordinates = [];
|
|
43
|
+
let shift = 0;
|
|
44
|
+
let result = 0;
|
|
45
|
+
let byte = null;
|
|
46
|
+
let latitude_change;
|
|
47
|
+
let longitude_change;
|
|
48
|
+
// Coordinates have variable length when encoded, so just keep
|
|
49
|
+
// track of whether we've hit the end of the string. In each
|
|
50
|
+
// loop iteration, a single coordinate is decoded.
|
|
51
|
+
while (index < str.length) {
|
|
52
|
+
// Reset shift, result, and byte
|
|
53
|
+
byte = null;
|
|
54
|
+
shift = 0;
|
|
55
|
+
result = 0;
|
|
56
|
+
do {
|
|
57
|
+
byte = str.charCodeAt(index++) - 63;
|
|
58
|
+
result |= (byte & 0x1f) << shift;
|
|
59
|
+
shift += 5;
|
|
60
|
+
} while (byte >= 0x20);
|
|
61
|
+
latitude_change = resultChange(result);
|
|
62
|
+
shift = result = 0;
|
|
63
|
+
do {
|
|
64
|
+
byte = str.charCodeAt(index++) - 63;
|
|
65
|
+
result |= (byte & 0x1f) << shift;
|
|
66
|
+
shift += 5;
|
|
67
|
+
} while (byte >= 0x20);
|
|
68
|
+
longitude_change = resultChange(result);
|
|
69
|
+
lat += latitude_change;
|
|
70
|
+
lng += longitude_change;
|
|
71
|
+
coordinates.push([lng / factor, lat / factor]);
|
|
72
|
+
}
|
|
73
|
+
return coordinates;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Encodes the given [latitude, longitude] coordinates array.
|
|
77
|
+
*
|
|
78
|
+
* @param coordinates Coordinates, in longitude, latitude order
|
|
79
|
+
* @returns encoded polyline
|
|
80
|
+
*/
|
|
81
|
+
function encode(coordinates) {
|
|
82
|
+
if (!coordinates.length) {
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
let output = encodeNumber(coordinates[0][1], 0, factor) +
|
|
86
|
+
encodeNumber(coordinates[0][0], 0, factor);
|
|
87
|
+
for (let i = 1; i < coordinates.length; i++) {
|
|
88
|
+
const a = coordinates[i];
|
|
89
|
+
const b = coordinates[i - 1];
|
|
90
|
+
output += encodeNumber(a[1], b[1], factor);
|
|
91
|
+
output += encodeNumber(a[0], b[0], factor);
|
|
92
|
+
}
|
|
93
|
+
return output;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Encodes a GeoJSON LineString feature/geometry.
|
|
97
|
+
*
|
|
98
|
+
* @param geojson A LineString
|
|
99
|
+
*/
|
|
100
|
+
function geoJSONToPolyline(geojson) {
|
|
101
|
+
return encode(geojson.coordinates);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Decodes to a GeoJSON LineString geometry.
|
|
105
|
+
*
|
|
106
|
+
* @param str An encoded polyline as a string.
|
|
107
|
+
*/
|
|
108
|
+
function polylineToGeoJSON(str) {
|
|
109
|
+
const coords = decode(str);
|
|
110
|
+
return {
|
|
111
|
+
type: "LineString",
|
|
112
|
+
coordinates: coords,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { decode, encode, geoJSONToPolyline, polylineToGeoJSON };
|
|
117
|
+
//# sourceMappingURL=polyline.es.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyline.es.mjs","sources":["../lib/lib/index.ts"],"sourcesContent":["import type { LineString, Position } from \"geojson\";\n\nconst factor = 100000; // Math.pow(10, 5);\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): Position[] {\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[][]) {\n if (!coordinates.length) {\n return \"\";\n }\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) {\n return encode(geojson.coordinates);\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): LineString {\n const coords = decode(str);\n return {\n type: \"LineString\",\n coordinates: coords,\n };\n}\n"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB;AAEA;AACA;AACA;AACA;AAEA,SAAS,SAAS,CAAC,KAAa,EAAA;;;AAG9B,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,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IAAA,IAAI,MAAM,GACR,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;AAC1C,QAAA,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAE7C,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC3C,QAAA,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7B,QAAA,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3C,QAAA,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC5C,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,OAAmB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC;AAED;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,GAAW,EAAA;AAC3C,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO;AACL,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,WAAW,EAAE,MAAM;KACpB,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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";const t=1e5;function n(e){return Math.floor(Math.abs(e)+.5)*(e>=0?1:-1)}function o(e,t,o){let r=(e=n(e*o))-(t=n(t*o));r<<=1,e-t<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 r(e){return 1&e?~(e>>1):e>>1}function i(e){let n=0,o=0,i=0;const f=[];let l,u,c=0,d=0,s=null;for(;n<e.length;){s=null,c=0,d=0;do{s=e.charCodeAt(n++)-63,d|=(31&s)<<c,c+=5}while(s>=32);l=r(d),c=d=0;do{s=e.charCodeAt(n++)-63,d|=(31&s)<<c,c+=5}while(s>=32);u=r(d),o+=l,i+=u,f.push([i/t,o/t])}return f}function f(e){if(!e.length)return"";let n=o(e[0][1],0,t)+o(e[0][0],0,t);for(let r=1;r<e.length;r++){const i=e[r],f=e[r-1];n+=o(i[1],f[1],t),n+=o(i[0],f[0],t)}return n}e.decode=i,e.encode=f,e.geoJSONToPolyline=function(e){return f(e.coordinates)},e.polylineToGeoJSON=function(e){return{type:"LineString",coordinates:i(e)}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=polyline.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyline.umd.js","sources":["../lib/lib/index.ts"],"sourcesContent":["import type { LineString, Position } from \"geojson\";\n\nconst factor = 100000; // Math.pow(10, 5);\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): Position[] {\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[][]) {\n if (!coordinates.length) {\n return \"\";\n }\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) {\n return encode(geojson.coordinates);\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): LineString {\n const coords = decode(str);\n return {\n type: \"LineString\",\n coordinates: coords,\n };\n}\n"],"names":["factor","py2_round","value","Math","floor","abs","encodeNumber","current","previous","coordinate","output","String","fromCharCode","resultChange","result","decode","str","index","lat","lng","coordinates","latitude_change","longitude_change","shift","byte","length","charCodeAt","push","encode","i","a","b","geojson","type"],"mappings":"iPAEA,MAAMA,EAAS,IASf,SAASC,EAAUC,GAGjB,OAAOC,KAAKC,MAAMD,KAAKE,IAAIH,GAAS,KAAQA,GAAS,EAAI,GAAK,EAChE,CAEA,SAASI,EAAaC,EAAiBC,EAAkBR,GAGvD,IAAIS,GAFJF,EAAUN,EAAUM,EAAUP,KAC9BQ,EAAWP,EAAUO,EAAWR,IAEhCS,IAAe,EACXF,EAAUC,EAAW,IACvBC,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,CASM,SAAUC,EAAOC,GACrB,IAAIC,EAAQ,EACRC,EAAM,EACNC,EAAM,EACV,MAAMC,EAAc,GACpB,IAIIC,EACAC,EALAC,EAAQ,EACRT,EAAS,EACTU,EAAO,KAQX,KAAOP,EAAQD,EAAIS,QAAQ,CAEzBD,EAAO,KACPD,EAAQ,EACRT,EAAS,EAET,GACEU,EAAOR,EAAIU,WAAWT,KAAW,GACjCH,IAAkB,GAAPU,IAAgBD,EAC3BA,GAAS,QACFC,GAAQ,IAEjBH,EAAkBR,EAAaC,GAE/BS,EAAQT,EAAS,EAEjB,GACEU,EAAOR,EAAIU,WAAWT,KAAW,GACjCH,IAAkB,GAAPU,IAAgBD,EAC3BA,GAAS,QACFC,GAAQ,IAEjBF,EAAmBT,EAAaC,GAEhCI,GAAOG,EACPF,GAAOG,EAEPF,EAAYO,KAAK,CAACR,EAAMnB,EAAQkB,EAAMlB,GACvC,CAED,OAAOoB,CACT,CAQM,SAAUQ,EAAOR,GACrB,IAAKA,EAAYK,OACf,MAAO,GAGT,IAAIf,EACFJ,EAAac,EAAY,GAAG,GAAI,EAAGpB,GACnCM,EAAac,EAAY,GAAG,GAAI,EAAGpB,GAErC,IAAK,IAAI6B,EAAI,EAAGA,EAAIT,EAAYK,OAAQI,IAAK,CAC3C,MAAMC,EAAIV,EAAYS,GAChBE,EAAIX,EAAYS,EAAI,GAC1BnB,GAAUJ,EAAawB,EAAE,GAAIC,EAAE,GAAI/B,GACnCU,GAAUJ,EAAawB,EAAE,GAAIC,EAAE,GAAI/B,EACpC,CAED,OAAOU,CACT,2CAOM,SAA4BsB,GAChC,OAAOJ,EAAOI,EAAQZ,YACxB,sBAOM,SAA4BJ,GAEhC,MAAO,CACLiB,KAAM,aACNb,YAHaL,EAAOC,GAKxB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@placemarkio/polyline",
|
|
3
|
+
"version": "1.1.0",
|
|
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": "jest",
|
|
22
|
+
"test:ci": "jest",
|
|
23
|
+
"lint": "eslint",
|
|
24
|
+
"doc": "typedoc --options ./typedoc.json",
|
|
25
|
+
"prepare": "rollup -c rollup.config.js && npm run doc",
|
|
26
|
+
"release": "standard-version"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@types/geojson": "*"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git://github.com/placemark/polyline.git"
|
|
34
|
+
},
|
|
35
|
+
"author": "Tom MacWright",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@rollup/plugin-typescript": "^8.5.0",
|
|
39
|
+
"@swc/core": "^1.3.4",
|
|
40
|
+
"@swc/jest": "^0.2.23",
|
|
41
|
+
"@types/geojson": "^7946.0.10",
|
|
42
|
+
"@types/jest": "^29.1.1",
|
|
43
|
+
"eslint": "^8.24.0",
|
|
44
|
+
"husky": "^8.0.1",
|
|
45
|
+
"jest": "^29.1.2",
|
|
46
|
+
"prettier": "^2.7.1",
|
|
47
|
+
"rollup": "^2.79.1",
|
|
48
|
+
"rollup-plugin-dts": "^4.2.2",
|
|
49
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
50
|
+
"standard-version": "^9.5.0",
|
|
51
|
+
"tslib": "^2.4.0",
|
|
52
|
+
"typedoc": "^0.23.15",
|
|
53
|
+
"typescript": "^4.8.4"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"polyline",
|
|
57
|
+
"geojson"
|
|
58
|
+
]
|
|
59
|
+
}
|