@duoquote/polytini 0.1.0 → 0.1.1
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/LICENSE +21 -21
- package/README.md +120 -120
- package/dist/types/cli.d.cts +2 -2
- package/dist/types/deckgl.d.cts +72 -60
- package/dist/types/flexible.d.cts +92 -80
- package/dist/types/geojson.jsr.d.cts +111 -0
- package/dist/types/google.d.cts +48 -48
- package/dist/types/google.jsr.d.cts +72 -60
- package/dist/types/index.d.cts +109 -87
- package/dist/types/leaflet-auto.d.cts +4 -4
- package/dist/types/leaflet-auto.jsr.d.cts +2 -2
- package/dist/types/leaflet.d.cts +39 -39
- package/dist/types/leaflet.jsr.d.cts +15 -13
- package/dist/types/mapbox.d.cts +50 -50
- package/dist/types/mapbox.jsr.d.cts +5 -0
- package/dist/types/maplibre.d.cts +54 -54
- package/dist/types/maplibre.jsr.d.cts +92 -0
- package/dist/types/openlayers.d.cts +23 -23
- package/dist/types/openlayers.jsr.d.cts +42 -0
- package/dist/types/presets.d.cts +70 -66
- package/dist/types/turf.d.cts +33 -33
- package/dist/types/turf.jsr.d.cts +46 -0
- package/dist/types/wasm.d.cts +42 -33
- package/package.json +200 -200
- package/src/browser.js +15 -15
- package/src/bun.js +4 -4
- package/src/cli-lib.js +160 -160
- package/src/cli.js +7 -7
- package/src/core.js +268 -268
- package/src/deckgl.js +176 -176
- package/src/deno.js +12 -12
- package/src/error.js +15 -15
- package/src/fast.js +179 -179
- package/src/flexible.js +283 -283
- package/src/google.js +70 -70
- package/src/leaflet-auto.js +11 -11
- package/src/leaflet.js +44 -44
- package/src/mapbox.js +10 -10
- package/src/maplibre.js +57 -57
- package/src/node.js +17 -17
- package/src/openlayers.js +172 -172
- package/src/presets.js +242 -242
- package/src/text.js +111 -111
- package/src/turf.js +80 -80
- package/src/wasm-bytes.js +2 -2
- package/src/wasm.js +235 -235
- package/src/web.js +9 -9
- package/types/cli.d.ts +2 -2
- package/types/deckgl.d.ts +72 -60
- package/types/flexible.d.ts +92 -80
- package/types/geojson.jsr.d.ts +111 -0
- package/types/google.d.ts +48 -48
- package/types/google.jsr.d.ts +72 -60
- package/types/index.d.ts +109 -87
- package/types/leaflet-auto.d.ts +4 -4
- package/types/leaflet-auto.jsr.d.ts +2 -2
- package/types/leaflet.d.ts +39 -39
- package/types/leaflet.jsr.d.ts +15 -13
- package/types/mapbox.d.ts +50 -50
- package/types/mapbox.jsr.d.ts +5 -0
- package/types/maplibre.d.ts +54 -54
- package/types/maplibre.jsr.d.ts +92 -0
- package/types/openlayers.d.ts +23 -23
- package/types/openlayers.jsr.d.ts +42 -0
- package/types/presets.d.ts +70 -66
- package/types/turf.d.ts +33 -33
- package/types/turf.jsr.d.ts +46 -0
- package/types/wasm.d.ts +42 -33
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// The GeoJSON types the JSR type files need, written out here because JSR
|
|
2
|
+
// builds its docs without node_modules, so `geojson` (@types/geojson) can't
|
|
3
|
+
// be imported. The npm type files use @types/geojson itself. These follow
|
|
4
|
+
// RFC 7946 and have the same shape as @types/geojson's, so values flow
|
|
5
|
+
// between the two.
|
|
6
|
+
|
|
7
|
+
/** [longitude, latitude], then an optional altitude and anything else. */
|
|
8
|
+
export type Position = number[];
|
|
9
|
+
|
|
10
|
+
/** [west, south, east, north], or with altitudes [west, south, low, east, north, high]. */
|
|
11
|
+
export type BBox = [number, number, number, number] | [number, number, number, number, number, number];
|
|
12
|
+
|
|
13
|
+
/** The properties of a Feature: any JSON object, or null. */
|
|
14
|
+
export type GeoJsonProperties = { [name: string]: unknown } | null;
|
|
15
|
+
|
|
16
|
+
/** A GeoJSON Point. */
|
|
17
|
+
export interface Point {
|
|
18
|
+
/** Always "Point". */
|
|
19
|
+
type: 'Point';
|
|
20
|
+
/** The position. */
|
|
21
|
+
coordinates: Position;
|
|
22
|
+
/** Optional bounding box. */
|
|
23
|
+
bbox?: BBox;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A GeoJSON MultiPoint. */
|
|
27
|
+
export interface MultiPoint {
|
|
28
|
+
/** Always "MultiPoint". */
|
|
29
|
+
type: 'MultiPoint';
|
|
30
|
+
/** The positions. */
|
|
31
|
+
coordinates: Position[];
|
|
32
|
+
/** Optional bounding box. */
|
|
33
|
+
bbox?: BBox;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A GeoJSON LineString: two or more positions. */
|
|
37
|
+
export interface LineString {
|
|
38
|
+
/** Always "LineString". */
|
|
39
|
+
type: 'LineString';
|
|
40
|
+
/** The positions, [lng, lat]. */
|
|
41
|
+
coordinates: Position[];
|
|
42
|
+
/** Optional bounding box. */
|
|
43
|
+
bbox?: BBox;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A GeoJSON MultiLineString. */
|
|
47
|
+
export interface MultiLineString {
|
|
48
|
+
/** Always "MultiLineString". */
|
|
49
|
+
type: 'MultiLineString';
|
|
50
|
+
/** One position array per line. */
|
|
51
|
+
coordinates: Position[][];
|
|
52
|
+
/** Optional bounding box. */
|
|
53
|
+
bbox?: BBox;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A GeoJSON Polygon: the outer ring, then holes. */
|
|
57
|
+
export interface Polygon {
|
|
58
|
+
/** Always "Polygon". */
|
|
59
|
+
type: 'Polygon';
|
|
60
|
+
/** One closed position array per ring. */
|
|
61
|
+
coordinates: Position[][];
|
|
62
|
+
/** Optional bounding box. */
|
|
63
|
+
bbox?: BBox;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A GeoJSON MultiPolygon. */
|
|
67
|
+
export interface MultiPolygon {
|
|
68
|
+
/** Always "MultiPolygon". */
|
|
69
|
+
type: 'MultiPolygon';
|
|
70
|
+
/** One ring array per polygon. */
|
|
71
|
+
coordinates: Position[][][];
|
|
72
|
+
/** Optional bounding box. */
|
|
73
|
+
bbox?: BBox;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A GeoJSON GeometryCollection. */
|
|
77
|
+
export interface GeometryCollection {
|
|
78
|
+
/** Always "GeometryCollection". */
|
|
79
|
+
type: 'GeometryCollection';
|
|
80
|
+
/** The geometries. */
|
|
81
|
+
geometries: Geometry[];
|
|
82
|
+
/** Optional bounding box. */
|
|
83
|
+
bbox?: BBox;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Any GeoJSON geometry. */
|
|
87
|
+
export type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon | GeometryCollection;
|
|
88
|
+
|
|
89
|
+
/** A GeoJSON Feature. */
|
|
90
|
+
export interface Feature<G extends Geometry | null = Geometry, P = GeoJsonProperties> {
|
|
91
|
+
/** Always "Feature". */
|
|
92
|
+
type: 'Feature';
|
|
93
|
+
/** The geometry, or null. */
|
|
94
|
+
geometry: G;
|
|
95
|
+
/** The properties. */
|
|
96
|
+
properties: P;
|
|
97
|
+
/** Optional id. */
|
|
98
|
+
id?: string | number;
|
|
99
|
+
/** Optional bounding box. */
|
|
100
|
+
bbox?: BBox;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A GeoJSON FeatureCollection. */
|
|
104
|
+
export interface FeatureCollection<G extends Geometry | null = Geometry, P = GeoJsonProperties> {
|
|
105
|
+
/** Always "FeatureCollection". */
|
|
106
|
+
type: 'FeatureCollection';
|
|
107
|
+
/** The features. */
|
|
108
|
+
features: Feature<G, P>[];
|
|
109
|
+
/** Optional bounding box. */
|
|
110
|
+
bbox?: BBox;
|
|
111
|
+
}
|
package/dist/types/google.d.cts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
// Types for @duoquote/polytini/google, using the google.maps types from
|
|
2
|
-
// @types/google.maps. Those are global declarations, not a module, so they
|
|
3
|
-
// are pulled in with a reference directive: types only, nothing at runtime.
|
|
4
|
-
/// <reference types="google.maps" />
|
|
5
|
-
import type * as P from './index.d.ts';
|
|
6
|
-
import type { Options, Point } from './index.d.ts';
|
|
7
|
-
|
|
8
|
-
export declare const PolylineError: typeof P.PolylineError;
|
|
9
|
-
export type PolylineError = P.PolylineError;
|
|
10
|
-
|
|
11
|
-
/** A LatLng constructor: google.maps.LatLng or anything built the same way. */
|
|
12
|
-
export type LatLngConstructor = new (lat: number, lng: number, noClampNoWrap?: boolean) => google.maps.LatLng;
|
|
13
|
-
|
|
14
|
-
export interface DecodePathOptions extends Omit<Options, 'order'> {
|
|
15
|
-
/**
|
|
16
|
-
* The class to build points with. Default: globalThis.google.maps.LatLng
|
|
17
|
-
* when it exists. false or null returns LatLngLiteral objects.
|
|
18
|
-
*/
|
|
19
|
-
LatLng?: LatLngConstructor | false | null;
|
|
20
|
-
/** Passed to the LatLng constructor. Without it, LatLng clamps latitude and wraps longitude into [-180, 180). */
|
|
21
|
-
noClampNoWrap?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** A point encodePath takes: google.maps.LatLng, LatLngLiteral or a [lat, lng] tuple. */
|
|
25
|
-
export type PathPoint = google.maps.LatLng | google.maps.LatLngLiteral | Point;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Decodes an encoded path to LatLngLiteral objects (`LatLng: false`).
|
|
29
|
-
*/
|
|
30
|
-
export function decodePath(encodedPath: string, options: DecodePathOptions & { LatLng: false | null }): google.maps.LatLngLiteral[];
|
|
31
|
-
/**
|
|
32
|
-
* Decodes an encoded path, like google.maps.geometry.encoding.decodePath,
|
|
33
|
-
* to google.maps.LatLng objects. Without a `LatLng` option this uses
|
|
34
|
-
* globalThis.google.maps.LatLng; when the Maps JavaScript API isn't loaded
|
|
35
|
-
* the result is LatLngLiteral objects at runtime, so pass `LatLng: false`
|
|
36
|
-
* there to get that type. Strict by default: a malformed string throws a
|
|
37
|
-
* PolylineError unless `strict: false`.
|
|
38
|
-
*/
|
|
39
|
-
export function decodePath(encodedPath: string, options?: number | (DecodePathOptions & { LatLng?: LatLngConstructor })): google.maps.LatLng[];
|
|
40
|
-
export function decodePath(encodedPath: string, options?: number | DecodePathOptions): google.maps.LatLng[] | google.maps.LatLngLiteral[];
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Encodes a path, like google.maps.geometry.encoding.encodePath: an array or
|
|
44
|
-
* MVCArray of google.maps.LatLng, LatLngLiteral or [lat, lng] tuples, mixed
|
|
45
|
-
* or not. Precision 5 by default. `order: 'lnglat'` applies to tuples and
|
|
46
|
-
* LatLng objects; literals are read by name. Strict by default.
|
|
47
|
-
*/
|
|
48
|
-
export function encodePath(path: readonly PathPoint[] | google.maps.MVCArray<PathPoint>, options?: number | Options): string;
|
|
1
|
+
// Types for @duoquote/polytini/google, using the google.maps types from
|
|
2
|
+
// @types/google.maps. Those are global declarations, not a module, so they
|
|
3
|
+
// are pulled in with a reference directive: types only, nothing at runtime.
|
|
4
|
+
/// <reference types="google.maps" />
|
|
5
|
+
import type * as P from './index.d.ts';
|
|
6
|
+
import type { Options, Point } from './index.d.ts';
|
|
7
|
+
|
|
8
|
+
export declare const PolylineError: typeof P.PolylineError;
|
|
9
|
+
export type PolylineError = P.PolylineError;
|
|
10
|
+
|
|
11
|
+
/** A LatLng constructor: google.maps.LatLng or anything built the same way. */
|
|
12
|
+
export type LatLngConstructor = new (lat: number, lng: number, noClampNoWrap?: boolean) => google.maps.LatLng;
|
|
13
|
+
|
|
14
|
+
export interface DecodePathOptions extends Omit<Options, 'order'> {
|
|
15
|
+
/**
|
|
16
|
+
* The class to build points with. Default: globalThis.google.maps.LatLng
|
|
17
|
+
* when it exists. false or null returns LatLngLiteral objects.
|
|
18
|
+
*/
|
|
19
|
+
LatLng?: LatLngConstructor | false | null;
|
|
20
|
+
/** Passed to the LatLng constructor. Without it, LatLng clamps latitude and wraps longitude into [-180, 180). */
|
|
21
|
+
noClampNoWrap?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A point encodePath takes: google.maps.LatLng, LatLngLiteral or a [lat, lng] tuple. */
|
|
25
|
+
export type PathPoint = google.maps.LatLng | google.maps.LatLngLiteral | Point;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Decodes an encoded path to LatLngLiteral objects (`LatLng: false`).
|
|
29
|
+
*/
|
|
30
|
+
export function decodePath(encodedPath: string, options: DecodePathOptions & { LatLng: false | null }): google.maps.LatLngLiteral[];
|
|
31
|
+
/**
|
|
32
|
+
* Decodes an encoded path, like google.maps.geometry.encoding.decodePath,
|
|
33
|
+
* to google.maps.LatLng objects. Without a `LatLng` option this uses
|
|
34
|
+
* globalThis.google.maps.LatLng; when the Maps JavaScript API isn't loaded
|
|
35
|
+
* the result is LatLngLiteral objects at runtime, so pass `LatLng: false`
|
|
36
|
+
* there to get that type. Strict by default: a malformed string throws a
|
|
37
|
+
* PolylineError unless `strict: false`.
|
|
38
|
+
*/
|
|
39
|
+
export function decodePath(encodedPath: string, options?: number | (DecodePathOptions & { LatLng?: LatLngConstructor })): google.maps.LatLng[];
|
|
40
|
+
export function decodePath(encodedPath: string, options?: number | DecodePathOptions): google.maps.LatLng[] | google.maps.LatLngLiteral[];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Encodes a path, like google.maps.geometry.encoding.encodePath: an array or
|
|
44
|
+
* MVCArray of google.maps.LatLng, LatLngLiteral or [lat, lng] tuples, mixed
|
|
45
|
+
* or not. Precision 5 by default. `order: 'lnglat'` applies to tuples and
|
|
46
|
+
* LatLng objects; literals are read by name. Strict by default.
|
|
47
|
+
*/
|
|
48
|
+
export function encodePath(path: readonly PathPoint[] | google.maps.MVCArray<PathPoint>, options?: number | Options): string;
|
|
@@ -1,60 +1,72 @@
|
|
|
1
|
-
// JSR copy of google.d.ts. JSR's type output can't carry the
|
|
2
|
-
// @types/google.maps reference, so the Maps shapes are described
|
|
3
|
-
// structurally here: anything with lat() and lng() is a LatLng. The npm
|
|
4
|
-
// package's google.d.ts uses the real google.maps types.
|
|
5
|
-
import type * as P from './index.d.ts';
|
|
6
|
-
import type { Options, Point } from './index.d.ts';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
// JSR copy of google.d.ts. JSR's type output can't carry the
|
|
2
|
+
// @types/google.maps reference, so the Maps shapes are described
|
|
3
|
+
// structurally here: anything with lat() and lng() is a LatLng. The npm
|
|
4
|
+
// package's google.d.ts uses the real google.maps types.
|
|
5
|
+
import type * as P from './index.d.ts';
|
|
6
|
+
import type { Options, Point } from './index.d.ts';
|
|
7
|
+
|
|
8
|
+
/** Anything with lat() and lng(), such as google.maps.LatLng. */
|
|
9
|
+
export interface LatLng {
|
|
10
|
+
/** Latitude in degrees. */
|
|
11
|
+
lat(): number;
|
|
12
|
+
/** Longitude in degrees. */
|
|
13
|
+
lng(): number;
|
|
14
|
+
}
|
|
15
|
+
/** A plain { lat, lng } object, like google.maps.LatLngLiteral. */
|
|
16
|
+
export interface LatLngLiteral {
|
|
17
|
+
/** Latitude in degrees. */
|
|
18
|
+
lat: number;
|
|
19
|
+
/** Longitude in degrees. */
|
|
20
|
+
lng: number;
|
|
21
|
+
}
|
|
22
|
+
/** Anything with getArray(), such as google.maps.MVCArray. */
|
|
23
|
+
export interface MVCArrayLike<T> {
|
|
24
|
+
/** The items as an array. */
|
|
25
|
+
getArray(): T[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The main entry's PolylineError. */
|
|
29
|
+
export declare const PolylineError: typeof P.PolylineError;
|
|
30
|
+
/** The main entry's PolylineError type. */
|
|
31
|
+
export type PolylineError = P.PolylineError;
|
|
32
|
+
|
|
33
|
+
/** A LatLng constructor: LatLng or anything built the same way. */
|
|
34
|
+
export type LatLngConstructor = new (lat: number, lng: number, noClampNoWrap?: boolean) => LatLng;
|
|
35
|
+
|
|
36
|
+
/** Options for decodePath: polytini's options without order, plus the LatLng class. */
|
|
37
|
+
export interface DecodePathOptions extends Omit<Options, 'order'> {
|
|
38
|
+
/**
|
|
39
|
+
* The class to build points with. Default: globalThis.LatLng
|
|
40
|
+
* when it exists. false or null returns LatLngLiteral objects.
|
|
41
|
+
*/
|
|
42
|
+
LatLng?: LatLngConstructor | false | null;
|
|
43
|
+
/** Passed to the LatLng constructor. Without it, LatLng clamps latitude and wraps longitude into [-180, 180). */
|
|
44
|
+
noClampNoWrap?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A point encodePath takes: LatLng, LatLngLiteral or a [lat, lng] tuple. */
|
|
48
|
+
export type PathPoint = LatLng | LatLngLiteral | Point;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Decodes an encoded path to LatLngLiteral objects (`LatLng: false`).
|
|
52
|
+
*/
|
|
53
|
+
export function decodePath(encodedPath: string, options: DecodePathOptions & { LatLng: false | null }): LatLngLiteral[];
|
|
54
|
+
/**
|
|
55
|
+
* Decodes an encoded path, like google.maps.geometry.encoding.decodePath,
|
|
56
|
+
* to LatLng objects. Without a `LatLng` option this uses
|
|
57
|
+
* globalThis.LatLng; when the Maps JavaScript API isn't loaded
|
|
58
|
+
* the result is LatLngLiteral objects at runtime, so pass `LatLng: false`
|
|
59
|
+
* there to get that type. Strict by default: a malformed string throws a
|
|
60
|
+
* PolylineError unless `strict: false`.
|
|
61
|
+
*/
|
|
62
|
+
export function decodePath(encodedPath: string, options?: number | (DecodePathOptions & { LatLng?: LatLngConstructor })): LatLng[];
|
|
63
|
+
/** decodePath when the LatLng option isn't known until runtime. */
|
|
64
|
+
export function decodePath(encodedPath: string, options?: number | DecodePathOptions): LatLng[] | LatLngLiteral[];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Encodes a path, like google.maps.geometry.encoding.encodePath: an array or
|
|
68
|
+
* MVCArray of LatLng, LatLngLiteral or [lat, lng] tuples, mixed
|
|
69
|
+
* or not. Precision 5 by default. `order: 'lnglat'` applies to tuples and
|
|
70
|
+
* LatLng objects; literals are read by name. Strict by default.
|
|
71
|
+
*/
|
|
72
|
+
export function encodePath(path: readonly PathPoint[] | MVCArrayLike<PathPoint>, options?: number | Options): string;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,87 +1,109 @@
|
|
|
1
|
-
// Types for every Google-format entry point of @duoquote/polytini: the
|
|
2
|
-
// default (web), node, bun, deno and wasm entries share this API.
|
|
3
|
-
|
|
4
|
-
/** A point as [lat, lng], or [lng, lat] with `order: 'lnglat'`. More values with `dimensions`. */
|
|
5
|
-
export type Point = [number, number, ...number[]];
|
|
6
|
-
|
|
7
|
-
/** Objects encode reads by name: lat or latitude, lng, lon or longitude, alt or altitude. */
|
|
8
|
-
export interface LatLngLike {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
|
|
1
|
+
// Types for every Google-format entry point of @duoquote/polytini: the
|
|
2
|
+
// default (web), node, bun, deno and wasm entries share this API.
|
|
3
|
+
|
|
4
|
+
/** A point as [lat, lng], or [lng, lat] with `order: 'lnglat'`. More values with `dimensions`. */
|
|
5
|
+
export type Point = [number, number, ...number[]];
|
|
6
|
+
|
|
7
|
+
/** Objects encode reads by name: lat or latitude, lng, lon or longitude, alt or altitude. */
|
|
8
|
+
export interface LatLngLike {
|
|
9
|
+
/** Latitude. */
|
|
10
|
+
lat?: number;
|
|
11
|
+
/** Latitude, the long name. */
|
|
12
|
+
latitude?: number;
|
|
13
|
+
/** Longitude. */
|
|
14
|
+
lng?: number;
|
|
15
|
+
/** Longitude, another short name. */
|
|
16
|
+
lon?: number;
|
|
17
|
+
/** Longitude, the long name. */
|
|
18
|
+
longitude?: number;
|
|
19
|
+
/** Altitude, the third value with `dimensions: 3`. */
|
|
20
|
+
alt?: number;
|
|
21
|
+
/** Altitude, the long name. */
|
|
22
|
+
altitude?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Options for every encode and decode function. */
|
|
26
|
+
export interface Options {
|
|
27
|
+
/** Decimal places, an integer from 0 to 15. Default 5. Google uses 5, OSRM's polyline6 and Valhalla 6. */
|
|
28
|
+
precision?: number;
|
|
29
|
+
/** Multiply by this instead of 10 ** precision. */
|
|
30
|
+
factor?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The order of the tuples you pass in and get back. The encoded string
|
|
33
|
+
* always stores latitude first. Default 'latlng'; GeoJSON uses 'lnglat'.
|
|
34
|
+
*/
|
|
35
|
+
order?: 'latlng' | 'lnglat';
|
|
36
|
+
/**
|
|
37
|
+
* Throw a PolylineError on malformed input. Default true. With false,
|
|
38
|
+
* decode skips invalid characters and drops an incomplete last point, and
|
|
39
|
+
* encode treats missing or non-finite coordinates as 0.
|
|
40
|
+
*/
|
|
41
|
+
strict?: boolean;
|
|
42
|
+
/** Values per point, 1 to 16. Default 2. The third can be elevation, like GraphHopper's. */
|
|
43
|
+
dimensions?: number;
|
|
44
|
+
/** Factor for the third and later values. Defaults to the main factor. */
|
|
45
|
+
zFactor?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Options, or just the precision. */
|
|
49
|
+
export type OptionsArg = number | Options;
|
|
50
|
+
|
|
51
|
+
/** PolylineError codes: a bad character, a cut-off string, a value past 2^53, a bad coordinate, input that isn't a string or array, a bad option, or /wasm used before init(). */
|
|
52
|
+
export type ErrorCode = 'char' | 'truncated' | 'overflow' | 'coordinate' | 'input' | 'option' | 'init';
|
|
53
|
+
|
|
54
|
+
/** What strict mode throws, with a code and, where it makes sense, an index. */
|
|
55
|
+
export class PolylineError extends Error {
|
|
56
|
+
/** Always "PolylineError". */
|
|
57
|
+
readonly name: 'PolylineError';
|
|
58
|
+
/** What went wrong. */
|
|
59
|
+
readonly code: ErrorCode;
|
|
60
|
+
/** Character index (decode) or point index (encode), when there is one. */
|
|
61
|
+
readonly index: number | undefined;
|
|
62
|
+
/** Makes an error; the message gets " at <index>" appended when there's an index. */
|
|
63
|
+
constructor(code: ErrorCode, message: string, index?: number);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A GeoJSON LineString, [lng, lat] positions. */
|
|
67
|
+
export interface LineString {
|
|
68
|
+
/** Always "LineString". */
|
|
69
|
+
type: 'LineString';
|
|
70
|
+
/** The positions. */
|
|
71
|
+
coordinates: number[][];
|
|
72
|
+
/** Optional bounding box. */
|
|
73
|
+
bbox?: number[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A GeoJSON Feature with a LineString geometry. */
|
|
77
|
+
export interface LineStringFeature {
|
|
78
|
+
/** Always "Feature". */
|
|
79
|
+
type: 'Feature';
|
|
80
|
+
/** The line. */
|
|
81
|
+
geometry: LineString;
|
|
82
|
+
/** The feature's properties. */
|
|
83
|
+
properties: Record<string, unknown> | null;
|
|
84
|
+
/** Optional id. */
|
|
85
|
+
id?: string | number;
|
|
86
|
+
/** Optional bounding box. */
|
|
87
|
+
bbox?: number[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Encodes points: tuples (or any array-like) or lat/lng objects. */
|
|
91
|
+
export function encode(points: ArrayLike<ArrayLike<number> | LatLngLike>, options?: OptionsArg): string;
|
|
92
|
+
|
|
93
|
+
/** Decodes to tuples, [lat, lng] by default. */
|
|
94
|
+
export function decode(str: string, options?: OptionsArg): Point[];
|
|
95
|
+
|
|
96
|
+
/** Encodes a flat array of numbers: [lat0, lng0, lat1, lng1, ...] (or lng first with order 'lnglat'). */
|
|
97
|
+
export function encodeFlat(values: ArrayLike<number>, options?: OptionsArg): string;
|
|
98
|
+
|
|
99
|
+
/** Decodes to one flat Float64Array, without an array per point. */
|
|
100
|
+
export function decodeFlat(str: string, options?: OptionsArg): Float64Array;
|
|
101
|
+
|
|
102
|
+
/** Decodes to {lat, lng} objects, the shape Google Maps and Leaflet take. */
|
|
103
|
+
export function decodeLatLng(str: string, options?: OptionsArg): { lat: number; lng: number }[];
|
|
104
|
+
|
|
105
|
+
/** Decodes to a GeoJSON LineString, [lng, lat] order. */
|
|
106
|
+
export function toGeoJSON(str: string, options?: OptionsArg): LineString;
|
|
107
|
+
|
|
108
|
+
/** Encodes a GeoJSON LineString, or a Feature with one. */
|
|
109
|
+
export function fromGeoJSON(geojson: LineString | LineStringFeature, options?: OptionsArg): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Side-effect import that patches the global L. The added methods are
|
|
2
|
-
// typed in leaflet.d.ts.
|
|
3
|
-
/// <reference path="./leaflet.d.ts" />
|
|
4
|
-
export {};
|
|
1
|
+
// Side-effect import that patches the global L. The added methods are
|
|
2
|
+
// typed in leaflet.d.ts.
|
|
3
|
+
/// <reference path="./leaflet.d.ts" />
|
|
4
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Side-effect import that patches the global L (JSR version, see leaflet.jsr.d.ts).
|
|
2
|
-
export {};
|
|
1
|
+
// Side-effect import that patches the global L (JSR version, see leaflet.jsr.d.ts).
|
|
2
|
+
export {};
|
package/dist/types/leaflet.d.cts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
// Types for @duoquote/polytini/leaflet. Leaflet's own types come from
|
|
2
|
-
// @types/leaflet (1.9) or leaflet's bundled types (2.x); this only adds the
|
|
3
|
-
// plugin's methods.
|
|
4
|
-
import type * as P from './index.d.ts';
|
|
5
|
-
import type { OptionsArg } from './index.d.ts';
|
|
6
|
-
import type { Polyline as LeafletPolyline, Polygon as LeafletPolygon } from 'leaflet';
|
|
7
|
-
|
|
8
|
-
/** One encoded line or ring, or nested arrays of them (multi-polylines, holes, multi-polygons). */
|
|
9
|
-
export type Encoded = string | Encoded[];
|
|
10
|
-
|
|
11
|
-
/** Leaflet path options plus polytini's precision, factor, strict and dimensions. */
|
|
12
|
-
export type EncodedOptions = Record<string, unknown> & Exclude<OptionsArg, number>;
|
|
13
|
-
|
|
14
|
-
/** Adds fromEncoded, toEncoded, encodePath and the polylineEncoded/polygonEncoded factories. Returns L. */
|
|
15
|
-
export function install<T>(L: T): T;
|
|
16
|
-
|
|
17
|
-
export declare const encode: typeof P.encode;
|
|
18
|
-
export declare const decode: typeof P.decode;
|
|
19
|
-
|
|
20
|
-
declare module 'leaflet' {
|
|
21
|
-
namespace Polyline {
|
|
22
|
-
/** A polyline from an encoded string, or a multi-polyline from an array of strings. */
|
|
23
|
-
// Generic with a default so Polygon's static side still extends Polyline's.
|
|
24
|
-
function fromEncoded<T = LeafletPolyline>(encoded: Encoded, options?: EncodedOptions): T;
|
|
25
|
-
}
|
|
26
|
-
namespace Polygon {
|
|
27
|
-
/** A polygon from one string, rings (outer, then holes) from string[], a multi-polygon from string[][]. */
|
|
28
|
-
function fromEncoded<T = LeafletPolygon>(encoded: Encoded, options?: EncodedOptions): T;
|
|
29
|
-
}
|
|
30
|
-
interface Polyline {
|
|
31
|
-
/** A string for a simple line, string[] for a multi-polyline. Polygons give string[] (rings) or string[][]. */
|
|
32
|
-
toEncoded(options?: OptionsArg): Encoded;
|
|
33
|
-
/** Alias of toEncoded, the Polyline.encoded.js name. */
|
|
34
|
-
encodePath(options?: OptionsArg): Encoded;
|
|
35
|
-
}
|
|
36
|
-
function polylineEncoded(encoded: Encoded, options?: EncodedOptions): LeafletPolyline;
|
|
37
|
-
function polygonEncoded(encoded: Encoded, options?: EncodedOptions): LeafletPolygon;
|
|
38
|
-
const PolylineUtil: { encode: typeof P.encode; decode: typeof P.decode };
|
|
39
|
-
}
|
|
1
|
+
// Types for @duoquote/polytini/leaflet. Leaflet's own types come from
|
|
2
|
+
// @types/leaflet (1.9) or leaflet's bundled types (2.x); this only adds the
|
|
3
|
+
// plugin's methods.
|
|
4
|
+
import type * as P from './index.d.ts';
|
|
5
|
+
import type { OptionsArg } from './index.d.ts';
|
|
6
|
+
import type { Polyline as LeafletPolyline, Polygon as LeafletPolygon } from 'leaflet';
|
|
7
|
+
|
|
8
|
+
/** One encoded line or ring, or nested arrays of them (multi-polylines, holes, multi-polygons). */
|
|
9
|
+
export type Encoded = string | Encoded[];
|
|
10
|
+
|
|
11
|
+
/** Leaflet path options plus polytini's precision, factor, strict and dimensions. */
|
|
12
|
+
export type EncodedOptions = Record<string, unknown> & Exclude<OptionsArg, number>;
|
|
13
|
+
|
|
14
|
+
/** Adds fromEncoded, toEncoded, encodePath and the polylineEncoded/polygonEncoded factories. Returns L. */
|
|
15
|
+
export function install<T>(L: T): T;
|
|
16
|
+
|
|
17
|
+
export declare const encode: typeof P.encode;
|
|
18
|
+
export declare const decode: typeof P.decode;
|
|
19
|
+
|
|
20
|
+
declare module 'leaflet' {
|
|
21
|
+
namespace Polyline {
|
|
22
|
+
/** A polyline from an encoded string, or a multi-polyline from an array of strings. */
|
|
23
|
+
// Generic with a default so Polygon's static side still extends Polyline's.
|
|
24
|
+
function fromEncoded<T = LeafletPolyline>(encoded: Encoded, options?: EncodedOptions): T;
|
|
25
|
+
}
|
|
26
|
+
namespace Polygon {
|
|
27
|
+
/** A polygon from one string, rings (outer, then holes) from string[], a multi-polygon from string[][]. */
|
|
28
|
+
function fromEncoded<T = LeafletPolygon>(encoded: Encoded, options?: EncodedOptions): T;
|
|
29
|
+
}
|
|
30
|
+
interface Polyline {
|
|
31
|
+
/** A string for a simple line, string[] for a multi-polyline. Polygons give string[] (rings) or string[][]. */
|
|
32
|
+
toEncoded(options?: OptionsArg): Encoded;
|
|
33
|
+
/** Alias of toEncoded, the Polyline.encoded.js name. */
|
|
34
|
+
encodePath(options?: OptionsArg): Encoded;
|
|
35
|
+
}
|
|
36
|
+
function polylineEncoded(encoded: Encoded, options?: EncodedOptions): LeafletPolyline;
|
|
37
|
+
function polygonEncoded(encoded: Encoded, options?: EncodedOptions): LeafletPolygon;
|
|
38
|
+
const PolylineUtil: { encode: typeof P.encode; decode: typeof P.decode };
|
|
39
|
+
}
|