@konfirm/geojson 1.0.0 → 1.0.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/README.md +7 -7
- package/dist/{geojson.d.ts → main.d.mts} +18 -79
- package/dist/main.d.ts +137 -15
- package/dist/main.global.js +853 -0
- package/dist/main.global.js.map +1 -0
- package/dist/main.js +824 -0
- package/dist/main.js.map +1 -0
- package/dist/main.mjs +772 -0
- package/dist/main.mjs.map +1 -0
- package/package.json +101 -63
- package/.editorconfig +0 -16
- package/.github/workflows/release.yml +0 -21
- package/.github/workflows/tests.yml +0 -56
- package/CHANGELOG.md +0 -21
- package/dist/Domain/Constants.d.ts +0 -5
- package/dist/Domain/GeoJSON/Concept/Altitude.d.ts +0 -3
- package/dist/Domain/GeoJSON/Concept/BoundingBox.d.ts +0 -6
- package/dist/Domain/GeoJSON/Concept/ExteriorRing.d.ts +0 -4
- package/dist/Domain/GeoJSON/Concept/GeoJSONObject.d.ts +0 -11
- package/dist/Domain/GeoJSON/Concept/InteriorRing.d.ts +0 -4
- package/dist/Domain/GeoJSON/Concept/Latitude.d.ts +0 -3
- package/dist/Domain/GeoJSON/Concept/LinearRing.d.ts +0 -4
- package/dist/Domain/GeoJSON/Concept/Longitude.d.ts +0 -3
- package/dist/Domain/GeoJSON/Concept/Position.d.ts +0 -7
- package/dist/Domain/GeoJSON/Feature.d.ts +0 -12
- package/dist/Domain/GeoJSON/FeatureCollection.d.ts +0 -8
- package/dist/Domain/GeoJSON/GeoJSON.d.ts +0 -7
- package/dist/Domain/GeoJSON/Geometry/LineString.d.ts +0 -11
- package/dist/Domain/GeoJSON/Geometry/MultiLineString.d.ts +0 -7
- package/dist/Domain/GeoJSON/Geometry/MultiPoint.d.ts +0 -8
- package/dist/Domain/GeoJSON/Geometry/MultiPolygon.d.ts +0 -7
- package/dist/Domain/GeoJSON/Geometry/Point.d.ts +0 -11
- package/dist/Domain/GeoJSON/Geometry/Polygon.d.ts +0 -11
- package/dist/Domain/GeoJSON/Geometry.d.ts +0 -9
- package/dist/Domain/GeoJSON/GeometryCollection.d.ts +0 -8
- package/dist/Domain/GeoJSON/GeometryObject.d.ts +0 -12
- package/dist/Domain/Guards/Number.d.ts +0 -3
- package/dist/Domain/Guards/Tuple.d.ts +0 -3
- package/dist/Domain/Iterator/IterablePair.d.ts +0 -32
- package/dist/Domain/Iterator/SimpleGeometry.d.ts +0 -90
- package/dist/Domain/Utility/Calculate.d.ts +0 -9
- package/dist/Domain/Utility/Distance.d.ts +0 -3
- package/dist/Domain/Utility/Intersect.d.ts +0 -2
- package/dist/Domain/Utility/Segments.d.ts +0 -2
- package/dist/Domain/Utility/Winding.d.ts +0 -3
- package/dist/geojson.cjs.js +0 -655
- package/dist/geojson.cjs.min.js +0 -1
- package/dist/geojson.es.js +0 -627
- package/dist/geojson.es.min.js +0 -1
- package/dist/geojson.js +0 -660
- package/dist/geojson.min.js +0 -1
- package/rollup.config.mjs +0 -43
- package/source/Domain/Constants.ts +0 -5
- package/source/Domain/GeoJSON/Concept/Altitude.ts +0 -9
- package/source/Domain/GeoJSON/Concept/BoundingBox.ts +0 -31
- package/source/Domain/GeoJSON/Concept/ExteriorRing.ts +0 -12
- package/source/Domain/GeoJSON/Concept/GeoJSONObject.ts +0 -23
- package/source/Domain/GeoJSON/Concept/InteriorRing.ts +0 -12
- package/source/Domain/GeoJSON/Concept/Latitude.ts +0 -7
- package/source/Domain/GeoJSON/Concept/LinearRing.ts +0 -14
- package/source/Domain/GeoJSON/Concept/Longitude.ts +0 -7
- package/source/Domain/GeoJSON/Concept/Position.ts +0 -18
- package/source/Domain/GeoJSON/Feature.ts +0 -24
- package/source/Domain/GeoJSON/FeatureCollection.ts +0 -16
- package/source/Domain/GeoJSON/GeoJSON.ts +0 -9
- package/source/Domain/GeoJSON/Geometry/LineString.ts +0 -12
- package/source/Domain/GeoJSON/Geometry/MultiLineString.ts +0 -9
- package/source/Domain/GeoJSON/Geometry/MultiPoint.ts +0 -10
- package/source/Domain/GeoJSON/Geometry/MultiPolygon.ts +0 -9
- package/source/Domain/GeoJSON/Geometry/Point.ts +0 -12
- package/source/Domain/GeoJSON/Geometry/Polygon.ts +0 -20
- package/source/Domain/GeoJSON/Geometry.ts +0 -11
- package/source/Domain/GeoJSON/GeometryCollection.ts +0 -23
- package/source/Domain/GeoJSON/GeometryObject.ts +0 -20
- package/source/Domain/Guards/Number.ts +0 -13
- package/source/Domain/Guards/Tuple.ts +0 -6
- package/source/Domain/Guards/Utility.ts +0 -1
- package/source/Domain/Iterator/IterablePair.ts +0 -47
- package/source/Domain/Iterator/SimpleGeometry.ts +0 -137
- package/source/Domain/Utility/Calculate.ts +0 -143
- package/source/Domain/Utility/Distance.ts +0 -56
- package/source/Domain/Utility/Intersect.ts +0 -42
- package/source/Domain/Utility/Numeric.ts +0 -8
- package/source/Domain/Utility/Segments.ts +0 -5
- package/source/Domain/Utility/Winding.ts +0 -19
- package/source/main.ts +0 -20
- package/test/Domain/GeoJSON/Concept/Altitude.ts +0 -58
- package/test/Domain/GeoJSON/Concept/BoundingBox.ts +0 -77
- package/test/Domain/GeoJSON/Concept/ExteriorRing.ts +0 -65
- package/test/Domain/GeoJSON/Concept/GeoJSONObject.ts +0 -56
- package/test/Domain/GeoJSON/Concept/InteriorRing.ts +0 -65
- package/test/Domain/GeoJSON/Concept/Latitude.ts +0 -56
- package/test/Domain/GeoJSON/Concept/LinearRing.ts +0 -63
- package/test/Domain/GeoJSON/Concept/Longitude.ts +0 -56
- package/test/Domain/GeoJSON/Concept/Position.ts +0 -56
- package/test/Domain/GeoJSON/Feature.ts +0 -9
- package/test/Domain/GeoJSON/FeatureCollection.ts +0 -9
- package/test/Domain/GeoJSON/GeoJSON.ts +0 -21
- package/test/Domain/GeoJSON/Geometry/LineString.ts +0 -11
- package/test/Domain/GeoJSON/Geometry/MultiLineString.ts +0 -11
- package/test/Domain/GeoJSON/Geometry/MultiPoint.ts +0 -11
- package/test/Domain/GeoJSON/Geometry/MultiPolygon.ts +0 -11
- package/test/Domain/GeoJSON/Geometry/Point.ts +0 -11
- package/test/Domain/GeoJSON/Geometry/Polygon.ts +0 -11
- package/test/Domain/GeoJSON/Geometry.ts +0 -9
- package/test/Domain/GeoJSON/GeometryCollection.ts +0 -9
- package/test/Domain/GeoJSON/GeometryObject.ts +0 -4
- package/test/Domain/Guards/Number.ts +0 -49
- package/test/Domain/Guards/Tuple.ts +0 -27
- package/test/Domain/Iterator/IterablePair.ts +0 -203
- package/test/Domain/Iterator/SimpleGeometry.ts +0 -195
- package/test/Domain/Utility/Calculate.ts +0 -178
- package/test/Domain/Utility/Distance.ts +0 -19
- package/test/Domain/Utility/Intersect.ts +0 -54
- package/test/Domain/Utility/Numeric.ts +0 -30
- package/test/Domain/Utility/Winding.ts +0 -52
- package/test/README.ts +0 -123
- package/test/data/Distance.ts +0 -51
- package/test/data/HolySee.ts +0 -74
- package/test/data/Intersect.ts +0 -300
- package/test/data/Italy.ts +0 -2883
- package/test/data/SanMarino.ts +0 -83
- package/test/data/Shapes.ts +0 -107
- package/test/helper/geometry.ts +0 -76
- package/test/helper/malform.ts +0 -82
- package/test/main.ts +0 -4
- package/tsconfig.json +0 -12
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The `isStrict*` variants of the type guards also validate the following:
|
|
|
33
33
|
- `Latitude` is a number in the range (inclusive) `-90..90`
|
|
34
34
|
- `Altitude` is a number in the range (inclusive) `-6371008.7714..20180000` (Earth center(-ish) up to the GPS satelite distance)
|
|
35
35
|
- `Polygon` "LinearRing" are closed (first and last `Position` are identical)
|
|
36
|
-
-
|
|
36
|
+
- ~~`Polygon` "LinearRing" have the correct winding (counterclockwise for exterior rings (outline), clockwise for interior rings (holes))~~ _(not yet enforced — planned for v2)_
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
| type | guard | strict guard | description |
|
|
@@ -107,7 +107,7 @@ import { distance, Feature } from '@konfirm/geojson';
|
|
|
107
107
|
const a: Feature = {
|
|
108
108
|
type: 'Feature',
|
|
109
109
|
properties: {
|
|
110
|
-
name: 'Schiphol
|
|
110
|
+
name: 'Schiphol Airport, Amsterdam',
|
|
111
111
|
},
|
|
112
112
|
geometry: {
|
|
113
113
|
type: 'Point',
|
|
@@ -125,15 +125,15 @@ import { distance, Feature } from '@konfirm/geojson';
|
|
|
125
125
|
},
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
console.log(distance(a, b));
|
|
129
|
-
console.log(distance(a, b, '
|
|
130
|
-
console.log(distance(a, b, 'haversine'); // 5847546.425707642
|
|
131
|
-
console.log(distance(a, b, 'vincenty'); // 5863355.371234315
|
|
128
|
+
console.log(distance(a, b)); // 8829424.604594177 ('cartesian' is the default)
|
|
129
|
+
console.log(distance(a, b, 'cartesian')); // 8829424.604594177
|
|
130
|
+
console.log(distance(a, b, 'haversine')); // 5847546.425707642
|
|
131
|
+
console.log(distance(a, b, 'vincenty')); // 5863355.371234315
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
### SimpleGeometryIterator
|
|
135
135
|
|
|
136
|
-
The SimpleGeometryIterator class is a convenience helper utility which
|
|
136
|
+
The SimpleGeometryIterator class is a convenience helper utility which yields all simple Geometric shapes (`Point`, `LineString`, `Polygon`) from any GeoJSON object. Using a SimpleGeometryIterator allows you to focus on just implementing logic for the simple Geometric shapes whilst supporting any combination of GeoJSON objects as input.
|
|
137
137
|
|
|
138
138
|
| input type | yields type(s) | description |
|
|
139
139
|
| -------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as _konfirm_guard from '@konfirm/guard';
|
|
2
|
+
import { Guard } from '@konfirm/guard';
|
|
2
3
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
type Longitude = number;
|
|
4
|
+
type Altitude = number;
|
|
6
5
|
|
|
7
6
|
type Latitude = number;
|
|
8
7
|
|
|
9
|
-
type
|
|
8
|
+
type Longitude = number;
|
|
9
|
+
|
|
10
|
+
type Position = [Longitude, Latitude, Altitude?];
|
|
11
|
+
declare const isPosition: _konfirm_guard.Guard<Position>;
|
|
12
|
+
declare const isStrictPosition: _konfirm_guard.Guard<Position>;
|
|
10
13
|
|
|
11
14
|
type BoundingBox = [Longitude, Latitude, Altitude, Longitude, Latitude, Altitude] | [Longitude, Latitude, Longitude, Latitude];
|
|
12
15
|
|
|
@@ -17,10 +20,6 @@ type GeoJSONBase = {
|
|
|
17
20
|
};
|
|
18
21
|
type GeoJSONObject<T extends GeoJSONBase = GeoJSONBase> = GeoJSONBase & T;
|
|
19
22
|
|
|
20
|
-
type Position = [Longitude, Latitude, Altitude?];
|
|
21
|
-
declare const isPosition: _konfirm_guard.Guard<Position>;
|
|
22
|
-
declare const isStrictPosition: _konfirm_guard.Guard<Position>;
|
|
23
|
-
|
|
24
23
|
type GeometryBase = GeoJSONObject & {
|
|
25
24
|
coordinates: Array<unknown>;
|
|
26
25
|
};
|
|
@@ -38,8 +37,8 @@ declare const isPoint: Guard<Point>;
|
|
|
38
37
|
declare const isStrictPoint: Guard<Point>;
|
|
39
38
|
|
|
40
39
|
type MultiPoint = MultiGeometryObject<Point>;
|
|
41
|
-
declare const isMultiPoint:
|
|
42
|
-
declare const isStrictMultiPoint:
|
|
40
|
+
declare const isMultiPoint: Guard<MultiPoint>;
|
|
41
|
+
declare const isStrictMultiPoint: Guard<MultiPoint>;
|
|
43
42
|
|
|
44
43
|
type LineString = GeometryObject<{
|
|
45
44
|
type: 'LineString';
|
|
@@ -77,8 +76,8 @@ type GeometryCollection = GeoJSONObject<{
|
|
|
77
76
|
type: 'GeometryCollection';
|
|
78
77
|
geometries: Array<Geometry | GeometryCollection>;
|
|
79
78
|
}>;
|
|
80
|
-
declare function isGeometryCollection(value:
|
|
81
|
-
declare function isStrictGeometryCollection(value:
|
|
79
|
+
declare function isGeometryCollection(value: unknown): value is GeometryCollection;
|
|
80
|
+
declare function isStrictGeometryCollection(value: unknown): value is GeometryCollection;
|
|
82
81
|
|
|
83
82
|
type Feature = GeoJSONObject<{
|
|
84
83
|
type: 'Feature';
|
|
@@ -101,12 +100,6 @@ type GeoJSON = Geometry | GeometryCollection | Feature | FeatureCollection;
|
|
|
101
100
|
declare const isGeoJSON: _konfirm_guard.Guard<GeoJSON>;
|
|
102
101
|
declare const isStrictGeoJSON: _konfirm_guard.Guard<GeoJSON>;
|
|
103
102
|
|
|
104
|
-
declare function intersect(a: GeoJSON, b: GeoJSON): boolean;
|
|
105
|
-
|
|
106
|
-
type PointToPointCalculation = 'cartesian' | 'haversine' | 'vincenty' | ((a: Point['coordinates'], b: Point['coordinates']) => number);
|
|
107
|
-
|
|
108
|
-
declare function distance(a: GeoJSON, b: GeoJSON, calculation?: PointToPointCalculation): number;
|
|
109
|
-
|
|
110
103
|
type SimpleGeometry = Point | LineString | Polygon;
|
|
111
104
|
/**
|
|
112
105
|
* Iterator class to turn any GeoJSON structure into one or more SimpleGeometry (Point | LineString | Polygon) objects
|
|
@@ -116,12 +109,6 @@ type SimpleGeometry = Point | LineString | Polygon;
|
|
|
116
109
|
*/
|
|
117
110
|
declare class SimpleGeometryIterator {
|
|
118
111
|
private readonly inputs;
|
|
119
|
-
/**
|
|
120
|
-
* Creates an instance of SimpleGeometryIterator
|
|
121
|
-
*
|
|
122
|
-
* @param {...[GeoJSON, ...Array<GeoJSON>]} inputs
|
|
123
|
-
* @memberof SimpleGeometryIterator
|
|
124
|
-
*/
|
|
125
112
|
constructor(...inputs: [GeoJSON, ...Array<GeoJSON>]);
|
|
126
113
|
/**
|
|
127
114
|
* Generator yielding all SimpleGeometry objects from the provided GeoJSON structure(s)
|
|
@@ -139,60 +126,12 @@ declare class SimpleGeometryIterator {
|
|
|
139
126
|
* @memberof SimpleGeometryIterator
|
|
140
127
|
*/
|
|
141
128
|
private unwrap;
|
|
142
|
-
/**
|
|
143
|
-
* Generate the geometries in a GeometryCollection
|
|
144
|
-
*
|
|
145
|
-
* @private
|
|
146
|
-
* @param {GeometryCollection} { geometries }
|
|
147
|
-
* @return {*} {Iterable<SimpleGeometry>}
|
|
148
|
-
* @memberof SimpleGeometryIterator
|
|
149
|
-
*/
|
|
150
|
-
private GeometryCollection;
|
|
151
|
-
/**
|
|
152
|
-
* Generate the geometries of the Feature object(s) in a FeatureCollection
|
|
153
|
-
*
|
|
154
|
-
* @private
|
|
155
|
-
* @param {FeatureCollection} { features }
|
|
156
|
-
* @return {*} {Iterable<SimpleGeometry>}
|
|
157
|
-
* @memberof SimpleGeometryIterator
|
|
158
|
-
*/
|
|
159
|
-
private FeatureCollection;
|
|
160
|
-
/**
|
|
161
|
-
* Generate the geometry of a Feature object
|
|
162
|
-
*
|
|
163
|
-
* @private
|
|
164
|
-
* @param {Feature} { geometry }
|
|
165
|
-
* @return {*} {Iterable<SimpleGeometry>}
|
|
166
|
-
* @memberof SimpleGeometryIterator
|
|
167
|
-
*/
|
|
168
|
-
private Feature;
|
|
169
|
-
/**
|
|
170
|
-
* Generate Point objects from a MultiPoint object
|
|
171
|
-
*
|
|
172
|
-
* @private
|
|
173
|
-
* @param {MultiPoint} multi
|
|
174
|
-
* @return {*} {Iterable<Point>}
|
|
175
|
-
* @memberof SimpleGeometryIterator
|
|
176
|
-
*/
|
|
177
|
-
private MultiPoint;
|
|
178
|
-
/**
|
|
179
|
-
* Generate LineString objects from a MultiLineString object
|
|
180
|
-
*
|
|
181
|
-
* @private
|
|
182
|
-
* @param {MultiLineString} multi
|
|
183
|
-
* @return {*} {Iterable<LineString>}
|
|
184
|
-
* @memberof SimpleGeometryIterator
|
|
185
|
-
*/
|
|
186
|
-
private MultiLineString;
|
|
187
|
-
/**
|
|
188
|
-
* Generate Polygon objects from a MultiPolygon object
|
|
189
|
-
*
|
|
190
|
-
* @private
|
|
191
|
-
* @param {MultiPolygon} multi
|
|
192
|
-
* @return {*} {Iterable<Polygon>}
|
|
193
|
-
* @memberof SimpleGeometryIterator
|
|
194
|
-
*/
|
|
195
|
-
private MultiPolygon;
|
|
196
129
|
}
|
|
197
130
|
|
|
198
|
-
|
|
131
|
+
type PointToPointCalculation = 'cartesian' | 'haversine' | 'vincenty' | ((a: Point['coordinates'], b: Point['coordinates']) => number);
|
|
132
|
+
|
|
133
|
+
declare function distance(a: GeoJSON, b: GeoJSON, calculation?: PointToPointCalculation): number;
|
|
134
|
+
|
|
135
|
+
declare function intersect(a: GeoJSON, b: GeoJSON): boolean;
|
|
136
|
+
|
|
137
|
+
export { type Feature, type FeatureCollection, type GeoJSON, type Geometry, type GeometryCollection, type LineString, type MultiLineString, type MultiPoint, type MultiPolygon, type Point, type Polygon, type Position, SimpleGeometryIterator, distance, intersect, isFeature, isFeatureCollection, isGeoJSON, isGeometry, isGeometryCollection, isLineString, isMultiLineString, isMultiPoint, isMultiPolygon, isPoint, isPolygon, isPosition, isStrictFeature, isStrictFeatureCollection, isStrictGeoJSON, isStrictGeometry, isStrictGeometryCollection, isStrictLineString, isStrictMultiLineString, isStrictMultiPoint, isStrictMultiPolygon, isStrictPoint, isStrictPolygon, isStrictPosition };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,15 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import * as _konfirm_guard from '@konfirm/guard';
|
|
2
|
+
import { Guard } from '@konfirm/guard';
|
|
3
|
+
|
|
4
|
+
type Altitude = number;
|
|
5
|
+
|
|
6
|
+
type Latitude = number;
|
|
7
|
+
|
|
8
|
+
type Longitude = number;
|
|
9
|
+
|
|
10
|
+
type Position = [Longitude, Latitude, Altitude?];
|
|
11
|
+
declare const isPosition: _konfirm_guard.Guard<Position>;
|
|
12
|
+
declare const isStrictPosition: _konfirm_guard.Guard<Position>;
|
|
13
|
+
|
|
14
|
+
type BoundingBox = [Longitude, Latitude, Altitude, Longitude, Latitude, Altitude] | [Longitude, Latitude, Longitude, Latitude];
|
|
15
|
+
|
|
16
|
+
type GeoJSONBase = {
|
|
17
|
+
type: string;
|
|
18
|
+
bbox?: BoundingBox;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
type GeoJSONObject<T extends GeoJSONBase = GeoJSONBase> = GeoJSONBase & T;
|
|
22
|
+
|
|
23
|
+
type GeometryBase = GeoJSONObject & {
|
|
24
|
+
coordinates: Array<unknown>;
|
|
25
|
+
};
|
|
26
|
+
type GeometryObject<T extends GeometryBase> = Omit<GeometryBase, 'coordinates'> & T;
|
|
27
|
+
type MultiGeometryObject<T extends GeometryBase> = GeometryObject<{
|
|
28
|
+
type: `Multi${T['type']}`;
|
|
29
|
+
coordinates: Array<T['coordinates']>;
|
|
30
|
+
}>;
|
|
31
|
+
|
|
32
|
+
type Point = GeometryObject<{
|
|
33
|
+
type: 'Point';
|
|
34
|
+
coordinates: Position;
|
|
35
|
+
}>;
|
|
36
|
+
declare const isPoint: Guard<Point>;
|
|
37
|
+
declare const isStrictPoint: Guard<Point>;
|
|
38
|
+
|
|
39
|
+
type MultiPoint = MultiGeometryObject<Point>;
|
|
40
|
+
declare const isMultiPoint: Guard<MultiPoint>;
|
|
41
|
+
declare const isStrictMultiPoint: Guard<MultiPoint>;
|
|
42
|
+
|
|
43
|
+
type LineString = GeometryObject<{
|
|
44
|
+
type: 'LineString';
|
|
45
|
+
coordinates: MultiPoint['coordinates'];
|
|
46
|
+
}>;
|
|
47
|
+
declare const isLineString: Guard<LineString>;
|
|
48
|
+
declare const isStrictLineString: Guard<LineString>;
|
|
49
|
+
|
|
50
|
+
type MultiLineString = MultiGeometryObject<LineString>;
|
|
51
|
+
declare const isMultiLineString: _konfirm_guard.Guard<MultiLineString>;
|
|
52
|
+
declare const isStrictMultiLineString: _konfirm_guard.Guard<MultiLineString>;
|
|
53
|
+
|
|
54
|
+
type LinearRing = Array<Position>;
|
|
55
|
+
|
|
56
|
+
type ExteriorRing = LinearRing;
|
|
57
|
+
|
|
58
|
+
type InteriorRing = LinearRing;
|
|
59
|
+
|
|
60
|
+
type Polygon = GeometryObject<{
|
|
61
|
+
type: 'Polygon';
|
|
62
|
+
coordinates: [ExteriorRing, ...Array<InteriorRing>];
|
|
63
|
+
}>;
|
|
64
|
+
declare const isPolygon: _konfirm_guard.Guard<Polygon>;
|
|
65
|
+
declare const isStrictPolygon: _konfirm_guard.Guard<Polygon>;
|
|
66
|
+
|
|
67
|
+
type MultiPolygon = MultiGeometryObject<Polygon>;
|
|
68
|
+
declare const isMultiPolygon: _konfirm_guard.Guard<MultiPolygon>;
|
|
69
|
+
declare const isStrictMultiPolygon: _konfirm_guard.Guard<MultiPolygon>;
|
|
70
|
+
|
|
71
|
+
type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;
|
|
72
|
+
declare const isGeometry: _konfirm_guard.Guard<Geometry>;
|
|
73
|
+
declare const isStrictGeometry: _konfirm_guard.Guard<Geometry>;
|
|
74
|
+
|
|
75
|
+
type GeometryCollection = GeoJSONObject<{
|
|
76
|
+
type: 'GeometryCollection';
|
|
77
|
+
geometries: Array<Geometry | GeometryCollection>;
|
|
78
|
+
}>;
|
|
79
|
+
declare function isGeometryCollection(value: unknown): value is GeometryCollection;
|
|
80
|
+
declare function isStrictGeometryCollection(value: unknown): value is GeometryCollection;
|
|
81
|
+
|
|
82
|
+
type Feature = GeoJSONObject<{
|
|
83
|
+
type: 'Feature';
|
|
84
|
+
geometry: Geometry | GeometryCollection;
|
|
85
|
+
properties: {
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
} | null;
|
|
88
|
+
}>;
|
|
89
|
+
declare const isFeature: _konfirm_guard.Guard<Feature>;
|
|
90
|
+
declare const isStrictFeature: _konfirm_guard.Guard<Feature>;
|
|
91
|
+
|
|
92
|
+
type FeatureCollection = GeoJSONObject<{
|
|
93
|
+
type: 'FeatureCollection';
|
|
94
|
+
features: Array<Feature>;
|
|
95
|
+
}>;
|
|
96
|
+
declare const isFeatureCollection: _konfirm_guard.Guard<FeatureCollection>;
|
|
97
|
+
declare const isStrictFeatureCollection: _konfirm_guard.Guard<FeatureCollection>;
|
|
98
|
+
|
|
99
|
+
type GeoJSON = Geometry | GeometryCollection | Feature | FeatureCollection;
|
|
100
|
+
declare const isGeoJSON: _konfirm_guard.Guard<GeoJSON>;
|
|
101
|
+
declare const isStrictGeoJSON: _konfirm_guard.Guard<GeoJSON>;
|
|
102
|
+
|
|
103
|
+
type SimpleGeometry = Point | LineString | Polygon;
|
|
104
|
+
/**
|
|
105
|
+
* Iterator class to turn any GeoJSON structure into one or more SimpleGeometry (Point | LineString | Polygon) objects
|
|
106
|
+
*
|
|
107
|
+
* @export
|
|
108
|
+
* @class SimpleGeometryIterator
|
|
109
|
+
*/
|
|
110
|
+
declare class SimpleGeometryIterator {
|
|
111
|
+
private readonly inputs;
|
|
112
|
+
constructor(...inputs: [GeoJSON, ...Array<GeoJSON>]);
|
|
113
|
+
/**
|
|
114
|
+
* Generator yielding all SimpleGeometry objects from the provided GeoJSON structure(s)
|
|
115
|
+
*
|
|
116
|
+
* @return {*} {Iterator<SimpleGeometry>}
|
|
117
|
+
* @memberof SimpleGeometryIterator
|
|
118
|
+
*/
|
|
119
|
+
[Symbol.iterator](): Iterator<SimpleGeometry>;
|
|
120
|
+
/**
|
|
121
|
+
* unwrap any GeoJSON object into one or more SimpleGeometry object
|
|
122
|
+
*
|
|
123
|
+
* @private
|
|
124
|
+
* @param {GeoJSON} geo
|
|
125
|
+
* @return {*} {Iterable<SimpleGeometry>}
|
|
126
|
+
* @memberof SimpleGeometryIterator
|
|
127
|
+
*/
|
|
128
|
+
private unwrap;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
type PointToPointCalculation = 'cartesian' | 'haversine' | 'vincenty' | ((a: Point['coordinates'], b: Point['coordinates']) => number);
|
|
132
|
+
|
|
133
|
+
declare function distance(a: GeoJSON, b: GeoJSON, calculation?: PointToPointCalculation): number;
|
|
134
|
+
|
|
135
|
+
declare function intersect(a: GeoJSON, b: GeoJSON): boolean;
|
|
136
|
+
|
|
137
|
+
export { type Feature, type FeatureCollection, type GeoJSON, type Geometry, type GeometryCollection, type LineString, type MultiLineString, type MultiPoint, type MultiPolygon, type Point, type Polygon, type Position, SimpleGeometryIterator, distance, intersect, isFeature, isFeatureCollection, isGeoJSON, isGeometry, isGeometryCollection, isLineString, isMultiLineString, isMultiPoint, isMultiPolygon, isPoint, isPolygon, isPosition, isStrictFeature, isStrictFeatureCollection, isStrictGeoJSON, isStrictGeometry, isStrictGeometryCollection, isStrictLineString, isStrictMultiLineString, isStrictMultiPoint, isStrictMultiPolygon, isStrictPoint, isStrictPolygon, isStrictPosition };
|