Class WraparoundAdjustment
RangeMeaning.WRAPAROUND,
this class can add or subtract an integer amount of periods (typically 360° of longitude)
in attempt to move positions or envelopes inside a domain of validity specified at construction time.
WraparoundAdjustment instances are not thread-safe.
- Since:
- 1.2
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ImmutableEnvelopeThe region inside which a given Area Of Interest (AOI) or Point Of Interest (POI) should be located.private final org.opengis.referencing.operation.MathTransformA transform from thedomainOfValidityCRS to theinputCRSif it was explicitly specified, ornullotherwise.private org.opengis.metadata.extent.GeographicBoundingBoxThe geographic bounds ofdomainOfValidity, ornullif not applicable.private booleanWhethergeographicDomainhas been computed (result may be null).private org.opengis.referencing.crs.CoordinateReferenceSystemCoordinate reference system of the last Area Of Interest (AOI) or Point Of Interest (POI).private org.opengis.referencing.operation.MathTransformA transform from theinputCRSto any destination user space at caller choice.private org.opengis.referencing.operation.MathTransformIf the input envelopes or positions need to be converted to a (usually) geographic CRS, the transform to that CRS.private double[]The span (maximum - minimum) of wraparound axes, with 0 value for axes that are not wraparound.private final org.opengis.referencing.crs.CoordinateReferenceSystemCoordinate reference system of results, ornullif unspecified.private AbstractEnvelopeThe domain of validity transformed to a CRS where wraparound axes exist, ornullif not yet computed.private org.opengis.referencing.operation.MathTransformThe transform from the intermediate CRS to final objects, computed when first needed. -
Constructor Summary
ConstructorsConstructorDescriptionWraparoundAdjustment(org.opengis.geometry.Envelope domain, org.opengis.referencing.crs.CoordinateReferenceSystem target) Creates a new instance for adjusting Area Of Interest (AOI) or Point Of Interest (POI) to the given domain.WraparoundAdjustment(org.opengis.geometry.Envelope domain, org.opengis.referencing.operation.MathTransform domainToInput, org.opengis.referencing.operation.MathTransform inputToResult) Creates a new instance with specified transforms from domain to the CRS of inputs, then to the CRS of outputs. -
Method Summary
Modifier and TypeMethodDescriptionprivate org.opengis.referencing.operation.CoordinateOperationfindOperation(org.opengis.referencing.crs.CoordinateReferenceSystem source, org.opengis.referencing.crs.CoordinateReferenceSystem target) Finds a coordinate operation from the given source CRS to target CRS.private booleaninitialize(org.opengis.referencing.crs.CoordinateReferenceSystem crs) Initializes thisWraparoundAdjustmentfor an AOI or POI having the given coordinate reference system.org.opengis.geometry.DirectPositionshift(org.opengis.geometry.DirectPosition pointOfInterest) Computes a position with coordinates equivalent to the givenpointOfInterest, but potentially shifted to interior of the domain of validity specified at construction time.shift(org.opengis.geometry.Envelope areaOfInterest) Computes an envelope with coordinates equivalent to the givenareaOfInterest, but potentially shifted for intersecting the domain of validity specified at construction time.private org.opengis.referencing.operation.MathTransformtoResult(boolean isResultShifted) Returns the final transform to apply on the AOI or POI before to return it to the user.private voidtransformDomain(org.opengis.referencing.crs.CoordinateReferenceSystem target) TransformsdomainOfValidityto a CRS where wraparound axes can be identified.
-
Field Details
-
domainOfValidity
The region inside which a given Area Of Interest (AOI) or Point Of Interest (POI) should be located. This domain is specified at construction time and does not change. -
shiftableDomain
The domain of validity transformed to a CRS where wraparound axes exist, ornullif not yet computed. For example ifdomainOfValidityis expressed in a projected CRS, then this envelope will be the same domain but converted to the base geographic CRS in order to allow identification of wraparound axes. -
geographicDomain
private org.opengis.metadata.extent.GeographicBoundingBox geographicDomainThe geographic bounds ofdomainOfValidity, ornullif not applicable. -
geographicDomainKnown
private boolean geographicDomainKnownWhethergeographicDomainhas been computed (result may be null). -
inputCRS
private org.opengis.referencing.crs.CoordinateReferenceSystem inputCRSCoordinate reference system of the last Area Of Interest (AOI) or Point Of Interest (POI). This is used for detecting when the input CRS changed. -
resultCRS
private final org.opengis.referencing.crs.CoordinateReferenceSystem resultCRSCoordinate reference system of results, ornullif unspecified. -
inputToResult
private org.opengis.referencing.operation.MathTransform inputToResultA transform from theinputCRSto any destination user space at caller choice. Objects returned byshift(…)methods will be transformed by this transform after all computations have been finished. This is done in order to allow final transforms to be concatenated in a single step.This field should be considered final if
domainToInputis non-null. -
domainToInput
private final org.opengis.referencing.operation.MathTransform domainToInputA transform from thedomainOfValidityCRS to theinputCRSif it was explicitly specified, ornullotherwise. If non-null, all input envelopes or positions will be assumed in the CRS which is the target of this transform. For performance reason, this assumption will not be verified. -
inputToShiftable
private org.opengis.referencing.operation.MathTransform inputToShiftableIf the input envelopes or positions need to be converted to a (usually) geographic CRS, the transform to that CRS. Otherwise an identity transform. This is computed when first needed. -
shiftableToResult
private org.opengis.referencing.operation.MathTransform shiftableToResultThe transform from the intermediate CRS to final objects, computed when first needed.- See Also:
-
periods
private double[] periodsThe span (maximum - minimum) of wraparound axes, with 0 value for axes that are not wraparound. Initially null and computed when first needed. The length of this array may be shorter than the CRS number of dimensions if all remaining axes are not wraparound axes.
-
-
Constructor Details
-
WraparoundAdjustment
public WraparoundAdjustment(org.opengis.geometry.Envelope domain, org.opengis.referencing.crs.CoordinateReferenceSystem target) Creates a new instance for adjusting Area Of Interest (AOI) or Point Of Interest (POI) to the given domain. The results ofshift(…)methods will be transformed (if needed) to the specified CRS.- Parameters:
domain- the region where a given area or point of interest should be located.target- the coordinate reference system of objects returned byshift(…)methods, ornullfor the same CRS than thedomainCRS..
-
WraparoundAdjustment
public WraparoundAdjustment(org.opengis.geometry.Envelope domain, org.opengis.referencing.operation.MathTransform domainToInput, org.opengis.referencing.operation.MathTransform inputToResult) Creates a new instance with specified transforms from domain to the CRS of inputs, then to the CRS of outputs. This constructor can be used when those transforms are known in advance; it avoids the cost of inferring them. With this constructor,WraparoundAdjustmentdoes not verify if a coordinate operation is needed for a pair of CRS; it is caller's responsibility to ensure that input objects use the expected CRS.Example: in the context ofGridGeometry, thedomainargument may be the geospatial envelope of the grid and theinputToResultargument may be the "CRS to grid" transform. This configuration allows to compute grid coordinates having more chances to be inside the grid.- Parameters:
domain- the region where a given area (AOI) or point of interest (POI) should be located.domainToInput- if the AOI or POI will use a different CRS thandomain, the transform fromdomainto the input CRS. Otherwisenullfor same CRS as the domain.inputToResult- a transform from thedomainCRS to any user space at caller choice. Ifnull, the results will be expressed in same CRS than the inputs.
-
-
Method Details
-
findOperation
private org.opengis.referencing.operation.CoordinateOperation findOperation(org.opengis.referencing.crs.CoordinateReferenceSystem source, org.opengis.referencing.crs.CoordinateReferenceSystem target) throws org.opengis.referencing.operation.TransformException Finds a coordinate operation from the given source CRS to target CRS. This method is invoked by all codes that need to find a coordinate operation.- Parameters:
source- the source CRS of the desired coordinate operation.target- the target CRS of the desired coordinate operation.- Returns:
- operation from
sourcetotarget. - Throws:
org.opengis.referencing.operation.TransformException- if the operation cannot be computed.
-
initialize
private boolean initialize(org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws org.opengis.referencing.operation.TransformException Initializes thisWraparoundAdjustmentfor an AOI or POI having the given coordinate reference system. If the given CRS is the same than the CRS given in last call to this method, then this method does nothing as thisWraparoundAdjustmentis assumed already initialized. Otherwise this method performs those steps:- If the given coordinate reference system is a projected CRS, replaces it by another CRS where wraparound axes can be identified.
- Set
shiftableDomainto an envelope in above CRS. - Set
periodsto an array with the periods of wraparound axes. - Set
inputToResultto the final transform to apply inshift(…)methods.
- Returns:
- whether there is at least one wraparound axis.
- Throws:
org.opengis.referencing.operation.TransformException
-
transformDomain
private void transformDomain(org.opengis.referencing.crs.CoordinateReferenceSystem target) throws org.opengis.referencing.operation.TransformException TransformsdomainOfValidityto a CRS where wraparound axes can be identified. This method should be invoked only when the caller detected at least one wraparound axis.If a
domainToInputhas been explicitly specified to the constructor, that transform is unconditionally used and thecrsargument is ignored.Preconditions
- The
inputToShiftabletransform must be initialized. - The
shiftableDomainfield is assumed initialized todomainOfValidity.
- Throws:
org.opengis.referencing.operation.TransformException
- The
-
toResult
private org.opengis.referencing.operation.MathTransform toResult(boolean isResultShifted) throws org.opengis.referencing.operation.TransformException Returns the final transform to apply on the AOI or POI before to return it to the user. IfinputCRSis null, returnsnullfor meaning "unknown transform".- Throws:
org.opengis.referencing.operation.TransformException
-
shift
public GeneralEnvelope shift(org.opengis.geometry.Envelope areaOfInterest) throws org.opengis.referencing.operation.TransformException Computes an envelope with coordinates equivalent to the givenareaOfInterest, but potentially shifted for intersecting the domain of validity specified at construction time. The dimensions that may be shifted are the ones having an axis with wraparound meaning. In order to perform this operation, the envelope may be temporarily converted to a geographic CRS and converted back to its original CRS.The coordinate reference system should be specified in the
areaOfInterest. If not, then the CRS is assumed same as the CRS of the domain specified at construction time.This method does not intersect the area of interest with the domain of validity. It is up to the caller to compute that intersection after this method call, if desired.
- Parameters:
areaOfInterest- the envelope to potentially shift toward domain of validity. If a shift is needed, then given envelope will be replaced by a new envelope; the given envelope will not be modified.- Returns:
- envelope potentially expanded or shifted toward the domain of validity.
- Throws:
org.opengis.referencing.operation.TransformException- if a coordinate conversion failed.- See Also:
-
shift
public org.opengis.geometry.DirectPosition shift(org.opengis.geometry.DirectPosition pointOfInterest) throws org.opengis.referencing.operation.TransformException Computes a position with coordinates equivalent to the givenpointOfInterest, but potentially shifted to interior of the domain of validity specified at construction time. The dimensions that may be shifted are the ones having an axis with wraparound meaning. In order to perform this operation, the position may be temporarily converted to a geographic CRS and converted back to its original CRS.The coordinate reference system should be specified in the
pointOfInterest. If not, then the CRS is assumed same as the CRS of the domain specified at construction time.- Parameters:
pointOfInterest- the position to potentially shift to domain of validity interior. If a shift is needed, then the given position will be replaced by a new position; the given position will not be modified.- Returns:
- position potentially shifted to the domain of validity interior.
- Throws:
org.opengis.referencing.operation.TransformException- if a coordinate conversion failed.
-