geos::PrecisionModel Class Reference

Specifies the precision model of the Coordinate in a Geometry. More...

#include <geos.h>

List of all members.

Public Types

enum  Type { FIXED, FLOATING, FLOATING_SINGLE }
 The types of Precision Model which GEOS supports. More...

Public Member Functions

 PrecisionModel (void)
 Creates a PrecisionModel with a default precision of FLOATING.
 PrecisionModel (Type nModelType)
 Creates a PrecisionModel specifying an explicit precision model type.
 PrecisionModel (double newScale)
 Creates a PrecisionModel with Fixed precision.
virtual ~PrecisionModel (void)
 destructor
double makePrecise (double val) const
 Rounds a numeric value to the PrecisionModel grid.
void makePrecise (Coordinate *coord) const
 Rounds the given Coordinate to the PrecisionModel grid.
bool isFloating () const
 Tests whether the precision model supports floating point.
int getMaximumSignificantDigits () const
 Returns the maximum number of significant digits provided by this precision model.
Type getType () const
 Gets the type of this PrecisionModel.
double getScale () const
 Returns the multiplying factor used to obtain a precise coordinate.
int compareTo (const PrecisionModel *other) const
 Compares this PrecisionModel object with the specified object for order.

Static Public Attributes

static const double maximumPreciseValue
 The maximum precise value representable in a double.


Detailed Description

Specifies the precision model of the Coordinate in a Geometry.

In other words, specifies the grid of allowable points for all Geometrys.

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:

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.


Member Enumeration Documentation

enum geos::PrecisionModel::Type

The types of Precision Model which GEOS supports.

Enumerator:
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.
FLOATING  Floating precision corresponds to the standard Java double-precision floating-point representation, which is based on the IEEE-754 standard
FLOATING_SINGLE  Floating single precision corresponds to the standard Java single-precision floating-point representation, which is based on the IEEE-754 standard


Constructor & Destructor Documentation

geos::PrecisionModel::PrecisionModel ( void   ) 

Creates a PrecisionModel with a default precision of FLOATING.

Creates a PrecisionModel with a default precision of FLOATING.

geos::PrecisionModel::PrecisionModel ( Type  nModelType  ) 

Creates a PrecisionModel specifying an explicit precision model type.

If the model type is FIXED the scale factor will default to 1.

Parameters:
nModelType the type of the precision model

geos::PrecisionModel::PrecisionModel ( double  newScale  ) 

Creates a PrecisionModel with Fixed precision.

Fixed-precision coordinates are represented as precise internal coordinates which are rounded to the grid defined by the scale factor.

Parameters:
newScale amount by which to multiply a coordinate after subtracting the offset, to obtain a precise coordinate


Member Function Documentation

double geos::PrecisionModel::makePrecise ( double  val  )  const

Rounds a numeric value to the PrecisionModel grid.

Rounds an numeric value to the PrecisionModel grid.

void geos::PrecisionModel::makePrecise ( Coordinate coord  )  const

Rounds the given Coordinate to the PrecisionModel grid.

Rounds given Coordinate to the PrecisionModel grid.

bool geos::PrecisionModel::isFloating (  )  const

Tests whether the precision model supports floating point.

Returns:
true if the precision model supports floating point

int geos::PrecisionModel::getMaximumSignificantDigits (  )  const

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

PrecisionModel::Type geos::PrecisionModel::getType (  )  const

Gets the type of this PrecisionModel.

Returns:
the type of this PrecisionModel

double geos::PrecisionModel::getScale (  )  const

Returns the multiplying factor used to obtain a precise coordinate.

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

int geos::PrecisionModel::compareTo ( const PrecisionModel other  )  const

Compares this 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.

Parameters:
other the PrecisionModel with which this PrecisionModel is being compared
Returns:
a negative integer, zero, or a positive integer as this PrecisionModel is less than, equal to, or greater than the specified PrecisionModel.


Member Data Documentation

const double geos::PrecisionModel::maximumPreciseValue [static]

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.


The documentation for this class was generated from the following files:
Generated on Wed Jan 10 22:13:55 2007 for GEOS by  doxygen 1.5.1