Various fixes

This commit is contained in:
Pieter Vander Vennet 2021-12-07 17:46:57 +01:00
parent 18044ff22b
commit 07fd8f404a
14 changed files with 154 additions and 60 deletions

View file

@ -10,6 +10,10 @@ export class BBox {
readonly minLat: number;
readonly minLon: number;
/***
* Coordinates should be [[lon, lat],[lon, lat]]
* @param coordinates
*/
constructor(coordinates) {
this.maxLat = -90;
this.maxLon = -180;
@ -44,6 +48,21 @@ export class BBox {
}
return feature.bbox;
}
static bboxAroundAll(bboxes: BBox[]): BBox{
let maxLat: number = -90;
let maxLon: number= -180;
let minLat: number= 80;
let minLon: number= 180;
for (const bbox of bboxes) {
maxLat = Math.max(maxLat, bbox.maxLat)
maxLon = Math.max(maxLon, bbox.maxLon)
minLat = Math.min(minLat, bbox.minLat)
minLon = Math.min(minLon, bbox.minLon)
}
return new BBox([[maxLon, maxLat],[minLon,minLat]])
}
static fromTile(z: number, x: number, y: number): BBox {
return new BBox(Tiles.tile_bounds_lon_lat(z, x, y))