# SDO_DISTANCE and tolerance

**user5394025**Sep 26, 2012 8:04 PM

I am very new to Geospatial (Oracle 11.2), so I am having a lot of trouble figuring out how to use tolerance in SDO_DISTANCE between a point and a polygon.

Distance between 2 points works as expected, but distance between a polygon and a point (SRID=8265 for both) seems to be always ignored.

SELECT

SDO_GEOM.SDO_DISTANCE(

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-50, 48, NULL), NULL, NULL),

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL),

*100*) as distance

FROM dual;

DISTANCE

--------

149.250735546699

SELECT

SDO_GEOM.SDO_DISTANCE(

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-50, 48, NULL), NULL, NULL),

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL),

*200*) as distance

FROM dual;

DISTANCE

--------

0

Here the tolerance parameter seems to be completely ignored:

SELECT

SDO_GEOM.SDO_DISTANCE(

g.arspc_border_sdo,

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL),

*1000*) as distance

FROM AIRSPACE_BORDER_GEOMETRY g, AIRSPACE_BORDER b, AIRSPACE asp

WHERE g.ARSPC_BORDER_UID = 123

DISTANCE

--------

148.808025088469

Even if I set all my DIM_ARRAYs explicitly, tolerance is still ignored:

SELECT

SDO_GEOM.SDO_DISTANCE(

g.arspc_border_sdo, MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,300),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,300)),

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL), MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,300),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,300)),

'unit=METER') as distance

FROM AIRSPACE_BORDER_GEOMETRY g, AIRSPACE_BORDER b, AIRSPACE asp

WHERE g.ARSPC_BORDER_UID =123;

DISTANCE

--------

148.808025088469

Am I doing something wrong? Any ideas would be greatly appreciated. Thanks.

Distance between 2 points works as expected, but distance between a polygon and a point (SRID=8265 for both) seems to be always ignored.

SELECT

SDO_GEOM.SDO_DISTANCE(

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-50, 48, NULL), NULL, NULL),

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL),

*100*) as distance

FROM dual;

DISTANCE

--------

149.250735546699

SELECT

SDO_GEOM.SDO_DISTANCE(

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-50, 48, NULL), NULL, NULL),

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL),

*200*) as distance

FROM dual;

DISTANCE

--------

0

Here the tolerance parameter seems to be completely ignored:

SELECT

SDO_GEOM.SDO_DISTANCE(

g.arspc_border_sdo,

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL),

*1000*) as distance

FROM AIRSPACE_BORDER_GEOMETRY g, AIRSPACE_BORDER b, AIRSPACE asp

WHERE g.ARSPC_BORDER_UID = 123

DISTANCE

--------

148.808025088469

Even if I set all my DIM_ARRAYs explicitly, tolerance is still ignored:

SELECT

SDO_GEOM.SDO_DISTANCE(

g.arspc_border_sdo, MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,300),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,300)),

SDO_GEOMETRY(2001, 8265, SDO_POINT_TYPE(-49.998, 48, NULL), NULL, NULL), MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,300),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,300)),

'unit=METER') as distance

FROM AIRSPACE_BORDER_GEOMETRY g, AIRSPACE_BORDER b, AIRSPACE asp

WHERE g.ARSPC_BORDER_UID =123;

DISTANCE

--------

148.808025088469

Am I doing something wrong? Any ideas would be greatly appreciated. Thanks.

I have the same question Show 0 Likes (0)