|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.geometry.iso.PrecisionModel
public class PrecisionModel
Specifies the precision model of the Coordinate
s in a
Geometry
. In other words, specifies the grid of allowable points for
all Geometry
s.
The makePrecise
method allows rounding a coordinate to a "precise"
value; that is, one whose precision is known exactly.
Coordinates are assumed to be precise in geometries. That is, the coordinates are assumed to be rounded to the precision model given for the geometry. JTS input routines automatically round coordinates to the precision model before creating Geometries. All internal operations assume that coordinates are rounded to the precision model. Constructive methods (such as boolean operations) always round computed coordinates to the appropriate precision model.
Currently three types of precision model are supported:
JTS methods currently do not handle inputs with different precision models.
Field Summary | |
---|---|
static org.opengis.geometry.PrecisionType |
FIXED
Fixed Precision indicates that coordinates have a fixed number of decimal places. |
static org.opengis.geometry.PrecisionType |
FLOATING
Floating precision corresponds to the standard Java double-precision floating-point representation, which is based on the IEEE-754 standard |
static org.opengis.geometry.PrecisionType |
FLOATING_SINGLE
Floating single precision corresponds to the standard Java single-precision floating-point representation, which is based on the IEEE-754 standard |
static double |
maximumPreciseValue
The maximum precise value representable in a double. |
Constructor Summary | |
---|---|
PrecisionModel()
Creates a PrecisionModel with a default precision of
FLOATING. |
|
PrecisionModel(double scale)
Creates a PrecisionModel that specifies Fixed precision. |
|
PrecisionModel(PrecisionModel pm)
Copy constructor to create a new PrecisionModel from an
existing one. |
|
PrecisionModel(org.opengis.geometry.PrecisionType modelType)
Creates a PrecisionModel that specifies an explicit
precision model type. |
Method Summary | |
---|---|
int |
compareTo(org.opengis.geometry.Precision precision)
|
int |
compareTo(PrecisionModel other)
Compares this PrecisionModel object with the specified object for
order. |
boolean |
equals(java.lang.Object other)
|
int |
getMaximumSignificantDigits()
Returns the maximum number of significant digits provided by this precision model. |
double |
getScale()
Returns the multiplying factor used to obtain a precise coordinate. |
org.opengis.geometry.PrecisionType |
getType()
Gets the type of this PrecisionModel |
boolean |
isFloating()
Tests whether the precision model supports floating point |
void |
makePrecise(Coordinate coord)
Rounds a Coordinate to the PrecisionModel grid. |
double |
makePrecise(double val)
Rounds a numeric value to the PrecisionModel grid. |
void |
round(org.opengis.geometry.DirectPosition position)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final org.opengis.geometry.PrecisionType FIXED
public static final org.opengis.geometry.PrecisionType FLOATING
public static final org.opengis.geometry.PrecisionType FLOATING_SINGLE
public static final double maximumPreciseValue
Constructor Detail |
---|
public PrecisionModel()
PrecisionModel
with a default precision of
FLOATING.
public PrecisionModel(org.opengis.geometry.PrecisionType modelType)
PrecisionModel
that specifies an explicit
precision model type. If the model type is FIXED the scale factor will
default to 1.
modelType
- the type of the precision modelpublic PrecisionModel(double scale)
PrecisionModel
that specifies Fixed precision.
Fixed-precision coordinates are represented as precise internal
coordinates, which are rounded to the grid defined by the scale factor.
scale
- amount by which to multiply a coordinate after subtracting the
offset, to obtain a precise coordinatepublic PrecisionModel(PrecisionModel pm)
PrecisionModel
from an
existing one.
Method Detail |
---|
public boolean isFloating()
true
if the precision model supports floating
pointpublic int getMaximumSignificantDigits()
getMaximumSignificantDigits
in interface org.opengis.geometry.Precision
public double getScale()
getScale
in interface org.opengis.geometry.Precision
public org.opengis.geometry.PrecisionType getType()
getType
in interface org.opengis.geometry.Precision
public double makePrecise(double val)
Note: Java's Math#rint
uses the "Banker's
Rounding" algorithm, which is not suitable for precision operations
elsewhere in JTS.
public void makePrecise(Coordinate coord)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int compareTo(PrecisionModel other)
PrecisionModel
object with the specified object for
order. A PrecisionModel is greater than another if it provides greater
precision. The comparison is based on the value returned by the
getMaximumSignificantDigits
method. This comparison is not
strictly accurate when comparing floating precision models to fixed
models; however, it is correct when both models are either floating or
fixed.
other
- the PrecisionModel
with which this
PrecisionModel
is being compared
PrecisionModel
is less than, equal to, or greater
than the specified PrecisionModel
public int compareTo(org.opengis.geometry.Precision precision)
compareTo
in interface java.lang.Comparable<org.opengis.geometry.Precision>
compareTo
in interface org.opengis.geometry.Precision
public void round(org.opengis.geometry.DirectPosition position)
round
in interface org.opengis.geometry.Precision
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |