forked from MapComplete/MapComplete
Docs: improve typing and testing of GeoOperations
This commit is contained in:
parent
87b5e49789
commit
5b3ca7e85c
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue