Is there a way with GeoTools to know whether a CRS is geographic (in degrees) or projected (in meter) ?
I have tried empirically with the following code (based on a check of the CRS unit) but I am not sure at all if it is going to work for all CRSs... Is there a better and more correct way ?
public enum CRSType { GEOG, CARTO, UNKNOWN }
private static CRSType getCRSType(Unit<?> unit) {
if(unit == null) return CRSType.UNKNOWN;
switch (unit.toString()) {
case "": return CRSType.UNKNOWN;
case "°": return CRSType.GEOG;
case "deg": return CRSType.GEOG;
case "dms": return CRSType.GEOG;
case "degree": return CRSType.GEOG;
case "m": return CRSType.CARTO;
default:
LOGGER.warn("Unexpected unit of measure for projection: "+unit);
return CRSType.UNKNOWN;
}
}
public static CRSType getCRSType(CoordinateReferenceSystem crs) {
return getCRSType(CRSUtilities.getUnit(crs.getCoordinateSystem()));
}