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 Stringprotected doublestatic final intThe default densification limit.static final StringSystem variable that can be used to override the default densification limit.protected doubleprotected static final doubleprotected SingleCRSprotected static final Loggerprotected booleanprotected booleanprotected ReferencedEnvelopeprotected CRS.AxisOrderprotected final CoordinateReferenceSystemprotected CRS.AxisOrderprotected final CoordinateReferenceSystemprotected doubleprotected final PreparedGeometryprotected final Geometryprotected 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 voidaccumulateTransforms(MathTransform mt, List<MathTransform> elements) protected voidaddGeometries(List<Geometry> geoms, GeometryCollection collection, String geometryType) Private method for adding to the input List only theGeometryobjects of the inputGeometryCollectionwhich belongs to the defined geometryTypeprotected voidprotected MathTransformconcatenateTransforms(List<MathTransform> datumShiftChain) protected GeometryDensifies 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 Geometryintersect(Geometry geometry, Geometry mask, CoordinateReferenceSystem geometryCRS) protected voidmergeEnvelopes(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 voidreprojectEnvelopes(CoordinateReferenceSystem queryCRS, List<ReferencedEnvelope> envelopes) booleanrequiresProcessing(Geometry geometry) Returns true if the geometry needs special handlingprotected voidsetCentralMeridian(double centralMeridian) voidsetProjectionParameters(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 ReferencedEnvelopetransformEnvelope(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. ACoordinateobject 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:
TransformExceptionFactoryException
-
getSourceEnvelopes
protected List<ReferencedEnvelope> getSourceEnvelopes(ReferencedEnvelope renderingEnvelope) throws TransformException, FactoryException - Throws:
TransformExceptionFactoryException
-
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:
TransformExceptionFactoryException
-
transformEnvelope
protected ReferencedEnvelope transformEnvelope(ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS) throws TransformException, FactoryException - Throws:
TransformExceptionFactoryException
-
reprojectEnvelopes
protected void reprojectEnvelopes(CoordinateReferenceSystem queryCRS, List<ReferencedEnvelope> envelopes) throws TransformException, FactoryException - Throws:
TransformExceptionFactoryException
-
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:
TransformExceptionFactoryException
-
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 theGeometryobjects of the inputGeometryCollectionwhich belongs to the defined geometryType
-