public static Feature createBounds ( final String id , final LngLatAlt southwest , final LngLatAlt northeast ) { final Feature feature = new Feature ( ) ; feature . setId ( id ) ; if ( northeast == null || southwest == null ) { throw new IllegalArgumentException ( "Must have a proper bounding box" ) ; } final double [ ] bbox = { southwest . getLongitude ( ) , southwest . getLatitude ( ) , northeast . getLongitude ( ) , northeast . getLatitude ( ) } ; final Polygon polygon = new Polygon ( ) ; feature . setGeometry ( polygon ) ; polygon . setBbox ( bbox ) ; final List < LngLatAlt > elements = new ArrayList <> ( 5 ) ; elements . add ( new LngLatAlt ( bbox [ SW_LNG ] , bbox [ SW_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ NE_LNG ] , bbox [ SW_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ NE_LNG ] , bbox [ NE_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ SW_LNG ] , bbox [ NE_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ SW_LNG ] , bbox [ SW_LAT ] ) ) ; polygon . add ( elements ) ; feature . setBbox ( bbox ) ; return feature ; }
Build a bounding box feature .