geojson.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /**
  2. * GeometryTypes
  3. *
  4. * https://tools.ietf.org/html/rfc7946#section-1.4
  5. * The valid values for the "type" property of GeoJSON geometry objects.
  6. */
  7. export declare type GeometryTypes = "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon" | "GeometryCollection";
  8. export declare type CollectionTypes = "FeatureCollection" | "GeometryCollection";
  9. /**
  10. * Types
  11. *
  12. * https://tools.ietf.org/html/rfc7946#section-1.4
  13. * The value values for the "type" property of GeoJSON Objects.
  14. */
  15. export declare type Types = "Feature" | GeometryTypes | CollectionTypes;
  16. /**
  17. * Bounding box
  18. *
  19. * https://tools.ietf.org/html/rfc7946#section-5
  20. * A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections.
  21. * The value of the bbox member MUST be an array of length 2*n where n is the number of dimensions represented in the contained geometries,
  22. * with all axes of the most southwesterly point followed by all axes of the more northeasterly point.
  23. * The axes order of a bbox follows the axes order of geometries.
  24. */
  25. export declare type BBox2d = [number, number, number, number];
  26. export declare type BBox3d = [number, number, number, number, number, number];
  27. export declare type BBox = BBox2d | BBox3d;
  28. /**
  29. * Id
  30. *
  31. * https://tools.ietf.org/html/rfc7946#section-3.2
  32. * If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of
  33. * the Feature object with the name "id", and the value of this member is either a JSON string or number.
  34. */
  35. export declare type Id = string | number;
  36. /**
  37. * Position
  38. *
  39. * https://tools.ietf.org/html/rfc7946#section-3.1.1
  40. * Array should contain between two and three elements.
  41. * The previous GeoJSON specification allowed more elements (e.g., which could be used to represent M values),
  42. * but the current specification only allows X, Y, and (optionally) Z to be defined.
  43. */
  44. export declare type Position = number[];
  45. /**
  46. * Properties
  47. *
  48. * https://tools.ietf.org/html/rfc7946#section-3.2
  49. * A Feature object has a member with the name "properties".
  50. * The value of the properties member is an object (any JSON object or a JSON null value).
  51. */
  52. export declare type Properties = {
  53. [name: string]: any;
  54. } | null;
  55. /**
  56. * Geometries
  57. */
  58. export declare type Geometries = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
  59. /**
  60. * GeoJSON Object
  61. *
  62. * https://tools.ietf.org/html/rfc7946#section-3
  63. * The GeoJSON specification also allows [foreign members](https://tools.ietf.org/html/rfc7946#section-6.1)
  64. * Developers should use "&" type in TypeScript or extend the interface to add these foreign members.
  65. */
  66. export interface GeoJSONObject {
  67. /**
  68. * Specifies the type of GeoJSON object.
  69. */
  70. type: string;
  71. /**
  72. * Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections.
  73. * https://tools.ietf.org/html/rfc7946#section-5
  74. */
  75. bbox?: BBox;
  76. }
  77. /**
  78. * Geometry Object
  79. *
  80. * https://tools.ietf.org/html/rfc7946#section-3
  81. */
  82. export interface GeometryObject extends GeoJSONObject {
  83. type: GeometryTypes;
  84. }
  85. /**
  86. * Geometry
  87. *
  88. * https://tools.ietf.org/html/rfc7946#section-3
  89. */
  90. export interface Geometry extends GeoJSONObject {
  91. coordinates: Position | Position[] | Position[][] | Position[][][];
  92. }
  93. /**
  94. * Point Geometry Object
  95. *
  96. * https://tools.ietf.org/html/rfc7946#section-3.1.2
  97. */
  98. export interface Point extends GeometryObject {
  99. type: "Point";
  100. coordinates: Position;
  101. }
  102. /**
  103. * MultiPoint Geometry Object
  104. *
  105. * https://tools.ietf.org/html/rfc7946#section-3.1.3
  106. */
  107. export interface MultiPoint extends GeometryObject {
  108. type: "MultiPoint";
  109. coordinates: Position[];
  110. }
  111. /**
  112. * LineString Geometry Object
  113. *
  114. * https://tools.ietf.org/html/rfc7946#section-3.1.4
  115. */
  116. export interface LineString extends GeometryObject {
  117. type: "LineString";
  118. coordinates: Position[];
  119. }
  120. /**
  121. * MultiLineString Geometry Object
  122. *
  123. * https://tools.ietf.org/html/rfc7946#section-3.1.5
  124. */
  125. export interface MultiLineString extends GeometryObject {
  126. type: "MultiLineString";
  127. coordinates: Position[][];
  128. }
  129. /**
  130. * Polygon Geometry Object
  131. *
  132. * https://tools.ietf.org/html/rfc7946#section-3.1.6
  133. */
  134. export interface Polygon extends GeometryObject {
  135. type: "Polygon";
  136. coordinates: Position[][];
  137. }
  138. /**
  139. * MultiPolygon Geometry Object
  140. *
  141. * https://tools.ietf.org/html/rfc7946#section-3.1.7
  142. */
  143. export interface MultiPolygon extends GeometryObject {
  144. type: "MultiPolygon";
  145. coordinates: Position[][][];
  146. }
  147. /**
  148. * GeometryCollection
  149. *
  150. * https://tools.ietf.org/html/rfc7946#section-3.1.8
  151. *
  152. * A GeoJSON object with type "GeometryCollection" is a Geometry object.
  153. * A GeometryCollection has a member with the name "geometries".
  154. * The value of "geometries" is an array. Each element of this array is a GeoJSON Geometry object.
  155. * It is possible for this array to be empty.
  156. */
  157. export interface GeometryCollection extends GeometryObject {
  158. type: "GeometryCollection";
  159. geometries: Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>;
  160. }
  161. /**
  162. * Feature
  163. *
  164. * https://tools.ietf.org/html/rfc7946#section-3.2
  165. * A Feature object represents a spatially bounded thing.
  166. * Every Feature object is a GeoJSON object no matter where it occurs in a GeoJSON text.
  167. */
  168. export interface Feature<G = Geometry | GeometryCollection, P = Properties> extends GeoJSONObject {
  169. type: "Feature";
  170. geometry: G;
  171. /**
  172. * A value that uniquely identifies this feature in a
  173. * https://tools.ietf.org/html/rfc7946#section-3.2.
  174. */
  175. id?: Id;
  176. /**
  177. * Properties associated with this feature.
  178. */
  179. properties: P;
  180. }
  181. /**
  182. * Feature Collection
  183. *
  184. * https://tools.ietf.org/html/rfc7946#section-3.3
  185. * A GeoJSON object with the type "FeatureCollection" is a FeatureCollection object.
  186. * A FeatureCollection object has a member with the name "features".
  187. * The value of "features" is a JSON array. Each element of the array is a Feature object as defined above.
  188. * It is possible for this array to be empty.
  189. */
  190. export interface FeatureCollection<G = Geometry | GeometryCollection, P = Properties> extends GeoJSONObject {
  191. type: "FeatureCollection";
  192. features: Array<Feature<G, P>>;
  193. }