@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.
Files changed (68) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +120 -120
  3. package/dist/types/cli.d.cts +2 -2
  4. package/dist/types/deckgl.d.cts +72 -60
  5. package/dist/types/flexible.d.cts +92 -80
  6. package/dist/types/geojson.jsr.d.cts +111 -0
  7. package/dist/types/google.d.cts +48 -48
  8. package/dist/types/google.jsr.d.cts +72 -60
  9. package/dist/types/index.d.cts +109 -87
  10. package/dist/types/leaflet-auto.d.cts +4 -4
  11. package/dist/types/leaflet-auto.jsr.d.cts +2 -2
  12. package/dist/types/leaflet.d.cts +39 -39
  13. package/dist/types/leaflet.jsr.d.cts +15 -13
  14. package/dist/types/mapbox.d.cts +50 -50
  15. package/dist/types/mapbox.jsr.d.cts +5 -0
  16. package/dist/types/maplibre.d.cts +54 -54
  17. package/dist/types/maplibre.jsr.d.cts +92 -0
  18. package/dist/types/openlayers.d.cts +23 -23
  19. package/dist/types/openlayers.jsr.d.cts +42 -0
  20. package/dist/types/presets.d.cts +70 -66
  21. package/dist/types/turf.d.cts +33 -33
  22. package/dist/types/turf.jsr.d.cts +46 -0
  23. package/dist/types/wasm.d.cts +42 -33
  24. package/package.json +200 -200
  25. package/src/browser.js +15 -15
  26. package/src/bun.js +4 -4
  27. package/src/cli-lib.js +160 -160
  28. package/src/cli.js +7 -7
  29. package/src/core.js +268 -268
  30. package/src/deckgl.js +176 -176
  31. package/src/deno.js +12 -12
  32. package/src/error.js +15 -15
  33. package/src/fast.js +179 -179
  34. package/src/flexible.js +283 -283
  35. package/src/google.js +70 -70
  36. package/src/leaflet-auto.js +11 -11
  37. package/src/leaflet.js +44 -44
  38. package/src/mapbox.js +10 -10
  39. package/src/maplibre.js +57 -57
  40. package/src/node.js +17 -17
  41. package/src/openlayers.js +172 -172
  42. package/src/presets.js +242 -242
  43. package/src/text.js +111 -111
  44. package/src/turf.js +80 -80
  45. package/src/wasm-bytes.js +2 -2
  46. package/src/wasm.js +235 -235
  47. package/src/web.js +9 -9
  48. package/types/cli.d.ts +2 -2
  49. package/types/deckgl.d.ts +72 -60
  50. package/types/flexible.d.ts +92 -80
  51. package/types/geojson.jsr.d.ts +111 -0
  52. package/types/google.d.ts +48 -48
  53. package/types/google.jsr.d.ts +72 -60
  54. package/types/index.d.ts +109 -87
  55. package/types/leaflet-auto.d.ts +4 -4
  56. package/types/leaflet-auto.jsr.d.ts +2 -2
  57. package/types/leaflet.d.ts +39 -39
  58. package/types/leaflet.jsr.d.ts +15 -13
  59. package/types/mapbox.d.ts +50 -50
  60. package/types/mapbox.jsr.d.ts +5 -0
  61. package/types/maplibre.d.ts +54 -54
  62. package/types/maplibre.jsr.d.ts +92 -0
  63. package/types/openlayers.d.ts +23 -23
  64. package/types/openlayers.jsr.d.ts +42 -0
  65. package/types/presets.d.ts +70 -66
  66. package/types/turf.d.ts +33 -33
  67. package/types/turf.jsr.d.ts +46 -0
  68. package/types/wasm.d.ts +42 -33
@@ -1,13 +1,15 @@
1
- // Types for @duoquote/polytini/leaflet on JSR. JSR doesn't allow module
2
- // augmentation, so this has the plugin's own exports but not the methods it
3
- // adds to Leaflet's classes. The npm package's leaflet.d.ts has those.
4
- import type * as P from './index.d.ts';
5
-
6
- /** One encoded line or ring, or nested arrays of them (multi-polylines, holes, multi-polygons). */
7
- export type Encoded = string | Encoded[];
8
-
9
- /** Adds fromEncoded, toEncoded, encodePath and the polylineEncoded/polygonEncoded factories. Returns L. */
10
- export function install<T>(L: T): T;
11
-
12
- export declare const encode: typeof P.encode;
13
- export declare const decode: typeof P.decode;
1
+ // Types for @duoquote/polytini/leaflet on JSR. JSR doesn't allow module
2
+ // augmentation, so this has the plugin's own exports but not the methods it
3
+ // adds to Leaflet's classes. The npm package's leaflet.d.ts has those.
4
+ import type * as P from './index.d.ts';
5
+
6
+ /** One encoded line or ring, or nested arrays of them (multi-polylines, holes, multi-polygons). */
7
+ export type Encoded = string | Encoded[];
8
+
9
+ /** Adds fromEncoded, toEncoded, encodePath and the polylineEncoded/polygonEncoded factories. Returns L. */
10
+ export function install<T>(L: T): T;
11
+
12
+ /** The main entry's encode. */
13
+ export declare const encode: typeof P.encode;
14
+ /** The main entry's decode. */
15
+ export declare const decode: typeof P.decode;
@@ -1,50 +1,50 @@
1
- // Types for @duoquote/polytini/mapbox: the same functions as the maplibre
2
- // module, typed with mapbox-gl's own types (type-only imports). mapbox-gl's
3
- // types use the GeoJSON namespace from @types/geojson.
4
- import type { Map, GeoJSONSource, GeoJSONSourceSpecification, LineLayerSpecification } from 'mapbox-gl';
5
- import type { FeatureCollection, LineString, GeoJsonProperties } from 'geojson';
6
- import type { Options } from './index.d.ts';
7
-
8
- export type { GeoJSONSourceSpecification, LineLayerSpecification };
9
-
10
- // Repeated from maplibre.d.ts so this file does not need maplibre-gl installed.
11
- export type FeatureId = string | number;
12
-
13
- export interface DataOptions<P = GeoJsonProperties> extends Options {
14
- /** Properties for every line, or an array with one object per line. Default {}. */
15
- properties?: P | P[];
16
- /** Feature id for every line, or an array with one per line. Feature state needs numeric ids or promoteId. */
17
- id?: FeatureId | FeatureId[];
18
- /** Add a [west, south, east, north] bbox to each feature. Default false. */
19
- bbox?: boolean;
20
- }
21
-
22
- export interface SourceOptions<P = GeoJsonProperties> extends DataOptions<P> {
23
- /** Other source options: lineMetrics, tolerance, promoteId, generateId, attribution, and so on. */
24
- source?: Partial<Omit<GeoJSONSourceSpecification, 'type' | 'data'>>;
25
- }
26
-
27
- export interface LayerOptions<P = GeoJsonProperties> extends SourceOptions<P> {
28
- /** Merged into the line layer: paint, layout, filter, slot, minzoom, maxzoom, or another id. */
29
- layer?: Partial<Omit<LineLayerSpecification, 'type' | 'source'>>;
30
- /** The id of an existing layer to insert the new layer before. */
31
- beforeId?: string;
32
- }
33
-
34
- /** A GeoJSON source specification whose data is a FeatureCollection of LineStrings. */
35
- export type PolylineSource<P = GeoJsonProperties> = GeoJSONSourceSpecification & {
36
- type: 'geojson';
37
- data: FeatureCollection<LineString, P>;
38
- };
39
-
40
- /** A FeatureCollection<LineString> ([lng, lat]) with one Feature per encoded string. */
41
- export function polylineData<P = GeoJsonProperties>(encoded: string | string[], options?: number | DataOptions<P>): FeatureCollection<LineString, P>;
42
-
43
- /** `{ type: 'geojson', data }` for map.addSource or a style's sources. */
44
- export function polylineSource<P = GeoJsonProperties>(encoded: string | string[], options?: number | SourceOptions<P>): PolylineSource<P>;
45
-
46
- /** Adds a GeoJSON source and a line layer, both named `id`. Returns the map. */
47
- export function addPolylineLayer<M extends Map, P = GeoJsonProperties>(map: M, id: string, encoded: string | string[], options?: number | LayerOptions<P>): M;
48
-
49
- /** Replaces the data of the GeoJSON source `id`. Returns what setData returns (the source). Throws a PolylineError if there is no such GeoJSON source. */
50
- export function setPolylineData<P = GeoJsonProperties>(map: Map, id: string, encoded: string | string[], options?: number | DataOptions<P>): ReturnType<GeoJSONSource['setData']>;
1
+ // Types for @duoquote/polytini/mapbox: the same functions as the maplibre
2
+ // module, typed with mapbox-gl's own types (type-only imports). mapbox-gl's
3
+ // types use the GeoJSON namespace from @types/geojson.
4
+ import type { Map, GeoJSONSource, GeoJSONSourceSpecification, LineLayerSpecification } from 'mapbox-gl';
5
+ import type { FeatureCollection, LineString, GeoJsonProperties } from 'geojson';
6
+ import type { Options } from './index.d.ts';
7
+
8
+ export type { GeoJSONSourceSpecification, LineLayerSpecification };
9
+
10
+ // Repeated from maplibre.d.ts so this file does not need maplibre-gl installed.
11
+ export type FeatureId = string | number;
12
+
13
+ export interface DataOptions<P = GeoJsonProperties> extends Options {
14
+ /** Properties for every line, or an array with one object per line. Default {}. */
15
+ properties?: P | P[];
16
+ /** Feature id for every line, or an array with one per line. Feature state needs numeric ids or promoteId. */
17
+ id?: FeatureId | FeatureId[];
18
+ /** Add a [west, south, east, north] bbox to each feature. Default false. */
19
+ bbox?: boolean;
20
+ }
21
+
22
+ export interface SourceOptions<P = GeoJsonProperties> extends DataOptions<P> {
23
+ /** Other source options: lineMetrics, tolerance, promoteId, generateId, attribution, and so on. */
24
+ source?: Partial<Omit<GeoJSONSourceSpecification, 'type' | 'data'>>;
25
+ }
26
+
27
+ export interface LayerOptions<P = GeoJsonProperties> extends SourceOptions<P> {
28
+ /** Merged into the line layer: paint, layout, filter, slot, minzoom, maxzoom, or another id. */
29
+ layer?: Partial<Omit<LineLayerSpecification, 'type' | 'source'>>;
30
+ /** The id of an existing layer to insert the new layer before. */
31
+ beforeId?: string;
32
+ }
33
+
34
+ /** A GeoJSON source specification whose data is a FeatureCollection of LineStrings. */
35
+ export type PolylineSource<P = GeoJsonProperties> = GeoJSONSourceSpecification & {
36
+ type: 'geojson';
37
+ data: FeatureCollection<LineString, P>;
38
+ };
39
+
40
+ /** A FeatureCollection<LineString> ([lng, lat]) with one Feature per encoded string. */
41
+ export function polylineData<P = GeoJsonProperties>(encoded: string | string[], options?: number | DataOptions<P>): FeatureCollection<LineString, P>;
42
+
43
+ /** `{ type: 'geojson', data }` for map.addSource or a style's sources. */
44
+ export function polylineSource<P = GeoJsonProperties>(encoded: string | string[], options?: number | SourceOptions<P>): PolylineSource<P>;
45
+
46
+ /** Adds a GeoJSON source and a line layer, both named `id`. Returns the map. */
47
+ export function addPolylineLayer<M extends Map, P = GeoJsonProperties>(map: M, id: string, encoded: string | string[], options?: number | LayerOptions<P>): M;
48
+
49
+ /** Replaces the data of the GeoJSON source `id`. Returns what setData returns (the source). Throws a PolylineError if there is no such GeoJSON source. */
50
+ export function setPolylineData<P = GeoJsonProperties>(map: Map, id: string, encoded: string | string[], options?: number | DataOptions<P>): ReturnType<GeoJSONSource['setData']>;
@@ -0,0 +1,5 @@
1
+ // JSR copy of mapbox.d.ts: the same functions as the maplibre module, which
2
+ // take the same calls on a Mapbox map. Structural types, for the same reason
3
+ // as maplibre.jsr.d.ts. The npm package's mapbox.d.ts uses mapbox-gl's own
4
+ // types.
5
+ export * from './maplibre.jsr.d.ts';
@@ -1,54 +1,54 @@
1
- // Types for @duoquote/polytini/maplibre, built from maplibre-gl's own types
2
- // (type-only imports, so nothing is loaded at runtime). The source and layer
3
- // types are taken from Map#addSource and Map#addLayer, so they follow the
4
- // installed maplibre-gl version.
5
- import type { Map, GeoJSONSource } from 'maplibre-gl';
6
- import type { FeatureCollection, LineString, GeoJsonProperties } from 'geojson';
7
- import type { Options } from './index.d.ts';
8
-
9
- /** MapLibre's GeoJSON source specification. */
10
- export type GeoJSONSourceSpecification = Extract<Parameters<Map['addSource']>[1], { type: 'geojson' }>;
11
-
12
- /** MapLibre's line layer specification. */
13
- export type LineLayerSpecification = Extract<Parameters<Map['addLayer']>[0], { type: 'line' }>;
14
-
15
- export type FeatureId = string | number;
16
-
17
- export interface DataOptions<P = GeoJsonProperties> extends Options {
18
- /** Properties for every line, or an array with one object per line. Default {}. */
19
- properties?: P | P[];
20
- /** Feature id for every line, or an array with one per line. MapLibre's feature state needs numeric ids or promoteId. */
21
- id?: FeatureId | FeatureId[];
22
- /** Add a [west, south, east, north] bbox to each feature. Default false. */
23
- bbox?: boolean;
24
- }
25
-
26
- export interface SourceOptions<P = GeoJsonProperties> extends DataOptions<P> {
27
- /** Other source options: lineMetrics, tolerance, promoteId, generateId, attribution, and so on. */
28
- source?: Partial<Omit<GeoJSONSourceSpecification, 'type' | 'data'>>;
29
- }
30
-
31
- export interface LayerOptions<P = GeoJsonProperties> extends SourceOptions<P> {
32
- /** Merged into the line layer: paint, layout, filter, minzoom, maxzoom, metadata, or another id. */
33
- layer?: Partial<Omit<LineLayerSpecification, 'type' | 'source'>>;
34
- /** The id of an existing layer to insert the new layer before. */
35
- beforeId?: string;
36
- }
37
-
38
- /** A GeoJSON source specification whose data is a FeatureCollection of LineStrings. */
39
- export type PolylineSource<P = GeoJsonProperties> = GeoJSONSourceSpecification & {
40
- type: 'geojson';
41
- data: FeatureCollection<LineString, P>;
42
- };
43
-
44
- /** A FeatureCollection<LineString> ([lng, lat]) with one Feature per encoded string. */
45
- export function polylineData<P = GeoJsonProperties>(encoded: string | string[], options?: number | DataOptions<P>): FeatureCollection<LineString, P>;
46
-
47
- /** `{ type: 'geojson', data }` for map.addSource or a style's sources. */
48
- export function polylineSource<P = GeoJsonProperties>(encoded: string | string[], options?: number | SourceOptions<P>): PolylineSource<P>;
49
-
50
- /** Adds a GeoJSON source and a line layer, both named `id`. Returns the map. */
51
- export function addPolylineLayer<M extends Map, P = GeoJsonProperties>(map: M, id: string, encoded: string | string[], options?: number | LayerOptions<P>): M;
52
-
53
- /** Replaces the data of the GeoJSON source `id`. Returns setData's Promise. Throws a PolylineError if there is no such GeoJSON source. */
54
- export function setPolylineData<P = GeoJsonProperties>(map: Map, id: string, encoded: string | string[], options?: number | DataOptions<P>): ReturnType<GeoJSONSource['setData']>;
1
+ // Types for @duoquote/polytini/maplibre, built from maplibre-gl's own types
2
+ // (type-only imports, so nothing is loaded at runtime). The source and layer
3
+ // types are taken from Map#addSource and Map#addLayer, so they follow the
4
+ // installed maplibre-gl version.
5
+ import type { Map, GeoJSONSource } from 'maplibre-gl';
6
+ import type { FeatureCollection, LineString, GeoJsonProperties } from 'geojson';
7
+ import type { Options } from './index.d.ts';
8
+
9
+ /** MapLibre's GeoJSON source specification. */
10
+ export type GeoJSONSourceSpecification = Extract<Parameters<Map['addSource']>[1], { type: 'geojson' }>;
11
+
12
+ /** MapLibre's line layer specification. */
13
+ export type LineLayerSpecification = Extract<Parameters<Map['addLayer']>[0], { type: 'line' }>;
14
+
15
+ export type FeatureId = string | number;
16
+
17
+ export interface DataOptions<P = GeoJsonProperties> extends Options {
18
+ /** Properties for every line, or an array with one object per line. Default {}. */
19
+ properties?: P | P[];
20
+ /** Feature id for every line, or an array with one per line. MapLibre's feature state needs numeric ids or promoteId. */
21
+ id?: FeatureId | FeatureId[];
22
+ /** Add a [west, south, east, north] bbox to each feature. Default false. */
23
+ bbox?: boolean;
24
+ }
25
+
26
+ export interface SourceOptions<P = GeoJsonProperties> extends DataOptions<P> {
27
+ /** Other source options: lineMetrics, tolerance, promoteId, generateId, attribution, and so on. */
28
+ source?: Partial<Omit<GeoJSONSourceSpecification, 'type' | 'data'>>;
29
+ }
30
+
31
+ export interface LayerOptions<P = GeoJsonProperties> extends SourceOptions<P> {
32
+ /** Merged into the line layer: paint, layout, filter, minzoom, maxzoom, metadata, or another id. */
33
+ layer?: Partial<Omit<LineLayerSpecification, 'type' | 'source'>>;
34
+ /** The id of an existing layer to insert the new layer before. */
35
+ beforeId?: string;
36
+ }
37
+
38
+ /** A GeoJSON source specification whose data is a FeatureCollection of LineStrings. */
39
+ export type PolylineSource<P = GeoJsonProperties> = GeoJSONSourceSpecification & {
40
+ type: 'geojson';
41
+ data: FeatureCollection<LineString, P>;
42
+ };
43
+
44
+ /** A FeatureCollection<LineString> ([lng, lat]) with one Feature per encoded string. */
45
+ export function polylineData<P = GeoJsonProperties>(encoded: string | string[], options?: number | DataOptions<P>): FeatureCollection<LineString, P>;
46
+
47
+ /** `{ type: 'geojson', data }` for map.addSource or a style's sources. */
48
+ export function polylineSource<P = GeoJsonProperties>(encoded: string | string[], options?: number | SourceOptions<P>): PolylineSource<P>;
49
+
50
+ /** Adds a GeoJSON source and a line layer, both named `id`. Returns the map. */
51
+ export function addPolylineLayer<M extends Map, P = GeoJsonProperties>(map: M, id: string, encoded: string | string[], options?: number | LayerOptions<P>): M;
52
+
53
+ /** Replaces the data of the GeoJSON source `id`. Returns setData's Promise. Throws a PolylineError if there is no such GeoJSON source. */
54
+ export function setPolylineData<P = GeoJsonProperties>(map: Map, id: string, encoded: string | string[], options?: number | DataOptions<P>): ReturnType<GeoJSONSource['setData']>;
@@ -0,0 +1,92 @@
1
+ // JSR copy of maplibre.d.ts. JSR builds its docs without node_modules, so
2
+ // maplibre-gl's and @types/geojson's types can't be imported; the map and
3
+ // the specifications are described structurally here, by the methods and
4
+ // fields this module uses. The npm package's maplibre.d.ts uses maplibre-gl's
5
+ // own types.
6
+ import type { Options } from './index.d.ts';
7
+ import type { FeatureCollection, LineString, GeoJsonProperties } from './geojson.jsr.d.ts';
8
+
9
+ export type { Feature, FeatureCollection, Geometry, GeometryCollection, Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, Position, BBox, GeoJsonProperties } from './geojson.jsr.d.ts';
10
+
11
+ /** The parts of a MapLibre or Mapbox Map this module calls. */
12
+ export interface MapLike {
13
+ /** Map#addSource. */
14
+ addSource(id: string, source: GeoJSONSourceSpecification): unknown;
15
+ /** Map#addLayer. */
16
+ addLayer(layer: LineLayerSpecification, beforeId?: string): unknown;
17
+ /** Map#getSource. */
18
+ getSource(id: string): unknown;
19
+ }
20
+
21
+ /** A GeoJSON source specification: { type: 'geojson', data, ...options }. */
22
+ export interface GeoJSONSourceSpecification {
23
+ /** Always "geojson". */
24
+ type: 'geojson';
25
+ /** A GeoJSON object or a URL to one. */
26
+ data?: unknown;
27
+ /** Any other source option: lineMetrics, tolerance, promoteId, generateId, attribution, and so on. */
28
+ [option: string]: unknown;
29
+ }
30
+
31
+ /** A line layer specification. */
32
+ export interface LineLayerSpecification {
33
+ /** The layer id. */
34
+ id: string;
35
+ /** Always "line". */
36
+ type: 'line';
37
+ /** The source id. */
38
+ source?: string;
39
+ /** Paint properties. */
40
+ paint?: { [property: string]: unknown };
41
+ /** Layout properties. */
42
+ layout?: { [property: string]: unknown };
43
+ /** Any other layer option: filter, minzoom, maxzoom, metadata, slot, and so on. */
44
+ [option: string]: unknown;
45
+ }
46
+
47
+ /** A feature id: a string, or a number for feature state. */
48
+ export type FeatureId = string | number;
49
+
50
+ /** Options for polylineData: polytini's options plus the feature fields. */
51
+ export interface DataOptions<P = GeoJsonProperties> extends Options {
52
+ /** Properties for every line, or an array with one object per line. Default {}. */
53
+ properties?: P | P[];
54
+ /** Feature id for every line, or an array with one per line. Feature state needs numeric ids or promoteId. */
55
+ id?: FeatureId | FeatureId[];
56
+ /** Add a [west, south, east, north] bbox to each feature. Default false. */
57
+ bbox?: boolean;
58
+ }
59
+
60
+ /** Options for polylineSource: DataOptions plus extra source options. */
61
+ export interface SourceOptions<P = GeoJsonProperties> extends DataOptions<P> {
62
+ /** Other source options: lineMetrics, tolerance, promoteId, generateId, attribution, and so on. */
63
+ source?: { [option: string]: unknown };
64
+ }
65
+
66
+ /** Options for addPolylineLayer: SourceOptions plus the layer. */
67
+ export interface LayerOptions<P = GeoJsonProperties> extends SourceOptions<P> {
68
+ /** Merged into the line layer: paint, layout, filter, minzoom, maxzoom, metadata, or another id. */
69
+ layer?: { [option: string]: unknown };
70
+ /** The id of an existing layer to insert the new layer before. */
71
+ beforeId?: string;
72
+ }
73
+
74
+ /** A GeoJSON source specification whose data is a FeatureCollection of LineStrings. */
75
+ export interface PolylineSource<P = GeoJsonProperties> extends GeoJSONSourceSpecification {
76
+ /** Always "geojson". */
77
+ type: 'geojson';
78
+ /** One Feature per encoded line. */
79
+ data: FeatureCollection<LineString, P>;
80
+ }
81
+
82
+ /** A FeatureCollection<LineString> ([lng, lat]) with one Feature per encoded string. */
83
+ export function polylineData<P = GeoJsonProperties>(encoded: string | string[], options?: number | DataOptions<P>): FeatureCollection<LineString, P>;
84
+
85
+ /** `{ type: 'geojson', data }` for map.addSource or a style's sources. */
86
+ export function polylineSource<P = GeoJsonProperties>(encoded: string | string[], options?: number | SourceOptions<P>): PolylineSource<P>;
87
+
88
+ /** Adds a GeoJSON source and a line layer, both named `id`. Returns the map. */
89
+ export function addPolylineLayer<M extends MapLike, P = GeoJsonProperties>(map: M, id: string, encoded: string | string[], options?: number | LayerOptions<P>): M;
90
+
91
+ /** Replaces the data of the GeoJSON source `id` and returns what its setData returns. Throws a PolylineError if there is no such GeoJSON source. */
92
+ export function setPolylineData<P = GeoJsonProperties>(map: MapLike, id: string, encoded: string | string[], options?: number | DataOptions<P>): unknown;
@@ -1,23 +1,23 @@
1
- // Types for @duoquote/polytini/openlayers. Type-only imports: nothing from
2
- // ol is loaded at runtime, you pass its classes to createPolylineFormat.
3
- import type OlPolyline from 'ol/format/Polyline.js';
4
- import type { Options } from 'ol/format/Polyline.js';
5
- import type OlLineString from 'ol/geom/LineString.js';
6
-
7
- export type { Options };
8
-
9
- /** ol's classes, as imported from ol/format/Polyline.js and ol/geom/LineString.js. */
10
- export interface OpenLayersClasses {
11
- Polyline: typeof OlPolyline;
12
- LineString: typeof OlLineString;
13
- }
14
-
15
- /**
16
- * Makes a drop-in for ol/format/Polyline: the same constructor options
17
- * (factor, geometryLayout), methods and output, faster. Unlike ol's,
18
- * writeGeometry never changes the geometry it is given. Also takes the `ol`
19
- * namespace of the full build ({ format: { Polyline }, geom: { LineString } }).
20
- */
21
- export function createPolylineFormat(
22
- ol: OpenLayersClasses | { format: { Polyline: typeof OlPolyline }; geom: { LineString: typeof OlLineString } },
23
- ): typeof OlPolyline;
1
+ // Types for @duoquote/polytini/openlayers. Type-only imports: nothing from
2
+ // ol is loaded at runtime, you pass its classes to createPolylineFormat.
3
+ import type OlPolyline from 'ol/format/Polyline.js';
4
+ import type { Options } from 'ol/format/Polyline.js';
5
+ import type OlLineString from 'ol/geom/LineString.js';
6
+
7
+ export type { Options };
8
+
9
+ /** ol's classes, as imported from ol/format/Polyline.js and ol/geom/LineString.js. */
10
+ export interface OpenLayersClasses {
11
+ Polyline: typeof OlPolyline;
12
+ LineString: typeof OlLineString;
13
+ }
14
+
15
+ /**
16
+ * Makes a drop-in for ol/format/Polyline: the same constructor options
17
+ * (factor, geometryLayout), methods and output, faster. Unlike ol's,
18
+ * writeGeometry never changes the geometry it is given. Also takes the `ol`
19
+ * namespace of the full build ({ format: { Polyline }, geom: { LineString } }).
20
+ */
21
+ export function createPolylineFormat(
22
+ ol: OpenLayersClasses | { format: { Polyline: typeof OlPolyline }; geom: { LineString: typeof OlLineString } },
23
+ ): typeof OlPolyline;
@@ -0,0 +1,42 @@
1
+ // JSR copy of openlayers.d.ts. JSR builds its docs without node_modules, so
2
+ // ol's classes are described structurally: the factory takes your Polyline
3
+ // and LineString classes and returns a subclass of the Polyline class you
4
+ // passed, with its type. The npm package's openlayers.d.ts uses ol's own
5
+ // types.
6
+
7
+ /** ol/format/Polyline's constructor options. */
8
+ export interface Options {
9
+ /** The factor the coordinates were multiplied by. Default 1e5. */
10
+ factor?: number;
11
+ /** The geometry layout. Default "XY". */
12
+ geometryLayout?: 'XY' | 'XYZ' | 'XYM' | 'XYZM';
13
+ }
14
+
15
+ /** A Polyline format class: ol/format/Polyline or a subclass. */
16
+ export type PolylineClass = new (options?: Options) => object;
17
+
18
+ /** A LineString geometry class: ol/geom/LineString. */
19
+ export type LineStringClass = new (...args: never[]) => object;
20
+
21
+ /** ol's classes, as imported from ol/format/Polyline.js and ol/geom/LineString.js. */
22
+ export interface OpenLayersClasses<T extends PolylineClass> {
23
+ /** ol/format/Polyline's default export. */
24
+ Polyline: T;
25
+ /** ol/geom/LineString's default export. */
26
+ LineString: LineStringClass;
27
+ }
28
+
29
+ /** The full build's `ol` namespace. */
30
+ export interface OpenLayersNamespace<T extends PolylineClass> {
31
+ /** ol.format, with Polyline. */
32
+ format: { Polyline: T };
33
+ /** ol.geom, with LineString. */
34
+ geom: { LineString: LineStringClass };
35
+ }
36
+
37
+ /**
38
+ * Makes a drop-in for ol/format/Polyline: the same constructor options
39
+ * (factor, geometryLayout), methods and output, faster. Unlike ol's,
40
+ * writeGeometry never changes the geometry it is given.
41
+ */
42
+ export function createPolylineFormat<T extends PolylineClass>(ol: OpenLayersClasses<T> | OpenLayersNamespace<T>): T;
@@ -1,66 +1,70 @@
1
- // Option presets for routing engines that use the Google encoded polyline
2
- // format. Each one is a plain options object for encode, decode,
3
- // encodeFlat, decodeFlat, toGeoJSON and fromGeoJSON. See src/presets.js for
4
- // the sources behind every value.
5
-
6
- /** A 2D preset: precision and the order of the tuples you pass and get back. */
7
- export interface Preset2D<P extends number = number, O extends 'latlng' | 'lnglat' = 'latlng' | 'lnglat'> {
8
- readonly precision: P;
9
- readonly order: O;
10
- }
11
-
12
- /** A preset with a third value per point, scaled by `zFactor`. */
13
- export interface Preset3D<P extends number = number, O extends 'latlng' | 'lnglat' = 'latlng' | 'lnglat'> extends Preset2D<P, O> {
14
- readonly dimensions: 3;
15
- readonly zFactor: number;
16
- }
17
-
18
- /** Google Maps Platform: precision 5, [lat, lng]. */
19
- export declare const google: Preset2D<5, 'latlng'>;
20
- /** OSRM geometries=polyline: precision 5, [lng, lat] like its GeoJSON. */
21
- export declare const osrm: Preset2D<5, 'lnglat'>;
22
- /** OSRM geometries=polyline6: precision 6, [lng, lat]. */
23
- export declare const osrm6: Preset2D<6, 'lnglat'>;
24
- /** Valhalla shapes: precision 6, [lng, lat] like its format=osrm GeoJSON. */
25
- export declare const valhalla: Preset2D<6, 'lnglat'>;
26
- /** Stadia Maps routing (Valhalla): precision 6, [lng, lat]. */
27
- export declare const stadia: Preset2D<6, 'lnglat'>;
28
- /**
29
- * GraphHopper points_encoded=true: precision 5 (the default
30
- * points_encoded_multiplier), [lng, lat] like points_encoded=false.
31
- */
32
- export declare const graphhopper: Preset2D<5, 'lnglat'>;
33
- /** GraphHopper with elevation=true: [lng, lat, elevation in meters], elevation stored in centimeters. */
34
- export declare const graphhopper3d: Preset3D<5, 'lnglat'>;
35
- /** openrouteservice JSON geometry: precision 5, [lng, lat] like its GeoJSON. */
36
- export declare const openrouteservice: Preset2D<5, 'lnglat'>;
37
- /** openrouteservice with elevation=true: [lng, lat, elevation in meters], elevation stored in centimeters. */
38
- export declare const openrouteservice3d: Preset3D<5, 'lnglat'>;
39
- /** Mapbox Directions geometries=polyline: precision 5, [lng, lat]. */
40
- export declare const mapbox: Preset2D<5, 'lnglat'>;
41
- /** Mapbox Directions geometries=polyline6: precision 6, [lng, lat]. */
42
- export declare const mapbox6: Preset2D<6, 'lnglat'>;
43
- /** Strava map.polyline and summary_polyline: precision 5, [lat, lng] like its latlng stream. */
44
- export declare const strava: Preset2D<5, 'latlng'>;
45
- /** OpenTripPlanner legGeometry.points: precision 5, [lat, lng]. */
46
- export declare const otp: Preset2D<5, 'latlng'>;
47
-
48
- /** Every preset, keyed by its export name. */
49
- export declare const presets: {
50
- readonly google: typeof google;
51
- readonly osrm: typeof osrm;
52
- readonly osrm6: typeof osrm6;
53
- readonly valhalla: typeof valhalla;
54
- readonly stadia: typeof stadia;
55
- readonly graphhopper: typeof graphhopper;
56
- readonly graphhopper3d: typeof graphhopper3d;
57
- readonly openrouteservice: typeof openrouteservice;
58
- readonly openrouteservice3d: typeof openrouteservice3d;
59
- readonly mapbox: typeof mapbox;
60
- readonly mapbox6: typeof mapbox6;
61
- readonly strava: typeof strava;
62
- readonly otp: typeof otp;
63
- };
64
-
65
- /** The name of a preset in `presets`. */
66
- export type PresetName = keyof typeof presets;
1
+ // Option presets for routing engines that use the Google encoded polyline
2
+ // format. Each one is a plain options object for encode, decode,
3
+ // encodeFlat, decodeFlat, toGeoJSON and fromGeoJSON. See src/presets.js for
4
+ // the sources behind every value.
5
+
6
+ /** A 2D preset: precision and the order of the tuples you pass and get back. */
7
+ export interface Preset2D<P extends number = number, O extends 'latlng' | 'lnglat' = 'latlng' | 'lnglat'> {
8
+ /** Decimal places. */
9
+ readonly precision: P;
10
+ /** The tuple order. */
11
+ readonly order: O;
12
+ }
13
+
14
+ /** A preset with a third value per point, scaled by `zFactor`. */
15
+ export interface Preset3D<P extends number = number, O extends 'latlng' | 'lnglat' = 'latlng' | 'lnglat'> extends Preset2D<P, O> {
16
+ /** Three values per point. */
17
+ readonly dimensions: 3;
18
+ /** The factor of the third value. */
19
+ readonly zFactor: number;
20
+ }
21
+
22
+ /** Google Maps Platform: precision 5, [lat, lng]. */
23
+ export declare const google: Preset2D<5, 'latlng'>;
24
+ /** OSRM geometries=polyline: precision 5, [lng, lat] like its GeoJSON. */
25
+ export declare const osrm: Preset2D<5, 'lnglat'>;
26
+ /** OSRM geometries=polyline6: precision 6, [lng, lat]. */
27
+ export declare const osrm6: Preset2D<6, 'lnglat'>;
28
+ /** Valhalla shapes: precision 6, [lng, lat] like its format=osrm GeoJSON. */
29
+ export declare const valhalla: Preset2D<6, 'lnglat'>;
30
+ /** Stadia Maps routing (Valhalla): precision 6, [lng, lat]. */
31
+ export declare const stadia: Preset2D<6, 'lnglat'>;
32
+ /**
33
+ * GraphHopper points_encoded=true: precision 5 (the default
34
+ * points_encoded_multiplier), [lng, lat] like points_encoded=false.
35
+ */
36
+ export declare const graphhopper: Preset2D<5, 'lnglat'>;
37
+ /** GraphHopper with elevation=true: [lng, lat, elevation in meters], elevation stored in centimeters. */
38
+ export declare const graphhopper3d: Preset3D<5, 'lnglat'>;
39
+ /** openrouteservice JSON geometry: precision 5, [lng, lat] like its GeoJSON. */
40
+ export declare const openrouteservice: Preset2D<5, 'lnglat'>;
41
+ /** openrouteservice with elevation=true: [lng, lat, elevation in meters], elevation stored in centimeters. */
42
+ export declare const openrouteservice3d: Preset3D<5, 'lnglat'>;
43
+ /** Mapbox Directions geometries=polyline: precision 5, [lng, lat]. */
44
+ export declare const mapbox: Preset2D<5, 'lnglat'>;
45
+ /** Mapbox Directions geometries=polyline6: precision 6, [lng, lat]. */
46
+ export declare const mapbox6: Preset2D<6, 'lnglat'>;
47
+ /** Strava map.polyline and summary_polyline: precision 5, [lat, lng] like its latlng stream. */
48
+ export declare const strava: Preset2D<5, 'latlng'>;
49
+ /** OpenTripPlanner legGeometry.points: precision 5, [lat, lng]. */
50
+ export declare const otp: Preset2D<5, 'latlng'>;
51
+
52
+ /** Every preset, keyed by its export name. */
53
+ export declare const presets: {
54
+ readonly google: typeof google;
55
+ readonly osrm: typeof osrm;
56
+ readonly osrm6: typeof osrm6;
57
+ readonly valhalla: typeof valhalla;
58
+ readonly stadia: typeof stadia;
59
+ readonly graphhopper: typeof graphhopper;
60
+ readonly graphhopper3d: typeof graphhopper3d;
61
+ readonly openrouteservice: typeof openrouteservice;
62
+ readonly openrouteservice3d: typeof openrouteservice3d;
63
+ readonly mapbox: typeof mapbox;
64
+ readonly mapbox6: typeof mapbox6;
65
+ readonly strava: typeof strava;
66
+ readonly otp: typeof otp;
67
+ };
68
+
69
+ /** The name of a preset in `presets`. */
70
+ export type PresetName = keyof typeof presets;