forked from w8r/martinez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
45 lines (42 loc) · 1.18 KB
/
types.ts
1
2
3
4
5
6
7
8
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
import * as martinez from '../'
// Fixtures
const poly1 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[[22, 24], [38, 24], [38, 37], [22, 37], [22, 24]]]
}
}
const poly2 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[[32, 34], [48, 34], [48, 47], [32, 47], [32, 34]]]
}
}
const multiPoly = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[[[22, 24], [38, 24], [38, 37], [22, 37], [22, 24]]],
[[[32, 34], [48, 34], [48, 47], [32, 47], [32, 34]]]
]
}
}
const poly1Coords = poly1.geometry.coordinates
const poly2Coords = poly2.geometry.coordinates
const multiPolyCoords = multiPoly.geometry.coordinates
// <method>(Polygon, Polygon)
martinez.xor(poly1Coords, poly2Coords)
martinez.diff(poly1Coords, poly2Coords)
martinez.union(poly1Coords, poly2Coords)
martinez.intersection(poly1Coords, poly2Coords)
// <method>(Poly, MultiPoly)
martinez.xor(poly1Coords, multiPolyCoords)
martinez.diff(poly1Coords, multiPolyCoords)
martinez.union(poly1Coords, multiPolyCoords)
martinez.intersection(poly1Coords, multiPolyCoords)