public interface PrecisionFactory
Here are a couple of examples of creating a Precision using a PrecisionFactory:
factory.createPrecision(PrecisionType.FIXED, 1000); // three significant digits
factory.createPrecision(PrecisionType.FLOAT, 0); // float precision - 6 digits
factory.createPrecision(PrecisionType.DOUBLE, 0); // double precision - 16 digits
Although the
DirectPosition makes use of double when representing ordinates some
implementations, transfer mechanisms or storage facilities will not be able
to maintain this accuracy. In order to maintain a valid geometry representation
in these situations you will need to provide a Percision
as a stratagy
object used to round coordinates during creation and transformation. We cannot
allow you to round to the correct precision afterwards as the result may be an
invalid geometry.
The easiest example is the construction of a very small poloygon for a WFS configured to use 2 significant digits when generating GML. When generating a polgon in meters of less than 1 cm in size the rounding policy would "collapse" all the points of the outer ring into the same location - a WFS faced with this situtation may choose to skip the polygon or represent it as a Point.
Modifier and Type | Method and Description |
---|---|
Precision |
createFixedPrecision(PrecisionType code,
double scale)
Creates a Precision of the provided type, scale is used for
PrecisionType.FIXED.
|
Precision createFixedPrecision(PrecisionType code, double scale)
Here are a couple of examples:
factory.createPrecision(PrecisionType.FIXED, 1000); // three significant digits
factory.createPrecision(PrecisionType.FLOAT, 0); // float precision - 6 digits
factory.createPrecision(PrecisionType.DOUBLE, 0); // double precision - 16 digits
type
- PercisionType The rounding policy usedscale
- Multiplying factor used to obtain a precise coordinateCopyright © 1996–2019 Geotools. All rights reserved.