Class AxisSwapper
Utility for swapping Geometry
coordinate order, typically so that it's in the right order for writing where
an output format demands a particular axis order.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.locationtech.jts.geom.CoordinateFilter
static final AxisSwapper.LocalProblems
-
Constructor Summary
ConstructorDescriptionAxisSwapper
(org.geotools.api.referencing.crs.CoordinateReferenceSystem newCrs) -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<AxisSwapper>
getForceEpsgDefined
(org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Returns anAxisSwapper
that flips coordinates to the order defined in the CRS's canonical EPSG definition, or empty if the CRS is the canonical version for.static Optional<AxisSwapper>
getForceXY
(org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, URI storedAt, nz.org.riskscape.problem.ProblemSink problemSink) Returns an AxisSwapper that will flip coordinates to x-y ordering, or empty if the crs is already in x-y order.org.geotools.api.referencing.crs.CoordinateReferenceSystem
A coordinate reference system with the desired ordering, or the original crs if none could be createdorg.locationtech.jts.geom.Geometry
swapAxis
(org.locationtech.jts.geom.Geometry geom)
-
Field Details
-
PROBLEMS
-
AXIS_SWAPPING_FILTER
public static final org.locationtech.jts.geom.CoordinateFilter AXIS_SWAPPING_FILTER
-
-
Constructor Details
-
AxisSwapper
public AxisSwapper(org.geotools.api.referencing.crs.CoordinateReferenceSystem newCrs)
-
-
Method Details
-
getForceXY
public static Optional<AxisSwapper> getForceXY(org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, URI storedAt, nz.org.riskscape.problem.ProblemSink problemSink) Returns an AxisSwapper that will flip coordinates to x-y ordering, or empty if the crs is already in x-y order. If a flipped crs could not be created, a swapper is still returned, but
newCrs
is set to be the original y-x crs. If required, we could change this to be optional, but at the moment we would prefer an incorrect prj to no prj, so it is set to simplify writer logic.- Parameters:
crs
- the crs that geometries are in.storedAt
- used for context if there's a problem with the CRSproblemSink
- a place to dump a problem if no flipped CRS could be created
-
getForceEpsgDefined
public static Optional<AxisSwapper> getForceEpsgDefined(org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Returns an
AxisSwapper
that flips coordinates to the order defined in the CRS's canonical EPSG definition, or empty if the CRS is the canonical version for. We say canonical definition, as a CRS can loosely match another CRS by ESPG code but have different axis order (such as if it's been loaded from a shapefile). This method will normalize the axis order so that it matches the canonically defined order. Or empty if no EPSG code could be matched or if the crs already matches the EPSG defined order. -
swapAxis
public org.locationtech.jts.geom.Geometry swapAxis(org.locationtech.jts.geom.Geometry geom) - Returns:
- a new geometry based on the input geometry, but with X and Y coordinates swapped
-
getNewCrs
public org.geotools.api.referencing.crs.CoordinateReferenceSystem getNewCrs()A coordinate reference system with the desired ordering, or the original crs if none could be created
-