8 Replies Latest reply: Mar 11, 2013 4:35 PM by bkazar RSS

    Gml Transformation

    773927
      Hi,

      what's mean the parameters on the SDO_UTIL.TO_GML311GEOMETRY function:

      - GEOMETRY --ok
      - SRSNAMESPACE -- ?
      - SRSNALIAS -- ?

      I'am not found any documentation ...

      Thanks
        • 1. Re: Gml Transformation
          bkazar
          Hi,-
          Here is information from the Spatial User Guide:
          SDO_UTIL.TO_GML311GEOMETRY
          Format
          SDO_UTIL.TO_GML311GEOMETRY(
          thegeom IN SDO_GEOMETRY
          ) RETURN CLOB;
          Description
          Converts a Spatial geometry object to a geography markup language (GML version 3.1.1) fragment based on the geometry types defined in the Open GIS geometry.xsd schema document.
          Parameters
          thegeom
          Geometry for which to return the GML version 3.1.1 fragment.

          Two examples:
          -- 2D example
          SQL> select SDO_UTIL.TO_GML311GEOMETRY(sdo_geometry(2001, 8307,
               null, sdo_elem_info_array(1,1,1), sdo_ordinate_array(10, 10)))
               AS Gml311Geometry FROM DUAL;
          GML311GEOMETRY
          --------------------------------------------------------------------------------
          <gml:Point srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml">
          <gml:pos srsDimension="2">10.0 10.0 </gml:pos></gml:Point>
          
          -- 3D example where 4979 is the 3D equivalent SRID of 2D SRID 8307
          SQL> select SDO_UTIL.TO_GML311GEOMETRY(sdo_geometry(3001,4979,     
               null, sdo_elem_info_array(1,1,1), sdo_ordinate_array(10, 10, 10)))
               AS Gml311Geometry FROM DUAL;
          
          GML311GEOMETRY
          --------------------------------------------------------------------------------
          <gml:Point srsName="SDO:4979" xmlns:gml="http://www.opengis.net/gml">
          <gml:pos srsDimension="3">10.0 10.0 10.0 </gml:pos></gml:Point>
          You can have multi-solids having composite solids, collection geometry etc. which has
          different gtype geometries. Would you please tell us your query involving
          SDO_UTIL.TO_GML311GEOMETRY so that we can help you more?

          Thanks
          • 2. Re: Gml Transformation
            773927
            Thanks,

            mi query is :

            SELECT SDO_UTIL.TO_GML311GEOMETRY(GEOM) FROM C618_PREN_P WHERE CD = '.344' AND TD = 'P';
            result :

            +<gml:Polygon srsName="*SDO:32632*" xmlns:gml="http://www.opengis.net/gml">+
            +     <gml:exterior>+
            +     <gml:LinearRing>+
            +     <gml:posList srsDimension="2">700397.6083 5151576.2193 700 397.9837 5151587.4005 700381.9834 5151587.3284 700383.0373 5151573.2165 700397.3 54 5151573.5963 700397.6083 5151576.2193+
            +     </gml:posList>+
            +     </gml:LinearRing>+
            +     </gml:exterior>+
            +     <gml:interior>+
            +     <gml:LinearRing>+
            +     <gml:posList srsDimension="2">700392.9802 5 151576.0772 700385.997 5151576.242 700385.7804 5151584.0012 700392.8127 5151584.2172 700392.9802 5151576.0772+
            +     </gml:posList>+
            +     </gml:LinearRing>+
            +     </gml:interior>+
            +</gml:Polygon>+

            result from another application is (geoserver):

            +<gml:Polygon srsName="*urn:x-ogc:def:crs:EPSG:32632*" >+
            +     <gml:exterior>+
            +     <gml:LinearRing>+
            +     <gml:posList>700397.6083 5151576.2193 700 397.9837 5151587.4005 700381.9834 5151587.3284 700383.0373 5151573.2165 700397.3 54 5151573.5963 700397.6083 5151576.2193+
            +     </gml:posList>+
            +     </gml:LinearRing>+
            +     </gml:exterior>+
            +     <gml:interior>+
            +     <gml:LinearRing>+
            +     <gml:posList>700392.9802 5 151576.0772 700385.997 5151576.242 700385.7804 5151584.0012 700392.8127 5151584.2172 700392.9802 5151576.0772+
            +     </gml:posList>+
            +     </gml:LinearRing>+
            +     </gml:interior>+
            +</gml:Polygon>+

            Question : Can i have in spatial the same result with srsName:="urn:x-ogc:def:crs:EPSG:32632" and </gml:posList> without srsDimension="2", or i must parse the gml after the spatial gml result ?

            Thanks
            • 3. Re: Gml Transformation
              bkazar
              Hi,-
              This is possible by using the following signature:
              sdo_util.to_gml311geometry(Geometry IN MDSYS.SDO_GEOMETRY,
              srsNameSpace IN varchar2, srsNSAlias IN varchar2)

              Here, you need to register srsNameSpace with the srsNSAlias and srsName in the
              MDSYS.SrsNameSpace_Table before using sdo_util.to_gml311geometry function.

              We are preparing a small example for your case and will post here shortly.

              Here is the columns for the table for registration of srsName:
              SQL> desc  MDSYS.SrsNameSpace_Table
               Name                                      Null?    Type
               ----------------------------------------- -------- ----------------------------
               SRSNAMESPACE                              NOT NULL VARCHAR2(2000)
               SRSNAME                                   NOT NULL VARCHAR2(2000)
               SDO_SRID                                           NUMBER
              Hope that things are clear now.
              Thanks
              • 4. Re: Gml Transformation
                bkazar
                Hi,-
                Here is the useage of the signature to_gml311geometry(Geometry IN MDSYS.SDO_GEOMETRY, srsNameSpace IN varchar2, srsNSAlias IN varchar2):
                delete from MDSYS.SrsNameSpace_Table where sdo_srid=32632;
                
                INSERT INTO MDSYS.SrsNameSpace_Table values (
                  'urn:x-ogc:def:crs:EPSG',
                  'x-ogc:def:crs:EPSG:32632',
                   32632
                );
                
                set long 2000;
                set serveroutput on;
                
                -- to_gml311geometry(Geometry IN MDSYS.SDO_GEOMETRY)
                select sdo_util.to_gml311geometry( mdsys.sdo_geometry(2003, 32632, null,
                mdsys.sdo_elem_info_array(1,1003,1, 11, 2003, 1),
                mdsys.sdo_ordinate_array(1,1, 2,1, 2,2, 1,2, 1,1,
                1.5,1.5, 1.5,1.7, 1.7,1.7, 1.7,1.5, 1.5,1.5))
                ) as GMLGEOMETRY from dual ;
                
                -- to_gml311geometry(Geometry IN MDSYS.SDO_GEOMETRY, srsNameSpace IN varchar2, srsNSAlias IN varchar2)
                select sdo_util.to_gml311geometry( mdsys.sdo_geometry(2003, 32632, null,
                mdsys.sdo_elem_info_array(1,1003,1, 11, 2003, 1),
                mdsys.sdo_ordinate_array( 1,1, 2,1, 2,2, 1,2, 1,1,
                1.5,1.5, 1.5,1.7, 1.7,1.7, 1.7,1.5, 1.5,1.5)),
                'urn:x-ogc:def:crs:EPSG', 'urn') as GMLGEOMETRY from dual ;
                These two queries above produce the following results respectively:
                GMLGEOMETRY
                --------------------------------------------------------------------------------
                <gml:Polygon srsName="SDO:32632" xmlns:gml="http://www.opengis.net/gml">
                <gml:exterior><gml:LinearRing><gml:posList srsDimension="2">
                1.0 1.0 2.0 1.0 2.0 2.0 1.0 2.0 1.0 1.0 </gml:posList></gml:LinearRing>
                </gml:exterior><gml:interior>
                <gml:LinearRing><gml:posList srsDimension="2">
                1.5 1.5 1.5 1.7 1.7 1.7 1.7 1.5 1.5 1.5 
                </gml:posList></gml:LinearRing></gml:interior></gml:Polygon>
                
                <gml:Polygon srsName='urn:x-ogc:def:crs:EPSG:32632' xmlns:gml="http://www.opengis.net/gml" 
                xmlns:urn="urn:x-ogc:def:crs:EPSG" ><gml:exterior><gml:LinearRing>
                <gml:posList srsDimension="2">1.0 1.0 2.0 1.0 2.0 2.0 1.0 2.0 1.0 1.0 </gml:posList>
                </gml:LinearRing></gml:exterior><gml:interior><gml:LinearRing>
                <gml:posList srsDimension="2">1.5 1.5 1.5 1.7 1.7 1.7 1.7 1.5 1.5 1.5 </gml:posList>
                </gml:LinearRing></gml:interior></gml:Polygon>
                You will still have srsDimension and you will need to parse and get rid of that in Java or PL/SQL.
                Same story applies for xmlns:urn. But, you have the desired srsName with this signature.

                Please let us know if you have further questions.
                Thanks
                • 5. Re: Gml Transformation
                  773927
                  Hi,
                  thanks it's works ....
                  • 6. Re: Gml Transformation
                    user6479601
                    Hi,

                    These suggestions were helpful, thanks. My solution includes them in the following way :

                    INSERT INTO MDSYS.SrsNameSpace_Table values (
                    'urn',
                    'ogc:def:crs:EPSG::28992',
                    28992
                    );


                    GML :

                    '<Polygon xmlns="http://www.opengis.net/gml" srsName="urn:ogc:def:crs:EPSG::28992">
                    <exterior>
                    <LinearRing>
                    <posList srsDimension="2" count="10">186562.139 450000.0 186559.383 450001.384 186556.625 450002.767 186555.963 450000.0 186554.604 449994.95 186561.092 449994.602 186667.806 449982.439 186668.499 449984.969 186669.401 449988.263 186562.139 450000.0</posList>
                    </LinearRing>
                    </exterior>
                    </Polygon>'


                    Then write SQL like :

                    select SDO_UTIL.FROM_GML311GEOMETRY(<GML>, 'urn') geom
                    from dual
                    • 7. Re: Gml Transformation
                      user6479601
                      Unfortunately this solution will run into an ORA-01000 error (too many open cursors) when a call to sdo_util.from_GML311geometry that uses the solution is applied in a loop.
                      I worked around this by updating the gml before calling sdo_util.from_GML311geometry (change srsName="SDO:28992").
                      • 8. Re: Gml Transformation
                        bkazar
                        Thanks for the update, please let us know if you need more help.
                        Thanks