< Prev - Examples - Next >

Special Oracle Type SDO_GEOMETRY

Example Description

Important Notes !

PL/SQL Function : GET_SDO_GEOMETRY
create or replace function get_sdo_geometry return sdo_geometry
is
begin
  return SDO_GEOMETRY(
    2003,  -- two-dimensional polygon
    NULL,
    NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,3), -- one rectangle (1003 = exterior)
    SDO_ORDINATE_ARRAY(1,1, 5,7) -- only 2 points needed to
          -- define rectangle (lower left and upper right) with
          -- Cartesian-coordinate data
  ); 
end get_sdo_geometry;
Java Calling Class : SdoGeometry.java
package plsql_workbench_examples;

import factory.ExamplesRPCFactory;
import oracle.spatial.geometry.JGeometry;
import service.GetSdoGeometryService;

public class SdoGeometry {
  public static void main(String[] args) {
    try {
      // get service
      GetSdoGeometryService service = ExamplesRPCFactory.getGetSdoGeometryService();

      // stored procedure produces data of a rectangle
      JGeometry rectangle = service.call();

      System.out.println(String.format("lower left corner : x=%f    y=%f",
                                       rectangle.getFirstPoint()[0],
                                       rectangle.getFirstPoint()[1]));
      System.out.println(String.format("upper right corner : x=%f    y=%f",
                                       rectangle.getLastPoint()[0],
                                       rectangle.getLastPoint()[1]));
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}