use of org.geotools.referencing.crs.DefaultGeographicCRS in project pipelines by gbif.
the class SpatialReferenceSystemParser method parseCRS.
/**
* Parses the given datum or SRS code and constructs a full 2D geographic reference system.
*
* @return the parsed CRS or null if it can't be interpreted
*/
public static CoordinateReferenceSystem parseCRS(String datum) {
CoordinateReferenceSystem crs = null;
ParseResult<Integer> epsgCode = PARSER.parse(datum);
if (epsgCode.isSuccessful()) {
final String code = "EPSG:" + epsgCode.getPayload();
// first try to create a full fledged CRS from the given code
try {
crs = CRS.decode(code);
} catch (FactoryException e) {
// that didn't work, maybe it is *just* a datum
try {
GeodeticDatum dat = datumFactory.createGeodeticDatum(code);
crs = new DefaultGeographicCRS(dat, DefaultEllipsoidalCS.GEODETIC_2D);
} catch (FactoryException e1) {
// also not a datum, no further ideas, log error
// swallow anything and return null instead
log.info("No CRS or DATUM for given datum code >>{}<<: {}", datum, e1.getMessage());
}
}
}
return crs;
}
Aggregations