SDO_UTIL.FROM_WKBGEOMETRY function

Hi there.
I have been struggling to convert WKB(Blobs) to SDO_GEOMETRY.
If I understand correctly there is some SDO functions that doesn't`t work in Oracle XE or should I rather say it has a differant syntax in XE than enterprise.
My problem is that I want to transform WKR(Blobs) to SDO_Geometry.
I tried the following procedure but to no avail.
CREATE OR REPLACE PROCEDURE IMIS_MAP_GEO.BLOB_TO_SDO
IS
CURSOR TCURS IS
SELECT SEQ,
SDO_GEOM.VALIDATE_GEOMETRY(SDO_UTIL.SIMPLIFY((SDO_UTIL.FROM_WKBGEOMETRY(A.GEOMETRY)),0.00000005),0.000001) AS "VALIDATION",
SDO_UTIL.SIMPLIFY((SDO_UTIL.FROM_WKBGEOMETRY(A.GEOMETRY)),0.00000005) AS GEOM
FROM LAND_PARCELS_REGD_ERVEN A
WHERE GEOMETRY IS NOT NULL;
BEGIN
FOR TROW IN TCURS LOOP
IF TROW."VALIDATION" = 'TRUE'
THEN
UPDATE LAND_PARCELS_REGD_ERVEN A
SET A.GEOMETRY_TEST = TROW.GEOM
WHERE A.SEQ = TROW.SEQ;
ELSE
DBMS_OUTPUT.PUT_LINE('GEOMETRY NOT VALID WITH ORA-' ||TROW."VALIDATION"|| ' ON SEQ'||TROW.SEQ);
END IF;
END LOOP;
END;
The values it returns is an blank GEOMETRY.
Any help would be appreciated.
Thanks in advance

Hi Siva.
Thanks for the reply.
Do you know of any workarounds?or is the only way to use Enterprise?
Thanks in advance,

Similar Messages

  • SDO_UTIL Missing Functions?

    Folks,
    I am accessing a 10.2.0.1 SE database at a client site and when I describe the SDO_UTIL package I don't get all the functions in 10.2.0.1 that I use when developing my PL/SQL packages (for download at my website).
    SQL*Plus: Release 10.2.0.1.0 - Production on Fri Feb 9 09:06:27 2007
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Release 10.2.0.1.0 - 64bit Production
    SQL> desc sdo_util
    FUNCTION APPEND RETURNS SDO_GEOMETRY
    Argument Name Type In/Out Default?
    GEOMETRY1 SDO_GEOMETRY IN
    GEOMETRY2 SDO_GEOMETRY IN
    FUNCTION EXTRACT RETURNS SDO_GEOMETRY
    Argument Name Type In/Out Default?
    GEOMETRY SDO_GEOMETRY IN
    ELEMENT NUMBER IN
    RING NUMBER IN DEFAULT
    FUNCTION GETVERTICES RETURNS VERTEX_SET_TYPE
    Argument Name Type In/Out Default?
    GEOMETRY SDO_GEOMETRY IN
    FUNCTION REMOVE_DUPLICATES RETURNS SDO_GEOMETRY
    Argument Name Type In/Out Default?
    GEOMETRY SDO_GEOMETRY IN
    DIM SDO_DIM_ARRAY IN
    FUNCTION REMOVE_DUPLICATE_VERTICES RETURNS SDO_GEOMETRY
    Argument Name Type In/Out Default?
    GEOMETRY SDO_GEOMETRY IN
    TOLERANCE NUMBER IN
    FUNCTION TRUNCATE_NUMBER RETURNS NUMBER
    Argument Name Type In/Out Default?
    VALUE NUMBER IN
    NO_OF_DIGITS NUMBER IN
    In particular, I am looking for CONCAT_LINES() and RECTIFY_GEOMETRY.
    Any pointers?
    regards
    Simon Greener

    Dan,
    This explains it. I am running 10.2.0.1 on my laptop and have all the functions etc.
    I have seen this error:
    ORA-04063: type body "MDSYS.SDO_INDEX_METHOD_9I" has errors
    at many sites but never quite got to the bottom as to why it occurred was occuring on 10g databases! I always assumed the _9I thing was a short term carry over.
    Now I know!
    Mate, I am really well. Thankfully, reasonably busy, though things were a bit quiet when I got back from Europe (last October). It was great to meet you though it would have been nice to have had a chance to catch up over a drink/dinner but you had to fly back to the USA. I have started down the OCP track which, on top of everything else, is keeping me out of mischief!
    I hope all is going well with you. We should drop each other an email off line...
    regards
    S

  • SDO_UTIL WKT functions appear to choke on multipoints

    Hi folks,
    Ugh. Not having fun with this. It appears that on both 10.2.0.4 and 11.1.0.6 that the WKT parser doesn't do multipoints correctly.
    Could someone familar with WKT check these results and tell me if I am missing something critical?
    This works just fine:
    <strong>SELECT SDO_UTIL.APPEND(</strong>
    <strong>SDO_GEOMETRY('POINT(-87.9033279296583 42.580894084168456)',8265),</strong>
    <strong>SDO_GEOMETRY('POINT(-87.89577482907342 42.60414701132971)',8265)</strong>
    <strong>) FROM dual;</strong>
    producing
    SDO_GEOMETRY
    2005,
    8265,
    NULL,
    SDO_ELEM_INFO_ARRAY
    1,
    1,
    1,
    3,
    1,
    1
    SDO_ORDINATE_ARRAY
    -87.9033279296583,
    42.5808940841685,
    -87.8957748290734,
    42.6041470113297
    But this
    <strong>SELECT</strong>
    <strong>SDO_GEOMETRY('MULTIPOINT((-87.9033279296583 42.580894084168456),(-87.89577482907342 42.60414701132971))',8265)</strong>
    <strong>FROM dual;
    </strong>produces a screwy SDO_ELEM_INFO_ARRAY indicating only a single element and I don't think that 2 is ever legit for a point.
    SDO_GEOMETRY
    2005,
    8265,
    NULL,
    SDO_ELEM_INFO_ARRAY
    1,
    1,
    2
    SDO_ORDINATE_ARRAY
    -87.90332792965830321918474510312080383301,
    42.58089408416845600413580541498959064484,
    -87.89577482907341732243367005139589309692,
    42.60414701132970805019795079715549945831
    Reversing around the situation, its just as bad
    <strong>SELECT SDO_UTIL.TO_WKTGEOMETRY(
    (SELECT SDO_GEOMETRY
    2005,
    8265,
    NULL,
    SDO_ELEM_INFO_ARRAY
    1,
    1,
    1,
    3,
    1,
    1
    SDO_ORDINATE_ARRAY
    -87.9033279296583,
    42.5808940841685,
    -87.8957748290734,
    42.6041470113297
    ) FROM dual)
    ) FROM dual</strong>
    produces a completely whacked
    MULTIPOINT ((-87.9033279296583 42.5808940841685))
    Am I missing something here? The WKT isn't rocket science so I think I have all the formats correct.
    Thanks,
    Paul

    Paul
    1. the second example is correct and seen as a point cluster.
    2. seems that the wkt parser only recognizes these point clusters rather then multipoints (possible defect).
    There is a slight distinction between a Multi-Point and a Pont cluster:
    General:
    In Oracle Spatial a Multi...geometry has for every element a triplet in the SDO_ELEM_info_array. Also for a Mulitpoint geometry.
    INSERT INTO t1 (i, d, g)
    VALUES (
    17,
    'Multipoint',
    sdo_geometry (2005, null, null, sdo_elem_info_array (1,1,1, 3,1,1, 5,1,1),
    sdo_ordinate_array (65,5, 70,7, 75,5))
    However, there is also 'Point cluster' definition, which just has 1 sdo_elem_info_array triplet (1, 1, n) with n the number of elements.
    INSERT INTO t1 (i, d, g)
    VALUES (
    16,
    'Point cluster',
    sdo_geometry (2005, null, null, sdo_elem_info_array (1,1,3),
    sdo_ordinate_array (50,5, 55,7, 60,5))
    In the Pro Oracle Spatial book, the last notation is recomended for a multipoint (performance + storage). It is seen as a single elements with N points, as opposed to an array of points.
    If you use in your case:
    SELECT SDO_UTIL.TO_WKTGEOMETRY(
    SDO_GEOMETRY
    2005,
    8265,
    NULL,
    SDO_ELEM_INFO_ARRAY
    1,
    1,
    2
    SDO_ORDINATE_ARRAY
    -87.9033279296583,
    42.5808940841685,
    -87.8957748290734,
    42.6041470113297
    ) FROM dual
    you will get MULTIPOINT ((-87.9033279296583 42.5808940841685), (-87.8957748290734 42.6041470113297))
    In the other case, the WKT parser will read the first triplet and will evaluate the 3rd element of that triplet as a "Point cluster" with 1 point, and will use in second step only parse the first two ordinates.
    I would raise this as a possible defect (not reading the full Multipoint) or consider working with the Point Clusters if feasible.
    Note: read this post also on issues with the Point Clusters and the number of points: Re: Run-time error using SDO_GEOMETRY constructor with WKT
    Hoping this could help.
    Luc
    Edited by: lucvanlinden on Dec 29, 2008 8:00 PM

  • Sdo_util.simplify - Error? Bug? Totally stumped !

    Hi folks,
    I have a confusing problem/error with using sdo_util.simplify. I am using Oracle 11G R2 with Spatial Option.
    I have loaded just over 2000 UK postown polygons - based on an OS source. These loaded fine and have been working perfectly well with spatial sql.
    The source data specifies the projection as British National Grid GCS_OSGB_1936 and the SRID within the Oracle metadata was correctly (i believe) determined (by calculate mbr) and set to 7405 - OSGB36 / British National Grid
    I can view the polygons perfectly fine in SqlDeveloper/GeoRaptor and if export them to KML and view them in Google Earth they position and display exactly as I would expect.
    All other spatial functions I have tried on the polygons work fine.
    The problem comes when I try and use sdo_util.simplify to reduce the number of co-ordinates used on the polygons :
    select sdo_util.simplify(poly_hi,100,0.005)
    from posttown_boundaries;
    ORA-13199: the given geometry cannot be rectified
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 17
    ORA-06512: at "MDSYS.SDO_UTIL", line 716
    ORA-06512: at "MDSYS.SDO_UTIL", line 770
    ORA-06512: at line 1
    13199. 00000 - "%s"
    *Cause:    This is an internal error.
    *Action:   Contact Oracle Support Services.
    I've tried various threshold and tolerance values ( the only threshold value that works is 0 which returns the same geometry.
    I have successfully used the sdo_util.simpify functions on the other spatial objects in the database so I don't believe it to be a database setup issue.
    When I run a validate geometry on the table for the geometry column I get the ORA-13029: Invalid SRID in the SDO_GEOMETRY object.
    However, as explained above the SRID was selected and checked using calculate MBR and it matches exactly what I would have expected given the source data and i have not found any other issues with the SRID.
    The error can be reproduced without any of the source tables by just taking one small polygon definition as follows:
    select sdo_util.simplify(
    MDSYS.SDO_GEOMETRY(
    2003,7405,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
    MDSYS.SDO_ORDINATE_ARRAY(407207.997315803,287087.001455892,
    406802.999914517,286916.000404434,
    406677.996543163,286831.004734191,
    406518.001132497,286741.000497636,
    406863.996876543,286566.000590838,
    407284.000289033,286672.000248752,
    407207.997315803,287087.001455892))
    ,5,0.005)
    FROM dual;
    ORA-13199: the given geometry cannot be rectified
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 17
    ORA-06512: at "MDSYS.SDO_UTIL", line 716
    ORA-06512: at "MDSYS.SDO_UTIL", line 770
    ORA-06512: at line 1
    13199. 00000 - "%s"
    *Cause:    This is an internal error.
    *Action:   Contact Oracle Support Services.
    Am totally stumped with this!
    Can anyone offer any thoughts or guidance?
    Many thanks in advance.
    Mike.

    Hi Mike,
    Usually someone jumps in early with the "geometry ain't valid" answer so I am late to the party. When I attempt to validate your 7405 geometry using 11gR2, I receive back error 13029.
    SELECT
    SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(
       MDSYS.SDO_GEOMETRY(
          2003,
          7405,
          NULL,
          MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
          MDSYS.SDO_ORDINATE_ARRAY(
             407207.997315803,287087.001455892,
             406802.999914517,286916.000404434,
             406677.996543163,286831.004734191,
             406518.001132497,286741.000497636,
             406863.996876543,286566.000590838,
             407284.000289033,286672.000248752,
             407207.997315803,287087.001455892
       0.005
    FROM
    dualThe error indicates that SRID 7405 "is invalid" which is not really all that informative. As you note above 7405 exists in MDSYS but its marked as a COMPOUND CRS which to keep it simple is a 3D CRS.
    (see http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_cs_concepts.htm#autoId18)
    Thus "invalid" in this context means the SRID is invalid for the geometry you are putting it upon.
    So if we just add a Z to your geometry everything works hunky-dory
    SELECT
    SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(
       MDSYS.SDO_GEOMETRY(
          3003,
          7405,
          NULL,
          MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
          MDSYS.SDO_ORDINATE_ARRAY(
             407207.997315803,287087.001455892,0,
             406802.999914517,286916.000404434,0,
             406677.996543163,286831.004734191,0,
             406518.001132497,286741.000497636,0,
             406863.996876543,286566.000590838,0,
             407284.000289033,286672.000248752,0,
             407207.997315803,287087.001455892,0
       0.005
    FROM
    dualAnd your SIMPLIFY task also then works fine
    SELECT
    SDO_UTIL.SIMPLIFY(
       MDSYS.SDO_GEOMETRY(
          3003,
          7405,
          NULL,
          MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
          MDSYS.SDO_ORDINATE_ARRAY(
             407207.997315803,287087.001455892,0,
             406802.999914517,286916.000404434,0,
             406677.996543163,286831.004734191,0,
             406518.001132497,286741.000497636,0,
             406863.996876543,286566.000590838,0,
             407284.000289033,286672.000248752,0,
             407207.997315803,287087.001455892,0
       5,
       0.005
    FROM
    dualSo long-winded way to reiterate what Ivan said - you are using the wrong SRID. 10g was more forgiving than 11g when mixing and matching 3D and 2D SRIDs with data. 11g is more picky but not always that great at explaining the pickiness. I would bet if you had got back an error such as "2D coordinates not valid with 3D SRID" you would never have needed to post the question. I would suggest putting in an enhancement request to Support for some better error messages.
    Cheers,
    Paul
    Edited by: Paul Dziemiela on Nov 6, 2011 10:58 AM

  • Is there a function in Oracle Spatial 11g to move/translate geometry?

    Hello Everybody,
         I am new to Oracle Spatial. I wanted to know if there is any function to move/translate a geometry in Oracle Spatial 11g? PostGIS has a function named ST_Translate to achieve the same.
    Regards,
    Shiva Shankar

    Hi
    There is an SDO_UTIL.AFFINETRANSFORMS function in the  SDO_UTIL Package (Utility)
    Note, that Simon Greener & Siva Ravada have published an excellent book ("Applying and Extending Oracle Spatial") that contains examples (in Chapter 7) of easy to use wrappers for this:
    http://www.packtpub.com/applying-and-extending-oracle-spatial/book
    Luc

  • JPA Error with SDO_GEOMETRY conversion

    Attempted to perform a native SQL query which invokes
    the Oracle SDO_UTIL.ELLIPSE_POLYGON() function within
    a JPA context and got a ClassCastException. Here is code snippet:
    try
    javax.persistence.Query query = entityManager_.createNativeQuery(
    "select SDO_UTIL.ELLIPSE_POLYGON( 32.4, 112.6, 1124.2, 992.4, 18.0, 5.0 ) from DUAL" );
    oracle.sql.STRUCT obj = ( oracle.sql.STRUCT ) query.getSingleResult();
    }catch( Exception e ) {}
    When the query is executed this error occurs:
    ERROR: java.lang.ClassCastException: org.eclipse.persistence.internal.helper.NonSynchronizedVector cannot be
    cast to oracle.sql.STRUCT
    NOTE: using Toplink 11G
    Thanks ...
    Edited by: user11177655 on Jul 22, 2009 12:45 PM

    I assume you are getting back a List (Vector) with the Struct inside it. Try ((List)query.getSingleResult()).get(0).
    In JPA you should get the Struct back directly if the result size was 1, otherwise an Object[], this was a bug in EclipseLink 1.0 that was fixed in EclipseLink 1.1.
    You should probably upgrade to EclipseLink 1.1.
    James : http://www.eclipselink.org

  • 8.1.7 Select a Points Coordinates.

    Please excuse this newbie question. I am using Oracle 8.1.7. I have a two dimensional point table and all I want to do is now extract the X and Y coordinates from each point.
    How do you do this? I have looked through the forum and seen reference to SDO_UTIL.GETVERTICES function and tried it but don't think its available in 8.1.7.
    Thanks in advance,
    Tim

    If you have stored the X/Y-values in SDO_POINT_TYPE
    (it would look like follows:
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(14848.674, 4635.151, NULL), NULL, NULL))
    you can easily access the two values by:
    select x.geoloc.sdo_point.x as X, x.geoloc.sdo_point.y as Y
    from e3_gis_eort x
    where rownum <5;
    RESULT:
    =======
    X Y
    14848.674 4635.151
    14071.406 4705.06
    11943.957 4567.079
    15010.953 5186.186
    Caution: it is very important to give a table-alias in the select (x) and acccess the spatial-column by referencing over this alias.
    regards
    Anna

  • Oracele Spatial 11g  - 2D-3D Geometry Extrusion

    Hi,
    I am trying to extrude some 2d data that is lat long format to 3d using the sdo_util.extrude function. The SQL workflow is as follows:
    *1. Create 2d data table, insert data and index*
    --table for 2d data
    CREATE TABLE "EGOVIS"."DUBLIN_F_TEST"
    (     "FID" NUMBER(38,0),
         "ID" NUMBER(38,0),
         "ZV" FLOAT(126),
         "X" FLOAT(126),
         "Y" FLOAT(126),
         "GEOM" "MDSYS"."SDO_GEOMETRY"
    --insert data
    Insert into DUBLIN_F_PROJECT (FID,ID,ZV,X,Y,GEOM)
    values
    47,
    1,
    97,
    -6.27175835549,
    53.3369421474,
    MDSYS.SDO_GEOMETRY(
    2003
    ,8307
    ,NULL
    ,SDO_ELEM_INFO_ARRAY(
    1,
    1003,
    1),
    SDO_ORDINATE_ARRAY(
    -6.271393982,53.337082684,
    -6.271432654,53.337085933,
    -6.271441366,53.337051319,
    -6.271337218,53.337041470,
    -6.271303925,53.337037787,
    -6.271287361,53.337035957,
    -6.271278835,53.337071497,
    -6.271335773,53.337077243,
    -6.271393982,53.33708268)));
    --insert metadata
    INSERT INTO USER_SDO_GEOM_METADATA VALUES
    'DUBLIN_F_PROJECT',
    'GEOM',
    MDSYS.SDO_DIM_INFO_ARRAY
    MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, 0.5),
    MDSYS.SDO_DIM_ELEMENT('Latitude',-90, 90, 0.5)
    8307
    --create spatial index
    CREATE INDEX "EGOVIS"."DUBLIN_F_PROJECT_SINDX" ON "EGOVIS"."DUBLIN_F_PROJECT" ("GEOM")
    INDEXTYPE IS "MDSYS"."SPATIAL_INDEX" ;
    *2. create 3d data table and Extrude data into DUBLIN_E_PROJECT table*
    --create table
    CREATE TABLE "EGOVIS"."DUBLIN_E_TEST"
    (     "FID" NUMBER(38,0),
         "ID" NUMBER(38,0),
         "ZV" FLOAT(126),
         "X" FLOAT(126),
         "Y" FLOAT(126),
         "GEOM" "MDSYS"."SDO_GEOMETRY"
    --extrude 2d data from DUBLIN_F_PROJECT to DUBLIN_E_PROJECT
    INSERT
    INTO
    DUBLIN_E_PROJECT
    SELECT
    FID
    ,ID
    ,ZV
    ,X
    ,Y
    ,SDO_UTIL.EXTRUDE(
    GEOM
    ,SDO_NUMBER_ARRAY(0)
    ,SDO_NUMBER_ARRAY(20)
    ,'TRUE'
    ,0.05)
    from DUBLIN_F_PROJECT
    when i try to extrude the data i get the following error:
    *An error was encountered performing the requested operation:
    ORA-29532: Java call terminated by uncaught exception:
    java.lang.Exception: 54550
    ORA-06512: at "MDSYS.SDO_UTIL",line 222
    29532. 0000 - "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.
    Error at Line:1*
    I have tried to drop the index and perform the extrusion but that does not help. Does any one have advice on how to solve this problem?
    Thanks for suggestions,
    Keith.
    Edited by: keithgardiner on Aug 26, 2009 4:48 AM

    Thanks for that siva,
    I have successfully extruded the data into 3d data. i now need to index the data. My steps are as follows:
    *1. update srid of data to 3d srid*
    update dublin_sample_test a set a.geom.sdo_srid=4327;
    *2. insert metadata for said data with height value*
    INSERT INTO USER_SDO_GEOM_METADATA VALUES
    'DUBLIN_sample_test3',
    'GEOM',
    MDSYS.SDO_DIM_ARRAY
    MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, 0.00005),
    MDSYS.SDO_DIM_ELEMENT('Latitude',-90, 90, 0.00005),
    MDSYS.SDO_DIM_ELEMENT('Height',0, 300, 0.00005)
    4327 --wgs84 3d
    *3. create 3d index on table*
    CREATE INDEX dublin_sample_test3_SIDX
    ON dublin_sample_test3 ("GEOM")
    INDEXTYPE IS
    MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3');
    I have tried but at index creation stage I am getting the following error:
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13236: internal error in R-tree processing: [specified index dimensionality
    should be 2 for geodetic indexes]
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
    29855. 00000 - "error occurred in the execution of ODCINDEXCREATE routine"
    *Cause:   Failed to successfully execute the ODCIIndexCreate routine.
    *Action: Check to see if the routine has been coded correctly.
    Error at Line: 3 Co;umn: 13
    Can you please advise me on the process of selecting a 3d srid for wgs84(lat/long) data and tell me if I am doing anything incorrect here.
    Thanks,
    keith.

  • Is a link traced direct or reversed by a path (path$, plink$)

    Hello
    After analyzing an "undirected" network via the java api, we stored the results in the path$ table and also filled the plink$ table, containing the sequence and the link_id's that made up the paths.
    Is there an easy way, or does anybody already created a way, to check or list in which "direction" (direct or reversed) the path traced the links? Is a link traced direct or reversed by a path?
    tx
    Luc

    Ok
    This is what I came up with, without guarantee that this is the best/fastest code/approach.
    The concept comes from the SDO_UTIL.GETVERTICES function (see spatial users guide).
    1. create type LINK_DIR_TYPE where direct holds a bit 0 = reversed, 1 direct)
    ========================================================
    Create type LINK_DIR_TYPE AS OBJECT
    PATH_ID NUMBER,
    LINK_ID NUMBER,
    SEQ_NO NUMBER,
    DIRECT NUMBER
    2. create type PLINK_DIR_TYPE
    =================================================
    CREATE TYPE PLINK_DIR_TYPE AS TABLE OF LINK_DIR_TYPE;
    3. A function returning the type PLINK_DIR_TYPE
    =====================================
    CREATE OR REPLACE FUNCTION GET_PLINK_DIRECTION (myNETWORK IN
    VARCHAR2, PATH_ID IN NUMBER) RETURN PLINK_DIR_TYPE
    AS
    PLTN VARCHAR2(50);
    LTN VARCHAR2(50);
    PTN VARCHAR2(50);
    PATH_START_NODE_ID NUMBER;
    Prev_stN NUMBER;
    Prev_dir NUMBER;
    v_sql VARCHAR2(500);
    TYPE cur_type IS REF CURSOR;
    c_cursor cur_type;
    c_cursor2 cur_type;
    TYPE NUMTAB IS TABLE OF NUMBER;
    LinkIDS NUMTAB;
    L_startids NUMTAB;
    L_endids NUMTAB;
    Directs NUMTAB;
    pl_DIR_TAB PLINK_DIR_TYPE := PLINK_DIR_TYPE(NULL) ;
    BEGIN
    SELECT PATH_TABLE_NAME, PATH_LINK_TABLE_NAME, LINK_TABLE_NAME INTO PTN, PLTN, LTN
    FROM USER_SDO_NETWORK_METADATA
    WHERE NETWORK = myNETWORK;
    v_sql := 'SELECT START_NODE_ID FROM ' || PTN || ' WHERE PATH_ID = ' || path_id;
    EXECUTE IMMEDIATE v_sql into PATH_START_NODE_ID;
    v_sql := 'select pl.link_id, l.start_node_id, l.end_node_id, 1 as DIRECT ' ||
    'from ' || pltn || ' pl, ' || ltn || ' l ' ||
    'where pl.path_id = :1 AND pl.link_id = l.link_id ' ||
    'ORDER BY pl.path_id, pl.seq_no ';
    OPEN c_cursor2 FOR v_sql using path_id;
    FETCH c_CURSOR2 BULK COLLECT INTO linkids, l_startids, l_endids, directs;
    CLOSE c_CURSOR2;
    pl_DIR_TAB.EXTEND(Linkids.last -1);
    Prev_stN := PATH_START_NODE_ID;
    Prev_dir := 0;
    IF (L_startIDs(1) = Prev_stN) THEN
    DIRECTS(1) := 1;
    ELSE
    DIRECTS(1) := 0;
    END IF;
    Prev_dir := DIRECTS(1);
    pl_DIR_TAB(1) := LINK_DIR_TYPE (PATH_ID, LINKIDS(1), 1, DIRECTS(1));
    FOR i IN 1..Linkids.last loop
    IF (L_startIDs(i) = Prev_STN) THEN
    DIRECTS(i) := 1;
    ELSE
    IF (Prev_dir = 0) THEN
    DIRECTS(i) := 0;
    ELSE
    IF (L_STARTIDS(i) = L_ENDIDs(i-1)) THEN
    DIRECTS(i) := 1;
    ELSE
    DIRECTS(i) := 0;
    END IF;
    END IF;
    END IF;
    Prev_stN := L_STARTIDS(i);
    Prev_dir := DIRECTS(i);
    pl_DIR_TAB(i) := LINK_DIR_TYPE (PATH_ID, LINKIDS(i), i, DIRECTS(i));
    END LOOP;
    RETURN pl_DIR_TAB;
    END;
    4.USE IN SQL:
    ============================================
    select t.path_id, t.link_id, t.seq_no, t.direct
    from
    table(GET_PLINK_DIRECTION(network_name, path_id)) t
    Maybe this can be of use
    Luc

  • Convert LAT/LONG to X/Y

    Hello all,
    i've searched this forum to see how I can convert LAT/LONG values to XY coordinates.
    I've found this:
    SELECT
    sdo_geometry(2001, 8307, null, sdo_elem_info_array(1, 1003, 1),
    sdo_ordinate_array(52.849497, 5.723975, 52.883151, 5.999025))
    FROM DUAL
    I thought that when i executed this query, i'd see 2 values. But i was wrong.
    Is there a function that will return the XY when I give the LAT/LONG values ???

    You geometry does not validate (sdo_geom.validate_geometry(...) ,gtype and etype don't match!). You used a gtype 2001 (point) but in your elem_info_array (etype 1003) is an exterior polygonal ring. You need to fix your geometry first.
    When you said you want to converting lat/long to X/Y did you mean to convert a lat/long to a point (x,Y) in a projected coordinate system? If so, you can convert the geodetic geometry to a projected geometry(sdo_cs.transform), then use the SDO_UTIL.GETVERTICES function to retrieve all points in their order.
    From oracle spatial manual :
    SDO_CS.TRANSFORM(
    geom IN MDSYS.SDO_GEOMETRY,
    to_srid IN NUMBER
    ) RETURN MDSYS.SDO_GEOMETRY;
    SDO_UTIL.GETVERTICES
    Format
    SDO_UTIL.GETVERTICES(
    geometry IN SDO_GEOMETRY
    ) RETURN VERTEX_SET_TYPE;
    Description
    Returns the coordinates of the vertices of the input geometry.
    Parameters
    geometry
    Geometry for which to return the coordinates of the vertices.
    Usage Notes
    This function returns an object of VERTEX_SET_TYPE, which consists of a table of objects of VERTEX_TYPE. Oracle Spatial defines the type VERTEX_SET_TYPE as:
    CREATE TYPE vertex_set_type as TABLE OF vertex_type;
    Oracle Spatial defines the object type VERTEX_TYPE as:
    CREATE TYPE vertex_type AS OBJECT
    (x NUMBER,
    y NUMBER,
    z NUMBER,
    w NUMBER,
    id NUMBER);
    This function can be useful in finding a vertex that is causing a geometry to be invalid. For example, if you have identified a geometry as invalid by using the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function or the SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT procedure (both of which are documented in Chapter 15), you can use the GETVERTICES function to view the vertices in tabular format.
    Examples
    The following example returns the X and Y coordinates and ID values of the vertices of the geometries in the SHAPE column of the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.)
    SELECT c.mkt_id, c.name, t.X, t.Y, t.id
    FROM cola_markets c,
    TABLE(SDO_UTIL.GETVERTICES(c.shape)) t
    ORDER BY c.mkt_id, t.id;
    MKT_ID NAME X Y ID
    1 cola_a 1 1 1
    1 cola_a 5 7 2
    2 cola_b 5 1 1
    2 cola_b 8 1 2
    2 cola_b 8 6 3
    2 cola_b 5 7 4
    2 cola_b 5 1 5
    3 cola_c 3 3 1
    3 cola_c 6 3 2
    3 cola_c 6 5 3
    3 cola_c 4 5 4
    3 cola_c 3 3 5
    4 cola_d 8 7 1
    4 cola_d 10 9 2
    4 cola_d 8 11 3
    15 rows selected.

  • How to create a 3D LINESTRING?

    Hello
    Our users a working in AutoDesk Map, which is configured for Oracle Spatial.In the current requirement, the user creates a new plot (polygon) and assign its number as attribute...
    I need to write a trigger in such a way that when ever a user creates any plot and gives its number, the trigger will store the plot number as a text record in a separate table..
    Now AutoCad stores Text as a LINE feature in Oracle Spatial. So now i am querying centroid of the new plot and then dynamically creating 2 points to store this value...
    In order to achieve this i am creating a LINESTRING and then passing the line string in MDSYS.SDO_UTIL.FROM_WKTGEOMETRY() function...but i am getting an error message ....stating that the spatial dimensions are different..I later found that the LINESTRING is generating a 2 Dimensional data(2002), where as AutoCad creates and register table as a 3 dimensional data(3002)...
    How can i create a 3 Dimensional WKT LINESTRING and pass it in MDSYS.SDO_UTIL.FROM_WKTGEOMETRY() to create a spatial object dynamically?
    Regards
    Sunny

    Hi
    Thanks for bothering to contact me.
    I had a couple of images that show the sort of thing I want to do but I don't see an attach faciity here. I've written a lot of eBooks and I'd like to sell them but I think I'll do better if the cover looks good.
    I do have something that does what I call a pretend cover as can be seen on one of my sites http://healthy-living-store.com at the bottom of the page but it's not a professional finish.
    There is a product that somehow fits into Photoshop but I don't really want to spend money when I already have a programme that supposedly does the job. Here's the site. http://coveractionpro.com/
    I hope you can help me.
    Thanks again
    Peter

  • Fixing Geometry Errors

    Has anyone put together a list of "x error can be fixed by doing y" for geometry errors?
    I ask this because I am in the middle of writting code to fix geometry errors within a database from imported ESRI-based data. Presently I have the code to find all errors, and can fix:
    13349 and 13366
    Fix with a self union (same geometry twice): SDO_GEOM.SDO_UNION
    13356
    Fix with the new SDO_UTIL.REMOVE_DUPLICATE_VERTICES function.
    I started with these, since they are most pervasive.
    Obviously, some errors like 13351 and 13350 are harder, since the code actually needs to slightly alter the original data (move the rings or touching points) to remove the errors.

    Bryan,
    I have a ShapeCheck routine in PL/SQL that I have deployed in the past databases as a dbms_job...
    I have a number of versions depending on how you want the errors to be reported: one via SMTP_UTL for emailing, another writes answers to a table for visualisation with Application Express.
    If you want a copy email me at simon at spatialdbadvisor dot com
    Or.... here it is...
    DEFINE defaultSchema='&1'
    set serverout on SIZE 1000000
    DROP PROCEDURE ShapeCheck;
    DROP TABLE ALL_FEATURE_ERROR;
    CREATE TABLE ALL_FEATURE_ERROR (
    owner VARCHAR2(30),
    table_name VARCHAR2(30),
    column_name VARCHAR2(30),
    feature_rowid VARCHAR2(20),
    error_code VARCHAR2(10),
    error_status CHAR(1),
    error_context VARCHAR2(2000),
    error_date DATE
    grant insert,update,delete,select on all_feature_error to public;
    CREATE PROCEDURE ShapeCheck( p_schema IN VARCHAR2,
    p_tableName IN VARCHAR2,
    p_shapeName IN VARCHAR2,
    p_whereClause IN VARCHAR2)
    AUTHID CURRENT_USER
    IS
    v_shape MDSYS.SDO_GEOMETRY;
    c_shape MDSYS.SDO_GEOMETRY;
    v_OwnerName VARCHAR2(30);
    v_TableName VARCHAR2(30);
    v_ColumnName VARCHAR2(30);
    c_rowid ROWID;
    v_error_code ALL_FEATURE_ERROR.ERROR_CODE%TYPE;
    v_error_status ALL_FEATURE_ERROR.ERROR_STATUS%TYPE;
    v_error_context ALL_FEATURE_ERROR.ERROR_CONTEXT%TYPE;
    v_error_count number;
    v_error_found number;
    v_fixed_count number;
    v_count number;
    v_diminfo MDSYS.SDO_DIM_ARRAY;
    v_start_date DATE;
    v_end_date DATE;
    v_tolerance number;
    v_query varchar2(1024);
    TYPE shapeCursorType IS REF CURSOR;
    shapeCursor shapeCursorType;
    BEGIN
    v_TableName := UPPER(p_tablename);
    v_OwnerName := UPPER(p_schema);
    v_ColumnName := UPPER(p_ShapeName);
    BEGIN -- In case get NO_DATA_FOUND
    SELECT diminfo
    INTO v_diminfo
    FROM ALL_SDO_GEOM_METADATA
    WHERE owner = v_OwnerName and table_name = v_TableName and column_name = v_ColumnName;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    dbms_output.put_line('No diminfo found in all_sdo_geom_metadata for '||v_OwnerName||'.'||v_TableName||'.'||v_ColumnName);
    RETURN;
    END;
    v_tolerance := v_diminfo(1).sdo_tolerance;
    v_count := 0;
    v_error_count := 0;
    v_fixed_count := 0;
    IF ( p_whereClause is not null ) THEN
    v_query := 'SELECT ROWID,' ||v_ColumnName|| ' FROM ' ||v_OwnerName|| '.' ||v_TableName|| ' WHERE ' ||p_whereClause;
    ELSE
    v_query := 'SELECT ROWID,' ||v_ColumnName|| ' FROM ' ||v_OwnerName|| '.' ||v_TableName;
    END IF;
    v_start_date := SYSDATE;
    OPEN shapeCursor
    FOR v_query;
    LOOP
    FETCH shapeCursor INTO c_rowid, c_shape;
    EXIT WHEN shapeCursor%NOTFOUND;
    IF ( c_shape IS NULL ) THEN
    v_error_code := 'NULL';
    ELSE
    v_error_code := SUBSTR(MDSYS.SDO_GEOM.VALIDATE_GEOMETRY( c_shape, v_diminfo ),1,5);
    END IF;
    IF ( v_error_code <> 'TRUE' ) THEN
    v_error_count := v_error_count + 1;
    v_error_status := 'E'; -- if exception raised in following block this will remain 'E'
    IF ( v_error_code <> 'NULL' ) THEN
    BEGIN -- Exception block in case any of the functions trying to fix the shape fail...
    IF ( v_error_code = '13356' ) THEN
    v_shape := mdsys.sdo_util.remove_duplicate_vertices(c_shape,v_tolerance);
    ELSIF c_shape.sdo_gtype in (2003,3007) THEN -- only try to fix bad polygons
    v_shape := mdsys.sdo_geom.sdo_union(c_shape,v_diminfo,c_shape,v_diminfo);
    IF ( v_shape.sdo_gtype = 2004 ) THEN
    v_shape := &&defaultSchema..geom.ExtractPolygon(v_shape);
    END IF;
    END IF;
    -- Update shape to reflect whatever happened...
    EXECUTE IMMEDIATE 'UPDATE ' || v_OwnerName||'.'||v_TableName || ' A SET A.'||v_ColumnName||' = :1 WHERE rowid = :2 '
    USING v_shape,c_rowid;
    -- Check whether it was corrected or not...
    v_error_context := SUBSTR(MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(v_shape,v_diminfo),1,2000);
    v_error_code := SUBSTR(v_error_context,1,5);
    v_error_context := SUBSTR(v_error_context,6,2000);
    IF v_error_code = 'TRUE' THEN
    v_error_status := 'F';
    v_fixed_count := v_fixed_count + 1;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    NULL;
    END;
    END IF; -- v_error_code = NULL
    INSERT INTO &&defaultSchema..All_Feature_Error(owner,table_name,column_name,feature_rowid,error_code,error_status,error_context,error_date) VALUES (v_OwnerName,v_TableName,v_ColumnName,c_rowid,v_error_code,v_error_status,v_error_context,SYSDATE);
    END IF;
    END LOOP;
    v_count := shapeCursor%ROWCOUNT;
    CLOSE shapeCursor;
    v_end_date := SYSDATE;
    dbms_output.put_line('SHAPECHECK SUMMARY.');
    dbms_output.put_line(' TABLE: ' || v_OwnerName||'.'||v_TableName||'.'||v_ColumnName);
    dbms_output.put_line(' PROCESSING START: ' || to_char(v_start_date,'YYYY-MM-DD HH24:MM') );
    dbms_output.put_line(' PROCESSING END: ' || to_char(v_end_date,'YYYY-MM-DD HH24:MM') );
    dbms_output.put_line('FEATURES PROCESSED: ' || to_char(v_count) );
    dbms_output.put_line('TOTAL ERRORS FOUND: ' || to_char(v_error_count) );
    dbms_output.put_line('TOTAL ERRORS FIXED: ' || to_char(v_fixed_count) );
    dbms_output.put_line('See table ALL_FEATURE_ERROR for list of errors');
    END ShapeCheck;
    show errors
    grant execute on &&defaultSchema..ShapeCheck to public;
    -- connect radtrain4@radtrain4@sdb1test
    -- execute &&defaultSchema..shapecheck('RADTRAIN4','AB_LANDCLAIM','GEOMETRY',NULL);
    -- VARIABLE jobno number;
    -- BEGIN
    -- DBMS_JOB.SUBMIT(:jobno,'&&defaultSchema..shapecheck(''RADTRAIN4'',''SP_PARCEL'',''GEOMETRY'',NULL)'',''[email protected],[email protected]'' );',SYSDATE,'next_day(sysdate,''SUNDAY'')' );
    -- COMMIT;
    -- END;
    --

  • Spatial license for oracle.spatial.util classes ?

    Who knows if a spatial license is needed in order to use the oracle.spatial.util.* classes?

    You can use ST_GEOMETRY as part of Locator.
    But you might be better off using sdo_util.from_wktgeometry() function.
    Or these two constructor functions of SDO_GEOMETRY:
    METHOD
    FINAL CONSTRUCTOR FUNCTION SDO_GEOMETRY RETURNS SELF AS RESULT
    Argument Name Type In/Out Default?
    WKT CLOB IN
    SRID NUMBER IN DEFAULT
    METHOD
    FINAL CONSTRUCTOR FUNCTION SDO_GEOMETRY RETURNS SELF AS RESULT
    Argument Name Type In/Out Default?
    WKT VARCHAR2 IN
    SRID NUMBER IN DEFAULT
    siva

  • Using SDO_UTIL.GETVERTICES() together with functions

    Hi again
    I'm having a problem here in my spatial database I trying to use the function
    TABLE(SDO_UTIL.GETVERTICES(c.shape)) in order to get the coordinates of shapes. But I need to first extract data from spatial functions like the centroid function. How do I get these 2 functions to work together.
    thanks very much
    Thomaz

    Hi Thomaz,
    Maybe I missed your point, but what about the following:
    select t.y, t.x, t.id
    from your_geom_table,
    table(
    sdo_util.GETVERTICES(
    sdo_geom.sdo_centroid(geom, 0.005)
    ) t
    regards,
    Thomas

  • Errors in sdo_util on 12c

    I have installed spatial on an Oracle 12C database and I am receiving the error below when using sdo_util.to_wktgeometry. Some of the other sdo_util functions work as expected. I checked the class files and they are all valid. Has anyone else encountered this error.
    ORA-29531: no method structToWktJS in class oracle/spatial/util/Adapters
    ORA-06512: at "MDSYS.SDO_JAVA_STP", line 350
    ORA-06512: at "MDSYS.SDO_UTIL", line 2813
    ORA-06512: at "MDSYS.SDO_UTIL", line 2836
    29531. 00000 -  "no method %s in class %s"
    *Cause:    An attempt was made to execute a non-existent method in a
               Java class.
    *Action:   Adjust the call or create the specified method.

    I am not getting any error, as shown below, using a few excerpts from the online documentation.  Can you run the same or similar script without error?  Can you post a run of a test case that does produce the error for you?
    SCOTT@orcl12c> set long 2000;
    SCOTT@orcl12c> SELECT banner FROM v$version;
    BANNER
    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
    PL/SQL Release 12.1.0.1.0 - Production
    CORE    12.1.0.1.0    Production
    TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
    NLSRTL Version 12.1.0.1.0 - Production
    5 rows selected.
    SCOTT@orcl12c> CREATE TABLE cola_markets
      2    (mkt_id    NUMBER PRIMARY KEY,
      3      name    VARCHAR2(32),
      4      shape    SDO_GEOMETRY);
    Table created.
    SCOTT@orcl12c> INSERT INTO cola_markets VALUES
      2    (2, 'cola_b',
      3      SDO_GEOMETRY
      4        (2003, NULL, NULL,
      5         SDO_ELEM_INFO_ARRAY (1,1003,1),
      6         SDO_ORDINATE_ARRAY(5,1, 8,1, 8,6, 5,7, 5,1)));
    1 row created.
    SCOTT@orcl12c> INSERT INTO user_sdo_geom_metadata (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES
      2    ('cola_markets', 'shape',
      3      SDO_DIM_ARRAY
      4        (SDO_DIM_ELEMENT('X', 0, 20, 0.005),
      5         SDO_DIM_ELEMENT('Y', 0, 20, 0.005)),
      6      NULL);
    1 row created.
    SCOTT@orcl12c> CREATE INDEX cola_spatial_idx ON cola_markets(shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    Index created.
    SCOTT@orcl12c> SELECT SDO_UTIL.TO_WKTGEOMETRY (shape) FROM cola_markets WHERE name = 'cola_b';
    SDO_UTIL.TO_WKTGEOMETRY(SHAPE)
    POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0))
    1 row selected.

Maybe you are looking for