use of org.n52.io.geojson.old.GeojsonPoint in project series-rest-api by 52North.
the class CRSUtils method convertToGeojsonFrom.
/**
* Creates a GeoJSON representation of the given point. Adds a named <code>crs</code> member if
* it is different to the internally used CRS:84.
*
* @param point the point to be converted to GeoJSON.
* @param targetCrs the target CRS.
* @return a GeoJSON representation of the given point.
* @throws TransformException if transforming point fails.
* @throws FactoryException if creating the target CRS fails.
*/
public GeojsonPoint convertToGeojsonFrom(Point point, String targetCrs) throws TransformException, FactoryException {
Point transformedPoint = (Point) transformInnerToOuter(point, targetCrs);
GeojsonPoint asGeoJSON = convertToGeojsonFrom(transformedPoint);
if (!DEFAULT_CRS.equalsIgnoreCase(targetCrs)) {
asGeoJSON.setCrs(GeojsonCrs.createNamedCRS(targetCrs));
}
return asGeoJSON;
}
use of org.n52.io.geojson.old.GeojsonPoint in project series-rest-api by 52North.
the class IoParameters method transformToInnerCrs.
/**
* @param point
* a GeoJSON point to be transformed to internally used CRS:84.
* @param crsUtils
* a reference helper.
* @return a transformed GeoJSON instance.
* @throws IoParseException
* if point could not be transformed, or if requested CRS object could not be created.
*/
private GeojsonPoint transformToInnerCrs(GeojsonPoint point, CRSUtils crsUtils) {
try {
Point toTransformed = crsUtils.convertToPointFrom(point, getCrs());
Point crs84Point = (Point) crsUtils.transformOuterToInner(toTransformed, getCrs());
return crsUtils.convertToGeojsonFrom(crs84Point);
} catch (TransformException e) {
throw new IoParseException("Could not transform to internally used CRS:84.", e);
} catch (FactoryException e) {
throw new IoParseException("Check if 'crs' parameter is a valid EPSG CRS. Was: '" + getCrs() + "'.", e);
}
}
Aggregations