refactor: define Position type for GeoJSON objects (#11259)

This commit is contained in:
Ariel Barabas 2025-04-15 15:53:19 -03:00 committed by GitHub
parent 56f1898c4e
commit 673f06549c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,60 +1,66 @@
/**
* Position object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1
*/
export type Position = number[]
/**
* Point geometry object.
* https://tools.ietf.org/html/rfc7946#section-3.1.2
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.2
*/
export type Point = {
type: "Point"
coordinates: number[]
coordinates: Position
}
/**
* LineString geometry object.
* https://tools.ietf.org/html/rfc7946#section-3.1.4
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.4
*/
export type LineString = {
type: "LineString"
coordinates: number[][]
coordinates: Position[]
}
/**
* Polygon geometry object.
* https://tools.ietf.org/html/rfc7946#section-3.1.6
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6
*/
export type Polygon = {
type: "Polygon"
coordinates: number[][][]
coordinates: Position[][]
}
/**
* MultiPoint geometry object.
* https://tools.ietf.org/html/rfc7946#section-3.1.3
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.3
*/
export type MultiPoint = {
type: "MultiPoint"
coordinates: number[][]
coordinates: Position[]
}
/**
* MultiLineString geometry object.
* https://tools.ietf.org/html/rfc7946#section-3.1.5
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.5
*/
export type MultiLineString = {
type: "MultiLineString"
coordinates: number[][][]
coordinates: Position[][]
}
/**
* MultiPolygon geometry object.
* https://tools.ietf.org/html/rfc7946#section-3.1.7
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.7
*/
export type MultiPolygon = {
type: "MultiPolygon"
coordinates: number[][][][]
coordinates: Position[][][]
}
/**
* Geometry Collection
* https://tools.ietf.org/html/rfc7946#section-3.1.8
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.8
*/
export type GeometryCollection = {
type: "GeometryCollection"
@ -83,7 +89,7 @@ export type Geography = Geometry
/**
* A feature object which contains a geometry and associated properties.
* https://tools.ietf.org/html/rfc7946#section-3.2
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.2
*/
export type Feature = {
type: "Feature"
@ -95,7 +101,7 @@ export type Feature = {
/**
* A collection of feature objects.
* https://tools.ietf.org/html/rfc7946#section-3.3
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.3
*/
export type FeatureCollection = {
type: "FeatureCollection"