forked from MapComplete/MapComplete
Docs: improve typing and testing of GeoOperations
This commit is contained in:
parent
7f9f7e7534
commit
557b41d70f
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
|
* @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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue