4 Replies Latest reply: Jan 26, 2009 4:42 AM by Simon Greener RSS

    sdo_geometry - sdo_gtype

    473423
      Hi, friends,

      In the sdo_geometry, what kind of problem I would have, if in sdo_gtype of the sdo_geometry, instead of 2003, the sdo_gtype=3, for example,

      SDO_GEOMETRY( 2003 , NULL, NULL,
      SDO_ELEM_INFO_ARRAY(1,1003,3),
      SDO_ORDINATE_ARRAY(4,6, 8,8))

      I have
      SDO_GEOMETRY( 3 , NULL, NULL,
      SDO_ELEM_INFO_ARRAY(1,1003,3),
      SDO_ORDINATE_ARRAY(4,6, 8,8))

      thanks
      Olga
        • 1. Re: sdo_geometry - sdo_gtype
          Luc Van Linden
          Olga


          From user manual section: 2.2.1 SDO_GTYPE

          http://download.oracle.com/docs/html/B14255_01/sdo_objrelschema.htm#sthref208


          Note:
          The 1-digit SDO_GTYPE values from before release 8.1.6 value are still supported. If a 1-digit value is used, however, Oracle Spatial determines the number of dimensions from the DIMINFO column of the metadata views, described in Section 2.6.3.

          Also, if 1-digit SDO_GTYPE values are converted to 4-digit values, any SDO_ETYPE values that end in 3 or 5 in the SDO_ELEM_INFO array (described in Section 2.2.4) must also be converted.


          Also:

          from section 2.2.4 SDO_ELEM_INFO

          You cannot mix 1-digit and 4-digit SDO_ETYPE values in a single geometry. If you use 4-digit SDO_ETYPE values, you must use 4-digit SDO_GTYPE values.

          this means your second exmaple is not following the guideline!

          Best is to use the 4 digit code.


          hope this helps

          Luc

          Edited by: lucvanlinden on Jan 23, 2009 2:09 PM
          • 2. Re: sdo_geometry - sdo_gtype
            473423
            Hi, Luc,
            thank you for the answer.

            your answer was very helpful,
            thank you again.

            hugs,
            Olga
            • 3. Re: sdo_geometry - sdo_gtype
              473423
              Hi, Luc,
              thank you for the answer.

              your answer was very helpful,
              thank you again.

              hugs,
              Olga
              • 4. Re: sdo_geometry - sdo_gtype
                Simon Greener
                If you have a lot of geometries with a single sdo_gtype value in a table you can convert them using SDO_MIGRATE.TO_CURRENT() as follows:
                SELECT SDO_MIGRATE.TO_CURRENT( SDO_GEOMETRY( 3 , NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)), 
                                               SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X',0,10,0.05),
                                                             SDO_DIM_ELEMENT('Y',0,10,0.05))
                                             ) as geom
                  FROM DUAL;
                
                GEOM
                --------------------------------------------------------------------------------------------------------------------
                MDSYS.SDO_GEOMETRY(2003,null,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(4,6,8,6,8,8,4,8,4,6))
                
                1 rows selected
                Note, however, that it converted your 1003,3 to a 5 vertex 1003,1. If you don't want this, just change the sdo_gtype directly.
                SELECT SDO_GEOMETRY( a.geom.sdo_gtype + 2000, a.geom.sdo_srid, a.geom.sdo_point, a.geom.SDO_ELEM_INFO, a.geom.SDO_ORDINATES) as geom
                  FROM (SELECT SDO_GEOMETRY( 3 , NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)) as geom
                          FROM DUAL) a;
                
                GEOM
                --------------------------------------------------------------------------------------------------------
                MDSYS.SDO_GEOMETRY(2003,null,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),MDSYS.SDO_ORDINATE_ARRAY(4,6,8,8))
                
                1 rows selected
                Hope this additional information helps.

                regards
                Simon