Class Referenced
- All Implemented Interfaces:
Type
,WrappingType
Type that adds CoordinateReferenceSystem
and an optional bounds to another type.
NB This class can wrap any type, not just geometry, so care should be taken when finding Referenced types to ensure that they are also Geometry types before casting the values to Geometry.
-
Constructor Summary
ConstructorDescriptionReferenced
(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Convenience constructor that omits the bounds from the Referenced type.Referenced
(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, org.locationtech.jts.geom.Envelope envelope) Create a new Referenced type that wraps the given type with a crs and a bounds envelope.Referenced
(Type underlying, org.geotools.geometry.jts.ReferencedEnvelope envelope) Convenience constructor that takes the crs and bounds from the given referenced envelope -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Attempt to convert the given value in to one represented by this type.static Type
computeAncestor
(Referenced lhs, Referenced rhs) boolean
org.geotools.geometry.jts.ReferencedEnvelope
org.geotools.api.referencing.crs.CoordinateReferenceSystem
getCrs()
org.locationtech.jts.geom.Envelope
int
hashCode()
Class<?>
The underlying java class used to represent this type.static Type
Now somewhat needless static constructor to avoid undue change in code that was calling it.static Type
of
(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, org.locationtech.jts.geom.Envelope envelope) Now somewhat needless static constructor to avoid undue change in code that was calling it.static Type
ofNullable
(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Static constructor that takes care of re-wrapping the produced referenced type with nullable if the given underlying type was nullablestatic Type
ofNullable
(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, org.locationtech.jts.geom.Envelope envelope) Static constructor that takes care of re-wrapping the produced referenced type with nullable if the given underlying type was nullablestatic Type
ofNullable
(Type underlying, org.geotools.geometry.jts.ReferencedEnvelope bounds) Static constructor that takes care of re-wrapping the produced referenced type with nullable if the given underlying type was nullabletoString()
Returns a new Type with underlyingType of toWrap with the same crs and bounds as this referenced.wrapNullable
(Type toWrap) Returns a new Type with underlyingType of toWrap with the same crs and bounds as this referenced.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nz.org.riskscape.engine.types.Type
checkForNull, find, findAllowNull, getUnwrappedType, isA, isNumeric, isWrapped, toString, unwrap
Methods inherited from interface nz.org.riskscape.engine.types.WrappingType
asStruct, estimateSize, fromBytes, isNullable, toBytes, visit
-
Constructor Details
-
Referenced
Convenience constructor that takes the crs and bounds from the given referenced envelope
-
Referenced
Convenience constructor that omits the bounds from the Referenced type.
-
Referenced
public Referenced(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, org.locationtech.jts.geom.Envelope envelope) Create a new Referenced type that wraps the given type with a crs and a bounds envelope.
- Parameters:
underlying
- not Nullable, not already Referenced, Type. Use one of the ofNullable constructors if the given type might be nullablecrs
- aCoordinateReferenceSystem
to associate with the given type. Can not be null.envelope
- an optional envelope to associate with the geometry. If this is given then it is expected that all geometry that emerges from this type will be within the bounds of the envelope. Can be null- Throws:
IllegalArgumentException
- if the type is nullable or already wrapped in a referenced type.
-
-
Method Details
-
computeAncestor
- Returns:
- the common ancestor type, preserving the Referenced info, if possible
-
ofNullable
public static Type ofNullable(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Static constructor that takes care of re-wrapping the produced referenced type with nullable if the given underlying type was nullable
-
ofNullable
Static constructor that takes care of re-wrapping the produced referenced type with nullable if the given underlying type was nullable
-
ofNullable
public static Type ofNullable(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, org.locationtech.jts.geom.Envelope envelope) Static constructor that takes care of re-wrapping the produced referenced type with nullable if the given underlying type was nullable
-
of
public static Type of(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs, org.locationtech.jts.geom.Envelope envelope) Now somewhat needless static constructor to avoid undue change in code that was calling it. NB static constructors are most useful when they do something that isn't possible in a vanilla constructor, such as handing out frequently used instances to avoid unnecessary promulgation of objects, or having some extra logic that might affect the return type, or perhaps giving it a more meaningful name in the case it accepts different arguments. I had originally started remove all the uses of this method, but it seemed petty so i've left them, but know that this method does nothing special beyond constructing an instance.
-
of
public static Type of(Type underlying, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) Now somewhat needless static constructor to avoid undue change in code that was calling it. NB static constructors are most useful when they do something that isn't possible in a vanilla constructor, such as handing out frequently used instances to avoid unnecessary promulgation of objects, or having some extra logic that might affect the return type, or perhaps giving it a more meaningful name in the case it accepts different arguments. I had originally started remove all the uses of this method, but it seemed petty so i've left them, but know that this method does nothing special beyond constructing an instance.
-
getBounds
public org.geotools.geometry.jts.ReferencedEnvelope getBounds() -
coerce
Description copied from interface:Type
Attempt to convert the given value in to one represented by this type.
- Specified by:
coerce
in interfaceType
- Parameters:
value
- The value to coerce- Returns:
- A value that conforms to this type
- Throws:
CoercionException
- if the given object can not be converted to something represented by this type
-
internalType
Description copied from interface:Type
The underlying java class used to represent this type.
- Specified by:
internalType
in interfaceType
-
wrapNullable
Returns a new Type with underlyingType of toWrap with the same crs and bounds as this referenced.
- Parameters:
toWrap
- type to reference with this crs/bounds- Returns:
- referenced toWrap
-
wrap
Returns a new Type with underlyingType of toWrap with the same crs and bounds as this referenced.
- Parameters:
toWrap
- type to reference with this crs/bounds- Returns:
- referenced toWrap
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getUnderlyingType
- Specified by:
getUnderlyingType
in interfaceWrappingType
- Returns:
- the type that we immediately wrap. Used by
Type.getUnwrappedType()
to descend through all wrappedType
to find the first unwrapped one.
-
getCrs
public org.geotools.api.referencing.crs.CoordinateReferenceSystem getCrs() -
getEnvelope
public org.locationtech.jts.geom.Envelope getEnvelope()
-