Add direction:centerpoint as calculated tag; improve typing of geoOperations.ts

This commit is contained in:
Pieter Vander Vennet 2022-09-27 18:52:13 +02:00
parent 4b6b709b4b
commit 4521889909
2 changed files with 37 additions and 3 deletions

View file

@ -13,7 +13,7 @@ import {
Polygon,
Properties,
} from "@turf/turf"
import {GeoJSON, LineString} from "geojson";
import {GeoJSON, LineString, Point} from "geojson";
export class GeoOperations {
private static readonly _earthRadius = 6378137
@ -27,8 +27,8 @@ export class GeoOperations {
* Converts a GeoJson feature to a point GeoJson feature
* @param feature
*/
static centerpoint(feature: any) {
const newFeature = turf.center(feature)
static centerpoint(feature: any): Feature<Point> {
const newFeature : Feature<Point> = turf.center(feature)
newFeature.properties = feature.properties
newFeature.id = feature.id
return newFeature