Package org.apache.sis.geometry
Class DirectPosition1D
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.geometry.AbstractDirectPosition
org.apache.sis.geometry.DirectPosition1D
- All Implemented Interfaces:
Serializable
,Cloneable
,org.opengis.geometry.coordinate.Position
,org.opengis.geometry.DirectPosition
A one-dimensional position within some coordinate reference system.
- Since:
- 0.3
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptiondouble
The coordinate value.private org.opengis.referencing.crs.CoordinateReferenceSystem
The coordinate reference system for this position;private static final long
Serial number for inter-operability with different versions. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a position initialized to (0) with anull
coordinate reference system.DirectPosition1D
(double coordinate) Constructs a 1D position from the specified coordinate.Constructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format.DirectPosition1D
(org.opengis.referencing.crs.CoordinateReferenceSystem crs) Constructs a position with the specified coordinate reference system. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a copy of this position.final double[]
Returns a sequence of numbers that hold the coordinate of this position in its reference system.final org.opengis.referencing.crs.CoordinateReferenceSystem
Returns the coordinate reference system in which the coordinate is given.final int
The length of coordinate sequence (the number of entries).final double
getOrdinate
(int dimension) Returns the coordinate at the specified dimension.int
hashCode()
Returns a hash value for this coordinate tuple.void
setCoordinateReferenceSystem
(org.opengis.referencing.crs.CoordinateReferenceSystem crs) Sets the coordinate reference system in which the coordinate is given.void
setLocation
(org.opengis.geometry.DirectPosition position) Sets this coordinate to the specified direct position.void
setOrdinate
(int dimension, double value) Sets the coordinate value along the specified dimension.toString()
Formats this position in the Well Known Text (WKT) format.Methods inherited from class org.apache.sis.geometry.AbstractDirectPosition
castOrCopy, equals, formatTo, getDirectPosition, normalize, parse, toString
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toWKT
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
crs
private org.opengis.referencing.crs.CoordinateReferenceSystem crsThe coordinate reference system for this position; -
coordinate
public double coordinateThe coordinate value.
-
-
Constructor Details
-
DirectPosition1D
public DirectPosition1D()Constructs a position initialized to (0) with anull
coordinate reference system. -
DirectPosition1D
public DirectPosition1D(org.opengis.referencing.crs.CoordinateReferenceSystem crs) Constructs a position with the specified coordinate reference system.- Parameters:
crs
- the coordinate reference system.
-
DirectPosition1D
public DirectPosition1D(double coordinate) Constructs a 1D position from the specified coordinate.- Parameters:
coordinate
- the coordinate value.
-
DirectPosition1D
Constructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format. The given string is typically aPOINT
element like below:- Parameters:
wkt
- thePOINT
or other kind of element to parse.- Throws:
IllegalArgumentException
- if the given string cannot be parsed.org.opengis.geometry.MismatchedDimensionException
- if the given point is not one-dimensional.- See Also:
-
-
Method Details
-
getDimension
public final int getDimension()The length of coordinate sequence (the number of entries). This is always 1 forDirectPosition1D
objects.- Specified by:
getDimension
in interfaceorg.opengis.geometry.DirectPosition
- Returns:
- the dimensionality of this position.
-
getCoordinateReferenceSystem
public final org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()Returns the coordinate reference system in which the coordinate is given. May benull
if this particularDirectPosition
is included in a larger object with such a reference to a CRS.- Specified by:
getCoordinateReferenceSystem
in interfaceorg.opengis.geometry.DirectPosition
- Overrides:
getCoordinateReferenceSystem
in classAbstractDirectPosition
- Returns:
- the coordinate reference system, or
null
.
-
setCoordinateReferenceSystem
public void setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs) Sets the coordinate reference system in which the coordinate is given.- Parameters:
crs
- the new coordinate reference system, ornull
.
-
getCoordinate
public final double[] getCoordinate()Returns a sequence of numbers that hold the coordinate of this position in its reference system.API note: This method is final for ensuring consistency with thecoordinate
field, which is public.- Specified by:
getCoordinate
in interfaceorg.opengis.geometry.DirectPosition
- Overrides:
getCoordinate
in classAbstractDirectPosition
- Returns:
- the coordinates.
-
getOrdinate
Returns the coordinate at the specified dimension.API note: This method is final for ensuring consistency with thecoordinate
field, which is public.- Specified by:
getOrdinate
in interfaceorg.opengis.geometry.DirectPosition
- Parameters:
dimension
- the dimension, which must be 0.- Returns:
- the
coordinate
. - Throws:
IndexOutOfBoundsException
- if the specified dimension is out of bounds.
-
setOrdinate
Sets the coordinate value along the specified dimension.- Specified by:
setOrdinate
in interfaceorg.opengis.geometry.DirectPosition
- Overrides:
setOrdinate
in classAbstractDirectPosition
- Parameters:
dimension
- the dimension, which must be 0.value
- the coordinate value.- Throws:
IndexOutOfBoundsException
- if the specified dimension is out of bounds.
-
setLocation
public void setLocation(org.opengis.geometry.DirectPosition position) throws org.opengis.geometry.MismatchedDimensionException Sets this coordinate to the specified direct position. If the specified position contains a coordinate reference system (CRS), then the CRS for this position will be set to the CRS of the specified position.- Overrides:
setLocation
in classAbstractDirectPosition
- Parameters:
position
- the new position for this point.- Throws:
org.opengis.geometry.MismatchedDimensionException
- if this point doesn't have the expected dimension.
-
toString
Formats this position in the Well Known Text (WKT) format. The output is like below: The string returned by this method can be parsed by theDirectPosition1D
constructor.- Overrides:
toString
in classAbstractDirectPosition
- Returns:
- this position as a
POINT
in Well Known Text (WKT) format.
-
clone
Returns a copy of this position. -
hashCode
public int hashCode()Returns a hash value for this coordinate tuple. This method returns a value compliant with the contract documented in theDirectPosition.hashCode()
javadoc. Consequently, it should be possible to mix differentDirectPosition
implementations in the same hash map.- Specified by:
hashCode
in interfaceorg.opengis.geometry.DirectPosition
- Overrides:
hashCode
in classAbstractDirectPosition
- Returns:
- a hash code value for this position.
-