Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
com.vividsolutions.jts.geom.PrecisionModel
public class PrecisionModel
extends java.lang.Object
implements Serializable, Comparable
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:
Field Summary | |
static com.vividsolutions.jts.geom.PrecisionModel.Type |
|
static com.vividsolutions.jts.geom.PrecisionModel.Type |
|
static com.vividsolutions.jts.geom.PrecisionModel.Type |
|
static double |
|
Constructor Summary | |
| |
| |
| |
| |
|
Method Summary | |
int |
|
boolean |
|
int |
|
double |
|
double |
|
double |
|
com.vividsolutions.jts.geom.PrecisionModel.Type |
|
boolean |
|
void |
|
double |
|
Coordinate |
|
void |
|
Coordinate |
|
void |
|
String |
|
public static final com.vividsolutions.jts.geom.PrecisionModel.Type FIXED
Fixed Precision indicates that coordinates have a fixed number of decimal places. The number of decimal places is determined by the log10 of the scale factor.
public static final com.vividsolutions.jts.geom.PrecisionModel.Type FLOATING
Floating precision corresponds to the standard Java double-precision floating-point representation, which is based on the IEEE-754 standard
public static final com.vividsolutions.jts.geom.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
public static final double maximumPreciseValue
The maximum precise value representable in a double. Since IEE754 double-precision numbers allow 53 bits of mantissa, the value is equal to 2^53 - 1. This provides almost 16 decimal digits of precision.
- Field Value:
- 2.147483647E9
public PrecisionModel()
Creates aPrecisionModel
with a default precision of FLOATING.
public PrecisionModel(PrecisionModel pm)
Copy constructor to create a newPrecisionModel
from an existing one.
public PrecisionModel(com.vividsolutions.jts.geom.PrecisionModel.Type modelType)
Creates aPrecisionModel
that specifies an explicit precision model type. If the model type is FIXED the scale factor will default to 1.
- Parameters:
modelType
- the type of the precision model
public PrecisionModel(double scale)
Creates aPrecisionModel
that specifies Fixed precision. Fixed-precision coordinates are represented as precise internal coordinates, which are rounded to the grid defined by the scale factor.
- Parameters:
scale
- amount by which to multiply a coordinate after subtracting the offset, to obtain a precise coordinate
public PrecisionModel(double scale, double offsetX, double offsetY)
Deprecated. offsets are no longer supported, since internal representation is rounded floating point
Creates aPrecisionModel
that specifies Fixed precision. Fixed-precision coordinates are represented as precise internal coordinates, which are rounded to the grid defined by the scale factor.
- Parameters:
scale
- amount by which to multiply a coordinate after subtracting the offset, to obtain a precise coordinateoffsetX
- not used.offsetY
- not used.
public int compareTo(Object o)
Compares thisPrecisionModel
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. @param o thePrecisionModel
with which thisPrecisionModel
is being compared @return a negative integer, zero, or a positive integer as thisPrecisionModel
is less than, equal to, or greater than the specifiedPrecisionModel
public boolean equals(Object other)
public int getMaximumSignificantDigits()
Returns the maximum number of significant digits provided by this precision model. Intended for use by routines which need to print out precise values.
- Returns:
- the maximum number of decimal places provided by this precision model
public double getOffsetX()
Deprecated. Offsets are no longer used
Returns the x-offset used to obtain a precise coordinate.
- Returns:
- the amount by which to subtract the x-coordinate before multiplying by the scale
public double getOffsetY()
Deprecated. Offsets are no longer used
Returns the y-offset used to obtain a precise coordinate.
- Returns:
- the amount by which to subtract the y-coordinate before multiplying by the scale
public double getScale()
Returns the multiplying factor used to obtain a precise coordinate. This method is private because PrecisionModel is intended to be an immutable (value) type.
- Returns:
- the amount by which to multiply a coordinate after subtracting the offset
public com.vividsolutions.jts.geom.PrecisionModel.Type getType()
Gets the type of this PrecisionModel
- Returns:
- the type of this PrecisionModel
public boolean isFloating()
Tests whether the precision model supports floating point
- Returns:
true
if the precision model supports floating point
public void makePrecise(Coordinate coord)
Rounds a Coordinate to the PrecisionModel grid.
public double makePrecise(double val)
Rounds a numeric value to the PrecisionModel grid. Symmetric Arithmetic Rounding is used, to provide uniform rounding behaviour no matter where the number is on the number line. Note: Java'sMath#rint
uses the "banker's rounding" algorithm, which is not suitable for precision operations elsewhere in JTS.
public Coordinate toExternal(Coordinate internal)
Deprecated. no longer needed, since internal representation is same as external representation
Returns the external representation ofinternal
.
- Parameters:
internal
- the original coordinate
- Returns:
- the coordinate whose values will be changed to the external representation of
internal
public void toExternal(Coordinate internal, Coordinate external)
Deprecated. no longer needed, since internal representation is same as external representation
Setsexternal
to the external representation ofinternal
.
- Parameters:
internal
- the original coordinateexternal
- the coordinate whose values will be changed to the external representation ofinternal
public Coordinate toInternal(Coordinate external)
Deprecated. use makePrecise instead
Returns the precise representation ofexternal
.
- Parameters:
external
- the original coordinate
- Returns:
- the coordinate whose values will be changed to the precise representation of
external
public void toInternal(Coordinate external, Coordinate internal)
Deprecated. use makePrecise instead
Setsinternal
to the precise representation ofexternal
.
- Parameters:
external
- the original coordinateinternal
- the coordinate whose values will be changed to the precise representation ofexternal
public String toString()