Docs: improve typing and testing of GeoOperations

This commit is contained in:
Pieter Vander Vennet 2024-12-06 01:20:20 +01:00 committed by Midgard
parent 87b5e49789
commit 5b3ca7e85c
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -76,10 +76,18 @@ export class GeoOperations {
}
/**
* Returns [lon,lat] coordinates
* Returns [lon,lat] coordinates.
* @param feature
*
* GeoOperations.centerpointCoordinates(undefined) // => undefined
*/
static centerpointCoordinates(feature: undefined | null): undefined ;
static centerpointCoordinates(feature: AllGeoJSON | GeoJSON | undefined): [number, number] | undefined;
static centerpointCoordinates(feature: NonNullable< AllGeoJSON> | NonNullable<GeoJSON>): NonNullable<[number, number]>;
static centerpointCoordinates(feature: AllGeoJSON | GeoJSON): [number, number] {
if(feature === undefined || feature === null){
return undefined
}
return <[number, number]>turf.center(<any>feature).geometry.coordinates
}