Search Results for

    Show / Hide Table of Contents

    Class PrecisionModel

    Specifies the precision model of the Coordinates in a Geometry. In other words, specifies the grid of allowable points for a Geometry. A precision model may befloating (Floating or FloatingSingle), in which case normal floating-point value semantics apply.

    Inheritance
    object
    PrecisionModel
    Implements
    IComparable
    IComparable<PrecisionModel>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: NetTopologySuite.Geometries
    Assembly: NetTopologySuite.dll
    Syntax
    [Serializable]
    public class PrecisionModel : IComparable, IComparable<PrecisionModel>
    Remarks

    For a Fixed precision model the MakePrecise(Coordinate) 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.

    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.
    Three types of precision model are supported:
    FloatingRepresents full double precision floating point. This is the default precision model used in NTS
    FloatingSingleRepresents single precision floating point
    FixedRepresents 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 = Math.Round( inputPt.X * scale, MidPointRounding.AwayFromZero ) / scale )
    • jtsPt.Y = Math.Round( inputPt.Y * scale, MidPointRounding.AwayFromZero ) / 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.

    It is also supported to specify a precise grid size by providing it as a negative scale factor. This allows setting a precise grid size rather than using a fractional scale, which provides more accurate and robust rounding. For example, to specify rounding to the nearest 1000 use a scale factor of -1000.

    Coordinates are represented internally as Java double-precision values. .NET uses the IEEE-394 floating point standard, which 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).

    Constructors

    | Edit this page View Source

    PrecisionModel()

    Creates a PrecisionModel with a default precision of Floating.

    Declaration
    public PrecisionModel()
    | Edit this page View Source

    PrecisionModel(PrecisionModel)

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

    Declaration
    public PrecisionModel(PrecisionModel pm)
    Parameters
    Type Name Description
    PrecisionModel pm
    | Edit this page View Source

    PrecisionModel(PrecisionModels)

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

    Declaration
    public PrecisionModel(PrecisionModels modelType)
    Parameters
    Type Name Description
    PrecisionModels modelType

    The type of the precision model.

    | Edit this page View Source

    PrecisionModel(double)

    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.

    The provided scale may be negative, to specify an exact grid size. The scale is then computed as the reciprocal.
    Declaration
    public PrecisionModel(double scale)
    Parameters
    Type Name Description
    double scale

    Amount by which to multiply a coordinate, to obtain a precise coordinate. Must be non-zero

    Fields

    | Edit this page View Source

    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.

    Declaration
    public const double MaximumPreciseValue = 9007199254740992
    Field Value
    Type Description
    double

    Properties

    | Edit this page View Source

    Fixed

    Gets a value indicating a precision model with a scale of 1.

    Declaration
    public static Lazy<PrecisionModel> Fixed { get; }
    Property Value
    Type Description
    Lazy<PrecisionModel>

    A fixed precision model

    | Edit this page View Source

    Floating

    Gets a value indicating a precision model with double precision.

    Declaration
    public static Lazy<PrecisionModel> Floating { get; }
    Property Value
    Type Description
    Lazy<PrecisionModel>

    A double precision model

    | Edit this page View Source

    FloatingSingle

    Gets a value indicating a precision model with single precision.

    Declaration
    public static Lazy<PrecisionModel> FloatingSingle { get; }
    Property Value
    Type Description
    Lazy<PrecisionModel>

    A single precision model

    | Edit this page View Source

    GridSize

    Computes the grid size for a fixed precision model. This is equal to the reciprocal of the scale factor. If the grid size has been set explicity (via a negative scale factor) it will be returned.

    Declaration
    public double GridSize { get; }
    Property Value
    Type Description
    double

    The grid size at a fixed precision scale.

    | Edit this page View Source

    IsFloating

    Tests whether the precision model supports floating point.

    Declaration
    public bool IsFloating { get; }
    Property Value
    Type Description
    bool

    true if the precision model supports floating point.

    | Edit this page View Source

    MaximumSignificantDigits

    Returns the maximum number of significant digits provided by this precision model. Intended for use by routines which need to print out precise values.

    Declaration
    public int MaximumSignificantDigits { get; }
    Property Value
    Type Description
    int

    The maximum number of decimal places provided by this precision model.

    | Edit this page View Source

    PrecisionModelType

    Gets the type of this PrecisionModel.

    Declaration
    public PrecisionModels PrecisionModelType { get; }
    Property Value
    Type Description
    PrecisionModels
    | Edit this page View Source

    Scale

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

    Declaration
    public double Scale { get; set; }
    Property Value
    Type Description
    double

    The scale factor for the fixed precision model

    Remarks

    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.

    Methods

    | Edit this page View Source

    CompareTo(PrecisionModel)

    Declaration
    public int CompareTo(PrecisionModel other)
    Parameters
    Type Name Description
    PrecisionModel other
    Returns
    Type Description
    int
    | Edit this page View Source

    CompareTo(object)

    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.

    Declaration
    public int CompareTo(object o)
    Parameters
    Type Name Description
    object o

    The PrecisionModel with which this PrecisionModel is being compared.

    Returns
    Type Description
    int

    A negative integer, zero, or a positive integer as this PrecisionModel is less than, equal to, or greater than the specified PrecisionModel.

    | Edit this page View Source

    Equals(PrecisionModel)

    Declaration
    public bool Equals(PrecisionModel otherPrecisionModel)
    Parameters
    Type Name Description
    PrecisionModel otherPrecisionModel
    Returns
    Type Description
    bool
    | Edit this page View Source

    Equals(object)

    Declaration
    public override bool Equals(object other)
    Parameters
    Type Name Description
    object other
    Returns
    Type Description
    bool
    Overrides
    object.Equals(object)
    | Edit this page View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    object.GetHashCode()
    | Edit this page View Source

    MakePrecise(Coordinate)

    Rounds a Coordinate to the PrecisionModel grid.

    Declaration
    public void MakePrecise(Coordinate coord)
    Parameters
    Type Name Description
    Coordinate coord
    | Edit this page View Source

    MakePrecise(double)

    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.

    Declaration
    public double MakePrecise(double val)
    Parameters
    Type Name Description
    double val
    Returns
    Type Description
    double
    Remarks

    This method has no effect on NaN values

    | Edit this page View Source

    MostPrecise(PrecisionModel, PrecisionModel)

    Determines which of two PrecisionModels is the most precise

    Declaration
    public static PrecisionModel MostPrecise(PrecisionModel pm1, PrecisionModel pm2)
    Parameters
    Type Name Description
    PrecisionModel pm1

    A precision model

    PrecisionModel pm2

    A precision model

    Returns
    Type Description
    PrecisionModel

    The PrecisionModel which is most precise

    | Edit this page View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()

    Operators

    | Edit this page View Source

    operator ==(PrecisionModel, PrecisionModel)

    Declaration
    public static bool operator ==(PrecisionModel obj1, PrecisionModel obj2)
    Parameters
    Type Name Description
    PrecisionModel obj1
    PrecisionModel obj2
    Returns
    Type Description
    bool
    | Edit this page View Source

    operator !=(PrecisionModel, PrecisionModel)

    Declaration
    public static bool operator !=(PrecisionModel obj1, PrecisionModel obj2)
    Parameters
    Type Name Description
    PrecisionModel obj1
    PrecisionModel obj2
    Returns
    Type Description
    bool

    Implements

    IComparable
    IComparable<T>
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX