Go to content Go to navigation and search


Current Oracle Spatial Blog Articles

    Using Oracle's ST_GEOMETRY type hierarchy with SDO_GEOMETRY: ST_PointN and ST_NumPoints
    Making Sdo Geometry Metadata
    SC4O Test log
    The Frontage Problem: Creating references from land parcel street frontage boundary to point in street
    Scheduling the Export of Spatial Data in Oracle to a Shapefile each night
    Oracle CENTROID package update
    Book: "Applying And Extending Oracle Spatial"
    Create Polygons and Linestrings From Bearings And Distances (COGO)
    Simple Implementation Of Travelling Salesman Problem
    ST_Densify for Object PLSQL
    PLSQL ST_AsEWKT and ST_FromWKT Functions For Oracle (any version)
    Useful Package of Wrapper Functions for Sdo_Util.AffineTransforms
    GeoRaptor 4.x Update 2 (Project has Stalled)
    Tip: Drop that Spatial Index!
    Convert Single Geometry to Multi-part Geometry in Oracle Spatial
    Optimized Rectangle to 5 Point Polygon
    Centroid Package now supports Y ordinate seeding
    Convert GeoJSON document to Sdo_Geometry objects
    Function That Returns a Compass Point From a Whole Circle Bearing
    Playing around with Centroids by using different seed values
    Simple Oracle C Sprintf or Java String.format
    Some Oriented Point Functions
    Extracting Inner Rings Changed Ordinate Ordering: A Trap For Players Who Don't Read Documentation!
    PLS-00306: wrong number or types of arguments in call to 'SDO_GEOMETRY'
    Converting Google Earth Formatted Longitude/Latitude points to decimal degrees
    Oracle Business Intelligence Warehousing and Analytics - Spatial Summit
    How far inside, is inside? Measuring actual distance.
    Noding and building a polygon from single, overlapping linestrings
    Analyzing Spatial Query Performance Improvements in Oracle Spatial and Graph 12c Through Cross-Vendor Comparison
    ST_VertexN / ST_PointN - Extracting a specific point from any geometry
    Convert Single Point stored in SDO_ORDINATES to SDO_POINT_TYPE
    Aggregate APPEND Islands and XOR polygons
    Circular Arcs in Geodetic Polygons
    Some SDO_GEOMETRY/DIMINFO handling functions
    Changing all DIMINFO sdo_tolerance values for all metadata records in one go.
    Building Polygons from Incomplete Linestrings using ST_PolygonBuilder
    Computing Cardinal Directions to nearby geometries
    Intersecting two aggregated polygon layers with SC4O
    Spatial and Oracle 12c
    Update Triggers and SDO_GEOMETRY Equality
    Duplicate Geometry data and Data Models
    CENTROID package update
    How to calculate cumulative length of a linestring
    Compute Location from known Lat/Long point using delta easting and northing in miles
    Sorting SDO_GEOMETRY data using the ORDER BY clause of a SELECT statement
    Creating linestrings from points
    Rounding Coordinates or Ordinates in SDO_GEOMETRY
    Effects of Sdo_Geometry Ordinate Precision on Performance
    Effects of Sdo_Geometry Ordinate Precision on Storage
    The Spatial filtering of geometries: The effect of tolerances on relationships
    Application of Delaunay Triangulation and Inverse Distance Weighting (IDW) in Oracle for Soils Interpolation
    Selecting all SDO_GTYPE values for all tables/sdo_geometry columns in a schema
    CENTROID package - Tips for Use
    Announcing the Spatial Companion For Oracle (SC4O)
    Filtering Rings (Oracle Spatial)
    Splitting a polygon using one or more linestrings
    isValid, isSimple, Dimension and CoordDim methods for SDO_Geometry
    Line Merging or Collecting lines together: ST_LineMerger
    ST_DeleteVertex for Oracle SDO_Geometry based on Jaspa/JTS
    3D/4D and SRID aware Conversion functions for SDO_Geometry: WKT and EWKT
    Topological vs Non-Topological Simplification/Generalization of Aggregated Area Geometies in Oracle
    Filtering very short linestrings via bitmap function index
    CENTROID For Oracle
    Gridding a sdo_geometry line/polygon object (Oracle)
    Finding centre and radius of a circular geometry
    Constraining geometry type for sdo_geometry column in a table.
    CASE Statements and SDO_GEOMETRY
    The Power of Constraints and Indexes for Spatial Constraints: stopping duplicate points
    Replacement for SDO_GEOM.RELATE - ST_Relate based on JTS
    Changing Oracle Spatial Index Parameters on existing index
    Writing Excel Spreadsheets files from within the Oracle database using Java and PL/SQL
    Writing xSV (eg csv) files from within the Oracle database using Java and PL/SQL
    A simple spike finder for Spatial/Locator
    JTS Java class compilation for 11g and above
    Random Spatial Search Procedure
    Geometry Snapping using JTS in Oracle
    Exposing JTS's MinimumBoundingCircle functionality
    Exposing JTS's Densifier functionality
    Using JTS's Comparison Functions - HausdorffSimilarityMeasure & AreaSimilarityMeasure with SDO_GEOMETRY
    Free JTS-based Area/Length Functions
    Handy way of systematically fixing polygon geometries with 13349 and other errors
    Standalone CENTROID package now available for download
    Free Union, Intersection, Xor and Difference Functions for Oracle Locator - Part 4 Processing Geodetic data
    Configurable Buffer: JTS and Oracle
    Free Union, Intersection, Xor and Difference Functions for Oracle Locator - Part 3
    Free Union, Intersection, Xor and Difference Functions for Oracle Locator - Part 2
    Free Union, Intersection, Xor and Difference Functions for Oracle Locator - Part 1
    Building Lines into Polygons in Oracle Locator / Spatial
    Finding Intersection Points between Line and Polygon
    Free version of sdo_length
    Alternative to my SQL based GetNumRings function
    External Tables and SDO_Geometry data.
    layer_gtype keyword issue when indexing linear data on 11g
    String Tokenizer for Oracle
    Free Aggregate Method for Concatenating 2D Lines in Oracle Locator 10g
    Reducing 5 Vertex Polygon to Optimized Rectangle
    Square Buffer
    Converting decimal seconds to string
    Valid conversion unit values for Oracle sdo_geom.sdo_length()
    Removing Steps in Gridded Vector Data - SmoothGrid for Oracle
    Oracle Spatial DISJOINT search/filtering
    Creating SDO_Geometry from geometric data recorded in the columns of a table
    Concave Hull Geometries in Oracle 11gR2
    Projecting SDO_GEOM_METADATA DIMINFO XY ordinates
    Instantiating MDSYS.VERTEX_TYPE
    New PL/SQL Packages - Rotate oriented point
    GeoRaptor Development Team
    Fast Refreshing Materialized View Containing SDO_GEOMETRY and SDO_GEOM.SDO_AREA function
    Performance of PL/SQL Functions using SQL vs Pure Code
    Implementing the BEST VicGrid Projection in Oracle 10gR2
    ORA-13011 errors when using SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT()
    Extract Polygons from Compound Polygon
    Detecting sdo_geometries with compound (3-point Arcs) segments
    GEOMETRY_COLUMNS for Oracle Spatial
    Convert GML to SDO_Geometry in Oracle 10gR2
    Spatial Sorting of Data via Morton Key
    Swapping Ordinates in an SDO_GEOMETRY object
    New To_3D Function
    Extend (Reduce/Contract/Skrink) Function for Oracle
    Loading and Processing GPX 1.1 files using Oracle XMLDB
    Loading Spatial Data from an external CSV file in Oracle
    Calling the Oracle Spatial shapefile loader from within the Oracle database itself
    Implementing SDO_VertexUpdate/ST_VertexUpdate for Oracle
    Implementing SDO_RemovePoint/ST_RemovePoint for Oracle
    Implementing SDO_AddPoint/ST_AddPoint for Oracle
    ESRI ArcSDE Exverted and Inverted Polygons and Oracle Spatial
    Funky Fix Ordinates By Formula
    Implementing a SetPoint/ST_SetPoint function in Oracle
    Implementing an ST_SnapToGrid (PostGIS) function for Oracle Spatial
    Generating random point data
    Implementing an Affine/ST_Affine function for Oracle Spatial
    Implementing a Scale/ST_Scale function for Oracle Spatial
    Implementing a Parallel/ST_Parallel function for linestring data for Oracle Spatial
    Implementing a Rotate/ST_Rotate function for Oracle Spatial
    Limiting table list returned when connecting to Oracle Database using ODBC
    ST_Azimuth for Oracle: AKA Cogo.Bearing
    Implementing a Translate/ST_Translate/Move function for Oracle Spatial
    Elem_Info_Array Processing: An alternative to SDO_UTIL.GetNumRings and querying SDO_ELEM_INFO itself
    Minumum Bounding Rectangle (MBR) Object Type for Oracle
    How to extract elements from the result of an sdo_intersection of two polygons.
    How to restart a database after failed parameter change
    Fixing failed spatial indexes after import using data pump
    generate_series: an Oracle implementation in light of SQL Design Patterns
    Multi-Centroid Shootout
    Oracle Spatial Centroid Shootout
    On the use of ROLLUP in Oracle SELECT statements
    Surrounding Parcels
    Spatial Pipelining
    Using Oracle's SDO_NN Operator - Some examples
    Converting distances and units of measure in Oracle Locator
    Split Sdo_Geometry Linestring at a known point
    Forcing an Sdo_Geometry object to contain only points, lines or areas
    Unpacking USER_SDO_GEOM_METADATA's DIMINFO structure using SQL
    Generating multi-points from single point records in Oracle Spatial
    Object Tables of Sdo_Geometry
    Oracle Locator vs Oracle Spatial: A Reflection on Oracle Licensing of the SDO_GEOM Package
    FAST REFRESHing of Oracle Materialized Views containing Sdo_Geometry columns
    Australian MGA/AMG Zone Calculation from geographic (longitude/latitude) data
    Loading Shapefiles (SHP) into Oracle Spatial
    Oracle Spatial Mapping and Map Rendering Performance Tips
    The significance of sdo_lb/sdo_ub in USER_SDO_GEOM_METDATA: Do I need it?
    Oracle Spatial Forum - Melbourne April 2007
    Layer_GTypes for spatial indexes
    Oracle's SQL/MM Compliant Types
    Tips and Tricks



