SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT

I am attempting to validate SDO_GEOMETRY types with SDO_GEOM_VALIDATE_LAYER_WITH_CONTEXT. I am using 2 different databases one 10GR1 and the other 10GR2. The validation on the R1 database is failing with a 1403 error - no data found. The validation is successfull in the R2 database.
I am using the documented example - 2.1 Simple Example: Inserting, Indexing, and Querying Spatial Data.
CREATE TABLE cola_markets (
mkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY);
INSERT INTO cola_markets VALUES(
1,
'RICO',
SDO_GEOMETRY(
2003, -- two-dimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3), -- one rectangle (1003 = exterior)
SDO_ORDINATE_ARRAY(1,1, 5,7) -- only 2 points needed to
-- define rectangle (lower left and upper right) with
-- Cartesian-coordinate data
INSERT INTO user_sdo_geom_metadata
(TABLE_NAME,
COLUMN_NAME,
DIMINFO,
SRID)
VALUES (
'cola_markets',
'shape',
SDO_DIM_ARRAY( -- 20X20 grid
SDO_DIM_ELEMENT('X', 0, 20, 0.005),
SDO_DIM_ELEMENT('Y', 0, 20, 0.005)
NULL );
Any ideas what the problem may be?
Update: I have tried on another R2 database which also produced the 1403 - no data found error. Did we missing something with the installation or creation of the databases that are failing?

Here is the SQL for the call
exec SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('cola_markets','SHAPE','SDOErrors');
Description of the procedure is
SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT(
geom_table IN VARCHAR2,
geom_column IN VARCHAR2,
result_table IN VARCHAR2
[, commit_interval IN NUMBER]);
The problem is that the result_table argument is not upper case. Changing to upper case resolved the problem. Note that geom_column must also be upper case if it is not this error is returned ORA-13203: failed to read USER_SDO_GEOM_METADATA view
Thanks

Similar Messages

  • Error: ORA-13199 following a SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT call

    Good afternoon all,
    I am new to this group. I tried to search the web for hints and clues to my error, but could not find a solution to my problem, so I decided to post here. I have an existing spatial table in which I recently inserted new values. I am trying to validate them, using the SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT function and I am getting errors:
    BEGIN
    SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('ALS.ALS_GEO_SVC_AREAS','GEOLOC','VALIDATION_RESULTS');
    END;
    Error at line 1
    ORA-13199: Invalid GEOMETRY table (or table does not exist)
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 17
    ORA-06512: at "MDSYS.SDO_GEOM", line 2828
    ORA-06512: at line 2
    Script Terminated on line 1.
    The spatial table is in a different schema = 'ALS' and is named 'ALS_GEO_SVC_AREAS'; the geometry column = 'GEOLOC'.
    I created the validation table ('VALIDATION_RESULTS') as such:
    CREATE TABLE VALIDATION_RESULTS(
    sdo_rowid ROWID,
    status VARCHAR2(2000));
    I am using TOAD 9.7.2.5.
    Can someone in the community help with this error?
    Thank you.
    Avridog

    Avridog,
    The only way I can see to get this cross-schema validation to work is via a view.
    Here is my use case.
    DROP  TABLE VALIDATION_RESULTS;
    CREATE TABLE VALIDATION_RESULTS(
    sdo_rowid ROWID,
    status VARCHAR2(2000)
    select count(*) from CODESYS.GEODPOINT2D;
    grant select on geodpoint2d to public with grant option;
    create view geodpoint2d as select * from codesys.geodpoint2d;
    insert into user_sdo_geom_metadata (table_name,column_name,diminfo,srid)
    select table_name,column_name,diminfo,srid
      from all_sdo_geom_metadata
    where owner = 'CODESYS' and table_name = 'GEODPOINT2D' and column_name = 'GEOM';
    commit;
    BEGIN
    SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('GEODPOINT2D','GEOM','VALIDATION_RESULTS');
    END;
    Select * from VALIDATION_RESULTS;
    SDO_ROWID STATUS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    NULL      Rows Processed <500>This worked for me (all points passed validation). If it works for you, and you believe your question is answered please award points.
    regards
    Simon

  • Validate_layer_with_context error

    BEGIN sdo_geom.validate_layer_with_context('COPPER', 'GEOM', 'VAL_RESULTS', 100); END;
    ERROR at line 1:
    ORA-04030: out of process memory when trying to allocate 16408 bytes (koh-kghu sessi,mdvgrr elmbr)
    ORA-06512: at "MDSYS.SDO_3GL", line 439
    ORA-06512: at "MDSYS.SDO_GEOM", line 3848
    ORA-06512: at line 1
    Is this a known bug in Oracle 9.2.0.2? Will I need to got to 9.2.0.3 to get this to work?
    R Clement
    Alaska DNR

    Hi Richard,
    This is reported in bug 2698729, and I don't see any info about it being fixed as of today.
    Sorry,
    Dan

  • UNDO exhaustion whilst performing validate_layer_with_context

    Trying to track down an ArcSDE problem, I've been performing validation on the layers we have loaded into Oracle Spatial. One table (part of OS Mastermap) containing 400 million features will not complete a validation, after several hours of processing and 24GB o consumed UNDO the following error is reported.
    SQL> execute sdo_geom.validate_layer_with_context('TOPOGRAPHIC_LINE', 'SHAPE',
    'TOPOGRAPHIC_LINE_VAL', 100);
    --After 8+ hours of processing
    BEGIN sdo_geom.validate_layer_with_context('TOPOGRAPHIC_LINE', 'SHAPE', 'TOPOGRA
    PHIC_LINE_VAL', 100); END;
    ERROR at line 1:
    ORA-29400: data cartridge error
    ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDOTBS1'
    ORA-06512: at "MDSYS.SDO_3GL", line 439
    ORA-06512: at "MDSYS.SDO_GEOM", line 3860
    ORA-06512: at line 1
    The topographic_line_val contains no records before or after running the validate procedure.
    I'm sure I've missed something fundamental, but I can't see why so much UNDO should be necessary. Nothing is running a long running query on the val table, the procedure doesn't modify the topographic_line table and the commit internval is set to only 100.
    Why is so much UNDO being consumed?
    Should I just keep increasing the amount of UNDO tablespace available until it completes?
    Is it a particularly bad idea to fake validate_layer(_with_context), using validate_geometry and a loop?
    Could I be running into a Spatial bug? The database is at patch level 9.2.0.6
    With thanks, Alex

    IMHO, call support, it sounds like a bug (using it on a larger dataset than it was ever tested with).
    Have you thought about using VALIDATE_GEOMETRY_WITH_CONTEXT instead? It might be a hair slower, but since it is called once per row, at least it won't blow up:
    CREATE TABLE geom_errors (rowid_text CHAR(18), error_text CLOB);
    INSERT INTO geom_errors (
    SELECT * FROM
    (SELECT a.ROWID, SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(a.shape, 0.5) the_error
    FROM topographic_line a)
    WHERE the_error != 'TRUE');

  • VALIDATE_LAYER_WITH_CONTEXT - am I using wrong SDO_TOLERANCE?

    Hello,
    I am testing some geometry validation with 10gR2 and struuggling to get my head around the tolerance values.
    If I am storing data in meters to a precision of centimeter.
    Below is a row from the USER_SDO_GEOM_METADATA table showing that I am using a SDO_TOLERANCE of 0.01
    select * from user_sdo_geom_metadata where table_name = 'LAKES';
    LAKES GEOMETRY MDSYS.SDO_DIM_ELEMENT(MDSYS.SDO_DIM_ELEMENT(null,100000,400032, *0.01* ),MDSYS.SDO_DIM_ELEMENT(null,300000,500704, *0.01* ))
    1 rows selected
    Here are the first few coordinates from the geometry:
    SDO_ORDINATE_ARRAY(
    519201.76,188910.7,
    519201.75,188910.7,
    519201.74,188910.7,
    519201.73,188910.7,
    519201.72,188910.7,
    If I use the SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT procedure it is returning an ORA-13356 error. E.g.:
    AAAuuVAANAAAAEOAAA 13356 [Element <1>] [Coordinate <3>][Ring <1>]
    I understand that this procedure uses the tolerance from the USER_SDO_GEOM_METADATA table so is my value incorrect for centimeter precision? Should I be using 0.005 as a SDO_TOLERANCE as I have read elsewhere on this forum?
    Thanks,
    Mark

    Thanks for your replies.
    I have spoken to the team who configured the values in the USER_SDO_GEOM_METADATA table and they now agree the value is wrong.
    As for the points being a straight line - the data is coming from a Shape file and are the first few coordinates which actually form a circle. I'm not allowed to change the geometries to simplify or change to circular polygons. However there has been comment on the number of vertices forming circles from a third party end user!

  • VALIDATE_LAYER_WITH_CONTEXT - Rowid and NULL in result table

    Hello,
    Oracle 10g R2
    I performed validity test using VALIDATE_LAYER_WITH_CONTEXT as follow:
    CREATE TABLE RESULT_TABLE_CP(SDO_ROWID ROWID, RESULT VARCHAR2(2000));
    CALL SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('VESSEL_ZONE_GEOMETRY', 'POLYGON', 'RESULT_TABLE_CP');
    What puzzled me was the result table contained the rowid and NULL as the result for each geometry. I was expecting to see what the error is, not just NULL.
    However when I use VALIDATE_GEOMETRY_WITH_CONTEXT to test the same layer, I got TRUE for all of them, as:
    select DISTINCT SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(a.POLYGON,b.DIMINFO)
    from VESSEL_ZONE_GEOMETRY a,
    USER_SDO_GEOM_METADATA b
    where b.TABLE_NAME = 'VESSEL_ZONE_GEOMETRY'
    and b.COLUMN_NAME = 'POLYGON'
    and a.POLYGON is not null;
    SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(A.POLYGON,B.DIMINFO) ------------------------------------------------------------------------------------
    TRUE
    Any suggestion would be much appreciated!
    Thanks, CP

    Can you get the geometry by running
    select polygon from VESSEL_ZONE_GEOMETRY where rowid = '....';

  • Using SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT effectively

    I have been using SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT to validate the geometry of several million polygon features. Here is an example of the SQL I have been using:
    Create table myResultsTable
    as
    SELECT A.myID, SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(A.GEOMETRY, 0.1) as invalidGeometry, FROM myGeometryTable A
    WHERE SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(A.GEOMETRY, 0.1) <> 'TRUE';
    I noticed that for each polygon in the table, this function returns only one result for the polygon before moving on to the next polygon despite it being possible that a polygon could fail the validation for several reasons.
    How can I return all reasons why a polygon has invalid geometry?
    Does it require me to use PL/SQL? If so, can anyone get me started?
    Or does it require me to use SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT? If so, how do I specify a tolerance when using this function like I did when I used SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT?
    Many thanks for your time.

    Hi,
    The validation routines only report the first reason geometry data is invalid.
    To validate several million polygon features I would use validate_layer_with_context because it is faster.
    If you don't want to for some reason then alter your statement to only run the validation procedure once:
    select a.status,a.id
    from (SELECT m.myID id, SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(m.GEOMETRY, 0.1) status
    FROM myGeometryTable m) a
    where a.status <> 'TRUE';
    Then there are possibilities in terms of automatically trying to fix things up to move on to the next error. For instance, if you get a duplicate vertices error your run remove_duplicate_vertices to try to fix that error, then revalidate and see if there are other errors. If you have a self-intersecting geometrt then running a self union may fix those kinds of problems (in 10g r2 this is automated with sdo_util.rectify_geometry, which attempts to automatically fix these kinds of errors).
    NOTE: Always check results of any automated geometry fix-up procedures to make sure you agree with the results of the procedure. I would recommend against automatically updating your data without checking the results.
    Hope this helps,
    Dan

  • SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT for polygon geometry validation

    Hi,
    I would like to make a validation of the polygon geometry upon a table SCHEMA.TABLE with the GEOM field, where the geometry is stored.
    Can someone help me with a sample SQL sentence to fill my SCHEMA.VALIDITY table with all the detected errors that occured in the SCHEMA.TABLE?
    Thanks!
    Dejan

    Greg
    Have you tried scrolling down to the bottom of that section? You will see the following example (as in all descriptions in the documentation):
    Examples*
    The following example validates the geometry objects stored in the SHAPE column of the COLA_MARKETS table. The example includes the creation of the result table. For this example, a deliberately invalid geometry was inserted into the table before the validation was performed.
    -- Is a layer valid? (First, create the result table.)
    CREATE TABLE val_results (sdo_rowid ROWID, result varchar2(1000));
    -- (Next statement must be on one command line.)
    CALL SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('COLA_MARKETS','SHAPE','VAL_RESULTS');
    Call completed.
    SQL> SELECT * from val_results;
    SDO_ROWID
    RESULT
    Rows Processed <12>
    AAABXNAABAAAKYAAC+
    +13349 [Element <1>] [Ring <1>][Edge <1>][Edge <3>]+
    CREATE TABLE val_results (sdo_rowid ROWID, result varchar2(1000));
    would have been in your case:
    CREATE TABLE schema.validity (sdo_rowid ROWID, result varchar2(1000));
    CALL SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('COLA_MARKETS','SHAPE','VAL_RESULTS');
    would have been in your case:
    CALL SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('SCHEMA.TABLE','GEOM','SCHEMA.VALIDITY');
    SQL> SELECT * from val_results;
    would have been in your case:
    SELECT * from schema.validity;
    If you would like to have your id included:
    Select a.id, b.*
    from schema.validity b left outer join schema.table a
    on (b.sdo_rowid= a.rowid);
    In order to help people making their life easier with the management of spatial metadata, spatial index and geometry validation, like yours, and possible fix up, 1Spatial has a product named Radius Check.
    Have a look at the second item from the top here: http://www.oracle.com/technology/products/spatial/htdocs/spatial_partners_downloads.html
    or
    http://www.1spatial.com/products/radius_check/index.php
    Maybe you can find it usefull.
    Luc

  • Sdo_geom.validate_geometry_with_context

    I have been using sdo_geom.validate_geometry_with_context to identify problems with geometry. When reporting errors the function returns, if one exists, an error code and the position of the error.
    Does anyone know whether the validation stops at this point, i.e. it does not continue through the remainder of the geometry to find further errors?

    The function SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT will validate a single geometry. You can write a PL/SQL cursor to validate each geometry in a table if you desire.
    You can validate all the geometries in a table with SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT, and the results are written to a table.
    See the Oracle Spatial Users Guide and Reference, Release 9.2 for further information

  • Error while inserting spatial data

    Hi All,
    I have a problem while inserting spatial data. could some one please help me in solving this.
    I have creatd a table with spatial index.
    INSERT INTO USER_SDO_GEOM_METADATA
                VALUES('SDO_CA_test', 'CA', SDO_DIM_ARRAY(
                    MDSYS.SDO_DIM_ELEMENT ('LON', 71.19545, 120.35101, 0.000005),
                    MDSYS.SDO_DIM_ELEMENT ('LAT', 12.1145, 26.58041, 0.000005)), 8687);
         CREATE INDEX IO_CA_test ON SDO_CAR_test(CA)
        INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS ('SDO_COMMIT_INTERVAL=10000 SDO_RTR_PCTFREE = 0');when I insert data from another spatail table that does not have a index I get an error.
    insert into sdo_ca_test as select * from base_sdo;
    ORA-29875 Failed in the ececution of the ODCINDEXINSERT routine
    ORA-13354 incorrect offset in ELEM_INFO_ARRAY
    ORA_06512 at MDSYS.SDO_INDEX_METHOD_101 line. 709I believe that there is some incorrect data that is not with my index defination.
    How do I check this invalid data at base_sdo table. The base_sdo table has no index.
    rgds
    Saz
    Edited by: Saaz Ena on Dec 21, 2009 6:16 PM

    Can you try SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT
    or SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT? e.g.
    select * from base_sdo a where
    SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(a.CA, 0.000005) != 'TRUE';

  • Spatial query (point in poly) problem

    Hi
    One of my users is trying to run the following query in SQL*Plus:
    CREATE TABLE erdpwip_join AS
    SELECT A.CSNGC, B.PARCELID
    FROM RLR.RLR87_SK B, ERDPWIPDATA A
    WHERE sdo_relate (a.geom, b.geom, 'mask=ANYINTERACT querytype=Window') = 'TRUE'
    He says it works on a small subset of the full dataset, but when he tries to run it on a larger selection of data it stops working. The full dataset has 1.6 million shapes and is held in an Oracle 9.2.0.5.0 database. It isn't clean data, unfortunately: I performed an sdo_geom.validate_layer_with_context on it and removed around 240 shapes with errors (mostly self-intersects), but when trying to access the dataset through ESRI's ArcSDE (version 8.3) a load_buffer error -2035 occurs, which I am informed is because there are other low-level self-intersects which Oracle's validation routine didn't pick up.
    There are two questions really: first, is the quality of the data (with these geometric errors) the reason for the user's point-in-polygon query not working on larger recordsets (e.g. about 400000 records), or is because of the volume of data?
    Secondly, is there any way that Oracle's validation routines will pick up these low-level self-intersects which were missed in the first pass? ESRI's support forum recommends running a query on the dataset which steps through so many records at a time until it finds an error - the full thread is at http://forums.esri.com/Thread.asp?c=2&f=1720&t=152985&mc=1.
    Any help would be appreciated.
    Thanks
    Sharon Evans

    Hi Sharon,
    What does "it stops working" mean? Error? Long running query?
    Assuming your data is now clean in spatial, I would try creating the table, then loading it with the query using the ordered hint. The number of geometries, while affecting run time, is certainly not more than spatial can handle.
    CREATE TABLE erdpwip_join AS
    SELECT A.CSNGC, B.PARCELID
    FROM RLR.RLR87_SK B, ERDPWIPDATA A
    WHERE rownum < 1;
    insert into erdpwip_join
    SELECT /*+ ordered */ A.CSNGC, B.PARCELID
    FROM RLR.RLR87_SK B, ERDPWIPDATA A
    WHERE sdo_relate (a.geom, b.geom, 'mask=ANYINTERACT querytype=Window') = 'TRUE';
    Regarding drawing in ESRI and tolerance/validation:
    In Oracle Spatial the tolerance is specified as the distance two points have to be apart to be considered different.
    I think for ESRI, points have to be greater than tolerance apart (not exactly tolerance apart, which is fine in spatial).
    So what you might want to try is kicking up the tolerance by some very small increment for the validation, remove or fix those invalid geometries, reset the tolerance back to the smaller value, and then try using ArcSDE again.
    I haven't tried this at all, so if you can let us know if this works we'll know this is probably a good general recommendation.

  • Extrude 3D polygons in Oracle spatial

    Dear Everyone,
    I have two data sets of the city footprints imported in the Oracle Spatial already. One is a 2D polygon layer with only x and y, and the other is a 3D polygon layer with z values (the x and y are identical to the first one).
    Now I am trying to extrude the 3D polygon to 3D composites based on the z value. I can successfully extrude the 2D polygons with specifying the ground heights (say sdo_ordinate_array(0)) and topheights (say, sdo_ordinate_array(20.0)).
    However, how to extrude the 3D polygon taking each vertex's z value as the ground heights to an specified top heights is a problem for me. Since, I am very new to use PL/SQL, besides, I am not sure if it is possible to do this.
    Here is the sample data extracted from the sample data:
    select sample.geom.sdo_ordinates from sample2d_polygon sample
    NUMBER(715202.739577727,733492.909091357,715206.759608945,733492.412077086,715208.666575034,733506.889047512,715204.72752625,733507.364066093,715202.739577727,733492.909091357)
    select sample.geom.sdo_ordinates from sample3d_polygon sample
    NUMBER(715202.739577727,733492.909091357,12.4890003204346,715206.759608945,733492.412077086,12.4890003204346,715208.666575034,733506.889047512,12.4540004730225,715204.72752625,733507.364066093,12.4320001602173,715202.739577727,733492.909091357,12.4890003204346)
    Can anybody help me about this
    select sdo_util.extrude(sample.geom, sdo_ordinate_array(), sdo_ordinate_array(20.0), 'true', 0.05) from sample2d_polygon sample, where the first sdo_ordinate_array is the array of corresponding vertex's z value?
    Any suggestions is anticipated and highly appreciated.
    Sincerely
    Jun

    Hi Jun,-
    I hope the following code solves your problem.
    Please also make sure your geometries are valid using sdo_geom.validate_geometry_with_context or
    sdo_geom.validate_layer_with_context for 3D geometries.
    Please let us know if you have questions.
    Best
    baris
    drop table myGeoms;
    drop table extruded_myGeoms;
    create table myGeoms(i number, geom sdo_geometry);
    insert into myGeoms(i, geom) values(1,
    MDSYS.SDO_GEOMETRY(3003, null,null,
    MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
    MDSYS.sdo_ordinate_array(
    715202.739577727,733492.909091357,12.4890003204346,
    715206.759608945,733492.412077086,12.4890003204346,
    715208.666575034,733506.889047512,12.4540004730225,
    715204.72752625, 733507.364066093,12.4320001602173,
    715202.739577727,733492.909091357,12.4890003204346
    insert into myGeoms(i, geom) values(2,
    MDSYS.SDO_GEOMETRY(3003, null,null,
    MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
    MDSYS.sdo_ordinate_array(
    715202.739577727,733492.909091357,14.4890003204346,
    715206.759608945,733492.412077086,14.4890003204346,
    715208.666575034,733506.889047512,14.4540004730225,
    715204.72752625, 733507.364066093,14.4320001602173,
    715202.739577727,733492.909091357,14.4890003204346
    insert into myGeoms(i, geom) values(3,
    mdsys.sdo_geometry(3003, null, null,
    mdsys.sdo_elem_info_array(1,1003,1),
    mdsys.sdo_ordinate_array(1,1,10,  0,1,10, 0,0,10, 1,0,10, 1,1,10))
    create table extruded_myGeoms(id number, geom sdo_geometry);
    -- This program assumes that each geometry in myGeoms table
    -- has only 1 ring per polygon ie, 1003 etype element.
    set serveroutput on;
    declare
    type cursor_type is REF CURSOR;
    query_crs cursor_type ;
    -- For each extruded geometry (result), this array has the ground heights
    ords_bottom_z_array sdo_number_array  := null;
    -- For each extruded geometry (result), this array has the top heights which is set to 20 for each element.
    -- Both arrays must have the same number of elements.
    ords_top_z_array sdo_number_array  := null;
    ords2d mdsys.sdo_ordinate_array  := null;
    result sdo_geometry;
    g1 sdo_geometry;
    g2d sdo_geometry;
    stmt  varchar2(100);
    id1 number;
    cnt integer;
    k integer;
    l integer;
    the_dim        number;
    gtype_2d       number;
    begin
    stmt := ' select i, geom from myGeoms ';
    OPEN query_crs FOR stmt;
    LOOP
      BEGIN
       FETCH query_crs into id1, g1;
       EXIT when query_crs%NOTFOUND ;
       ords2d := mdsys.sdo_ordinate_array();
       ords_bottom_z_array := SDO_NUMBER_ARRAY();
       ords_top_z_array := SDO_NUMBER_ARRAY();
       k:=ords_bottom_z_array.count;
       l:=ords2d.count;
       FOR cnt in 1..g1.sdo_ordinates.count LOOP
         if (mod(cnt, 3) = 0) then
           -- Get z values of polygon
           ords_bottom_z_array.extend(1);
           ords_top_z_array.extend(1);
           k:=k+1;
           ords_bottom_z_array(k) := g1.sdo_ordinates(cnt);
           ords_top_z_array(k) := 20.0; -- Constant
         else
           -- To have 2D geometry for input to sdo_util.extrude
           ords2d.extend(1);
           l := l+1;
           ords2d(l) := g1.sdo_ordinates(cnt);
         end if;
       end loop;
       the_dim := floor(g1.sdo_gtype / 1000);
       gtype_2d := (the_dim-1)*1000 + mod(g1.sdo_gtype, 10);
       g2d:= sdo_geometry(gtype_2d, null,  null,
               mdsys.sdo_elem_info_array(1,1003,1),
               ords2d);
       result:= sdo_util.extrude(g2d, ords_bottom_z_array, ords_top_z_array, 'FALSE', 0.05);
       -- insert the extruded geometry (result) into new table
       insert into extruded_myGeoms(id, geom) values(id1, result);
       dbms_output.put_line('id = '||id1);
      END;
    END LOOP;
    end;
    /

  • Spatial Query that uses Result of another Spatial Query

    Hi all,
    I am using the SDO_DIFFERENCE Operator to return the difference between a query window and an intersection geometry. This is fine and i get an object back that is cast to a STRUCT using the SDO API. I want then to use this (returned)object in another SQL query that uses the SDO_RELATE Operator. The problem is that i dont know what type it needs to be so that the SDO_RELATE operator will accept it as a valid argument. Has anyone done this before or seen anything like it? Any help will be very much appreciated.
    Keith.

    Thanks for your help,
    I have done the following steps, but i still dont understand why it doesnt work.
    CREATE TABLE val_results (sdo_rowid ROWID, result varchar2(1000));
    CALL SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('SHAPES','SHAPE','VAL_RESULTS');
    SELECT * FROM val_results;
    1 null     Rows Processed <3>
    2 AAARDDAAEAAAAA+AAA     13348 [Element <1>] [Ring <1>]
    3 AAARDDAAEAAAAA+AAB     13367 [Element <1>] [Ring <1>]
    SELECT shape_id,SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(c.shape, 0.005)
    FROM shapes c;
    3     TRUE
    2     13348 [Element <1>] [Ring <1>]
    1     13367 [Element <1>] [Ring <1>]
    If my rectangle and polygon is still invalid, can someone tell me why they are invalid. And how can i make them valid?
    Thanks.
    UPDATE:
    I have solved Polygon issue.
    In Spatial Developer's Guide it says:
    Simple polygon whose vertices are connected by straight line
    segments. You must specify a point for each vertex; and the
    last point specified must be exactly the same point as the first
    (within the tolerance value), to close the polygon. For
    example, for a 4-sided polygon, specify 5 points, with point 5
    the same as point 1.
    I have added a point to polygon which is same as first point. Now, it can find the point in polygon.
    INSERT INTO shapes VALUES (4, 'Polygon', SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(306,193,130,441,489,653,88,183,442,354,306,193)));
    But, when i run this query again:
    SELECT shape_id,SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(c.shape, 0.005) FROM shapes c;
    4     13349 [Element <1>] [Ring <1>][Edge <4>][Edge <1>]
    3     TRUE
    2     13348 [Element <1>] [Ring <1>]
    1     13367 [Element <1>] [Ring <1>]
    it doesn't say TRUE like it did for Circle ??
    Edited by: WhiteScars on Jan 4, 2010 12:45 AM

  • ORA-13050 unable to construct spatial object - Error

    Hi friends!,
    I to realize the follow query:
    SELECT A.MI_PRINX, B.DESCRIP
    FROM PEVEDISC A, PEVEGEO B
    WHERE SDO_GEOM.RELATE(A.GEOLOC,'ANYINTERACT',B.GEOLOC,0.005) = 'TRUE'
    AND SDO_GEOM.RELATE(A.GEOLOC,'TOUCH',B.GEOLOC,0.005) = 'FALSE'
    AND ROWNUM <= 10
    and result error "ORA-13050 unable to construct spatial object". Please help me, i don't know what to do!. thanks

    Hi,
    Have you validated your data? Try validating using sdo_geom.validate_geometry_with_context or sdo_geom.validate_layer_with_context.
    I would also like to offer a suggestion on how to write this query. If there are a significant number of geometries in either or both of these tables, this query can take a long time to run.
    If you create spatial indexes on these tables, then the following might be better:
    SELECT /*+ ordered */ A.MI_PRINX, B.DESCRIP
    FROM PEVEGEO B, PEVEDISC A
    WHERE SDO_RELATE(A.GEOLOC,B.GEOLOC,
    'querytype=window mask=inside+coveredby') = 'TRUE'
    AND ROWNUM <= 10;

  • Topology Built from Spatial Geometries

    Hello, I am trying creating topology from example:
    CREATE TABLE city_streets6_geom ( -- City streets/roads
    name VARCHAR2(30) PRIMARY KEY,
    geometry SDO_GEOMETRY);
    CREATE TABLE traffic_signs6_geom ( -- Traffic signs
    name VARCHAR2(30) PRIMARY KEY,
    geometry SDO_GEOMETRY);
    CREATE TABLE land_parcels6_geom ( -- Land parcels
    name VARCHAR2(30) PRIMARY KEY,
    geometry SDO_GEOMETRY);
    INSERT INTO user_sdo_geom_metadata
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'city_streets6_GEOM',
    'GEOMETRY',
    SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', 0, 65, 0.005),
    SDO_DIM_ELEMENT('Y', 0, 45, 0.005)
    NULL -- SRID
    INSERT INTO user_sdo_geom_metadata
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'traffic_signs6_GEOM',
    'GEOMETRY',
    SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', 0, 65, 0.005),
    SDO_DIM_ELEMENT('Y', 0, 45, 0.005)
    NULL -- SRID
    INSERT INTO user_sdo_geom_metadata
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'land_parcels6_GEOM',
    'GEOMETRY',
    SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', 0, 65, 0.005),
    SDO_DIM_ELEMENT('Y', 0, 45, 0.005)
    NULL -- SRID
    -- Load these tables (names and geometries for city streets/roads,
    -- traffic signs, and land parcels).
    -- Insert data into city street line geometries.
    -- R1
    INSERT INTO city_streets6_geom VALUES('R1',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(9,14, 21,14, 35,14, 47,14)));
    -- R2
    INSERT INTO city_streets6_geom VALUES('R2',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(36,38, 38,35, 41,34, 42,33, 45,32, 47,28, 50,28, 52,32,
    57,33, 57,36, 59,39, 61,38, 62,41, 47,42, 45,40, 41,40)));
    -- R3
    INSERT INTO city_streets6_geom VALUES('R3',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(9,35, 13,35)));
    -- R4
    INSERT INTO city_streets6_geom VALUES('R4',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(25,30, 25,35)));
    -- Insert data into traffic sign point geometries.
    -- S1
    INSERT INTO traffic_signs6_geom VALUES('S1',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(21,14,NULL), NULL, NULL));
    -- S2
    INSERT INTO traffic_signs6_geom VALUES('S2',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(35,14,NULL), NULL, NULL));
    -- S3
    INSERT INTO traffic_signs6_geom VALUES('S3',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(57,33,NULL), NULL, NULL));
    -- S4
    INSERT INTO traffic_signs6_geom VALUES('S4',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(20,37,NULL), NULL, NULL));
    -- Insert data into land parcel polygon geometries.
    -- P1
    INSERT INTO land_parcels6_geom VALUES('P1',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
    SDO_ORDINATE_ARRAY(9,6, 21,6, 21,14, 21,22, 9,22, 9,14, 9,6)));
    -- P2
    INSERT INTO land_parcels6_geom VALUES('P2',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),
    SDO_ORDINATE_ARRAY(21,6, 35,6, 35,14, 35,22, 21,22, 21,14, 21,6)));
    -- P3
    INSERT INTO land_parcels6_geom VALUES('P3',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),
    SDO_ORDINATE_ARRAY(35,6, 47,6, 47,14, 47,22, 35,22, 35,14, 35,6)));
    -- P4
    INSERT INTO land_parcels6_geom VALUES('P4',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),
    SDO_ORDINATE_ARRAY(17,30, 31,30, 31,40, 17,40, 17,30)));
    -- P5 (polygon with a hole; exterior ring and one interior ring)
    INSERT INTO land_parcels6_geom VALUES('P5',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1, 11,2003,1),
    SDO_ORDINATE_ARRAY(3,30, 16,30, 16,38, 3,38, 3,30, 4,31, 4,34, 7,34, 7,31, 4,31)));
    -- Validate the layers.
    create table val_results (sdo_rowid ROWID, result VARCHAR2(2000));
    call SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('city_streets6_GEOM','GEOMETRY','VAL_RESULTS');
    SELECT * from val_results;
    truncate table val_results;
    call SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('traffic_signs6_GEOM','GEOMETRY','VAL_RESULTS');
    SELECT * from val_results;
    truncate table val_results;
    call SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('land_parcels6_GEOM','GEOMETRY','VAL_RESULTS');
    SELECT * from val_results;
    drop table val_results;
    -- Create the spatial indexes.
    CREATE INDEX city_streets6_geom_idx ON city_streets6_geom(geometry)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    CREATE INDEX traffic_signs6_geom_idx ON traffic_signs6_geom(geometry)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    CREATE INDEX land_parcels6_geom_idx ON land_parcels6_geom(geometry)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    -- Start the main steps for using the topology data model with a
    -- topology built from Spatial geometry data.
    -- 1. Create the topology. (Null SRID in this example.)
    EXECUTE SDO_TOPO.CREATE_TOPOLOGY('CITY_DATA6', 0.00005);
    -- 2. Insert the universe face (F0). (id = -1, not 0)
    INSERT INTO CITY_DATA6_FACE$ values (
    -1, NULL, SDO_LIST_TYPE(), SDO_LIST_TYPE(), NULL);
    COMMIT;
    -- 3. Create feature tables.
    CREATE TABLE city_streets6 ( -- City streets/roads
    feature_name VARCHAR2(30) PRIMARY KEY,
    feature SDO_TOPO_GEOMETRY);
    CREATE TABLE traffic_signs6 ( -- Traffic signs
    feature_name VARCHAR2(30) PRIMARY KEY,
    feature SDO_TOPO_GEOMETRY);
    CREATE TABLE land_parcels6 ( -- Land parcels
    feature_name VARCHAR2(30) PRIMARY KEY,
    feature SDO_TOPO_GEOMETRY);
    -- 4. Associate feature tables with the topology.
    -- Add the three topology geometry layers to the CITY_DATA6 topology.
    -- Any order is OK.
    EXECUTE SDO_TOPO.ADD_TOPO_GEOMETRY_LAYER('CITY_DATA6', 'city_streets6', 'FEATURE','LINE');
    EXECUTE SDO_TOPO.ADD_TOPO_GEOMETRY_LAYER('CITY_DATA6', 'traffic_signs6','FEATURE', 'POINT');
    EXECUTE SDO_TOPO.ADD_TOPO_GEOMETRY_LAYER('CITY_DATA6', 'land_parcels6','FEATURE', 'POLYGON');
    -- As a result, Spatial generates a unique TG_LAYER_ID for each layer in
    -- the topology metadata (USER/ALL_SDO_TOPO_METADATA).
    -- 5. Create a TopoMap object and load the whole topology into cache for updating.
    EXECUTE SDO_TOPO_MAP.CREATE_TOPO_MAP('CITY_DATA6', 'CITY_DATA6_TOPOMAP');
    EXECUTE SDO_TOPO_MAP.LOAD_TOPO_MAP('CITY_DATA6_TOPOMAP', 'true');
    -- 6. Load feature tables, inserting data from the spatial tables and
    -- using SDO_TOPO_MAP.CREATE_FEATURE.
    BEGIN
    FOR street_rec IN (SELECT name, geometry FROM city_streets6_geom) LOOP
    INSERT INTO city_streets6 VALUES(street_rec.name,
    SDO_TOPO_MAP.CREATE_FEATURE('CITY_DATA6', 'city_streets6', 'FEATURE',
    street_rec.geometry));
    END LOOP;
    FOR sign_rec IN (SELECT name, geometry FROM traffic_signs6_geom) LOOP
    INSERT INTO traffic_signs6 VALUES(sign_rec.name,
    SDO_TOPO_MAP.CREATE_FEATURE('CITY_DATA6', 'traffic_signs6', 'FEATURE',
    sign_rec.geometry));
    END LOOP;
    FOR parcel_rec IN (SELECT name, geometry FROM land_parcels6_geom) LOOP
    INSERT INTO land_parcels6 VALUES(parcel_rec.name,
    SDO_TOPO_MAP.CREATE_FEATURE('CITY_DATA6', 'land_parcels6', 'FEATURE',
    parcel_rec.geometry));
    END LOOP;
    END;
    But process failed in sixth step with error:
    Error report:
    ORA-29532: java.lang.NumberFormatException: Infinite or NaN
    ORA-06512: line 3
    29532. 00000 - "Java call terminated by uncaught Java exception: %s"
    *Cause:    A Java exception or error was signaled and could not be
    resolved by the Java code.
    *Action:   Modify Java code, if this behavior is not intended.
    What should i do with this problem?
    Thanks

    thank you for reply.
    i can try to network topology.
    but i have more than one layer. for example lands, waters, etc.
    actually i need left face, right face, start node, end node etc. (topology info) information for my application.
    my question is on going...
    thanks for interest again

Maybe you are looking for

  • Can I have more than one iCloud email address and if so how do I create it

    I have multiple businesses and would like to create a second iCloud email.  Is that possible and if so will it sync to my previous one or can I sync it on the Iphone?  Thank you

  • Vendor payment doc type KZ looking for account type A which is not defined

    Hi Experts We are processing a Vendor payment where discount is received, howeve,  the message "For document type KZ, account type A is not defined'  in the job log. Can anyone please put some light on this error. Many thanks Kind regards Dawn

  • Multiple line items in migo

    Hi, Is it possible to have multiple line items in MIGO by purchase order. Issue is PO (UB) created with 10 qty. Issued in 3 different qtys (351-mvt) with different material docs. while doing GR by PO in MIGO (101) instead of commulative i want it sho

  • One  credit  note  with reference to several invoices??

    Hello, my  customer  came  up  with  specia  requirement , Is  it  possible  to  have  One  credit  note request  with reference to several invoices?? I  never  seen  but  your  input  would  be  helpful. Points  will  be  added  for  helpful  answer

  • Ichat won't connect to AIM

    Hi. I know there's other topics with this exact problem but none of them were helpful, so I have to post my own here. For months I have had the problem with iChat, where if I try to sign in, it collapses and expands many times and tells me I have tri