Interface PrecisionFactory


  • public interface PrecisionFactory
    A factory for managing direct position creation. A Precision is used to describe the accuracy at which you would like your geometry maintained during operations and transformations.

    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 Precision as a strategy 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.

    Since:
    GeoAPI 2.1
    • Method Detail

      • createFixedPrecision

        Precision createFixedPrecision​(PrecisionType code,
                                       double scale)
        Creates a Precision of the provided type, scale is used for PrecisionType.FIXED.

        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
         
        Parameters:
        code - PrecisionType The rounding policy used
        scale - Multiplying factor used to obtain a precise coordinate
        Returns:
        Precision capable of rounding as described by type and scale