From 750a0620e9aa0c2124a353c2aafe380b425523e5 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 11 Mar 2023 02:34:47 +0100 Subject: [PATCH] docs: improve typing --- Logic/BBox.ts | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Logic/BBox.ts b/Logic/BBox.ts index abb0e3711..9f1cbceab 100644 --- a/Logic/BBox.ts +++ b/Logic/BBox.ts @@ -1,6 +1,7 @@ import * as turf from "@turf/turf" import { TileRange, Tiles } from "../Models/TileRange" import { GeoOperations } from "./GeoOperations" +import { Feature, Polygon } from "geojson" export class BBox { static global: BBox = new BBox([ @@ -185,22 +186,26 @@ export class BBox { ] } - asGeoJson(properties: any): any { + public asGeoJson(properties: T): Feature { return { type: "Feature", properties: properties, - geometry: { - type: "Polygon", - coordinates: [ - [ - [this.minLon, this.minLat], - [this.maxLon, this.minLat], - [this.maxLon, this.maxLat], - [this.minLon, this.maxLat], - [this.minLon, this.minLat], - ], + geometry: this.asGeometry(), + } + } + + public asGeometry(): Polygon { + return { + type: "Polygon", + coordinates: [ + [ + [this.minLon, this.minLat], + [this.maxLon, this.minLat], + [this.maxLon, this.maxLat], + [this.minLon, this.maxLat], + [this.minLon, this.minLat], ], - }, + ], } }