RSS / Atom

Email me


Creative Commons License
All Blog Articles, Data Models and Free Source Code by Simon Greener, The SpatialDB Advisor is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Implementing SDO_VertexUpdate/ST_VertexUpdate for Oracle

Tuesday February 17 2009 at 09:32

I have implemented an SDO_SetPoint/ST_SetPoint (PostGIS) function for Oracle. But in so doing I discovered the SE_VertexUpdate(geom ST_LineString,old ST_Point, new ST_Point) function that IBM has implemented.

The interesting difference is that the ST_SetPoint function requires you to supply the original geometry, the new point value and the position of the point in the existing geometry that you want to update: the VertexUpdate version simply requires you to provide the before and after point values.

The problem with the PostGIS approach is apparent and explains why PostGIS has only implemented the function for LineString geometries. The reaons is that if you want to update a polygon geometry and can only supply a single point position, you can end up with a polygon that has its start and end points with different values. An example from my article shows this:

-- How to set the first and last points in a single outer shelled compound polygon polygon
select Geom.SDO_SetPoint(
          1) as setGeom
  from dual;


1 rows selected

Note that you have to call the function twice AND know the position of the first and last coordinate.

The alternate approach, implemented in the IBM function, is to provide actual values of the existing point and its replacement and to replace all possible old values with new values wherever they occur.

My coding of such a function for Oracle is as follows.

First, the declarations:

  /** ----------------------------------------------------------------------------------------
  * function   : SDO_VertexUpdate
  * precis     : Replace all points of geometry with new point where they match (including Z and M)
  * version    : 1.0
  * usage      : FUNCTION SDO_VertexUpdate(p_geometry in mdsys.sdo_geometry,
  *                                         p_old_point in mdsys.vertex_type,
  *                                         p_new_point in mdsys.vertex_type )
  *                 RETURN mdsys.sdo_geometry DETERMINISTIC;
  * param      : p_geometry  : Original geometry object
  * paramtype  : p_geometry  : mdsys.sdo_geometry
  * param      : p_old_point : Actual point coordinates of an existing point
  * paramtype  : p_old_point : mdsys.vertex_type
  * param      : p_new_point : Actual point coordinates of replacement point
  * paramtype  : p_new_point : mdsys.vertex_type
  * return     : input geometry with changed point.
  * returnType : mdsys.sdo_geometry
  * history    : Simon Greener - February 2009 - Original coding.
  * copyright  : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. (http://creativecommons.org/licenses/by-sa/2.5/au/)
  Function SDO_VertexUpdate(p_geometry  IN MDSYS.SDO_Geometry,
                            p_old_point IN MDSYS.Vertex_Type,
                            p_new_point IN MDSYS.Vertex_Type)
    Return MDSYS.SDO_Geometry Deterministic;

  /* ST_* Wrapper */
  Function ST_VertexUpdate(p_geometry  IN MDSYS.ST_Geometry,
                           p_old_point IN MDSYS.ST_Point,
                           p_new_point IN MDSYS.ST_Point)
    Return MDSYS.ST_Geometry Deterministic;

And the body:

  Function SDO_VertexUpdate(p_geometry  IN MDSYS.SDO_Geometry,
                            p_old_point IN MDSYS.Vertex_Type,
                            p_new_point IN MDSYS.Vertex_Type)
    Return MDSYS.SDO_Geometry
    v_ordinates       MDSYS.SDO_Ordinate_Array;
    v_dims            Number;
    v_gtype           PLS_Integer;
    v_sdo_point       Mdsys.SDO_Point_Type;
    v_measure_posn    Number;
    If ( p_geometry is NULL ) Then
      raise NULL_GEOMETRY;
    End If;
    If ( p_old_point is null or 
        p_new_point is null ) Then
    End If;

    v_dims  := TRUNC(p_geometry.sdo_gtype/1000,0);
    v_gtype := Mod(p_geometry.sdo_gtype,10);
    v_measure_posn := MOD(trunc(p_geometry.sdo_gtype/100),10);
    v_sdo_point := p_geometry.sdo_point;
    v_ordinates := p_geometry.sdo_ordinates;
    -- If sdo_geometry is a single point coded in sdo_point, then update it
    If ( p_geometry.sdo_point is not null ) Then
      If ( ( p_old_point.x = v_sdo_point.x 
             ( v_sdo_point.x is null And p_old_point.x is null )
           ( p_old_point.y = v_sdo_point.y 
             ( v_sdo_point.y is null And p_old_point.y is null )
            )           and
           ( v_Dims = 2
             ( v_Dims = 3 
               ( p_old_point.z = v_sdo_point.z 
                 ( v_sdo_point.z is null And p_old_point.z is null )
         ) Then
        v_sdo_point.X := p_new_point.X;
        v_sdo_point.Y := p_new_point.Y;
        v_sdo_point.Z := p_new_point.Z;
      End If;
    End If;
    If ( v_ordinates is not null ) Then
      -- Update the point in the ordinate array
      SELECT CASE e.rin
                  WHEN 1 THEN e.x
                  WHEN 2 THEN e.y
                  WHEN 3 THEN CASE v_measure_posn
                                   WHEN 0 THEN e.z 
                                   WHEN 3 THEN e.w
                  WHEN 4 THEN e.w
              END as ord
       BULK COLLECT INTO v_ordinates
      FROM (SELECT d.cin, a.rin, d.x, d.y, d.z, d.w
              FROM (SELECT LEVEL as rin
                      FROM DUAL
                    CONNECT BY LEVEL <= v_dims) a,
                   (SELECT cin,
                           case when xm = 1 and ym = 1 
                                 and ( zexists = 0 or (zm = 1 and zexists = 1)) 
                                 and ( wexists = 0 or (wm = 1 and wexists = 1 ))
                                then p_new_point.x else c.x end as x,
                           case when xm = 1 and ym = 1 
                                 and ( zexists = 0 or (zm = 1 and zexists = 1)) 
                                 and ( wexists = 0 or (wm = 1 and wexists = 1 ))
                                then p_new_point.y else c.y end as y,
                           case when xm = 1 and ym = 1 
                                 and ( zexists = 0 or (zm = 1 and zexists = 1)) 
                                 and ( wexists = 0 or (wm = 1 and wexists = 1 ))
                                then p_new_point.z else c.z end as z,
                           case when xm = 1 and ym = 1 
                                 and ( zexists = 0 or (zm = 1 and zexists = 1)) 
                                 and ( wexists = 0 or (wm = 1 and wexists = 1 ))
                                then p_new_point.w else c.w end as w
                      FROM (SELECT rownum as cin,
                                   DECODE(b.x,p_old_point.x,1,0) as xm,
                                   DECODE(b.y,p_old_point.y,1,0) as ym,
                                   DECODE(b.z,p_old_point.z,1,0) as zm,
                                   DECODE(b.w,p_old_point.w,1,0) as wm,
                                   CASE WHEN (( v_dims >= 3 And (v_measure_posn <> 3) )                 ) THEN 1 ELSE 0 END as zexists,
                                   CASE WHEN (( v_dims  = 3 And (v_measure_posn  = 3) ) Or (v_dims = 4) ) THEN 1 ELSE 0 END as wexists
                              FROM (SELECT v.x,
                                           CASE WHEN v_measure_posn <> 3 /* If measured geometry and measure position is not 3 then Z is coded in this position */
                                                THEN v.z
                                                ELSE NULL
                                            END as z,
                                           CASE WHEN v_measure_posn = 3 /* If measured geometry and measure position is 3 then Z has been coded with W so move it */
                                                THEN v.z
                                                ELSE v.w
                                            END as w
                                      FROM TABLE(mdsys.sdo_util.GetVertices(p_geometry)) v
                                   ) b
                            ) c
                    ) d
             ) e
          order by e.cin, e.rin;
    End If;
    -- Return the updated geometry
    Return MDSYS.SDO_Geometry(p_geometry.sdo_gtype,

        RETURN p_geometry;
        raise_application_error(-20001,'p_point is null',true);
        RETURN p_geometry;
        raise_application_error(-20001,'invalid p_position value',true);
        RETURN p_geometry;
  End SDO_VertexUpdate;

  -- Replace point (p_position) of linestring with given point. Index is 1-based.
  Function ST_VertexUpdate(p_geometry   IN MDSYS.ST_Geometry,
                           p_old_point  IN MDSYS.ST_Point,
                           p_new_point  IN MDSYS.ST_Point )
    Return MDSYS.ST_Geometry
                                                            null, /*p_old_point.ST_Z(),*/
                                                            null, /*p_old_point.ST_M(),*/
                                                            null, /*p_new_point.ST_Z(),*/
                                                            null, /*p_new_point.ST_M(),*/
  End ST_VertexUpdate;

(At 10gR2 a point does not have Z and M values.)

Note that I continue to make extensive use of SQL in my functions. I find using SQL makes it easy to develop solutions in SQLPlus/SQL Developer and transfer into PL/SQL. It is most likely more efficient (in terms of processing resources) to manipulate the sdo_ordinate array directly in PL/SQL but the speed of development (and understanding to ordinary users) is most likely less than via straight SQL. I will investigate this aspect of algorithm development in a later article.

Now, let’s run through some examples.

-- Update 2D null point
select geom.SDO_VertexUpdate(mdsys.SDO_Geometry(2001,null,sdo_point_type(null,null,null),null,null),
                               ) as point
  from dual;


1 rows selected

-- Update 3D null point
select geom.SDO_VertexUpdate(mdsys.SDO_Geometry(2001,null,sdo_point_type(null,null,null),null,null),
                               ) as point
  from dual;


1 rows selected

-- Update 4D null point
select geom.SDO_VertexUpdate(mdsys.SDO_Geometry(4001,null,null,
                               ) as point
  from dual;


1 rows selected

-- Update first point 
select geom.SDO_VertexUpdate(mdsys.SDO_Geometry(2002,null,null,sdo_elem_info_array(1,2,1),
                               mdsys.vertex_type(29.8,29.9,99,null,1)) as point
  from dual;


1 rows selected

-- Update any point 
select geom.SDO_VertexUpdate(mdsys.SDO_Geometry(3002,null,null,sdo_elem_info_array(1,2,1),
                               mdsys.vertex_type(29.8,29.9,99,null,1)) as point
  from dual;


1 rows selected

-- Update last point 
select geom.SDO_VertexUpdate(mdsys.SDO_Geometry(2001,null,null,sdo_elem_info_array(1,2,1),
                               mdsys.vertex_type(29.8,29.9,99,null,1)) as point
  from dual;


1 rows selected

--Change first point in a OGC 2D single linestring 
SELECT GEOM.ST_VertexUpdate(a.linestring,a.old_point,a.new_point).Get_WKT() as st_geom
  FROM (SELECT mdsys.OGC_LineStringFromText('LINESTRING(1.12345 1.3445,2.43534 2.03998398,3.43513 3.451245)') as linestring,
               mdsys.OGC_PointFromText('POINT(3.43513 3.451245)') as old_point,
               mdsys.OGC_PointFromText('POINT(29.8 29.9)') as new_point
          FROM dual) a;

LINESTRING (1.12345 1.3445, 2.43534 2.03998398, 29.8 29.9)

1 rows selected

-- Update the last point in a simple polygon (note result is correct, as against SDO_SetPoint)
select Geom.SDO_VertexUpdate(b.the_geom,
                         mdsys.vertex_type(29,29,null,null,1)) as setGeom
  from (select sdo_geometry('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL) as the_geom
         from dual
       ) b;


1 rows selected

-- Update first point of complex polygon
select Geom.SDO_VertexUpdate(
                 mdsys.vertex_type(1,1,null,null,1)) as UpdateGeom
  from dual;


1 rows selected

-- MultiPolygon: Update first/last point in second geometry
select Geom.SDO_VertexUpdate(b.the_geom,
                         mdsys.vertex_type(21,21,null,null,1)).Get_WKT() as UpdateGeom
  from (select sdo_geometry('MULTIPOLYGON(((2 2, 2 7, 12 7, 12 2, 2 2)), ((20 20, 20 70, 120 70, 120 20, 20 20)) )',NULL) as the_geom
         from dual
       ) b;

MULTIPOLYGON (((2.0 2.0, 2.0 7.0, 12.0 7.0, 12.0 2.0, 2.0 2.0)), ((21.0 21.0, 20.0 70.0, 120.0 70.0, 120.0 20.0, 21.0 21.0)))

1 rows selected


I have to admin that, having implemented the PostGIS *_SetPoint functions and the IBM *_VertexUpdate functions, I think that the IBM versions are far better than the PostGIS ones because one does not have to worry about the complexity of start/end points for polygon geometry elements (inner and outer rings).

I hope this article is of use to someone.

Creative Commons License

post this at del.icio.uspost this at Diggpost this at Technoratipost this at Redditpost this at Farkpost this at Yahoo! my webpost this at Windows Livepost this at Google Bookmarkspost this to Twitter

Comment [6]


Interesting point about *_SetPoint vs. *_VertexUpdate, though I can see the benefit in both approaches.

I think in some cases such as when you have duplicate vertexes, you may only want to set one or remove one, not both. Then again as you said the simplicity of vertexupdate is nice and is the common case.

One other observation — though has nothing to do with this so much.

You use mdsys.OGC_LineStringFromText

I assume there is an

Is there a penalty in oracle with using the POintFromText, LineFromText vs GeomFromText.

I tend to avoid using those in PostGIS ans just stick with ST_GeomFromText because there is a noticable speed penalty with the added checking that those do over the ST_GeomFromText and also its just more fluff to remember.

Regina 17 February 2009, 18:02 #


I agree with your comments about *_SetPoint and *_VertexUpdate both having benefits. My last paragraph was written too quickly: I should have described the benefits of both as you succinctly do in your second paragraph. (I am a big believer in “both/and” solutions rather than “either/or”.)

With regards to your latter comments, the Oracle mdsys.OGC_* functions are there to return true points, linestrings and polygons (+ multi*) as the standard Oracle constructors associated with their subtype in the ST_Geometry type hierachy produce ST_Geometries and not ST_Points etc. Constructing proper ST_LineStrings etc is important if one wants to access type-specific methods eg ST_InteriorRingN() of ST_LineString.

Only the OGC_LineFromText() etc functions do this hence why I use them.

I will, however, have a look at the performance issues and report back.

Thanks for commenting.


Simon Greener 18 February 2009, 00:01 #

Interesting. So all Polygons, Lines and Points are not created the same.

Is there a reason why you would use ST_GeomFromText then to create a Polygon, Point etc except when stuffing in a collection?

I guess I’m so used to thinking in PostGIS terms where a Line is a Line regardless of which function you use to create it.

I should try this in SQL Server 2008. Hadn’t given it much thought.

Regina 19 February 2009, 09:07 #

Regina, It depends on the way you create the object. Oracle does not have an ST_GeomFromText() method. Here are some examples of how to create an ST_Polygon in Oracle and then access its methods.
select mdsys.st_geometry(sdo_geometry('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL)).st_numinteriorring() geom
  from dual;

Error starting at line 1 in command:
select mdsys.st_geometry(sdo_geometry('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL)).st_numinteriorring() geom
  from dual
Error at Command Line:1 Column:102
Error report:
SQL Error: ORA-00904: "MDSYS"."ST_GEOMETRY"."ST_NUMINTERIORRING": invalid identifier
00904. 00000 -  "%s: invalid identifier"

select a.geom.st_numinteriorring() as geom 
  from (select mdsys.st_geometry(sdo_geometry('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL)) geom
          from dual ) a;

Error starting at line 4 in command:
select a.geom.st_numinteriorring() as geom 
  from (select mdsys.st_geometry(sdo_geometry('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL)) geom
          from dual ) a
Error at Command Line:4 Column:7
Error report:
SQL Error: ORA-00904: "A"."GEOM"."ST_NUMINTERIORRING": invalid identifier
00904. 00000 -  "%s: invalid identifier"

select a.geom.st_numinteriorring() as geom 
  from (select mdsys.st_polygon(sdo_geometry('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL)) geom
          from dual ) a;


1 rows selected

select a.geom.st_numinteriorring() as geom 
  from (select mdsys.OGC_PolygonFromText('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL) geom
          from dual ) a;


1 rows selected

select mdsys.OGC_PolygonFromText('POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))',NULL).st_numinteriorring() geom
  from dual;


1 rows selected
Hope this helps. regards Simon

Simon Greener 19 February 2009, 09:46 #

i have to write a report about IBM primary function and i dnt knw what to write
can u gyz help me plz

Silent girl 6 November 2010, 12:28 #

I am not sure what you mean by an “IBM primary function” but the DB2 Spatial Extender version of my function is called ST_ChangePoint (related ones are ST_RemovePoint and ST_AppendPoint – there is no ST_InsertPoint)


Simon Greener 6 November 2010, 22:55 #