use of org.n52.io.response.BBox in project series-rest-api by 52North.
the class IoParameters method createBbox.
/**
* @return a {@link BBox} instance or <code>null</code> if no {@link #BBOX} parameter is present.
* @throws IoParseException
* if parsing parameter fails.
* @throws IoParseException
* if a requested {@value #CRS} object could not be created
*/
private BBox createBbox() {
if (!containsParameter(BBOX)) {
return null;
}
String bboxValue = getAsString(BBOX);
BBox bbox = parseJson(bboxValue, BBox.class);
bbox.setLl(convertToCrs84(bbox.getLl()));
bbox.setUr(convertToCrs84(bbox.getUr()));
return bbox;
}
use of org.n52.io.response.BBox in project series-rest-api by 52North.
the class IoParameters method extendBy.
/**
* Extends the bounding box with the given point. If point is contained by this instance nothing is
* changed.
*
* @param point
* the point in CRS:84 which shall extend the bounding box.
*/
private void extendBy(Point point, BoundingBox bbox) {
if (bbox.contains(point)) {
return;
}
double llX = Math.min(point.getX(), bbox.getLowerLeft().getX());
double llY = Math.max(point.getX(), bbox.getUpperRight().getX());
double urX = Math.min(point.getY(), bbox.getLowerLeft().getY());
double urY = Math.max(point.getY(), bbox.getUpperRight().getY());
CRSUtils crsUtils = CRSUtils.createEpsgForcedXYAxisOrder();
bbox.setLl(crsUtils.createPoint(llX, llY, bbox.getSrs()));
bbox.setUr(crsUtils.createPoint(urX, urY, bbox.getSrs()));
}
use of org.n52.io.response.BBox in project series-rest-api by 52North.
the class IoParameters method mergeBounds.
private BoundingBox mergeBounds(BoundingBox bounds, BBox bboxBounds) {
if (bboxBounds == null) {
// nothing to merge
return bounds;
}
CRSUtils crsUtils = CRSUtils.createEpsgForcedXYAxisOrder();
Point lowerLeft = crsUtils.convertToPointFrom(bboxBounds.getLl());
Point upperRight = crsUtils.convertToPointFrom(bboxBounds.getUr());
if (bounds == null) {
BoundingBox parsed = new BoundingBox(lowerLeft, upperRight, CRSUtils.DEFAULT_CRS);
LOGGER.debug("Parsed bbox bounds: {}", parsed.toString());
return parsed;
} else {
extendBy(lowerLeft, bounds);
extendBy(upperRight, bounds);
LOGGER.debug("Merged bounds: {}", bounds.toString());
return bounds;
}
}
use of org.n52.io.response.BBox in project series-rest-api by 52North.
the class IoParameters method getSpatialFilter.
/**
* Creates a {@link BoundingBox} instance from given spatial request parameters. The resulting bounding
* box is the merged extent of all spatial filters given. For example if {@value #NEAR} and {@value #BBOX}
* exist, the returned bounding box includes both extents.
*
* @return a spatial filter created from given spatial parameters.
* @throws IoParseException
* if parsing parameters fails, or if a requested {@value #CRS} object could not be created.
*/
public BoundingBox getSpatialFilter() {
if (!containsParameter(NEAR) && !containsParameter(BBOX)) {
return null;
}
BBox bboxBounds = createBbox();
BoundingBox bounds = parseBoundsFromVicinity();
return mergeBounds(bounds, bboxBounds);
}
use of org.n52.io.response.BBox in project series-rest-api by 52North.
the class CRSUtilsTest method setUp.
@Before
public void setUp() throws Exception {
referenceHelper = CRSUtils.createEpsgStrictAxisOrder();
Point ll = referenceHelper.createPoint(6.4, 51.9, DEFAULT_CRS);
Point ur = referenceHelper.createPoint(8.9, 53.4, DEFAULT_CRS);
// EastingNorthing ll = new EastingNorthing(6.4, 51.9, DEFAULT_CRS);
// EastingNorthing ur = new EastingNorthing(8.9, 53.4, DEFAULT_CRS);
bbox = new BoundingBox(ll, ur, DEFAULT_CRS);
}
Aggregations