Using ANYINTERACT in sdo_relate

Hey. OK I am having slight problems here with performing spatial queries using ANYINTERACT from the sdo_relate option. I presume that when you perform a window query using ANYINTERACT, the query returns all geoemtries that either 1) intersect the query window or 2) lie wholly inside the window without touching the window. In my application I am trying to return all geometries that either fall directly inside the window or intersect the window at any point. My only problem is that my application only returns those geometries that intersect the window and not those that lie inside the window. I consulted the Spatial Index Advisor and performed sdo_relate ANYINTERACT queries on the same data and those geometries that both intersect the window and fall inside the window are highlighted as a result of executing the query. I have compared my query to the sample one in the Index Advisor and cannot see any difference. Has anyone encountered this problem themselves or has anyone any suggestions on the matter. I am completely baffled. Thanks Joe

Hey. I just tried a few things there after I posted that message and they have not solved my dilemma but might be able to shed a little more light on the issue. When I perform sdo_nn, sdo_within_distance or sdo_filter queries on point, linestring and polygon geometries I dont encounter any problems. All the queries are constructed as they would appear in the Spatial Index Advisor except that I added sdo_cs.viewport_transform to each of the queries because I was getting errors of the form "Element of type Extent is not supported for Geodetic data". As I mentioned above, these three queries all work without any hassle. However my queries using ANYINTERACT, as I stated in my original post, are not working correctly. I have played around with the structure of the query and now it works some of the time but not all of the time. When the query is built as follows it kind of works and returns some but not all the point geometries falling inside the window:
select geom from table where sdo_relate(geom,
(mdsys.sdo_geometry(2003, 8307, null,
mdsys.sdo_elem_info_array(1, 1003, 1),
mdsys.sdo_ordinate_array(coords here))), 'MASK=(Anyinteract) querytype=window')='true';
This query is very inconsistent as it sometimes returns all the points inside the window and then when I run it again it only returns a subset of the total number of points falling inside the window. I am not sure as to why it works one minute and not the next. This query also returns only a subset of the total number of polygons or linestrings falling inside the query window!
When I restructure the query to appear as follows it returns all geometries (linestring or polygon) that intersect the window but not those lying directly inside the window!!!! However it does not return any point geometries interacting with the window at all. This is where my confusion stems from:
select geom from table where sdo_relate(geom,
sdo_cs.viewport_transform(mdsys.sdo_geometry
(2003, 0, null,
mdsys.sdo_elem_info_array(1, 1003, 3),
mdsys.sdo_ordinate_array(coords here)), 8307), 'MASK=(Anyinteract) querytype=window')='true';
The major differences between the two above queries are the addition of "sdo_cs.viewport_transform" into the second query and the modifcation of the elem_info_array from (1, 1003, 1) to (1, 1003, 3). Also the line
(2003, 8307, null,...) has become (2003, 0, null,...). Can you explain to me as to what affect these subtle changes
have on the query and also maybe show me one query that will return all geometries (polygon, linestring AND point)
that either intersect or fall directly inside the query window!!! Thank you for taking the time out to read my qyery. Joe

Similar Messages

  • Not using Index when SDO_RELATE in Spatial Query is used in LEFT OUTER JOIN

    I want to know for every City (Point geometry) in which Municipality (Polygon geometry) it is.
    Some cities will not be covered by any municipality (as there is no data for it), so its municipality name should be blank in the result
    We have 4942 cities (point geometries)
    and 500 municipalities (polygon geometry)
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1
    LEFT OUTER JOIN MUNICIPALITY T2 ON SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'The explain plan for this query is:
    SELECT STATEMENT
      FILTER
        Filter Predicates
          MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'
        MERGE JOIN
          TABLE ACCESS              CITY               FULL                            11
          BUFFER                                       SORT                        100605
              TABLE ACCESS          MUNICIPALITY       FULL                            20So the cost is in the BUFFER (whatever that is), it takes +2000 seconds to run this, it is not using the spatial index.
    And we are not getting all rows, but only the ones interacting with a municipality, e.g. 2436 rows.
    But I want all rows, including the ones not interacting with any Municipality.
    When we want only those cities that actually are in a municipality, I use a different query and it will use the index.
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1, MUNICIPALITY T2
    WHERE SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'I get (only) 2436 rows (as expected) in 5 seconds (it is fast) and the explain plan shows it is using the spatial index.
    But in this case, I am not getting any cities not inside any municipality (of course)
    SELECT STATEMENT
       NESTED LOOPS
          TABLE ACCESS                   MUNICIPALITY       FULL                22
          TABLE ACCESS                   CITY               BY INDEX ROWID      22
             DOMAIN INDEX                CITY_SDX                                0
                Access Predicates
                   MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'I always thought a LEFT OUTER JOIN would return all rows from the Table, whatever happens in the next,
    but it seems the query has been rewritten so that it is now using a Filter Predicate in the end, which filters those geometries having no interaction.
    As an example I also do thing alphanumerically, I do get 4942 rows, including the ones which have no Municipality name.
    In this case the names must match, so its only for testing if the LEFT OUTER JOIN returns stuff correctly, which it does in this case.
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1
    LEFT OUTER JOIN MUNICIPALITY T2 ON T1.NAME = T2.NAMEIs this an Oracle Spatial bug, e.g. not return 4942 rows, but only 2436 rows on the first query?
    Note all tests performed on Oracle 11g R2 (11.2.0.1.0)

    Patrick,
    Even so, your geoms in the relate were the wrong way around.
    Also, I don't recall you saying (or showing) that you wanted the municipality geometry returned. Still,
    no matter, easy to do.
    Here are some additional suggestions. I don't have your data so I have had to use some of my own.
    set serveroutput on timing on autotrace on
    SELECT T1.SPECIES as City,
           (SELECT T2.ADMIN_NAME FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as Municipality,
           (SELECT T2.GEOM       FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as geom
      FROM GUTDATA T1;
    762 rows selected
    Elapsed: 00:00:21.656
    Plan hash value: 2160035213
    | Id  | Operation                   | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                            |   762 | 49530 |     5   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES          |     1 |   115 |     0   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES          |     1 |   115 |     0   (0)| 00:00:01 |
    |*  4 |   DOMAIN INDEX              | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   5 |  TABLE ACCESS FULL          | GUTDATA                    |   762 | 49530 |     5   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
               24576  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksThe above can look messy as you add more (SELECT ...) attributes, but is is fast (though can't use in Materialized Views).
    /* The set of all cities not in municipalities */
    SELECT T1.SPECIES                 as City,
           cast(null as varchar2(42)) as municipality,
           cast(null as sdo_geometry) as geom
      FROM GUTDATA T1
    WHERE NOT EXISTS (SELECT 1
                         FROM AUSTRALIAN_STATES T2
                        WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    UNION ALL
    /* The set of all cities in municipalities */
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality,
           T2.GEOM       as geom
      FROM GUTDATA T1
           INNER JOIN
           AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
    762 rows selected
    Elapsed: 00:00:59.953
    Plan hash value: 2854682795
    | Id  | Operation           | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                            |    99 | 13450 |    38  (87)| 00:00:01 |
    |   1 |  UNION-ALL          |                            |       |       |            |          |
    |*  2 |   FILTER            |                            |       |       |            |          |
    |   3 |    TABLE ACCESS FULL| GUTDATA                    |   762 | 49530 |     5   (0)| 00:00:01 |
    |*  4 |    DOMAIN INDEX     | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   5 |   NESTED LOOPS      |                            |    61 | 10980 |    33   (0)| 00:00:01 |
    |   6 |    TABLE ACCESS FULL| AUSTRALIAN_STATES          |     8 |   920 |     3   (0)| 00:00:01 |
    |*  7 |    TABLE ACCESS FULL| GUTDATA                    |     8 |   520 |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter( NOT EXISTS (SELECT 0 FROM "AUSTRALIAN_STATES" "T2" WHERE "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE'))
       4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       7 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
              131072  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksMuch slower but Materialized View friendly.
    This one is a bit more "natural" but still slower than the first.
    set serveroutput on timing on autotrace on
    /* The set of all cities in municipalities */
    WITH municipal_cities As (
      SELECT T1.ID         as City,
             T2.ADMIN_NAME as Municipality,
             T2.GEOM       as geom
        FROM GUTDATA T1
             INNER JOIN
             AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    SELECT T1.ID           as City,
           T2.Municipality as Municipality,
           T2.GEOM         as geom
      FROM GUTDATA          T1
           LEFT OUTER JOIN
           municipal_cities T2
           ON (T2.CITY = T1.ID);
    762 rows selected
    Elapsed: 00:00:50.228
    Plan hash value: 745978991
    | Id  | Operation             | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |                   |   762 | 44196 |    36   (3)| 00:00:01 |
    |*  1 |  HASH JOIN RIGHT OUTER|                   |   762 | 44196 |    36   (3)| 00:00:01 |
    |   2 |   VIEW                |                   |    61 |  3294 |    33   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS       |                   |    61 | 10980 |    33   (0)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL | AUSTRALIAN_STATES |     8 |   920 |     3   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL | GUTDATA           |     8 |   520 |     4   (0)| 00:00:01 |
    |   6 |   INDEX FAST FULL SCAN| GUTDATA_ID_PK     |   762 |  3048 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("T2"."CITY"(+)="T1"."ID")
       5 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
               49152  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksFinally, the Pièce de résistance: trick the LEFT OUTER JOIN operator...
    set serveroutput on timing on autotrace on
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality,
           T2.GEOM       as geom
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (t2.admin_name = to_char(t1.ID) OR
               SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
    762 rows selected
    Elapsed: 00:00:50.273
    Plan hash value: 158854308
    | Id  | Operation           | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                   |   762 | 92964 |  2294   (1)| 00:00:28 |
    |   1 |  NESTED LOOPS OUTER |                   |   762 | 92964 |  2294   (1)| 00:00:28 |
    |   2 |   TABLE ACCESS FULL | GUTDATA           |   762 | 49530 |     5   (0)| 00:00:01 |
    |   3 |   VIEW              |                   |     1 |    57 |     3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL| AUSTRALIAN_STATES |     1 |   115 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - filter("T2"."ADMIN_NAME"=TO_CHAR("T1"."ID") OR
                  "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
                   0  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksTry these combinations to see what works for you.
    Interestingly, for me, the following returns absolutely nothing.
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    MINUS
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (t2.admin_name =  to_char(t1.ID) OR
               SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');(I leave it to you to see if you can see why as the LEFT OUTER JOIN seems to be working correctly for me but I am not going to dedicate time to detailed checking of results.)
    Note all tests performed on Oracle 11g R2 (11.2.0.1.0)
    If you get the answer you want: mark the post as answered to assign points.
    regards
    Simon

  • Error using mdsys.sdo_relate()

    Hi, I am using Oracle 8.1.5 and i am trying to execute the following sql statement
    SQL> select p.name
    2 from parks p
    3 where mdsys.sdo_relate(p.shape,
    mdsys.sdo_geometry(
    3,null,null,
    mdsys.sdo_elem_info_array(1,3,3),
    4 mdsys.sdo_ordinate_array(10,10,20,20)),
    5 'mask=anyinteract querytype=window')
    = 'true';
    But i recieved the following error message
    ERROR at line 1:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-13207: incorrect use of the [SDO_RELATE] operator
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 73
    ORA-06512: at line 1
    Do anyone know how to recify this?
    Thanks!
    null

    Ops, sorry it's TRUE not true
    I managed to solved it. Thanks:>
    brian
    null

  • HELP!! SDO_RELATE inside Oracle procedure - ORA-13207: incorrect use of the

    Hello,
    I need help !
    I have a problem with queries inside procedures/packages.
    When execute sql
    SQL> SELECT LOC_OBJ_ID
    2 FROM VORO_LOC X, LBS_OZ_AREAS OZ
    3 WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, 'MASK=ANYINTERACT') = 'TRUE'
    4 AND OZ.OZ_NAME='PTK' AND OZ.OZ_GROUP='GORCZEWSKA';
    LOC_OBJ_ID
    2211379
    i have results - it's OK
    The next sql is same, but with agregation
    SQL> SELECT COUNT(*) ILOSC
    2 FROM VORO_LOC X, LBS_OZ_AREAS OZ
    3 WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, 'MASK=ANYINTERACT') = 'TRUE'
    4 AND OZ.OZ_NAME='PTK' AND OZ.OZ_GROUP='GORCZEWSKA';
    ILOSC
    1
    it's OK
    But when i want use this SQL inside proedurees in store result in variable i have problem
    SQL> declare
    2 V_NUMBER_NEI_LOC number;
    3 begin
    4 SELECT COUNT(*) ILOSC
    5 INTO V_NUMBER_NEI_LOC
    6 FROM VORO_LOC X, LBS_OZ_AREAS OZ
    7 WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, 'MASK=ANYINTERACT') = 'TRUE'
    8 AND OZ.OZ_NAME='PTK' AND OZ.OZ_GROUP='GORCZEWSKA';
    9 end;
    10 /
    declare
    ORA-13207: incorrect use of the [SDO_RELATE] operator
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 259
    ORA-06512: at line 4
    ORA-06512: at line 4
    Please help!

    This might be some issue with SQL in PL/SQL. We will check into this.
    In the meantime, can you try the dynamic SQL to execute that
    sdo_relate query to see if it works?
    Here is the example with dynamic SQL:
    declare
    V_NUMBER_NEI_LOC number;
    begin
    EXECUTE IMMEDIATE
    ' SELECT COUNT(*) ILOSC ' ||
    ' FROM VORO_LOC X, LBS_OZ_AREAS OZ ' ||
    ' WHERE MDSYS.SDO_RELATE(X.SHAPE, OZ.GEOLOC, ' ||
    ' ''MASK=ANYINTERACT'') = ''TRUE'' ' ||
    ' AND OZ.OZ_NAME=''PTK'' AND OZ.OZ_GROUP=''GORCZEWSKA'' '
    INTO V_NUMBER_NEI_LOC;
    end;
    /

  • How do u use SDO_RELATE for dynamic theme

    Hi ,
    I have line geometry. For this line geometry I have to create a buffer using SDO_GEOM.SDO_BUFFER and I have to check whether the given point geometry is with in this buffer.
    How can i do it?
    i have used buffer and SDO_RELATE but its giving error as
    "SDO_RELATE can not be used with out Spatial Index". Here my buffer is a dynamic theme.
    Is there any possibility to create index for dynamic theme?
    Thanks and Regards
    Aravindan

    Hello
    We did something familiar in a sence.
    We used an analysis based sdo_NN.
    Also therefor the spatial index is required and used.
    We created a Materialized view containing the sdo_buffered result geometry, based on additional where clauses for the base table..
    We defined a spatial index on the materialized view result table, and an additional view containing the sdo_nn operator to this materialized view result table.
    So when we changed the requirements in which geometry had to be buffered in the first step, we refreshed to materialized view. This caused the de sdo_index being updated. this way the view with the operator was actualized.
    I hope this explained a little bit the way we did this, maybe this can help you out.
    Luc

  • Buffer and relate using single table

    I have a table with a geometry column representing parcel information with the shape of the parcel. I need to write a query that will select 1 or many parcel(s) from this table based on the parcel ID, but also select all parcels within 300 feet of the selected ones.
    So right now I have something like this example to select the parcels based on their ID:
    SELECT PARCEL_DATA.ADDRESS,
    PARCEL_DATA.CITY,
    PARCEL_DATA.STATE,
    PARCEL_DATA.ZIP,
    PARCEL_DATA.APN
    FROM PARCEL_DATA
    WHERE PARCEL_DATA.APN IN ('6465', '4654');
    I'm not sure where to go from here to also select parcels within 300 feet of each of these 2 that are already selected. I have been trying various queries with using SDO_BUFFER and SDO_RELATE, but nothing has worked. Any help would be much appreciated.
    The below query works, but only for one APN. If I add multiple APNs to APN IN (...), I get the error "ORA-01427: single-row subquery returns more than one row". I need this to work for multiple, not just one. Any ideas?
    SELECT PARCEL_DATA.ADDRESS,
    PARCEL_DATA.CITY,
    PARCEL_DATA.STATE,
    PARCEL_DATA.ZIP,
    PARCEL_DATA.APN
    FROM PARCEL_DATA
    WHERE SDO_RELATE (PARCEL_DATA.SHAPE,
    (SELECT SDO_GEOM.SDO_BUFFER (SHAPE, 300, 1)
    FROM PARCEL_DATA
    WHERE APN IN ('6465')),
    'mask=anyinteract') = 'TRUE';
    Edited by: Guddie on Apr 15, 2010 9:00 AM

    I actually have 2 tables, one table has the Parcel addresses and the other has the Parcel geometry. They are joined using the APN column. So from my previous example, I want to select the address of the Parcel from one table, but I need to use SDO_WITHIN_DISTANCE so I need the geometry from another table. I need to join these two tables using the APN, but I'm not sure how to write that query. How do I work the join into the SDO_WITHIN_DISTANCE solution you provided earlier? What I need to accomplish is illustrated below in the FROM, but it is clearly not correct. Any help would be much appreciated.
    SELECT PARCEL_DATA.ADDRESS,
    PARCEL_DATA.CITY,
    PARCEL_DATA.STATE,
    PARCEL_DATA.ZIP,
    PARCEL_DATA.APN
    FROM (PARCEL_DATA LEFT OUTER JOIN PARCEL_GEOM ON PARCEL_DATA.APN = PARCEL_GEOM.APN) A,
    (PARCEL_DATA LEFT OUTER JOIN PARCEL_GEOM ON PARCEL_DATA.APN = PARCEL_GEOM.APN) B
    WHERE SDO_WITHIN_DISTANCE(A.SHAPE, B.SHAPE, 'distance=300') = 'TRUE' AND
    B.APN IN ('6465', '4654');

  • Can mdsys.sdo_relate return FALSE?

    I have the following query:
    SELECT MIN (dtczas) dtczas
    FROM sd_car_location
    WHERE dyza_id = 2
    AND dtczas > '24-JUN-2002 11:06:48'
    AND mdsys.sdo_relate(
    geom,
    MDSYS.SDO_GEOMETRY( 2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3),
    MDSYS.SDO_ORDINATE_ARRAY( 3734329.56686484, 5567865.09443332,
    3735261.90177227, 5568277.30732063 )
    'mask=ANYINTERACT querytype=WINDOW') = 'FALSE'
    while executing this query I receive:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-13207: incorrect use of the [SDO_RELATE] operator
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 84
    ORA-06512: at line 1
    so, is it possible to use sdo_relate in such way? When I try "<> 'TRUE'" or "AND NOT .... = 'TRUE'" index is not used.
    Thanks in advance for help.
    regards
    Krzysztof

    It is not possible. You must use ='TRUE'.
    The reason for this is related to how the operators work.
    First they do an index lookup to return the data that is
    likely to interact, then they do further filtering to find the
    data that actually interacts. All operators use the index
    in this way.
    If ='FALSE' was allowed, you'd get an answer that includes
    only the geometries that were likely to interact (returned from
    the index query), but that didn't interact, i.e. wrong answer.
    You might be able to do something like this:
    select min (dtczas) from
    SELECT dtczas
    FROM sd_car_location
    WHERE dyza_id = 2
    AND dtczas > '24-JUN-2002 11:06:48
    MINUS
    SELECT dtczas
    FROM sd_car_location
    WHERE dyza_id = 2
    AND dtczas > '24-JUN-2002 11:06:48'
    AND mdsys.sdo_relate(
    geom,
    MDSYS.SDO_GEOMETRY( 2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3),
    MDSYS.SDO_ORDINATE_ARRAY( 3734329.56686484, 5567865.09443332,
    3735261.90177227, 5568277.30732063 ) ),
    'mask=ANYINTERACT querytype=WINDOW') = 'TRUE');
    Hope this helps,
    Dan

  • Error with : SDO_RELATE(.........) = 'FALSE'

    When i use the operator SDO_RELATE and i try to evaluate it with "= 'FALSE'" or with "!= 'TRUE'" instead of "= 'TRUE'", a receive some errors. The same query works fine when i use "= 'TRUE'",
    Is it possible to evaluate the SDO_RELATE operator with "= 'FALSE'" or with "!= 'TRUE'" ?
    Example with "= 'FALSE'"
    SELECT IDE_TEST
    FROM TEST
    WHERE (sdo_relate (TEST.GEO_TEST, mdsys.sdo_geometry(2003, 1557057, NULL, mdsys.sdo_elem_info_array(1,1003,1), mdsys.sdo_ordinate_array (994431.1035,519763.6176,995340.97698,518071.25296,995944.125,518928.5,994431.1035,519763.6176)),'mask=anyinteract querytype=WINDOW') = 'FALSE');
    ERROR at line 1:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-13207: incorrect use of the [SDO_RELATE] operator
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 368
    ORA-06512: at line 1
    Example with "!= 'TRUE'"
    SELECT IDE_TEST
    FROM TEST
    WHERE (sdo_relate (TEST.GEO_TEST, mdsys.sdo_geometry(2003, 1557057, NULL, mdsys.sdo_elem_info_array(1,1003,1), mdsys.sdo_ordinate_array (994431.1035,519763.6176,995340.97698,518071.25296,995944.125,518928.5,994431.1035,519763.6176)),'mask=anyinteract querytype=WINDOW') != 'TRUE');
    ERROR at line 1:
    ORA-13268: error obtaining dimension from USER_SDO_GEOM_METADATA
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 89

    What you want to do is a little tricky. When you use an operator, the first thing spatial does is use the index to try to narrow the search field to geometries that are likely to interact. If you then use disjoint as a mask, what you will return is all of the geometries that are likely to interact, but don't.
    Instead, you might want to try something like this:
    select IDE_TEST
    FROM TEST
    MINUS
    SELECT IDE_TEST
    FROM TEST
    WHERE sdo_relate (TEST.GEO_TEST, mdsys.sdo_geometry(2003, 1557057, NULL, mdsys.sdo_elem_info_array(1,1003,1), mdsys.sdo_ordinate_array (994431.1035,519763.6176,995340.97698,518071.25296,995944.125,518928.5,994431.1035,519763.6176)),'mask=anyinteract querytype=WINDOW') = 'TRUE');

  • Oracle Spatial performance question

    All,
    I am doing a performance test on Oracle 11g Spatial. I am simulating doing searches in 10 degree by 10 degree windows over 6M+ images, six arc minutes per side. Here is my spatial query construction:
    String intersectSQL = "SELECT A.name, A.GEOMETRY.Get_WKT() " +
    "FROM six_amin_polygons A " +
    "WHERE SDO_RELATE(A.GEOMETRY,?, " +
    "'mask=inside+coveredby+overlapbdyintersect')='TRUE'";
    where the question mark is replaced by the geometry structure of the search window. The results for the first few searches are fast, then the query times balloon very quickly. PostGIS/PostgreSQL performs these searches in an average time of 30 s per window.
    Here are the initial (first four rows) of Oracle Spatial results:
    area_idx area_name sql_query_time number_results
    0 S80.0W90.0 3890 10100
    1 S80.0W80.0 3124 10100
    2 S80.0W70.0 186484 10100
    3 S80.0W60.0 183077 10100
    Any ideas? Am I using the best mask for image/area intersection? Please advise.
    Thanks,
    Jeff

    With anyinteract you get
    inside+coveredby+overlapbdyintersect+touch
    since you are comparing polygons to polygons.
    Do you want polygons that touch the window geometry in the result ? Do you want all the geometries
    that have some kind of intersection with the window query ? Then you should use ANYINTERACT mask.
    siva

  • SDO_GEOM.RELATE or SDO_CONTAINS

    Hallo,
    I have two tables:
    - table1 with id-column, geometry-column --> about 5 million records with point-geometry
    - table2 with id-column, geometry-column --> about 10000 records with polygons
    Now I want to query for each record in table2 the records in table2 that are within the area.
    That means for each area in table2 the points from table1 that are in the area of table2.
    How can I do this so that is is not so time consuming?
    1.
    select table1.id, table2.id from table1, table2
    where SDO_GEOM.RELATE(table1.geo, 'contains', table2.geo, 0.005);
    2.
    select table1.id, table2.id from table1, table2
    where SDO_CONTAINS(table1.geo, table2.geo) ='TRUE';
    Is there another way more efficient way to do that?
    Thanks a lot

    1. there is big difference between sdo_geom.relate FUNCTION and sdo_relate OPERATOR. The operator will use the spatial index, the FUNCTION does not.
    2. In this case a spatial join could be used. SDO_JOIN (http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#BGEDJIBF)
    SELECT /*+ ordered */ a.id, b.id
    FROM TABLE(SDO_JOIN('TABLE1', 'GEO',
    'TABLE2', 'GEO',
    'mask=ANYINTERACT')) c,
    table1 a,
    tabel2 b
    WHERE c.rowid1 = a.rowid AND c.rowid2 = b.rowid
    use ANYINTERACT if points can be on one or more polygon boundaries, otherwise use CONTAINS.
    Luc

  • Clipping/Bounding Box

    Am looking for some suggestions on the optimal way to do the following.
    Using the data in the table geod_counties, one could request the features and geometries of state='New Hampshire' and county='Hillsborough'. But when one displays the results in a mapping tool such as MapViewer one would also want some of the features/geometries from the 7 counties that TOUCH (or ANYINTERACT) with Hillsborough county. In essence one clips (or cuts) the map around an area of interest creating a box. As far as I understand, other than when applied to LRS, there isn't an explicit clip/box procedure. I have tried a number of ways to do this using SDO_TOUCH, SDO_BUFFER, SDO_RELATE, SDO_INTERSECTION, and a number of others. It appears that a combination of SDO_RELATE and SDO_INTERSECTION is the correct way to do this but I am not clear that this is the optimal way to "create the box" around an area of interest.
    Any comments or advice would be appreciated. And also if someone has written a function to do the above and wouldn't mind sharing, it would be appreciated.
    Thank you.

    I resolved this issue last Friday; am just posting this now. The following appeared to work. In this particular case, the user request is to select geometric features of Hillsborough County, New Hampshire without inputing an x/y starting centroid or a map size as you would find in MapViewer demo applications such as topology.jsp.
    SQL> select sdo_geom.sdo_mbr(a.geom) mbr from geod_counties a where a.state = 'New Hampshire' and county = 'Hillsborough';
    MBR(SDO_GTYPE, SDO_SRID, SDO_POINT (X,Y,Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO)GEOMETRY(2003,8307,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(-72.062851,42.696899,-71.246002,43.207188))
    SQL> select sdo_geom.sdo_intersection(geom.sdo_geometry(2003,8037,null,
    sdo_elem_info_array(1,1003,3),sdo_ordinate_array(-72.062751,42.696899,-71.246002,43.207188)),0.0005) int_geom
    from geod_counties a
    where mdsys.sdo_relate(a.geom,sdo_geometry(2003,8307,null,sdo_elem_info_array(1,1003,3),
    mdsys.sdo_ordinate_array(-72.062751,42.696899,-71.246002,43.207188)),
    'mask=anyinteract querytype=window') = 'TRUE;
    Thank you all for your assistance.

  • How to find a line/edge that starts at the same point as the end of another

    I have an edges table of Lat/Lon data and for a specific edge I want to find any other edges that have the same start point as the end point of the given edge.
    I tried the following query:
    select geo_street_id from geo_street s2
    where SDO_LRS.GEOM_SEGMENT_START_PT(s2.geom) =
    (select SDO_LRS.GEOM_SEGMENT_END_PT(s.geom) as geom from geo_street s
    where geo_street_id = 122978214)
    but it gets the following error:
    ORA-22901: cannot compare nested table or VARRAY or LOB attributes of an object type
    Any Ideas?

    1. to compare geometry to be equal you should use appropriate function (SDO_GEOM.RELATE http://download.oracle.com/docs/html/B14255_01/sdo_objgeom.htm#sthref1561) or operators (sdo_relate http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#i78531) with specific mask EQUAL.
    2. to filter down the resultset in first place you can use the operator SDO_RELATE with mask TOUCH as this will return already the set of lines sharing endpoints, but will also include lines touching eachother not at endpoints (endpoint intersecting the otherone's interior)
    something like
    select geo_street_id from geo_street s2, geo_street s
    where
    s.geo_street_id = 122978214
    AND
    sdo_relate(s2.geom, s.geom,'mask=touch') = 'TRUE'
    AND
    sdo_geom.relate(SDO_LRS.GEOM_SEGMENT_START_PT(s2.geom),
    'EQUAL',
    SDO_LRS.GEOM_SEGMENT_END_PT(s.geom),0.005)='EQUAL'
    3. if you would do this for the full table, an SDO_JOIN (http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#BGEDJIBF) might be more appropriate.
    4. you might also consider 4 cases:
    start = start
    start = end
    end = start
    end = end
    5. alternative would be to take only the endpoints of your selected geometry and perform a touch with the edges. using the sdo_util.APPEND on the startpoint en endpoint of your geometry will return a multipoint. although there might some specific cases that this would not return respected result I think
    something like:
    select geo_street_id from geo_street s2, geo_street s
    where
    s.geo_street_id = 122978214
    AND
    sdo_relate(s2.geom,
    SDO_UTIL.APPEND(
    SDO_LRS.GEOM_SEGMENT_START_PT(s.geom),
    SDO_LRS.GEOM_SEGMENT_END_PT(s.geom)
    ,'mask=touch') = 'TRUE'
    Let us know how it works.
    Luc

  • Oracle Spatial and Oracle Forms

    Hi,
    Does anyone have experience with Oracle Spatial and Oracle Forms?
    I have generated a form, which is based on a view. The view uses the mdsys.sdo_relate operator. Somehow I am unable to get the form to perform (to get one record it takes over 20 minutes). While useing sql-navigator to process the same statement it seems no problem. The query that also uses the view, is then processed in 10 seconds.
    I also noticed that when text-functions like ' lower' of ' upper' are used to query the view, the query is processed within 15 seconds. If I don't use ' lower' or ' upper' it takes a long time (> 20 minutes) to process the query. Is it possible that this causes the bad performance of the form?
    On metalink I have found that forms and spatial do not cooperate because of the pl/sql version that
    forms6 uses. There is no solution presented, does anyone know of a work around?
    My configuration is:
    Oracle 8.1.7 on WIN2K @ PIII-800Mhz 256 Mb memory.
    Formsbuilder 6
    If requested I can post the queries that I have made.
    With regards,
    Gerjan Walrecht
    [email protected]
    null

    Hello Priya,
    Look into the following.
    1. Book - Pro Oracle Spatial for Oracle Database 11g by r. Kothuri, A. Godfrind, E. Beinat. This book provides a nice introduction on Oracle Spatial concepts and have examples.
    2. Look at the Oracle Spatial & Graph User Guide
    2. Book - Applying and Extending Oracle Spatial by S. Greener and S. Ravada. This book provides hands on information for advanced oracle spatial application developers. Practical guide on hands-on examples, Data models and  develop cross-vendor database solutions.
    3. This oracle spatial forum, once you understand these concepts.
    In the future consider Certification on Oracle Spatial 11g Certified Implementation Specialist.
    Best
    Navaneet

  • Please reply: Why are indices not supported in sdo_geom.relate?

    Hi,
    I read somewhere in the newsgroup that the spatial indicesa re
    used in the sdo_relate operator but not in the sdo_geom.relate
    function. Could someone please let me know why this difference?
    Thanks,
    Hemant.R

    Hi,
    The SDO_GEOM.RELATE function should be used when comparing a
    small number of geometries geometries with an area-of-interest.
    The SDO_RELATE operator should be used when comparing an
    area-of-interest with a layer, and it will use the index on the
    layer.
    There are reasons why the SDO_GEOM.RELATE function exists. If
    you have two geometries that were created as part of an
    application, however they aren't stored in a table and neither
    one is indexed, sdo_geom.relate is a convenient way of testing or
    determining what the relationship is between the geometries.
    Regarding the SDO_LEVEL you are using for indexing - 17 seems
    pretty high, and it might take a long time to create an index at
    level 17 using geometries the size of states - you might want to
    try increasing the SDO_LEVEL from 8 to 10 and see if that makes a
    difference before going higher.
    One thing you can do is look at the geometries using Spatial
    Index Advisor - you can also see the fixed size tiles and do some
    queries to get a sense of the amount of work being done by the
    index as well as the work being done in the relate portion of the
    operator.
    Hope this helps,
    Dan

  • SDO_GEOM.RELATE... speed up!

    With 8.1.7, I run the following querry to check if one geometry(GEOM1) is the same as the other geometry(GEOM2).
    SELECT MDSYS.SDO_GEOM.RELATE(GEOM1, v_DIMINFO,'EQUAL',GEOM2,v_DIMINFO) INTO v_OUT FROM DUAL;
    IF v_OUT='FALSE' THEN
    BUT I FOUND it will take TWO OR THREE MINUTES to complete. Because both of these geometries are not indexed, I can not use operator like SDO_RELATE.
    Another option is to run the following querry:
    IF MDSYS.SDO_GEOM.SDO_XOR(GEOM1, v_DIMINFO, GEOM2, v_DIMINFO IS NOT NULL THEN;
    But it took more than FOUR minutes.
    Is there any other suggestion to speed it up???
    Thanks in advance.
    Jerry

    Thanks for Dan's help.
    I will check the tolerance and the complicity of the geometry.
    Now the geometries are both linestrings.
    It is what I worry about that the query may take quite long time for complicate geomerties.
    Another interesting thing I just found.
    Because GEOM2 is always a part or all of the GEOM1. That is, GEOM1 should never be inside GEOM2.
    So, If I run the following query:
    SELECT MDSYS.SDO_GEOM.RELATE(GEOM1, v_DIMINFO,'EQUAL+INSIDE', GEOM2, v_DIMINFO) INTO v_OUT FROM DUAL;
    IF v_OUT='FALSE' THEN.......
    The determinant part of the mask is 'equal' and it will do the same thing as the query:
    SELECT MDSYS.SDO_GEOM.RELATE(GEOM1, v_DIMINFO,'EQUAL',GEOM2,v_DIMINFO) INTO v_OUT FROM DUAL;
    BUT, I found it(equal+inside) faster(+50% improvement!) than just using 'equal' as mask.
    Anyone can tell me the reason? Is this cheating safe if I assume GEOM1 is never inside GEOM2??
    Thanks in advance!!!

Maybe you are looking for

  • Getting Portrait Mode prior to X11 startup and in SLIM

    Hi all, I've been on Arch for about a week now and am having a fun time coding on it. I finally got an LCD stand that allows me to swivel my screen to portrait orientation so I suddenly have some great vertical real estate. My current setup is Arch L

  • Somyac Font Zoomer ruined my font size??

    I have a nokia n8 with anna. I recently installed font zoomer 3.20 full version. From there i notice a bug (wheneven in the photo gallery the options/exit buttons are in black instead of white making them impossible to see on a black background) so i

  • Deleting photos out of camera roll leaves black spaces where pics used to b

    Only happens on my iPhone 4. 3GS with os4 it doesn't. Any ideas For info they do disappear if u sync in iTunes.

  • GetConnection error

    guys plz help. theres an error on my program on the line: dbcon= DriverManager.getConnection(url); i already have my database connection and everything is set on my Data sources. ty import javax.servlet.*; import javax.servlet.http.*; import java.io.

  • Blocking DataFactory.INSTANCE.create(Class)

    Hello, we are using SOA suite 11g 1.1.2 and have some issues with SDO objects. Our EJB web service returns a SDO object and calls commonj.sdo.helper.DataFactory.INSTANCE.create(Class) to construct it. This call however blocks and jrockit mission cont