Current Oracle Spatial Blog Articles
• Some SDO_GEOMETRY/DIMINFO handling functions
• Applying And Extending Oracle Spatial - Book Released
• 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
• Useful Package of Wrapper Functions for Sdo_Util.AffineTransforms
• 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 (2002) from points (2001)
• 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
• SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT - 13356 Issues
• 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
• Making Sdo Geometry Metadata Update Generic Code
• 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
• Converting Google Earth Formatted Longitude/Latitude points to decimal degrees
• 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
This reflection has come about because of the many times I have gone to sites running Oracle Standard Edition (SE or SE1) that are, accidently, using some of the “geoprocessing” functions in the SDO_GEOM package that are licensed only for use with Enterprise Edition (EE). Oracle XE adds to this confusion as it is shipped with the complete SDO_GEOM package.
Where a restricted use exists for a certain SDO_GEOM package “geoprocessing” function, that restriction also applies to its related ST_* function in the SQL3/MM (or OGC) type library.
Oracle Locator is a cut down version of Oracle Spatial Standard Edition (SE/SE1) database installations.
From Appendix B of the Spatial User Guide we see:
Much confusion exists about what is licensed and what is not wrt Locator. What is actually licensed is clearly documented in Appendix B of the Spatial User guide. Because, this article concentrates on the SDO_GEOM package functions and procedures, we note that only those functions listed in Table B-1 are licensed. These are:
There is no confusion about the other, self-contained, packages as these are only installed for Enterprise Edition. These packages are:
1.2 Why confusion?
Why is there such confusion about the user of the SDO_GEOM function other than the three mentioned above in Standard Edition databases?
Simply put, when an SE database is created using Oracle’s DataBase Configuration Assistant (DBCA), all the functions and procedures in SDO_GEOM are installed: not just the actual three that are licensed for SE (see above). (The installer should be fixed to ensure that these are not installed.)
Coupled to this is the fact that very few day-to-day practitioners read the documentation and most certainly do not read or are a party to the license agreements negotiated and signed by management. Users simply connect to the installed software and start using it. When one of these users describes the SDO_GEOM package in SqlPlus (DESCRIBE MDSYS.SDO_GEOM) all SDO_GEOM functions are displayed: they therefore assume that use of these must be allowed. Finally, much/most commercial software used in the GIS world is keycoded to stop use of unlicensed components: that Oracle doesn’t do this is not widely known and contributes to the unintentional breaking of the license agreement.
1.3 A way out of this?
Is there a way out of this problem?
Well, certainly, users should try and familiarise themselves with the license and try and conform to it. After all, Oracle owns the software and has the right to set whatever terms they want with respect to the licensing and use of their software.
I personally have a view that some of the “geoprocessing” functions in the SDO_GEOM package are not “geoprocessing” functions at all but properties of a spatial object and should be free of license restrictions. Specifically:
With respect to the other functions, eg SDO_UNION, SDO_INTERSECTION etc, while these are “geoprocessing” functions they are a necessary part of the OGC and SQL3/MM standard for an implementation of a spatial type that that Oracle should allow their use within Locator for no additional charge. However, they have decided otherwise and I respect that decision: perhaps they could consider licensing these functions independently of other Enterprise Edition Spatial features (eg LRS etc)? Certainly, most of the Locator users I know would happily part with $1,000 per cpu to be able to use these functions.
However, until such a thing happens, I will now outline some of the common SDO_GEOM functions that are illegally used in Locator installations demonstrating how they can be replaced by SQL or functions that are licensed for use.
2. MBR Functions.
2.1 SDO_GEOM Functions.
The SDO_GEOM package contains the following functions:
The SDO_MBR SDO_MBR function returns an optimized rectangle SDO_GEOMETRY object:
To access the actual optimized rectangle ordinates one can do this:
To “flatten” this into a single row, one could use the Locator licensed SDO_UTIL package’s GetVertices function as follows:
Sensibly, however, most people simplify the SQL to access the lower left and upper right ordinates of the MBR optimized rectangle by using the provided MIN/MAX MBR functions as follows:
So how do we avoid the use of these licensed functions in Locator installations?
Firstly, one should note that the SDO_AGGR_MBR aggregate operator is licensed for use in Locator. The MBR functions in SDO_GEOM can be replaced with something that would conform to Oracle licensing in a trivial amount of time.
For example, the above SQL could be replaced by (a slightly different form of the SDO_MBR example above):
To return a single row we could do this:
Or we could do this:
(Note: there are many ways, in SQL, to “skin the cat”. I have deliberately done this in this article.)
Locator also includes the SDO_3GL package which is not mentioned in any of the licensing documents. One can conclude from this that the SDO_3GL package is not constrained by Locator license restrictions.
Investigating SDO_3GL we find that the package contains the following MBR procedure.
Note that this is a procedure not a function: it cannot be used in SQL SELECT statements. The only way we could use this would be via creating a set of functions that encapsulate this procedure and return the relevant elements. I will not do this here as these functions are relatively simple to write and I have already encapsulated them in an MBR object which is included in my free PL/SQL packages I will demonstrate their use in Section 2.3.3 below.
The SDO_3GL package also contains the MBR_GEOMETRY function whose signature is:
FUNCTION MBR_GEOMETRY RETURNS SDO_GEOMETRY Argument Name Type In/Out Default? ——————————————— ———————————- ——— ———— GEOM SDO_GEOMETRY IN DIM SDO_DIM_ARRAY IN
This can be used to return the extent of a feature as follows:
2.3.3 MBR package.
The above query using my MBR package would be:
The MBR package only uses SDO_3GL.EXTENT_OF_OBJECT procedure and so does not break Standard Edition license restrictions. The MDSYS dependencies of the MBR package can be ascertained as follows:
In more detail (connected as CODESYS):
But what about SDO_GEOM? Using:
No SDO_GEOM package functions are being used by my MBR package.
Now, the SDO_GEOM.SDO_CENTROID function is an Enterprise feature. The SDO_GEOM.SDO_CENTROID function computes a mathematically weighted centroid that does not necessarily fall within a polygon as in the following example:
This function is called as follows:
But what if you don’t have an Enterprise license?
You have two other options for generating a centroid from geometry data using Standard Edition functions.
Firstly, you could use my GEOM package’s sdo_centroid function. This is a powerful function that is different from Oracle’s SDO_GEOM.SDO_CENTROID function in that it guarantees that a centroid will fall within a polygon and not outside it (a “para-centroid”). It will also place the centroid in the largest of all parts of a multi-part polygon and will not place a centroid inside any hole in any of the parts.
We call this function as follows:
Secondly, you can use the CENTROID function in the SDO_3GL package. This will return exactly the same result as the SDO_GEOM.SDO_CENTROID function. You use it as follows:
The SDO_GEOM.SDO_BUFFER function is also licensed only for use in Enterprise Edition.
We use this function as follows:
But how can we generate a buffer in Standard Edition?
Again, we can look to the SDO_3GL package.
Which we use as follows:
Are the buffers generated by the sdo_geom and sdo_3gl functions the same?
However, we now meet another problem: SDO_GEOM.RELATE is an Enterprise function! How can we check the relationship between two object with Locator?
Can we find a solution in the SDO_3GL RELATE functions?
What does this mean?
Well, if we do this:
So, a bit mask of all 1s cannot mean EQUAL. I will investigate these masks and functions further to see what else I can discover and report back on them in an edited version of this article.
5.0 Area and Length
It has always amazed me that these two functions:
…are considered geoprocessing as these are properties of a geometric object and not something that results from the interaction of two objects. Still, it is Oracle’s right to license their technology as they see fit. But, given that these two functions are used an enormous amount in Locator installations we need a way out of the licensing dilemma.
There are two approaches. One is to see what is in the MDSYS.SDO_3GL package; the other is Java Topology Suite. I will only cover the first here and leave the latter for another blog article.
5.2 SDO_3GL functions.
The MDSYS.SDO_3GL package contains two procedures (not functions):
Note that the two procedures implement both the area and length processing. Both take a flag that indicates which property is required: length or area. The latter includes a UNIT field in case the caller wants the result in different units from the default: to use the units the SDO_SRID property of the SDO_GEOMETRY object must be non-NULL and the value must exist in the MDSYS.SDO_UNITS_OF_MEASURE table.
Experimenting with the FLAG argument shows that:
1 computes the Area of the geometry object
(Note: This is counter-intuitive as the our parameters in the SDO_3GL.LENGTH_AREA procedures are the revers of this.)
In my GEOM package I have created four “wrapper” functions that provide a drop-in replacement for the SDO_GEOM.SDO_AREA and SDO_GEOM.SDO_LENGTH functions. Here is the definition of the GEOM.AREA implementations.
Finally, an example to show that these functions return the correct results.
6.0 Java Topology Suite – Spatial Companion For Oracle (SC4O)
The Java Topology Suite is a free API for spatial data that is capable of being deployed into the JVM that is shipped with Oracle 10gR2 and 11g. JTS has a set of “geoprocessing” functions that could be used as “drop in” replacements for the Enterprise Edition licensed functions in the SDO_GEOM package or to complement the existing package.
In investigated this capability over the past year or so and have now released a set of Java classes that wrap JTS and Jaspa functions. This package of functionality is called the Spatial Companion for Oracle. The package can be downloaded from here