KML
I have a package that will allow you to convert a single geometry into KML or create a whole KML document from a recordset containing many geometries.
It doesn’t do a whole lot, but it has been of interest to some users out there who have improved the original work.
DEFINE defaultSchema = ‘&1’ create or replace package KML authid current_user As Procedure Header( p_document_name In Varchar2, p_visibility In Integer := 1, p_open In Integer := 1, p_object_list In VarChar2 := 'POINT,LINE,POLYGON', p_colour In VarChar2 := 'ff00ff00', p_normal_mode In Integer := 1, p_point_scale In Number := 1.1, p_line_width In Integer := 4, p_polygon_fill In Integer := 0 ); /** * ==@==function : TO_KML * ==@==precis : Procedure takes a geodetic shape, converts it to a KML representation which * could be used within Google Earth and adds it to an internal document. * ==@==version : 1.0 * ==@==description: As per precis. If you need to handle projected data then I suggest you call the function * with the relevant Oracle projection call eg SDO_CS.TRANSFORM(geom,to_srid); * ==@==usage : Procedure To_KML(p_geometry In MdSys.Sdo_Geometry, * p_placemark_name In Varchar2, * p_description In Varchar2, * p_elevation In Number := 0.0 * ); * eg KML := CODESYS.geom.To_KML(shape,'My House','My house converted from oracle'); * ==@==param : p_geometry : MDSYS.SDO_GEOMETRY : An geodetic Sdo_Geometry object of any type. * ==@==history : Simon Greener - Feb 2007 - Original coding. * ==@==copyright : Free for public use **/ Procedure To_KML( p_geometry In MdSys.Sdo_Geometry, p_placemark_name In Varchar2, p_description In Varchar2, p_elevation In Number := 0.0 ); Function To_KML( p_geometry In MdSys.Sdo_Geometry, p_placemark_name In Varchar2, p_description In Varchar2, p_elevation In Number := 0.0 ) Return CLOB Deterministic; Procedure Footer; Function GetDocument Return CLOB Deterministic; End KML;End KML;
Here is an example of how to use it.
Prompt Test Geodetic points ... DECLARE CURSOR c_kml IS SELECT rownum as ID, PolyType, geom FROM GeodPoly2D a; BEGIN KML.Header('Geodetic 2D Poly'); FOR rec IN c_KML LOOP KML.TO_KML(rec.geom,'Polygon (' || rec.ID || ') of type ' || rec.polytype,'Test description' ); END LOOP; KML.Footer; dbms_output.put_line(SUBSTR(KML.GetDocument,1,250)); END; /