@konfirm/geojson 1.0.0 → 1.0.1-beta.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 +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/test/data/SanMarino.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Feature, MultiPoint, Polygon } from '../../source/main';
|
|
2
|
-
|
|
3
|
-
export const coordinates: MultiPoint['coordinates'] = [
|
|
4
|
-
[12.514457702636719, 43.990838502564706],
|
|
5
|
-
[12.515830993652344, 43.9845395701046],
|
|
6
|
-
[12.513084411621094, 43.98379847528122],
|
|
7
|
-
[12.510337829589844, 43.98033991044406],
|
|
8
|
-
[12.512741088867188, 43.97255740289798],
|
|
9
|
-
[12.507076263427734, 43.97070427457235],
|
|
10
|
-
[12.507076263427734, 43.96390897601157],
|
|
11
|
-
[12.508964538574219, 43.96292050418772],
|
|
12
|
-
[12.506217956542969, 43.957854327949335],
|
|
13
|
-
[12.51394271850586, 43.950192460407486],
|
|
14
|
-
[12.51617431640625, 43.94030472005806],
|
|
15
|
-
[12.506904602050781, 43.93301145781231],
|
|
16
|
-
[12.503814697265623, 43.92757183247526],
|
|
17
|
-
[12.503128051757812, 43.92336814487696],
|
|
18
|
-
[12.498149871826172, 43.922378998741294],
|
|
19
|
-
[12.49214172363281, 43.91854590212644],
|
|
20
|
-
[12.492656707763672, 43.91557817385638],
|
|
21
|
-
[12.493515014648438, 43.91026062387522],
|
|
22
|
-
[12.495231628417969, 43.90939493123444],
|
|
23
|
-
[12.492828369140625, 43.90667410096243],
|
|
24
|
-
[12.486648559570312, 43.89628433227728],
|
|
25
|
-
[12.469310760498047, 43.89616063363387],
|
|
26
|
-
[12.46192932128906, 43.89393401411192],
|
|
27
|
-
[12.456607818603516, 43.89368660680359],
|
|
28
|
-
[12.449913024902344, 43.896408030663714],
|
|
29
|
-
[12.447338104248045, 43.902592622357595],
|
|
30
|
-
[12.442874908447266, 43.90543731881505],
|
|
31
|
-
[12.438926696777344, 43.90494259876104],
|
|
32
|
-
[12.43377685546875, 43.90271630763886],
|
|
33
|
-
[12.428970336914062, 43.90345841393034],
|
|
34
|
-
[12.424678802490234, 43.902592622357595],
|
|
35
|
-
[12.42279052734375, 43.901232067303724],
|
|
36
|
-
[12.413349151611328, 43.900489933260076],
|
|
37
|
-
[12.408885955810547, 43.90209787866277],
|
|
38
|
-
[12.412147521972656, 43.90902391624818],
|
|
39
|
-
[12.408199310302734, 43.921142542944274],
|
|
40
|
-
[12.409915924072266, 43.92547002580864],
|
|
41
|
-
[12.41506576538086, 43.929302676319814],
|
|
42
|
-
[12.413177490234373, 43.93449490565162],
|
|
43
|
-
[12.41180419921875, 43.93634916341316],
|
|
44
|
-
[12.41231918334961, 43.93783252799222],
|
|
45
|
-
[12.404937744140625, 43.94215879665083],
|
|
46
|
-
[12.405109405517578, 43.94870940420277],
|
|
47
|
-
[12.403221130371094, 43.95315846180105],
|
|
48
|
-
[12.404594421386719, 43.95563001655701],
|
|
49
|
-
[12.408714294433594, 43.95328204198018],
|
|
50
|
-
[12.414722442626953, 43.95278771972178],
|
|
51
|
-
[12.420043945312498, 43.95773075727856],
|
|
52
|
-
[12.435493469238281, 43.956989327857265],
|
|
53
|
-
[12.440643310546875, 43.959460723283826],
|
|
54
|
-
[12.446479797363281, 43.965762316351324],
|
|
55
|
-
[12.452144622802733, 43.96885108842451],
|
|
56
|
-
[12.460556030273438, 43.973298638037974],
|
|
57
|
-
[12.470340728759766, 43.977869383633376],
|
|
58
|
-
[12.479782104492188, 43.98071048059949],
|
|
59
|
-
[12.486820220947266, 43.981822177188285],
|
|
60
|
-
[12.490596771240234, 43.982933852960805],
|
|
61
|
-
[12.493000030517578, 43.98330440692579],
|
|
62
|
-
[12.496948242187498, 43.98676279906447],
|
|
63
|
-
[12.499523162841797, 43.9862687553803],
|
|
64
|
-
[12.502613067626953, 43.98762736561758],
|
|
65
|
-
[12.504329681396484, 43.99046799562939],
|
|
66
|
-
[12.506904602050781, 43.99145600898366],
|
|
67
|
-
[12.509136199951172, 43.99195000949295],
|
|
68
|
-
[12.510337829589844, 43.99120900718707],
|
|
69
|
-
];
|
|
70
|
-
export const polygon: Polygon = {
|
|
71
|
-
type: 'Polygon',
|
|
72
|
-
coordinates: [coordinates.concat([coordinates[0]])],
|
|
73
|
-
};
|
|
74
|
-
export const feature: Feature = {
|
|
75
|
-
type: 'Feature',
|
|
76
|
-
properties: {
|
|
77
|
-
name: 'Palazzo Pubblico'
|
|
78
|
-
},
|
|
79
|
-
geometry: {
|
|
80
|
-
type: 'Point',
|
|
81
|
-
coordinates: [12.44632724672556, 43.9367772279862]
|
|
82
|
-
}
|
|
83
|
-
}
|
package/test/data/Shapes.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Point } from "../../source/Domain/GeoJSON/Geometry/Point";
|
|
2
|
-
import { MultiPoint } from "../../source/Domain/GeoJSON/Geometry/MultiPoint";
|
|
3
|
-
import { LineString } from "../../source/Domain/GeoJSON/Geometry/LineString";
|
|
4
|
-
import { MultiLineString } from "../../source/Domain/GeoJSON/Geometry/MultiLineString";
|
|
5
|
-
import { Polygon } from "../../source/Domain/GeoJSON/Geometry/Polygon";
|
|
6
|
-
import { MultiPolygon } from "../../source/Domain/GeoJSON/Geometry/MultiPolygon";
|
|
7
|
-
import { GeometryCollection } from "../../source/Domain/GeoJSON/GeometryCollection";
|
|
8
|
-
import { Feature } from "../../source/Domain/GeoJSON/Feature";
|
|
9
|
-
import { FeatureCollection } from "../../source/Domain/GeoJSON/FeatureCollection";
|
|
10
|
-
|
|
11
|
-
export const point: Point = {
|
|
12
|
-
type: 'Point',
|
|
13
|
-
coordinates: [5.911738872528076, 51.97496770044958]
|
|
14
|
-
};
|
|
15
|
-
export const multipoint: MultiPoint = {
|
|
16
|
-
type: 'MultiPoint',
|
|
17
|
-
coordinates: [
|
|
18
|
-
[5.90837001800537, 51.97143834257323],
|
|
19
|
-
[5.911073684692383, 51.9743596661051],
|
|
20
|
-
[5.912296772003173, 51.97550963714963],
|
|
21
|
-
[5.913434028625488, 51.97669923130859],
|
|
22
|
-
[5.914957523345947, 51.97794166259651],
|
|
23
|
-
],
|
|
24
|
-
};
|
|
25
|
-
export const linestring: LineString = {
|
|
26
|
-
type: 'LineString',
|
|
27
|
-
coordinates: multipoint.coordinates,
|
|
28
|
-
}
|
|
29
|
-
export const multilinestring: MultiLineString = {
|
|
30
|
-
type: 'MultiLineString',
|
|
31
|
-
coordinates: [
|
|
32
|
-
linestring.coordinates,
|
|
33
|
-
[
|
|
34
|
-
[5.9014177322387695, 51.9811401037613],
|
|
35
|
-
[5.901675224304199, 51.98059823516843],
|
|
36
|
-
[5.899229049682617, 51.97844391227356],
|
|
37
|
-
[5.898284912109375, 51.97762444937298],
|
|
38
|
-
]
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
export const polygon: Polygon = {
|
|
42
|
-
type: 'Polygon',
|
|
43
|
-
coordinates: [
|
|
44
|
-
[
|
|
45
|
-
[5.913562774658203, 51.981827342304214],
|
|
46
|
-
[5.913991928100586, 51.981060806327854],
|
|
47
|
-
[5.914270877838134, 51.98021495830347],
|
|
48
|
-
[5.9151506423950195, 51.9792369266152],
|
|
49
|
-
[5.9154510498046875, 51.97985811137786],
|
|
50
|
-
[5.915493965148926, 51.98059823516843],
|
|
51
|
-
[5.9151506423950195, 51.98143085981622],
|
|
52
|
-
[5.914850234985352, 51.98211809389835],
|
|
53
|
-
[5.913562774658203, 51.981827342304214]
|
|
54
|
-
]
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
export const multipolygon: MultiPolygon = {
|
|
58
|
-
type: 'MultiPolygon',
|
|
59
|
-
coordinates: [[
|
|
60
|
-
[
|
|
61
|
-
[5.913562774658203, 51.981827342304214],
|
|
62
|
-
[5.913991928100586, 51.981060806327854],
|
|
63
|
-
[5.914270877838134, 51.98021495830347],
|
|
64
|
-
[5.9151506423950195, 51.9792369266152],
|
|
65
|
-
[5.9154510498046875, 51.97985811137786],
|
|
66
|
-
[5.915493965148926, 51.98059823516843],
|
|
67
|
-
[5.9151506423950195, 51.98143085981622],
|
|
68
|
-
[5.914850234985352, 51.98211809389835],
|
|
69
|
-
[5.913562774658203, 51.981827342304214]
|
|
70
|
-
]
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[5.911159515380859, 51.98404757938432],
|
|
75
|
-
[5.911331176757812, 51.98421937885664],
|
|
76
|
-
[5.910944938659668, 51.984364747126214],
|
|
77
|
-
[5.908627510070801, 51.98458940625121],
|
|
78
|
-
[5.906803607940674, 51.98449689968914],
|
|
79
|
-
[5.90665340423584, 51.98433831656684],
|
|
80
|
-
[5.906867980957031, 51.98423259417338],
|
|
81
|
-
[5.907554626464844, 51.98439117767001],
|
|
82
|
-
[5.908541679382324, 51.984364747126214],
|
|
83
|
-
[5.90989351272583, 51.98427224010017],
|
|
84
|
-
[5.911159515380859, 51.98404757938432]
|
|
85
|
-
]
|
|
86
|
-
]]
|
|
87
|
-
};
|
|
88
|
-
export const geometrycollection: GeometryCollection = {
|
|
89
|
-
type: 'GeometryCollection',
|
|
90
|
-
geometries: [
|
|
91
|
-
point,
|
|
92
|
-
multipoint,
|
|
93
|
-
linestring,
|
|
94
|
-
multilinestring,
|
|
95
|
-
polygon,
|
|
96
|
-
multipolygon,
|
|
97
|
-
],
|
|
98
|
-
};
|
|
99
|
-
export const feature: Feature = {
|
|
100
|
-
type: 'Feature',
|
|
101
|
-
properties: null,
|
|
102
|
-
geometry: point,
|
|
103
|
-
}
|
|
104
|
-
export const featurecollection: FeatureCollection = {
|
|
105
|
-
type: 'FeatureCollection',
|
|
106
|
-
features: geometrycollection.geometries.map((geometry) => ({ type: 'Feature', properties: null, geometry })),
|
|
107
|
-
};
|
package/test/helper/geometry.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import test from 'tape';
|
|
2
|
-
import * as Shapes from '../data/Shapes';
|
|
3
|
-
import { geometry, coordinates } from './malform';
|
|
4
|
-
|
|
5
|
-
const shapes = Object.keys(Shapes).map((key) => Shapes[key]);
|
|
6
|
-
const geometries = shapes.filter(({ coordinates }) => coordinates);
|
|
7
|
-
|
|
8
|
-
function sortStringList(list: Array<string>): Array<string> {
|
|
9
|
-
return list.slice().sort((a, b) => a < b ? -1 : Number(a > b));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function explain(value: any): string {
|
|
13
|
-
return JSON.stringify(value).replace(/^(.{20}).{3,}(.{20})$/, '$1 … $2');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function exported(group, exports, ...expect: Array<string>) {
|
|
17
|
-
test(`${group} - exports`, (t) => {
|
|
18
|
-
const defined = sortStringList(Object.keys(exports).filter((key) => typeof exports[key] !== 'undefined'));
|
|
19
|
-
const expected = sortStringList(expect);
|
|
20
|
-
|
|
21
|
-
t.deepEqual(defined, expected, `exports ${expect.join(', ')}`);
|
|
22
|
-
expected.forEach((key) => {
|
|
23
|
-
t.equal(typeof exports[key], 'function', `${key} is a function`);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
t.end();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function runner(group, exports, ...run: Array<string | [string, Array<string>]>) {
|
|
31
|
-
const config = run.map((fun) => (Array.isArray(fun) ? fun : [fun, []]) as [string, Array<string>]);
|
|
32
|
-
|
|
33
|
-
exported(group, exports, ...config.map(([fun]) => fun));
|
|
34
|
-
|
|
35
|
-
config
|
|
36
|
-
.forEach(([fun, types = []]) => {
|
|
37
|
-
const exec = exports[fun];
|
|
38
|
-
const [, is, strict, name, coords] = fun.match(/^(is)(Strict)?(.+?)(Coordinates)?$/);
|
|
39
|
-
const type = `${strict ? 'strict ' : ''}${name}`;
|
|
40
|
-
|
|
41
|
-
test(`${group} - ${fun}`, (t) => {
|
|
42
|
-
if (coords) {
|
|
43
|
-
geometries.forEach((shape) => {
|
|
44
|
-
if (shape.type === name || types.includes(shape.type)) {
|
|
45
|
-
t.ok(exec(shape.coordinates), `${explain(shape.coordinates)} is ${type} coordinates`);
|
|
46
|
-
|
|
47
|
-
coordinates(shape.coordinates, Boolean(strict))
|
|
48
|
-
.forEach((coordinates) => {
|
|
49
|
-
t.notOk(exec(coordinates), `${explain(coordinates)} is not ${type} coordinates`);
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
t.notOk(exec(shape.coordinates), `${explain(shape.coordinates)} is not ${type} coordinates`);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
shapes.forEach((shape: any) => {
|
|
59
|
-
if (shape.type === name || types.includes(shape.type)) {
|
|
60
|
-
t.ok(exec(shape), `${explain(shape)} is a ${type}`);
|
|
61
|
-
|
|
62
|
-
geometry(shape, Boolean(strict))
|
|
63
|
-
.forEach((shape) => {
|
|
64
|
-
t.notOk(exec(shape), `${explain(shape)} is not a ${type}`);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
t.notOk(exec(shape), `${explain(shape)} is not a ${type}`);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
t.end();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
package/test/helper/malform.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { isNumber } from "@konfirm/guard";
|
|
2
|
-
|
|
3
|
-
type Target = { [key: string]: unknown };
|
|
4
|
-
type GeometryTarget = Target & { type: string };
|
|
5
|
-
|
|
6
|
-
function omit(o: Target): Array<Target> {
|
|
7
|
-
return Object.keys(o)
|
|
8
|
-
.map((key) => {
|
|
9
|
-
const { [key]: _omit, ...rest } = o;
|
|
10
|
-
|
|
11
|
-
return rest;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function less(a: Array<unknown>): Array<unknown> {
|
|
16
|
-
if (isNumber(a[0])) {
|
|
17
|
-
return a.slice(0, 1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return a.map((v) => less(v as Array<unknown>));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function more(a: Array<unknown>): Array<unknown> {
|
|
24
|
-
if (isNumber(a[0])) {
|
|
25
|
-
return a.concat(Math.random(), Math.random());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return a.map((v) => more(v as Array<unknown>));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function values(a: Array<unknown>, add: number): Array<unknown> {
|
|
32
|
-
if (isNumber(a[0])) {
|
|
33
|
-
return a.map((v) => (v as number) + add);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return a.map((v) => values(v as Array<unknown>, add));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function geometry(o: GeometryTarget, strict: boolean = false): Array<Target> {
|
|
40
|
-
const malformed = omit(o);
|
|
41
|
-
|
|
42
|
-
switch (o.type) {
|
|
43
|
-
case 'Feature':
|
|
44
|
-
malformed.push(
|
|
45
|
-
{ ...o, geometry: geometry(o.geometry as GeometryTarget, strict) },
|
|
46
|
-
);
|
|
47
|
-
break;
|
|
48
|
-
case 'FeatureCollection':
|
|
49
|
-
malformed.push(
|
|
50
|
-
{ ...o, features: (o.features as Array<GeometryTarget>).map((v) => geometry(v, strict)) },
|
|
51
|
-
);
|
|
52
|
-
break;
|
|
53
|
-
case 'GeometryCollection':
|
|
54
|
-
malformed.push(
|
|
55
|
-
{ ...o, geometries: (o.geometries as Array<GeometryTarget>).map((v) => geometry(v, strict)) },
|
|
56
|
-
);
|
|
57
|
-
break;
|
|
58
|
-
|
|
59
|
-
default:
|
|
60
|
-
const mapped = coordinates(o.coordinates as Array<unknown>, strict);
|
|
61
|
-
|
|
62
|
-
malformed.push(...mapped.map((coordinates) => ({ ...o, coordinates })));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return malformed;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function coordinates(a: Array<unknown>, strict: boolean = false): Array<typeof a> {
|
|
69
|
-
const malformed = [
|
|
70
|
-
less(a),
|
|
71
|
-
more(a),
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
if (strict) {
|
|
75
|
-
malformed.push(
|
|
76
|
-
values(a, 360),
|
|
77
|
-
values(a, -360),
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return malformed;
|
|
82
|
-
}
|
package/test/main.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as Export from '../source/main';
|
|
2
|
-
import { exported } from './helper/geometry';
|
|
3
|
-
|
|
4
|
-
exported('main', Export, 'SimpleGeometryIterator', 'intersect', 'distance', 'isPosition', 'isStrictPosition', 'isPoint', 'isStrictPoint', 'isMultiPoint', 'isStrictMultiPoint', 'isLineString', 'isStrictLineString', 'isMultiLineString', 'isStrictMultiLineString', 'isPolygon', 'isStrictPolygon', 'isMultiPolygon', 'isStrictMultiPolygon', 'isGeometryCollection', 'isStrictGeometryCollection', 'isFeature', 'isStrictFeature', 'isFeatureCollection', 'isStrictFeatureCollection', 'isGeoJSON', 'isGeometry', 'isStrictGeoJSON', 'isStrictGeometry');
|