Package org.geotools.renderer.crs
Class ProjectionHandler
Object
ProjectionHandler
- Direct Known Subclasses:
WrappingProjectionHandler
A class that can perform transformations on geometries to handle the singularity of the rendering CRS, deal with
geometries that are crossing the dateline, and eventually wrap them around to produce a seamless continuous map
effect.
This basic implementation will cut the geometries that get outside of the area of validity of the projection (as provided by the constructor)
WARNING: this API is not finalized and is meant to be used by StreamingRenderer only
- Author:
- Andrea Aime - OpenGeo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
protected double
static final int
The default densification limit.static final String
System variable that can be used to override the default densification limit.protected double
protected static final double
protected SingleCRS
protected static final Logger
protected boolean
protected boolean
protected ReferencedEnvelope
protected CRS.AxisOrder
protected final CoordinateReferenceSystem
protected CRS.AxisOrder
protected final CoordinateReferenceSystem
protected double
protected final PreparedGeometry
protected final Geometry
protected final ReferencedEnvelope
-
Constructor Summary
ConstructorsConstructorDescriptionProjectionHandler
(CoordinateReferenceSystem sourceCRS, Envelope validAreaBounds, ReferencedEnvelope renderingEnvelope) Initializes a projection handlerProjectionHandler
(CoordinateReferenceSystem sourceCRS, Geometry validArea, ReferencedEnvelope renderingEnvelope) Initializes a projection handlerProjectionHandler
(CoordinateReferenceSystem sourceCRS, Geometry validArea, ReferencedEnvelope renderingEnvelope, boolean keepGeometry) Initializes a projection handler -
Method Summary
Modifier and TypeMethodDescriptionprotected void
accumulateTransforms
(MathTransform mt, List<MathTransform> elements) protected void
addGeometries
(List<Geometry> geoms, GeometryCollection collection, String geometryType) Private method for adding to the input List only theGeometry
objects of the inputGeometryCollection
which belongs to the defined geometryTypeprotected void
protected MathTransform
concatenateTransforms
(List<MathTransform> datumShiftChain) protected Geometry
Densifies the given geometry using the current densification configuration.getProjectedEnvelope
(ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS) Reprojects the given envelope to the target CRS, taking into account the ProjectionHandler constraints (valid area bounds, etc.).Returns a set of envelopes that will be used to query the data given the specified rendering envelope and the current query envelopeReturns the current rendering envelopeCan modify/wrap the transform to handle specific projection issuesprotected List<ReferencedEnvelope>
getSourceEnvelopes
(ReferencedEnvelope renderingEnvelope) Returns the valid area as a JTS geometry, if it's a complex area (otherwise usegetValidAreaBounds()
)Returns the area where the transformation from source to target is valid, expressed in the source coordinate reference system, or null if there is no limitprotected Geometry
intersect
(Geometry geometry, Geometry mask, CoordinateReferenceSystem geometryCRS) protected void
mergeEnvelopes
(List<ReferencedEnvelope> envelopes) postProcess
(MathTransform mt, Geometry geometry) Processes the geometry already projected to the target SRS.preProcess
(Geometry geometry) Pre processes the geometry, e.g. cuts it, splits it, etc. in its native srs.protected void
reprojectEnvelopes
(CoordinateReferenceSystem queryCRS, List<ReferencedEnvelope> envelopes) boolean
requiresProcessing
(Geometry geometry) Returns true if the geometry needs special handlingprotected void
setCentralMeridian
(double centralMeridian) void
setProjectionParameters
(Map<String, Object> projectionParameters) Set one of the supported projection parameters: - advancedProjectionDensify (double) if > 0 enables densification on preprocessing with the given distance between points.protected ReferencedEnvelope
transformEnvelope
(ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS)
-
Field Details
-
ADVANCED_PROJECTION_DENSIFY
- See Also:
-
EPS
protected static final double EPS- See Also:
-
LOGGER
-
DEFAULT_DENSIFICATION_LIMIT
public static final int DEFAULT_DENSIFICATION_LIMITThe default densification limit. ACoordinate
object is 40 bytes, this number allows the allocation of at most 10MB worth of Coordinate objects- See Also:
-
DENSIFICATION_LIMIT_KEY
System variable that can be used to override the default densification limit.- See Also:
-
sourceAxisOrder
-
targetAxisOrder
-
renderingEnvelope
-
validAreaBounds
-
validArea
-
validaAreaTester
-
sourceCRS
-
targetCRS
-
datelineX
protected double datelineX -
targetHalfCircle
protected double targetHalfCircle -
queryAcrossDateline
protected boolean queryAcrossDateline -
geometryCRS
-
noReprojection
protected boolean noReprojection -
densify
protected double densify
-
-
Constructor Details
-
ProjectionHandler
public ProjectionHandler(CoordinateReferenceSystem sourceCRS, Envelope validAreaBounds, ReferencedEnvelope renderingEnvelope) throws FactoryException Initializes a projection handler- Parameters:
sourceCRS
- The source CRSvalidAreaBounds
- The valid area (used to cut geometries that go beyond it)renderingEnvelope
- The target rendering area and target CRS- Throws:
FactoryException
-
ProjectionHandler
public ProjectionHandler(CoordinateReferenceSystem sourceCRS, Geometry validArea, ReferencedEnvelope renderingEnvelope) throws FactoryException Initializes a projection handler- Parameters:
sourceCRS
- The source CRSvalidArea
- The valid area (used to cut geometries that go beyond it)renderingEnvelope
- The target rendering area and target CRS- Throws:
FactoryException
-
ProjectionHandler
public ProjectionHandler(CoordinateReferenceSystem sourceCRS, Geometry validArea, ReferencedEnvelope renderingEnvelope, boolean keepGeometry) throws FactoryException Initializes a projection handler- Parameters:
sourceCRS
- The source CRSvalidArea
- The valid area (used to cut geometries that go beyond it)renderingEnvelope
- The target rendering area and target CRSkeepGeometry
- Can be used to force the valid area to be treated as a polygon, even when it's a rectangle- Throws:
FactoryException
-
-
Method Details
-
setProjectionParameters
Set one of the supported projection parameters: - advancedProjectionDensify (double) if > 0 enables densification on preprocessing with the given distance between points. -
getRenderingEnvelope
Returns the current rendering envelope -
getSourceCRS
-
getQueryEnvelopes
Returns a set of envelopes that will be used to query the data given the specified rendering envelope and the current query envelope- Throws:
TransformException
FactoryException
-
getSourceEnvelopes
protected List<ReferencedEnvelope> getSourceEnvelopes(ReferencedEnvelope renderingEnvelope) throws TransformException, FactoryException - Throws:
TransformException
FactoryException
-
getProjectedEnvelope
public ReferencedEnvelope getProjectedEnvelope(ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS) throws TransformException, FactoryException Reprojects the given envelope to the target CRS, taking into account the ProjectionHandler constraints (valid area bounds, etc.).- Parameters:
envelope
- envelope to reprojecttargetCRS
- target CRS- Returns:
- reprojected envelope
- Throws:
TransformException
FactoryException
-
transformEnvelope
protected ReferencedEnvelope transformEnvelope(ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS) throws TransformException, FactoryException - Throws:
TransformException
FactoryException
-
reprojectEnvelopes
protected void reprojectEnvelopes(CoordinateReferenceSystem queryCRS, List<ReferencedEnvelope> envelopes) throws TransformException, FactoryException - Throws:
TransformException
FactoryException
-
mergeEnvelopes
-
requiresProcessing
Returns true if the geometry needs special handling -
preProcess
Pre processes the geometry, e.g. cuts it, splits it, etc. in its native srs. May return null if the geometry is not to be drawn- Throws:
TransformException
FactoryException
-
densify
Densifies the given geometry using the current densification configuration.It returns the original geometry if densification is not enabled.
-
intersect
protected Geometry intersect(Geometry geometry, Geometry mask, CoordinateReferenceSystem geometryCRS) -
getRenderingTransform
Can modify/wrap the transform to handle specific projection issues- Throws:
FactoryException
-
concatenateTransforms
-
accumulateTransforms
-
postProcess
Processes the geometry already projected to the target SRS. May return null if the geometry is not to be drawn.- Parameters:
mt
- optional reverse transformation to facilitate unwrapping
-
getValidAreaBounds
Returns the area where the transformation from source to target is valid, expressed in the source coordinate reference system, or null if there is no limit -
getValidArea
Returns the valid area as a JTS geometry, if it's a complex area (otherwise usegetValidAreaBounds()
)- Returns:
-
setCentralMeridian
protected void setCentralMeridian(double centralMeridian) -
computeDatelineX
protected void computeDatelineX() -
addGeometries
protected void addGeometries(List<Geometry> geoms, GeometryCollection collection, String geometryType) Private method for adding to the input List only theGeometry
objects of the inputGeometryCollection
which belongs to the defined geometryType
-