-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.js
152 lines (120 loc) · 2.79 KB
/
types.js
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* @flow */
'use strict';
const assert = require('assert');
assert(false, `geojson-flow shouldn't be used at runtime`);
/**
* 2. GeoJSON Objects
* http://geojson.org/geojson-spec.html#geojson-objects
*/
export type GeoJSONObject =
| GeometryObject
| Feature
| FeatureCollection;
type Common = { // TODO inline
crs?: ?CRS,
bbox?: BBox
};
/**
* 2.1 Geometry Objects
* http://geojson.org/geojson-spec.html#geometry-objects
*/
export type GeometryObject =
| Point
| MultiPoint
| LineString
| MultiLineString
| Polygon
| MultiPolygon
| GeometryCollection;
/**
* 2.1.1. Positions
* http://geojson.org/geojson-spec.html#positions
*/
type Position = [number, number];
/**
* 2.1.2. Point
* http://geojson.org/geojson-spec.html#point
*/
export type Point = {
type: 'Point',
coordinates: Position
};
/**
* 2.1.3. MultiPoint
* http://geojson.org/geojson-spec.html#multipoint
*/
export type MultiPoint = {
type: 'MultiPoint',
coordinates: Array<Position>
};
/**
* 2.1.4. LineString
* http://geojson.org/geojson-spec.html#linestring
*/
export type LineString = {
type: 'LineString',
coordinates: Array<Position> // TODO it should be > 2, but we can't validate it statically (maybe [Position, Position] would work?)
};
/**
* 2.1.5. MultiLineString
* http://geojson.org/geojson-spec.html#multilinestring
*/
export type MultiLineString = {
type: 'MultiLineString',
coordinates: Array<Array<Position>>
};
/**
* 2.1.6. Polygon
* http://geojson.org/geojson-spec.html#polygon
*/
export type Polygon = {
type: 'Polygon',
coordinates: Array<Array<Position>>
};
/**
* 2.1.7. MultiPolygon
* http://geojson.org/geojson-spec.html#multipolygon
*/
export type MultiPolygon = {
type: 'MultiPolygon',
coordinates: Array<Array<Array<Position>>>
};
/**
* 2.1.8 Geometry Collection
* http://geojson.org/geojson-spec.html#geometry-collection
*/
export type GeometryCollection = {
type: 'GeometryCollection',
geometries: Array<GeometryObject> // TODO make generic
};
/**
* 2.2. Feature Objects
* http://geojson.org/geojson-spec.html#geometry-collection
*/
export type Feature = { // TODO make generic
type: 'Feature',
geometry: ?GeometryObject,
properties: ?{},
id?: number | string // is not specified, but nothing else makes sense
};
/**
* 2.3. Feature Collection Objects
* http://geojson.org/geojson-spec.html#feature-collection-objects
*/
export type FeatureCollection = { // TODO make generic
type: 'FeatureCollection',
features: Array<Feature>
};
/**
* 3. Coordinate Reference System Objects
* http://geojson.org/geojson-spec.html#coordinate-reference-system-objects
*/
type CRS = {
type: string,
properties: {}
};
/**
* 4. Bounding Boxes
* http://geojson.org/geojson-spec.html#bounding-boxes
*/
type BBox = [Position, Position, Position, Position];