A position is an array of numbers. There MUST be two or more
elements. The first two elements are longitude and latitude, or
easting and northing, precisely in that order and using decimal
numbers. Altitude or elevation MAY be included as an optional third
element.
From @types/geojson
/**
* A Position is an array of coordinates.
* https://tools.ietf.org/html/rfc7946#section-3.1.1
* Array should contain between two and three elements.
* The previous GeoJSON specification allowed more elements (e.g., which could be used to represent M values),
* but the current specification only allows X, Y, and (optionally) Z to be defined.
*/
export type Position = number[]; // [number, number] | [number, number, number];
The center validation check should be something similar to this:
if (!Array.isArray(center) || ![2,3].includes(center.length)) {
throw new Error("ERROR! Center has to be an array of length two or three");
}
In version
2.0.0
, thevalidateCenter
function fails when passing a 3rd element (altitude/elevation) as the center point:From RFC 7946
From
@types/geojson
The center validation check should be something similar to this: