Top 5 Recent Articles
ARTICLES CATEGORIES
- Algorithms (22)
- All (399)
- Biography (1)
- Blog (44)
- Business Requirements (1)
- Commentary (1)
- Conversion (2)
- Customers (2)
- Data Models (1)
- Education (2)
- GeoRaptor (13)
- GPS (1)
- Image Processing (2)
- Import Export (8)
- Licensing (2)
- LiDAR (1)
- Linear Referencing (4)
- Manifold GIS (3)
- Mapping (1)
- MySQL Spatial (7)
- Networking and Routing (including Optimization) (5)
- Open Source (18)
- Oracle Spatial and Locator (194)
- Partitioning (1)
- PostGIS (36)
- Projections (1)
- Published Articles (1)
- qGIS (1)
- Recommendations (1)
- Services (1)
- Software Change Log (1)
- Source Code (37)
- Space Curves (9)
- Spatial Database Functions (109)
- Spatial DB comparison (1)
- Spatial XML Processing (11)
- SQL Server Spatial (92)
- Standards (3)
- Stored Procedure (17)
- Tessellation or Gridding (10)
- Tools (2)
- Topological Relationships (1)
- Training (2)
- Triangulation (2)
Minumum Bounding Rectangle (MBR) Object Type for Oracle
Many years ago I wrote a “comprehensive” Minimum Bounding Rectangle (MBR) Object type for Oracle. This provides a lot fo the functionality of the BOX operators for PostGIS.
Here is the public interface of the MBR type:
create or replace TYPE MBR AS OBJECT ( MinX Number, MinY Number, MaxX Number, MaxY Number, -- ================== Constructors -- Constructor Function MBR Return Self as Result, Constructor Function MBR( p_geometry IN MDSYS.SDO_GEOMETRY, p_tolerance IN NUMBER ) Return Self as Result, Constructor Function MBR( p_geometry IN MDSYS.SDO_GEOMETRY, p_dimarray IN MDSYS.SDO_DIM_ARRAY ) Return Self as Result, Constructor Function MBR( p_MBR In MBR ) Return Self as Result, Constructor Function MBR( p_Point In ST_Point, p_dExtent In Number) Return Self As Result, Constructor Function MBR( p_Point In MDSYS.Vertex_Type, p_dExtent In Number) Return Self As Result, Constructor Function MBR( p_Coord2D In &&defaultSchema..Coord2DType, p_dExtent In Number) Return Self as Result, Constructor Function MBR( p_dX In NUMBER, p_dY In Number, p_dExtent In Number) Return Self as Result, -- ================== Modifiers -- Member Procedure SetEmpty, Member Procedure Expand( p_Coord2D IN &&defaultSchema..Coord2DType), Member Procedure Expand( p_dX IN NUMBER, p_dY IN NUMBER), Member Procedure Expand( p_other IN MBR), Member Procedure Normalise( p_dRatio In Number), Member Procedure SetLargestPart( p_geometry IN MDSYS.SDO_GEOMETRY, p_dimarray IN MDSYS.SDO_DIM_ARRAY ), Member Procedure Intersection(. p_other In MBR ), -- ================== Testers -- Member Function isEmpty Return Boolean Deterministic, Member Function Contains( p_other In MBR ) Return Boolean Deterministic, Member Function Contains( p_dX In Number, p_dY In Number ) Return Boolean Deterministic, Member Function Contains( p_Point In ST_Point ) Return Boolean Deterministic, Member Function Contains( p_Point In MDSYS.Vertex_Type) Return Boolean Deterministic, Member Function Contains( p_Coord2D In Coord2DType ) Return Boolean Deterministic, Member Function Equals( p_other In MBR ) Return Boolean Deterministic, Member Function Compare( p_other In MBR ) Return Number Deterministic, Member Function Overlap( p_other in MBR ) Return Boolean Deterministic, -- ================== Inspectors Member Function X Return Number Deterministic, Member Function Y Return Number Deterministic, Member Function Width Return Number Deterministic, Member Function Height Return Number Deterministic, Member Function Area Return Number Deterministic, Member Function Centre Return &&defaultSchema..Coord2DType Deterministic, Member Function Center Return &&defaultSchema..Coord2DType Deterministic, Member Function AsDimArray Return MDSYS.SDO_DIM_ARRAY Deterministic, Member Function AsString Return VarChar2 Deterministic, Member Function AsCSV Return VarChar2 Deterministic, Member Function AsWKT Return VARCHAR2 Deterministic, Member Function AsSVG Return VarChar2 Deterministic, Member Function getCentreAsSVG Return VarChar2 Deterministic, Order Member Function Evaluate(p_other In MBR) Return PLS_Integer );
Follow the link to download the full implementation of my MBR type for Oracle.
An example of the use of the MBR object can be seen from the following:
set serveroutput on size 100000 declare myExtent MBR := New MBR; anExtent MBR; Begin dbms_output.put_line( '=============================' ); If ( myExtent.isEmpty ) Then dbms_output.put_line( 'isEmpty: True'); Else dbms_output.put_line( 'isEmpty: False'); End If; myExtent := MBR(337900, 5429000, 338900, 5430000); dbms_output.put_line( myExtent.AsString ); dbms_output.put_line( myExtent.AsCSV ); dbms_output.put_line( myExtent.AsWKT ); dbms_output.put_line( myExtent.AsSVG ); dbms_output.put_line( myExtent.GetCentreAsSVG ); dbms_output.put_line( myExtent.X ); dbms_output.put_line( myExtent.Width ); dbms_output.put_line( myExtent.Height ); dbms_output.put_line( myExtent.Y ); If ( myExtent.contains(337950, 5429050) ) Then dbms_output.put_line( 'Contains: True'); Else dbms_output.put_line( 'Contains: False'); End If; If ( myExtent.contains(337950, 5439050) ) Then dbms_output.put_line( 'Contains: True'); Else dbms_output.put_line( 'Contains: False'); End If; anExtent := New MBR(337950, 5429050, 338950, 5430500); dbms_output.put_line( 'Compare = ' || myExtent.Compare(anExtent)); End; / show errors anonymous block completed ============================= isEmpty: True <mbr minx='337900' miny='5429000' maxx='338900' maxy='5430000' /> 337900,5429000,338900,5430000 POLYGON((337900 5429000,338900 5429000,338900 5430000,337900 5430000,337900 5429000)) <rect x='337900' y='5429000' width='1000' height='1000' /> <point x='338400' y='5429500' /> 338400 1000 1000 5429500 Contains: True Contains: False Compare = .9025 No Errors.
I hope this is of interest to someone.
Documentation
- MySQL Spatial General Functions
- Oracle LRS Objects
- Oracle Spatial Exporter (Java + pl/SQL)
- Oracle Spatial Object Functions
- Oracle Spatial Object Functions (Multi Page)
- PostGIS pl/pgSQL Functions
- SC4O Oracle Java Topology Suite (Java + pl/SQL)
- SQL Server Spatial General TSQL Functions
- SQL Server Spatial LRS TSQL Functions