Package org.geotools.renderer.crs
Class ProjectionHandler
- Object
-
- ProjectionHandler
-
- Direct Known Subclasses:
WrappingProjectionHandler
public class ProjectionHandler extends Object
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
Fields Modifier and Type Field Description static String
ADVANCED_PROJECTION_DENSIFY
protected double
datelineX
static int
DEFAULT_DENSIFICATION_LIMIT
The default densification limit.static String
DENSIFICATION_LIMIT_KEY
System variable that can be used to override the default densification limit.protected double
densify
protected static double
EPS
protected SingleCRS
geometryCRS
protected static Logger
LOGGER
protected boolean
noReprojection
protected boolean
queryAcrossDateline
protected ReferencedEnvelope
renderingEnvelope
protected CRS.AxisOrder
sourceAxisOrder
protected CoordinateReferenceSystem
sourceCRS
protected CRS.AxisOrder
targetAxisOrder
protected CoordinateReferenceSystem
targetCRS
protected double
targetHalfCircle
protected PreparedGeometry
validaAreaTester
protected Geometry
validArea
protected ReferencedEnvelope
validAreaBounds
-
Constructor Summary
Constructors Constructor Description ProjectionHandler(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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
computeDatelineX()
protected MathTransform
concatenateTransforms(List<MathTransform> datumShiftChain)
protected Geometry
densify(Geometry geometry, boolean validate)
Densifies the given geometry using the current densification configuration.ReferencedEnvelope
getProjectedEnvelope(ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS)
Reprojects the given envelope to the target CRS, taking into account the ProjectionHandler constraints (valid area bounds, etc.).List<ReferencedEnvelope>
getQueryEnvelopes()
Returns a set of envelopes that will be used to query the data given the specified rendering envelope and the current query envelopeReferencedEnvelope
getRenderingEnvelope()
Returns the current rendering envelopeMathTransform
getRenderingTransform(MathTransform mt)
Can modify/wrap the transform to handle specific projection issuesCoordinateReferenceSystem
getSourceCRS()
protected List<ReferencedEnvelope>
getSourceEnvelopes(ReferencedEnvelope renderingEnvelope)
Geometry
getValidArea()
Returns the valid area as a JTS geometry, if it's a complex area (otherwise usegetValidAreaBounds()
)ReferencedEnvelope
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 limitprotected Geometry
intersect(Geometry geometry, Geometry mask, CoordinateReferenceSystem geometryCRS)
protected void
mergeEnvelopes(List<ReferencedEnvelope> envelopes)
Geometry
postProcess(MathTransform mt, Geometry geometry)
Processes the geometry already projected to the target SRS.Geometry
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 Detail
-
ADVANCED_PROJECTION_DENSIFY
public static final String ADVANCED_PROJECTION_DENSIFY
- See Also:
- Constant Field Values
-
EPS
protected static final double EPS
- See Also:
- Constant Field Values
-
LOGGER
protected static final Logger LOGGER
-
DEFAULT_DENSIFICATION_LIMIT
public static final int DEFAULT_DENSIFICATION_LIMIT
The default densification limit. ACoordinate
object is 40 bytes, this number allows the allocation of at most 10MB worth of Coordinate objects- See Also:
- Constant Field Values
-
DENSIFICATION_LIMIT_KEY
public static final String DENSIFICATION_LIMIT_KEY
System variable that can be used to override the default densification limit.- See Also:
- Constant Field Values
-
sourceAxisOrder
protected CRS.AxisOrder sourceAxisOrder
-
targetAxisOrder
protected CRS.AxisOrder targetAxisOrder
-
renderingEnvelope
protected ReferencedEnvelope renderingEnvelope
-
validAreaBounds
protected final ReferencedEnvelope validAreaBounds
-
validArea
protected final Geometry validArea
-
validaAreaTester
protected final PreparedGeometry validaAreaTester
-
sourceCRS
protected final CoordinateReferenceSystem sourceCRS
-
targetCRS
protected final CoordinateReferenceSystem targetCRS
-
datelineX
protected double datelineX
-
targetHalfCircle
protected double targetHalfCircle
-
queryAcrossDateline
protected boolean queryAcrossDateline
-
geometryCRS
protected SingleCRS geometryCRS
-
noReprojection
protected boolean noReprojection
-
densify
protected double densify
-
-
Constructor Detail
-
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 Detail
-
setProjectionParameters
public 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.
-
getRenderingEnvelope
public ReferencedEnvelope getRenderingEnvelope()
Returns the current rendering envelope
-
getSourceCRS
public CoordinateReferenceSystem getSourceCRS()
-
getQueryEnvelopes
public List<ReferencedEnvelope> getQueryEnvelopes() throws TransformException, FactoryException
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
protected void mergeEnvelopes(List<ReferencedEnvelope> envelopes)
-
requiresProcessing
public boolean requiresProcessing(Geometry geometry)
Returns true if the geometry needs special handling
-
preProcess
public Geometry preProcess(Geometry geometry) throws TransformException, FactoryException
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
protected Geometry densify(Geometry geometry, boolean validate)
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
public MathTransform getRenderingTransform(MathTransform mt) throws FactoryException
Can modify/wrap the transform to handle specific projection issues- Throws:
FactoryException
-
concatenateTransforms
protected MathTransform concatenateTransforms(List<MathTransform> datumShiftChain)
-
accumulateTransforms
protected void accumulateTransforms(MathTransform mt, List<MathTransform> elements)
-
postProcess
public Geometry postProcess(MathTransform mt, Geometry geometry)
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
public ReferencedEnvelope 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
public Geometry 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
-
-