3 Replies Latest reply on Jan 22, 2013 11:18 PM by Ivan Bush

# SDO_DISTANCE - Tolerance

If I have 2 point parms (not layers), with lat/longs with decimal places from 5 to 7 long, and I wanted to calculate the distance to within 5 CM, the formula would be:

SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(f_long,f_lat,NULL),NULL,NULL),
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(t_long,t_lat,NULL),NULL,NULL),
.05,'unit=KM' ) AS km_dist2 FROM dual;

What would be the equivalent (roughly within 5 cm) using a unit=MILE? Would I need to use a Tolerance of .0005?

SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(f_long,f_lat,NULL),NULL,NULL),
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(t_long,t_lat,NULL),NULL,NULL),
.0005,'unit=MILE' ) AS mi_dist2 FROM dual;

Thanks,
JB
• ###### 1. Re: SDO_DISTANCE - Tolerance
``````SELECT FACTOR_B
FROM SDO_UNITS_OF_MEASURE
WHERE UNIT_OF_MEAS_NAME = 'Mile';

FACTOR_B
----------
1609.344``````

HTH,
Stefan
• ###### 2. Re: SDO_DISTANCE - Tolerance
It looks like the Tolerance Check is ALWAYS being done against Meters, even though, the Unit is either KM or MILE. It looks like if we were to set the tolerance to 0.05 it will always consider any 2 points as 1 point ONLY IF they are within approx. 5 CM of each other, even if MILE is specified as the UNIT?

SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
18300,'unit=KM' ) AS km_dist2 FROM dual;

Result = 20.6698332651529

SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
18325,'unit=KM' ) AS km_dist2 FROM dual;

Result = 0.0

SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
18300,'unit=MILE' ) AS km_dist2 FROM dual;

Result = 12.843638939315

SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
18325,'unit=MILE' ) AS km_dist2 FROM dual;

Result = 0.0
• ###### 3. Re: SDO_DISTANCE - Tolerance
JB,

The Spatial documentation has the following description of tolerance.

1.5.5 Tolerance

Tolerance is used to associate a level of precision with spatial data. Tolerance reflects the distance that two points can be apart and still be considered the same (for example, to accommodate rounding errors). The tolerance value must be a non-negative number greater than zero. The significance of the value depends on whether or not the spatial data is associated with a geodetic coordinate system. (Geodetic and other types of coordinate systems are described in Section 1.5.4.)

For geodetic data (such as data identified by longitude and latitude coordinates), the tolerance value is a number of meters. For example, a tolerance value of 100 indicates a tolerance of 100 meters.

For non-geodetic data, the tolerance value is a number of the units that are associated with the coordinate system associated with the data. For example, if the unit of measurement is miles, a tolerance value of 0.005 indicates a tolerance of 0.005 (that is, 1/200) mile (approximately 105 feet), and a tolerance value of 2 indicates a tolerance of two miles.

In both cases, the smaller the tolerance value, the more precision is to be associated with the data.

A tolerance value is specified in two cases:

In the geometry metadata definition for a layer (see Section 1.5.5.1)

As an optional input parameter to certain functions (see Section 1.5.5.2)

Regards

Ivan