Fix bug in bounds calculation for negative lats/lons

This commit is contained in:
Pieter Vander Vennet 2021-09-27 15:38:12 +02:00
parent 215aebce19
commit 38037014b0
6 changed files with 65 additions and 51 deletions

View file

@ -388,10 +388,10 @@ export class BBox {
static global: BBox = new BBox([[-180, -90], [180, 90]]);
constructor(coordinates) {
this.maxLat = Number.MIN_VALUE;
this.maxLon = Number.MIN_VALUE;
this.minLat = Number.MAX_VALUE;
this.minLon = Number.MAX_VALUE;
this.maxLat = -90;
this.maxLon = -180;
this.minLat = 90;
this.minLon = 180;
for (const coordinate of coordinates) {
@ -491,4 +491,23 @@ export class BBox {
toLeaflet() {
return [[this.minLat, this.minLon], [this.maxLat, this.maxLon]]
}
asGeoJson(properties: any) : any{
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],
]]
}
}
}
}