Package org.n52.io.crs
Class CRSUtils
java.lang.Object
org.n52.io.crs.CRSUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.geotools.api.referencing.crs.CRSAuthorityFactorystatic final StringDefault is CRS:84 (EPSG:4326 with lon/lat ordering).static final int -
Method Summary
Modifier and TypeMethodDescriptionstatic CRSUtilsCreates aCRSUtilswhich offers assistance when doing spatial opererations.static CRSUtilscreateEpsgReferenceHelper(org.geotools.util.factory.Hints hints) Creates aCRSUtilswhich offers assistance when doing spatial opererations.static CRSUtilsCreates anCRSUtilswhich offers assistance when doing spatial opererations.org.locationtech.jts.geom.GeometryFactoryorg.locationtech.jts.geom.GeometryFactorycreateGeometryFactory(String srsId) org.locationtech.jts.geom.GeometrycreateLineString(org.locationtech.jts.geom.Coordinate[] coordinates, String srs) org.locationtech.jts.geom.PointcreatePoint(Double x, Double y, Double z, String srs) Creates a 2D point geometry with respect to its height and given reference system.org.locationtech.jts.geom.PointcreatePoint(Double x, Double y, String srs) Creates a 2D point geometry within the given reference system.static StringextractSRSCode(String srs) static intgetSrsIdFrom(String srs) Extracts the SRS number of the incoming SRS definition string.static intgetSrsIdFromEPSG(String srs) booleanisLatLonAxesOrder(String outer) Indicates if the given reference frame has switched axes compared to the inner default (lon/lat).booleanisNorthingFirstEpsgCode(int epsgCode) booleanisNorthingFirstEpsgCode(String epsgCode) org.locationtech.jts.geom.Geometryorg.locationtech.jts.geom.GeometryTransforms a given geometry from a given reference to a destinated reference.org.locationtech.jts.geom.GeometrytransformInnerToOuter(org.locationtech.jts.geom.Geometry geometry, String destFrame) Transforms a given geometry from its inner reference (which is WGS84 (CRS:84)) to a given reference.org.locationtech.jts.geom.GeometrytransformOuterToInner(org.locationtech.jts.geom.Geometry geometry, String srcFrame) Transforms a given geometry from a given reference to inner reference, which is WGS84 (CRS:84).org.locationtech.jts.geom.PointtransformOuterToInner(org.locationtech.jts.geom.Point point, String srcFrame) Transforms a given point from a given reference to inner reference, which is WGS84 (CRS:84).
-
Field Details
-
EPSG_WGS84
public static final int EPSG_WGS84- See Also:
-
DEFAULT_CRS
Default is CRS:84 (EPSG:4326 with lon/lat ordering).- See Also:
-
crsFactory
protected org.geotools.api.referencing.crs.CRSAuthorityFactory crsFactory
-
-
Method Details
-
createPoint
Creates a 2D point geometry within the given reference system.- Parameters:
x- the coordinate's x value.y- the coordinate's y value.srs- an authoritive spatial reference system code, e.g.EPSG:4326orCRS:84.- Returns:
- a point referenced by the given spatial reference system.
-
createPoint
Creates a 2D point geometry with respect to its height and given reference system.- Parameters:
x- the point's x value.y- the point's y value.z- the height ornullorNaNif coordinate is 2D.srs- an authoritive spatial reference system code, e.g.EPSG:4326orCRS:84.- Returns:
- a point referenced by the given spatial reference system.
-
createLineString
public org.locationtech.jts.geom.Geometry createLineString(org.locationtech.jts.geom.Coordinate[] coordinates, String srs) -
createGeometryFactory
public org.locationtech.jts.geom.GeometryFactory createGeometryFactory() -
createGeometryFactory
-
getSrsIdFrom
Extracts the SRS number of the incoming SRS definition string. This can be either an HTTP URL (likehttp://www.opengis.net/def/crs/EPSG/0/4326) or a URN (likeurn:ogc:def:crs:EPSG::31466).- Parameters:
srs- the SRS definition string, either as URL ('/'-separated) or as URN (':'-separated).- Returns:
- the SRS number, e.g. 4326
-
extractSRSCode
- Parameters:
srs- the SRS definition string, either as URL ('/'-separated) or as URN (':'-separated).- Returns:
- SRS string in the form of for example 'EPSG:4326' or 'EPSG:31466'.
-
getSrsIdFromEPSG
-
transformOuterToInner
public org.locationtech.jts.geom.Point transformOuterToInner(org.locationtech.jts.geom.Point point, String srcFrame) throws org.geotools.api.referencing.FactoryException, org.geotools.api.referencing.operation.TransformException Transforms a given point from a given reference to inner reference, which is WGS84 (CRS:84).- Parameters:
point- the point to transform.srcFrame- the CRS authority code the given point is referenced in.- Returns:
- a point referenced in WGS84
- Throws:
org.geotools.api.referencing.FactoryException- if the creation ofCoordinateReferenceSystemfails or no appropriateMathTransformcould be createdorg.geotools.api.referencing.operation.TransformException- if transformation fails for any other reason
-
transformOuterToInner
public org.locationtech.jts.geom.Geometry transformOuterToInner(org.locationtech.jts.geom.Geometry geometry, String srcFrame) throws org.geotools.api.referencing.FactoryException, org.geotools.api.referencing.operation.TransformException Transforms a given geometry from a given reference to inner reference, which is WGS84 (CRS:84).- Parameters:
geometry- the geometry to transform.srcFrame- the CRS authority code the given point is referenced in.- Returns:
- a geometry referenced in WGS84
- Throws:
org.geotools.api.referencing.FactoryException- if the creation ofCoordinateReferenceSystemfails or no appropriateMathTransformcould be created.org.geotools.api.referencing.operation.TransformException- if transformation fails for any other reason.
-
transformInnerToOuter
public org.locationtech.jts.geom.Geometry transformInnerToOuter(org.locationtech.jts.geom.Geometry geometry, String destFrame) throws org.geotools.api.referencing.FactoryException, org.geotools.api.referencing.operation.TransformException Transforms a given geometry from its inner reference (which is WGS84 (CRS:84)) to a given reference.- Parameters:
geometry- the geometry to transform.destFrame- the CRS authority code the given point shall be transformed to.- Returns:
- a transformed geometry with dest reference.
- Throws:
org.geotools.api.referencing.FactoryException- if the creation ofCoordinateReferenceSystemfails or no appropriateMathTransformcould be created.org.geotools.api.referencing.operation.TransformException- if transformation fails for any other reason.
-
transform
public org.locationtech.jts.geom.Geometry transform(org.locationtech.jts.geom.Geometry geometry, String srcFrame, String destFrame) throws org.geotools.api.referencing.FactoryException, org.geotools.api.referencing.operation.TransformException Transforms a given geometry from a given reference to a destinated reference.- Parameters:
geometry- the geometry to transform.srcFrame- the reference the given point is in.destFrame- the reference frame the point shall be transformed to.- Returns:
- a transformed point.
- Throws:
org.geotools.api.referencing.FactoryException- if the creation ofCoordinateReferenceSystemfails or no appropriateMathTransformcould be created.org.geotools.api.referencing.operation.TransformException- if transformation fails for any other reason.
-
parseWkt
-
isLatLonAxesOrder
Indicates if the given reference frame has switched axes compared to the inner default (lon/lat).- Parameters:
outer- the given reference frame code to check.- Returns:
trueif axes order is switched compared to the inner default.- Throws:
org.geotools.api.referencing.FactoryException- if no proper CRS could be created.
-
isNorthingFirstEpsgCode
public boolean isNorthingFirstEpsgCode(int epsgCode) throws org.geotools.api.referencing.FactoryException - Throws:
org.geotools.api.referencing.FactoryException
-
isNorthingFirstEpsgCode
public boolean isNorthingFirstEpsgCode(String epsgCode) throws org.geotools.api.referencing.FactoryException - Throws:
org.geotools.api.referencing.FactoryException
-
createEpsgStrictAxisOrder
Creates anCRSUtilswhich offers assistance when doing spatial opererations. Strict means that all CRS defined with lat/lon axis ordering will be handled as defined.- Returns:
- creates a reference helper which (strictly) handles referencing operations.
- Throws:
IllegalStateException- if decoding default CRS fails.
-
createEpsgForcedXYAxisOrder
Creates aCRSUtilswhich offers assistance when doing spatial opererations. Forcing XY means that CRS axis ordering is considered lon/lat ordering, even if defined lat/lon.- Returns:
- creates a reference helper which (strictly) handles referencing operations.
- Throws:
IllegalStateException- if decoding default CRS fails.
-
createEpsgReferenceHelper
public static CRSUtils createEpsgReferenceHelper(org.geotools.util.factory.Hints hints) throws IllegalStateException Creates aCRSUtilswhich offers assistance when doing spatial opererations.- Parameters:
hints- Some GeotoolsHintswhich set behavior and special considerations regarding to the spatial operations.- Returns:
- an instance of
CRSUtilsusing given hints - Throws:
IllegalStateException
-