|
JTS Topology Suite version 1.12 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vividsolutions.jts.geom.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(Coordinate)
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:
Coordinates are represented internally as Java double-precision values. Since Java uses the IEEE-394 floating point standard, this provides 53 bits of precision. (Thus the maximum precisely representable integer is 9,007,199,254,740,992).
JTS methods currently do not handle inputs with different precision models.
Nested Class Summary | |
---|---|
static class |
PrecisionModel.Type
The types of Precision Model which JTS supports. |
Field Summary | |
---|---|
static PrecisionModel.Type |
FIXED
Fixed Precision indicates that coordinates have a fixed number of decimal places. |
static PrecisionModel.Type |
FLOATING
Floating precision corresponds to the standard Java double-precision floating-point representation, which is based on the IEEE-754 standard |
static PrecisionModel.Type |
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(double scale,
double offsetX,
double offsetY)
Deprecated. offsets are no longer supported, since internal representation is rounded floating point |
|
PrecisionModel(PrecisionModel.Type modelType)
Creates a PrecisionModel that specifies
an explicit precision model type. |
|
PrecisionModel(PrecisionModel pm)
Copy constructor to create a new PrecisionModel
from an existing one. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
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 |
getOffsetX()
Deprecated. Offsets are no longer used |
double |
getOffsetY()
Deprecated. Offsets are no longer used |
double |
getScale()
Returns the scale factor used to specify a fixed precision model. |
PrecisionModel.Type |
getType()
Gets the type of this precision model |
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. |
static PrecisionModel |
mostPrecise(PrecisionModel pm1,
PrecisionModel pm2)
Determines which of two PrecisionModel s is the most precise
(allows the greatest number of significant digits). |
Coordinate |
toExternal(Coordinate internal)
Deprecated. no longer needed, since internal representation is same as external representation |
void |
toExternal(Coordinate internal,
Coordinate external)
Deprecated. no longer needed, since internal representation is same as external representation |
Coordinate |
toInternal(Coordinate external)
Deprecated. use makePrecise instead |
void |
toInternal(Coordinate external,
Coordinate internal)
Deprecated. use makePrecise instead |
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 PrecisionModel.Type FIXED
public static final PrecisionModel.Type FLOATING
public static final PrecisionModel.Type FLOATING_SINGLE
public static final double maximumPreciseValue
Constructor Detail |
---|
public PrecisionModel()
PrecisionModel
with a default precision
of FLOATING.
public PrecisionModel(PrecisionModel.Type 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, double offsetX, double offsetY)
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 coordinateoffsetX
- not used.offsetY
- not used.public 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 static PrecisionModel mostPrecise(PrecisionModel pm1, PrecisionModel pm2)
PrecisionModel
s is the most precise
(allows the greatest number of significant digits).
pm1
- a PrecisionModelpm2
- a PrecisionModel
public boolean isFloating()
true
if the precision model supports floating pointpublic int getMaximumSignificantDigits()
WKTWriter
).
This method would be more correctly called getMinimumDecimalPlaces, since it actually computes the number of decimal places that is required to correctly display the full precision of an ordinate value.
Since it is difficult to compute the required number of decimal places for scale factors which are not powers of 10, the algorithm uses a very rough approximation in this case. This has the side effect that for scale factors which are powers of 10 the value returned is 1 greater than the true value.
public double getScale()
public PrecisionModel.Type getType()
PrecisionModel.Type
public double getOffsetX()
public double getOffsetY()
public void toInternal(Coordinate external, Coordinate internal)
internal
to the precise representation of external
.
external
- the original coordinateinternal
- the coordinate whose values will be changed to the
precise representation of external
public Coordinate toInternal(Coordinate external)
external
.
external
- the original coordinate
external
public Coordinate toExternal(Coordinate internal)
internal
.
internal
- the original coordinate
internal
public void toExternal(Coordinate internal, Coordinate external)
external
to the external representation of internal
.
internal
- the original coordinateexternal
- the coordinate whose values will be changed to the
external representation of internal
public double makePrecise(double val)
This method has no effect on NaN values.
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(java.lang.Object o)
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.
compareTo
in interface java.lang.Comparable
o
- the PrecisionModel
with which this PrecisionModel
is being compared
PrecisionModel
is less than, equal to, or greater than the specified PrecisionModel
|
JTS Topology Suite version 1.12 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |