public class PrecisionUtil extends Object
OverlayNG
).
WARNING: the inherentScale
and robustScale
functions can be very slow, due to the method used to determine
number of decimal places of a number.
These are not recommended for production use.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_ROBUST_DP_DIGITS
A number of digits of precision which leaves some computational "headroom"
to ensure robust evaluation of certain double-precision floating point geometric operations.
|
Constructor and Description |
---|
PrecisionUtil() |
Modifier and Type | Method and Description |
---|---|
static double |
inherentScale(double value)
Computes the inherent scale of a number.
|
static double |
inherentScale(Geometry geom)
Computes the inherent scale of a geometry.
|
static double |
inherentScale(Geometry a,
Geometry b)
Computes the inherent scale of two geometries.
|
static PrecisionModel |
robustPM(Geometry a)
Determines a precision model to
use for robust overlay operations for one geometry.
|
static PrecisionModel |
robustPM(Geometry a,
Geometry b)
Determines a precision model to
use for robust overlay operations.
|
static double |
robustScale(Geometry a)
Determines a scale factor which maximizes
the digits of precision and is
safe to use for overlay operations.
|
static double |
robustScale(Geometry a,
Geometry b)
Determines a scale factor which maximizes
the digits of precision and is
safe to use for overlay operations.
|
static double |
safeScale(double value)
Computes a safe scale factor for a numeric value.
|
static double |
safeScale(Geometry geom)
Computes a safe scale factor for a geometry.
|
static double |
safeScale(Geometry a,
Geometry b)
Computes a safe scale factor for two geometries.
|
public static int MAX_ROBUST_DP_DIGITS
public static PrecisionModel robustPM(Geometry a, Geometry b)
NOTE: this is a heuristic determination, so is not guaranteed to eliminate precision issues.
WARNING: this is very slow.
a
- a geometryb
- a geometrypublic static double safeScale(double value)
MAX_ROBUST_DP_DIGITS
digits of precision.value
- a numeric valuepublic static double safeScale(Geometry geom)
MAX_ROBUST_DP_DIGITS
digits of precision.geom
- a geometrypublic static double safeScale(Geometry a, Geometry b)
MAX_ROBUST_DP_DIGITS
digits of precision.a
- a geometryb
- a geometry (which may be null)public static double inherentScale(double value)
num = round( num, inherentScale(num) )
value
- a numberpublic static double inherentScale(Geometry geom)
This is the maximum inherent scale of all ordinate values in the geometry.
WARNING: this is very slow.
geom
- geometrypublic static double inherentScale(Geometry a, Geometry b)
This is the maximum inherent scale of all ordinate values in the geometries.
WARNING: this is very slow.
a
- a geometryb
- a geometrypublic static PrecisionModel robustPM(Geometry a)
NOTE: this is a heuristic determination, so is not guaranteed to eliminate precision issues.
WARNING: this is very slow.
a
- a geometrypublic static double robustScale(Geometry a, Geometry b)
WARNING: this is very slow.
a
- a geometryb
- a geometrypublic static double robustScale(Geometry a)
a
- a geometryCopyright © 2022. All rights reserved.