SDO_CONTAINS Returns Wrong Result For Point Inside Polygon (Doc ID 1148598.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Spatial - Version: 10.1.0.4 and later   [Release: 10.1 and later ]
Information in this document applies to any platform.

Symptoms


  • SDO_CONTAINS Returns Wrong Result For Point Inside Polygon
  • The Point is expected to be inside the Polygon, however a SDO_CONTAINS query brings back no rows.
  • the following testcase demonstrates the problem:
SQL> create table area_test (id number, shape sdo_geometry);

Table created.

SQL> INSERT INTO user_sdo_geom_metadata
values('AREA_TEST','SHAPE',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.001),
MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.001)),8307);

1 row created.

SQL> insert into area_test (id, shape)
values ( 200, SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1 ),
SDO_ORDINATE_ARRAY(-3.833333, 57.083333, 8.772, 57.083333, 8.772, 61.238667, -3.833333, 61.238667, -3.833333, 57.083333)));

1 row created.

SQL> COMMIT;

Commit complete.

SQL> CREATE INDEX Area_Test_Spatial_Index ON area_test
(SHAPE)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
PARAMETERS(' ');

Index created.

SQL> /* The point is inside the polygon, but the query states it is not */
SQL> select id from area_test a
where id = 200
and sdo_contains(a.shape, sdo_geometry('POINT(2.0 57.1)',8307))='TRUE'; 2 3

no rows selected



Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms