Search in sources :

Example 6 with CRSUtils

use of org.n52.io.crs.CRSUtils in project series-rest-api by 52North.

the class IoParameters method parseBoundsFromVicinity.

private BoundingBox parseBoundsFromVicinity() {
    if (!containsParameter(NEAR)) {
        return null;
    }
    String nearValue = getAsString(NEAR);
    CRSUtils crsUtils = CRSUtils.createEpsgForcedXYAxisOrder();
    Vicinity vicinity = null;
    if (bboxMatching(nearValue, 2)) {
        String[] coordArray = nearValue.split(SPLIT_REGEX);
        Point point = crsUtils.createPoint(Double.valueOf(coordArray[0].trim()), Double.valueOf(coordArray[1].trim()), CRSUtils.DEFAULT_CRS);
        vicinity = new Vicinity(point, Double.valueOf(coordArray[2].trim()));
    } else {
        vicinity = handleJsonValueParseException(NEAR, Vicinity.class, this::parseJson);
    }
    if (containsParameter(CRS)) {
        vicinity.setCenter(convertToCrs84(vicinity.getCenter()));
    }
    BoundingBox bounds = vicinity.calculateBounds();
    LOGGER.debug("Parsed vicinity bounds: {}", bounds.toString());
    return bounds;
}
Also used : BoundingBox(org.n52.io.crs.BoundingBox) CRSUtils(org.n52.io.crs.CRSUtils) Point(org.locationtech.jts.geom.Point)

Aggregations

BoundingBox (org.n52.io.crs.BoundingBox)4 CRSUtils (org.n52.io.crs.CRSUtils)4 Point (org.locationtech.jts.geom.Point)3 Point (com.vividsolutions.jts.geom.Point)2 IoParseException (org.n52.io.IoParseException)2 GeojsonPoint (org.n52.io.geojson.old.GeojsonPoint)2 FactoryException (org.opengis.referencing.FactoryException)2 TransformException (org.opengis.referencing.operation.TransformException)1