Docs: improve typing and testing of GeoOperations

This commit is contained in:
Pieter Vander Vennet 2024-12-06 01:20:20 +01:00
parent 7f9f7e7534
commit 557b41d70f

View file

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