1 | // Type definitions for non-npm package geojson 7946.0
|
2 | // Project: https://geojson.org/
|
3 | // Definitions by: Jacob Bruun <https://github.com/cobster>
|
4 | // Arne Schubert <https://github.com/atd-schubert>
|
5 | // Jeff Jacobson <https://github.com/JeffJacobson>
|
6 | // Ilia Choly <https://github.com/icholy>
|
7 | // Dan Vanderkam <https://github.com/danvk>
|
8 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
9 | // TypeScript Version: 2.3
|
10 |
|
11 | // Note: as of the RFC 7946 version of GeoJSON, Coordinate Reference Systems
|
12 | // are no longer supported. (See https://tools.ietf.org/html/rfc7946#appendix-B)}
|
13 |
|
14 | export as namespace GeoJSON;
|
15 |
|
16 | /**
|
17 | * The valid values for the "type" property of GeoJSON geometry objects.
|
18 | * https://tools.ietf.org/html/rfc7946#section-1.4
|
19 | */
|
20 | export type GeoJsonGeometryTypes = Geometry["type"];
|
21 |
|
22 | /**
|
23 | * The value values for the "type" property of GeoJSON Objects.
|
24 | * https://tools.ietf.org/html/rfc7946#section-1.4
|
25 | */
|
26 | export type GeoJsonTypes = GeoJSON["type"];
|
27 |
|
28 | /**
|
29 | * Bounding box
|
30 | * https://tools.ietf.org/html/rfc7946#section-5
|
31 | */
|
32 | export type BBox = [number, number, number, number] | [number, number, number, number, number, number];
|
33 |
|
34 | /**
|
35 | * A Position is an array of coordinates.
|
36 | * https://tools.ietf.org/html/rfc7946#section-3.1.1
|
37 | * Array should contain between two and three elements.
|
38 | * The previous GeoJSON specification allowed more elements (e.g., which could be used to represent M values),
|
39 | * but the current specification only allows X, Y, and (optionally) Z to be defined.
|
40 | */
|
41 | export type Position = number[]; // [number, number] | [number, number, number];
|
42 |
|
43 | /**
|
44 | * The base GeoJSON object.
|
45 | * https://tools.ietf.org/html/rfc7946#section-3
|
46 | * The GeoJSON specification also allows foreign members
|
47 | * (https://tools.ietf.org/html/rfc7946#section-6.1)
|
48 | * Developers should use "&" type in TypeScript or extend the interface
|
49 | * to add these foreign members.
|
50 | */
|
51 | export interface GeoJsonObject {
|
52 | // Don't include foreign members directly into this type def.
|
53 | // in order to preserve type safety.
|
54 | // [key: string]: any;
|
55 | /**
|
56 | * Specifies the type of GeoJSON object.
|
57 | */
|
58 | type: GeoJsonTypes;
|
59 | /**
|
60 | * Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections.
|
61 | * The value of the bbox member is an array of length 2*n where n is the number of dimensions
|
62 | * represented in the contained geometries, with all axes of the most southwesterly point
|
63 | * followed by all axes of the more northeasterly point.
|
64 | * The axes order of a bbox follows the axes order of geometries.
|
65 | * https://tools.ietf.org/html/rfc7946#section-5
|
66 | */
|
67 | bbox?: BBox | undefined;
|
68 | }
|
69 |
|
70 | /**
|
71 | * Union of GeoJSON objects.
|
72 | */
|
73 | export type GeoJSON = Geometry | Feature | FeatureCollection;
|
74 |
|
75 | /**
|
76 | * Geometry object.
|
77 | * https://tools.ietf.org/html/rfc7946#section-3
|
78 | */
|
79 | export type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon | GeometryCollection;
|
80 | export type GeometryObject = Geometry;
|
81 |
|
82 | /**
|
83 | * Point geometry object.
|
84 | * https://tools.ietf.org/html/rfc7946#section-3.1.2
|
85 | */
|
86 | export interface Point extends GeoJsonObject {
|
87 | type: "Point";
|
88 | coordinates: Position;
|
89 | }
|
90 |
|
91 | /**
|
92 | * MultiPoint geometry object.
|
93 | * https://tools.ietf.org/html/rfc7946#section-3.1.3
|
94 | */
|
95 | export interface MultiPoint extends GeoJsonObject {
|
96 | type: "MultiPoint";
|
97 | coordinates: Position[];
|
98 | }
|
99 |
|
100 | /**
|
101 | * LineString geometry object.
|
102 | * https://tools.ietf.org/html/rfc7946#section-3.1.4
|
103 | */
|
104 | export interface LineString extends GeoJsonObject {
|
105 | type: "LineString";
|
106 | coordinates: Position[];
|
107 | }
|
108 |
|
109 | /**
|
110 | * MultiLineString geometry object.
|
111 | * https://tools.ietf.org/html/rfc7946#section-3.1.5
|
112 | */
|
113 | export interface MultiLineString extends GeoJsonObject {
|
114 | type: "MultiLineString";
|
115 | coordinates: Position[][];
|
116 | }
|
117 |
|
118 | /**
|
119 | * Polygon geometry object.
|
120 | * https://tools.ietf.org/html/rfc7946#section-3.1.6
|
121 | */
|
122 | export interface Polygon extends GeoJsonObject {
|
123 | type: "Polygon";
|
124 | coordinates: Position[][];
|
125 | }
|
126 |
|
127 | /**
|
128 | * MultiPolygon geometry object.
|
129 | * https://tools.ietf.org/html/rfc7946#section-3.1.7
|
130 | */
|
131 | export interface MultiPolygon extends GeoJsonObject {
|
132 | type: "MultiPolygon";
|
133 | coordinates: Position[][][];
|
134 | }
|
135 |
|
136 | /**
|
137 | * Geometry Collection
|
138 | * https://tools.ietf.org/html/rfc7946#section-3.1.8
|
139 | */
|
140 | export interface GeometryCollection<G extends Geometry = Geometry> extends GeoJsonObject {
|
141 | type: "GeometryCollection";
|
142 | geometries: G[];
|
143 | }
|
144 |
|
145 | export type GeoJsonProperties = { [name: string]: any } | null;
|
146 |
|
147 | /**
|
148 | * A feature object which contains a geometry and associated properties.
|
149 | * https://tools.ietf.org/html/rfc7946#section-3.2
|
150 | */
|
151 | export interface Feature<G extends Geometry | null = Geometry, P = GeoJsonProperties> extends GeoJsonObject {
|
152 | type: "Feature";
|
153 | /**
|
154 | * The feature's geometry
|
155 | */
|
156 | geometry: G;
|
157 | /**
|
158 | * A value that uniquely identifies this feature in a
|
159 | * https://tools.ietf.org/html/rfc7946#section-3.2.
|
160 | */
|
161 | id?: string | number | undefined;
|
162 | /**
|
163 | * Properties associated with this feature.
|
164 | */
|
165 | properties: P;
|
166 | }
|
167 |
|
168 | /**
|
169 | * A collection of feature objects.
|
170 | * https://tools.ietf.org/html/rfc7946#section-3.3
|
171 | */
|
172 | export interface FeatureCollection<G extends Geometry | null = Geometry, P = GeoJsonProperties> extends GeoJsonObject {
|
173 | type: "FeatureCollection";
|
174 | features: Array<Feature<G, P>>;
|
175 | }
|