NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
NetTopologySuite.Geometries.PrecisionModel Class Reference

Specifies the precision model of the Coordinates in a Geometry. In other words, specifies the grid of allowable points for all Geometrys. More...

Inheritance diagram for NetTopologySuite.Geometries.PrecisionModel:

Public Member Functions

 PrecisionModel ()
 Creates a PrecisionModel with a default precision of Floating. More...
 
 PrecisionModel (PrecisionModels modelType)
 Creates a PrecisionModel that specifies an explicit precision model type. If the model type is Fixed the scale factor will default to 1. More...
 
 PrecisionModel (double scale, double offsetX, double offsetY)
 Creates a 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. More...
 
 PrecisionModel (double scale)
 Creates a 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. More...
 
 PrecisionModel (PrecisionModel pm)
 Copy constructor to create a new PrecisionModel from an existing one. More...
 
override int GetHashCode ()
 Return HashCode. More...
 
void ToInternal (Coordinate cexternal, Coordinate cinternal)
 Sets internal to the precise representation of external. More...
 
Coordinate ToInternal (Coordinate cexternal)
 Returns the precise representation of external. More...
 
Coordinate ToExternal (Coordinate cinternal)
 Returns the external representation of internal. More...
 
void ToExternal (Coordinate cinternal, Coordinate cexternal)
 Sets external to the external representation of internal. More...
 
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. More...
 
void MakePrecise (Coordinate coord)
 Rounds a Coordinate to the PrecisionModel grid. More...
 
override string ToString ()
 
override bool Equals (object other)
 
bool Equals (IPrecisionModel otherPrecisionModel)
 
int CompareTo (object o)
 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. More...
 
int CompareTo (IPrecisionModel other)
 

Static Public Member Functions

static IPrecisionModel MostPrecise (IPrecisionModel pm1, IPrecisionModel pm2)
 Determines which of two IPrecisionModels is the most precise /summary>

Parameters
pm1A precision model
pm2A precision model
Returns
The PrecisionModel which is most precise

 
static bool operator== (PrecisionModel obj1, PrecisionModel obj2)
 
static bool operator!= (PrecisionModel obj1, PrecisionModel obj2)
 

Public Attributes

const double MaximumPreciseValue = 9007199254740992.0
 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. More...
 

Properties

bool IsFloating [get]
 Tests whether the precision model supports floating point. More...
 
int MaximumSignificantDigits [get]
 Returns the maximum number of significant digits provided by this precision model. Intended for use by routines which need to print out precise values. More...
 
double Scale [get, set]
 Returns the scale factor used to specify a fixed precision model. More...
 
PrecisionModels PrecisionModelType [get]
 Gets the type of this PrecisionModel. More...
 
double OffsetX [get]
 Returns the x-offset used to obtain a precise coordinate. More...
 
double OffsetY [get]
 Returns the y-offset used to obtain a precise coordinate. More...
 

Detailed Description

Specifies the precision model of the Coordinates 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 point. NTS 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 bool operations) always round computed coordinates to the appropriate precision model. Currently three types of precision model are supported:

Floating: represents full double precision floating point. This is the default precision model used in NTS FloatingSingle: represents single precision floating point. Fixed: represents a model with a fixed number of decimal places.

