Home » Server Options » Spatial » How to search within a polygon (oracle 11g)
How to search within a polygon [message #598540] Tue, 15 October 2013 12:36 Go to next message
gentleman777us
Messages: 122
Registered: April 2005
Senior Member
Hi,

How can I search with in a polygon. ie. if the polygon has five vertices ie. (x1,y1), (x2.y2), (x3, y3), (x4,y4), (x5,y5).

My aim is to find a point of interest within this polygon.

should I use SDO_WITHIN_DISTANCE function if so what is the exact syntax?

Thanks
Re: How to search within a polygon [message #598749 is a reply to message #598540] Thu, 17 October 2013 06:46 Go to previous message
_jum
Messages: 577
Registered: February 2008
Senior Member
You can search in a polygon with SDO_DISTANCE, SDO_WITHIN_DISTANCE and SDO_NN (link).
Only with the first You don't need a SPATIAL INDEX:
WITH gdata AS
 (
 SELECT 1 id, sdo_geometry(2003, NULL, NULL,    SDO_ELEM_INFO_ARRAY(1,1003,1),  SDO_ORDINATE_ARRAY(0,0, 10,0, 10,10, 0,10, 0,0)) geom FROM dual UNION ALL
 SELECT 2   , sdo_geometry(2003, NULL, NULL,    SDO_ELEM_INFO_ARRAY(1,1003,1),  SDO_ORDINATE_ARRAY(0,0,  5,0,  5, 5, 0, 5, 0,0)) geom FROM dual
 )
SELECT id,
       sdo_geom.SDO_DISTANCE(geom, sdo_geometry(2001, NULL, SDO_POINT_TYPE(5, 7, NULL),NULL, NULL),0.001) dist
  FROM gdata;

ID   DIST
------------
1	0
2	2

You get the DISTANCE of the POINT(7,7) to the polygon (rectangle) (<0,0> <5,5>)=2 and (<0,0> <10,10>)=0 (inside).

If You need an example with SPATIAL INDEX, please create a test case (CREATE TABLE, INSERT, ...)

[Updated on: Thu, 17 October 2013 06:49]

Report message to a moderator

Previous Topic: Move segments of a partitioned table containing SDO_GEOMETRY
Next Topic: Creting local spatial index on list partition
Goto Forum:
  


Current Time: Thu Mar 28 07:12:44 CDT 2024