Top 5 Recent Articles
ARTICLES CATEGORIES
- Algorithms (13)
- All (401)
- Biography (1)
- Blog (44)
- Business Requirements (1)
- Commentary (1)
- Customers (2)
- Data Models (1)
- Education (2)
- GeoRaptor (2)
- Image Processing (2)
- Import Export (5)
- Licensing (2)
- Linear Referencing (3)
- Manifold GIS (3)
- Mapping (1)
- MySQL Spatial (7)
- Networking and Routing (including Optimization) (3)
- Open Source (16)
- Oracle Spatial and Locator (177)
- PostGIS (33)
- Published Articles (1)
- Recommendations (1)
- Services (1)
- Software Change Log (1)
- Source Code (35)
- Space Curves (9)
- Spatial Database Functions (102)
- Spatial DB comparison (1)
- Spatial XML Processing (10)
- SQL Server Spatial (General) (83)
- SQL Server Spatial (LRS) (38)
- Standards (1)
- Stored Procedure (15)
- Tessellation or Gridding (9)
- Tools (2)
- Training (2)
Create GeoJSON Document from Selection of SDO_Geometry objects.
The SDO2GEOJSON function available on this website converts a single SDO_GEOMETRY object to a GeoJSON Snippet.
Here we present a procedure that creates an GeoJSON document from a collection of SDO_GEOMETRY objects in a SQL SELECT ref_cursor:
CREATE OR REPLACE FUNCTION sdo2geojson_document(r_cur SYS_REFCURSOR) RETURN CLOB deterministic IS GEOM MDSYS.SDO_GEOMETRY; js_geom CLOB; j_geom CLOB; start_tag VARCHAR2(100); end_tag VARCHAR2(100); BEGIN DBMS_LOB.CREATETEMPORARY (LOB_LOC => JS_GEOM, cache => TRUE); start_tag := '{ "type": "FeatureCollection", "features": ['; DBMS_LOB.WRITE(LOB_LOC => JS_GEOM, AMOUNT => LENGTH(START_TAG), OFFSET => DBMS_LOB.GETLENGTH(JS_GEOM)+1, buffer => start_tag ); LOOP FETCH r_cur INTO geom; EXIT WHEN R_CUR%NOTFOUND; J_GEOM := SDO2GEOJSON(GEOM); DBMS_LOB.APPEND(dest_lob => JS_GEOM, src_lob => j_geom ); END LOOP; end_tag := '] }'; DBMS_LOB.WRITE(LOB_LOC => JS_GEOM, AMOUNT => LENGTH(END_TAG), OFFSET => DBMS_LOB.GETLENGTH(JS_GEOM)+1, buffer => end_tag ); RETURN JS_GEOM; END;
I hope this is of use to someone.
Documentation
- MySQL Spatial General Function Documentation
- Oracle Spatial Exporter Package Documentation
- Oracle Spatial Object Function Documentation
- Oracle Spatial Object Function Documentation (Multi Page Version)
- PostGIS pl/pgSQL Function Documentation
- SC4O Oracle Java Topology Suite (Stored Procedures) Package Documentation
- SQL Server Spatial General TSQL Function Documentation
- SQL Server Spatial LRS TSQL Function Documentation