A Fixed Precision Model is specified by a scale factor. The scale factor specifies the size of the grid which numbers are rounded to. Input coordinates are mapped to fixed coordinates according to the following equations:

  • jtsPt.x = round( (inputPt.x * scale ) / scale
  • jtsPt.y = round( (inputPt.y * scale ) / scale

For example, to specify 3 decimal places of precision, use a scale factor of 1000. To specify -3 decimal places of precision (i.e. rounding to the nearest 1000), use a scale factor of 0.001.

Coordinates are represented internally as Java double-precision values. Since .NET 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 - or almost 16 decimal digits of precision).

NTS binary methods currently do not handle inputs which have different precision models. The precision model of any constructed geometric value is undefined.

Constructor & Destructor Documentation

NetTopologySuite.Geometries.PrecisionModel.PrecisionModel ( )

Creates a PrecisionModel with a default precision of Floating.

NetTopologySuite.Geometries.PrecisionModel.PrecisionModel ( PrecisionModels  modelType)

Creates a PrecisionModel that specifies an explicit precision model type. If the model type is Fixed the scale factor will default to 1.

Parameters
modelTypeThe type of the precision model.
NetTopologySuite.Geometries.PrecisionModel.PrecisionModel ( double  scale,
double  offsetX,
double  offsetY 
)

Creates a 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.

Parameters
scaleAmount by which to multiply a coordinate after subtracting the offset, to obtain a precise coordinate
offsetXNot used.
offsetYNot used.
NetTopologySuite.Geometries.PrecisionModel.PrecisionModel ( double  scale)

Creates a 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.

Parameters
scaleAmount by which to multiply a coordinate after subtracting the offset, to obtain a precise coordinate.
NetTopologySuite.Geometries.PrecisionModel.PrecisionModel ( PrecisionModel  pm)

Copy constructor to create a new PrecisionModel from an existing one.

Parameters
pm

Member Function Documentation

int NetTopologySuite.Geometries.PrecisionModel.CompareTo ( object  o)

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
oThe 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.
int NetTopologySuite.Geometries.PrecisionModel.CompareTo ( IPrecisionModel  other)

Parameters
other
Returns
override bool NetTopologySuite.Geometries.PrecisionModel.Equals ( object  other)

Parameters
other
Returns
bool NetTopologySuite.Geometries.PrecisionModel.Equals ( IPrecisionModel  otherPrecisionModel)

Parameters
otherPrecisionModel
Returns
override int NetTopologySuite.Geometries.PrecisionModel.GetHashCode ( )

Return HashCode.

double NetTopologySuite.Geometries.PrecisionModel.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.

This method has no effect on NaN values

Parameters
val
void NetTopologySuite.Geometries.PrecisionModel.MakePrecise ( Coordinate  coord)

Rounds a Coordinate to the PrecisionModel grid.

Parameters
coord
static bool NetTopologySuite.Geometries.PrecisionModel.operator!= ( PrecisionModel  obj1,
PrecisionModel  obj2 
)
static

Parameters
obj1
obj2
Returns
static bool NetTopologySuite.Geometries.PrecisionModel.operator== ( PrecisionModel  obj1,
PrecisionModel  obj2 
)
static

Parameters
obj1
obj2
Returns
Coordinate NetTopologySuite.Geometries.PrecisionModel.ToExternal ( Coordinate  cinternal)

Returns the external representation of internal.

Parameters
cinternalThe original coordinate.
Returns
The coordinate whose values will be changed to the external representation of internal.
void NetTopologySuite.Geometries.PrecisionModel.ToExternal ( Coordinate  cinternal,
Coordinate  cexternal 
)

Sets external to the external representation of internal.

Parameters
cinternalThe original coordinate.
cexternalThe coordinate whose values will be changed to the external representation of internal.
void NetTopologySuite.Geometries.PrecisionModel.ToInternal ( Coordinate  cexternal,
Coordinate  cinternal 
)

Sets internal to the precise representation of external.

Parameters
cexternalThe original coordinate.
cinternalThe coordinate whose values will be changed to the precise representation of external.
Coordinate NetTopologySuite.Geometries.PrecisionModel.ToInternal ( Coordinate  cexternal)

Returns the precise representation of external.

Parameters
cexternalThe original coordinate.
Returns
The coordinate whose values will be changed to the precise representation of external
override string NetTopologySuite.Geometries.PrecisionModel.ToString ( )

Returns

Member Data Documentation

const double NetTopologySuite.Geometries.PrecisionModel.MaximumPreciseValue = 9007199254740992.0

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.

Property Documentation

bool NetTopologySuite.Geometries.PrecisionModel.IsFloating
get

Tests whether the precision model supports floating point.

Returns
true if the precision model supports floating point.
int NetTopologySuite.Geometries.PrecisionModel.MaximumSignificantDigits
get

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.
double NetTopologySuite.Geometries.PrecisionModel.OffsetX
get

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.
double NetTopologySuite.Geometries.PrecisionModel.OffsetY
get

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
PrecisionModels NetTopologySuite.Geometries.PrecisionModel.PrecisionModelType
get

Gets the type of this PrecisionModel.

Returns
double NetTopologySuite.Geometries.PrecisionModel.Scale
getset

Returns the scale factor used to specify a fixed precision model.

The number of decimal places of precision is equal to the base-10 logarithm of the scale factor. Non-integral and negative scale factors are supported. Negative scale factors indicate that the places of precision is to the left of the decimal point.

Returns
The scale factor for the fixed precision model

The documentation for this class was generated from the following file: