import { CRS } from './crs' ; import { Polygon } from '@turf/helpers' ; export class BBox { public crs : CRS ; public minX : number ; public minY : number ; public maxX : number ; public maxY : number ; public constructor ( crs , minX , minY , maxX , maxY ) { if ( minX >= maxX ) { throw new Error ( 'MinX should be lower than maxX' ) ; } if ( minY >= maxY ) { throw new Error ( 'MinY should be lower than maxY' ) ; } this . crs = crs ; this . minX = minX ; this . maxX = maxX ; this . minY = minY ; this . maxY = maxY ; } public toGeoJSON ( ) { return { type : 'Polygon' , crs : { type : 'name' , properties : { name : this . crs . urn } } , coordinates : [ [ [ this . minX , this . minY ] , [ this . maxX , this . minY ] , [ this . maxX , this . maxY ] , [ this . minX , this . maxY ] , [ this . minX , this . minY ] , ] , ] , } ; } }