Package org.apache.sis.geometry
Class DirectPosition1D
Object
FormattableObject
AbstractDirectPosition
DirectPosition1D
- All Implemented Interfaces:
- Serializable,- Cloneable,- Position,- DirectPosition
A one-dimensional position within some coordinate reference system.
- Since:
- 0.3
- See Also:
Defined in the sis-referencing module
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a position initialized to (0) with anullcoordinate 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.Constructs a position with the specified coordinate reference system.
- 
Method SummaryModifier 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.Returns the coordinate reference system in which the coordinate is given.final intThe length of coordinate sequence (the number of entries).final doublegetOrdinate(int dimension) Returns the coordinate at the specified dimension.intReturns a hash value for this coordinate tuple.voidSets the coordinate reference system in which the coordinate is given.voidsetLocation(DirectPosition position) Sets this coordinate to the specified direct position.voidsetOrdinate(int dimension, double value) Sets the coordinate value along the specified dimension.Formats this position in the Well Known Text (WKT) format.Methods inherited from class AbstractDirectPositioncastOrCopy, equals, formatTo, getDirectPosition, normalizeMethods inherited from class FormattableObjectprint, toString, toWKT
- 
Field Details- 
coordinatepublic double coordinateThe coordinate value.
 
- 
- 
Constructor Details- 
DirectPosition1Dpublic DirectPosition1D()Constructs a position initialized to (0) with anullcoordinate reference system.
- 
DirectPosition1DConstructs a position with the specified coordinate reference system.- Parameters:
- crs- the coordinate reference system.
 
- 
DirectPosition1Dpublic DirectPosition1D(double coordinate) Constructs a 1D position from the specified coordinate.- Parameters:
- coordinate- the coordinate value.
 
- 
DirectPosition1DConstructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format. The given string is typically aPOINTelement like below:POINT(6) - Parameters:
- wkt- the- POINTor other kind of element to parse.
- Throws:
- IllegalArgumentException- if the given string cannot be parsed.
- MismatchedDimensionException- if the given point is not one-dimensional.
- See Also:
 
 
- 
- 
Method Details- 
getDimensionpublic final int getDimension()The length of coordinate sequence (the number of entries). This is always 1 forDirectPosition1Dobjects.- Specified by:
- getDimensionin interface- DirectPosition
- Returns:
- the dimensionality of this position.
 
- 
getCoordinateReferenceSystemReturns the coordinate reference system in which the coordinate is given. May benullif this particularDirectPositionis included in a larger object with such a reference to a CRS.- Specified by:
- getCoordinateReferenceSystemin interface- DirectPosition
- Overrides:
- getCoordinateReferenceSystemin class- AbstractDirectPosition
- Returns:
- the coordinate reference system, or null.
 
- 
setCoordinateReferenceSystemSets the coordinate reference system in which the coordinate is given.- Parameters:
- crs- the new coordinate reference system, or- null.
 
- 
getCoordinatepublic 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 thecoordinatefield, which is public.- Specified by:
- getCoordinatein interface- DirectPosition
- Overrides:
- getCoordinatein class- AbstractDirectPosition
- Returns:
- the coordinates.
 
- 
getOrdinateReturns the coordinate at the specified dimension.API note: This method is final for ensuring consistency with thecoordinatefield, which is public.- Specified by:
- getOrdinatein interface- DirectPosition
- Parameters:
- dimension- the dimension, which must be 0.
- Returns:
- the coordinate.
- Throws:
- IndexOutOfBoundsException- if the specified dimension is out of bounds.
 
- 
setOrdinateSets the coordinate value along the specified dimension.- Specified by:
- setOrdinatein interface- DirectPosition
- Overrides:
- setOrdinatein class- AbstractDirectPosition
- Parameters:
- dimension- the dimension, which must be 0.
- value- the coordinate value.
- Throws:
- IndexOutOfBoundsException- if the specified dimension is out of bounds.
 
- 
setLocationSets 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:
- setLocationin class- AbstractDirectPosition
- Parameters:
- position- the new position for this point.
- Throws:
- MismatchedDimensionException- if this point doesn't have the expected dimension.
 
- 
toStringFormats this position in the Well Known Text (WKT) format. The output is like below:
 The string returned by this method can be parsed by thePOINT(coordinate) DirectPosition1Dconstructor.- Overrides:
- toStringin class- AbstractDirectPosition
- Returns:
- this position as a POINTin Well Known Text (WKT) format.
 
- 
cloneReturns a copy of this position.
- 
hashCodepublic 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 differentDirectPositionimplementations in the same hash map.- Specified by:
- hashCodein interface- DirectPosition
- Overrides:
- hashCodein class- AbstractDirectPosition
- Returns:
- a hash code value for this position.
 
 
-