Oracle Spatial Java Library (SDOAPI) Sample Programs

These sample programs (also available in this sdoapi_samples.zip file) demonstrate how to convert Java geometry objects to and from various formats, how to transform geometries, and how to get geo-spatial relationships and apply geo-spatial operators.

These programs illustrate the use of the oracle.sdoapi.geom and oracle.sdoapi.adapter packages.  To run these programs, you will need to download the Oracle Spatial Java Library Read the Oracle Spatial Java Library User's Guide for detailed information about the library.

Give us feedback

Installation Notes:

  • Unzip sdoapi_samples.zip It will create a directory called "sample"

  • Change the following variables in each of the sample programs.
          private static String m_host = "<your host>";
       private static String m_port = "<your port >";
       private static String m_sid = "<your sid >";
       private static String m_user = "<your username >";
       private static String m_password = "<your password >";


  • Compile all the samples using the following command
       javac sample/*.java sample/adapter/*.java

Read the Java Library User's Guide, section 1.1.3 for details on compiling these sample programs

Migrate shapefile geometries into Oracle Spatial table
   SampleShapefileToSDO reads data from a shapefile and writes it to an Oracle Spatial table.

  • Run the sample, specifying 2 parameters

    java sample.SampleShapefileToSDO <Shapefile name> <Oracle8i table name>

    for example...
    java sample.SampleShapefileToSDO USStates.shp USSTATES

       IMPORTANT: If the table specified in the Run command exists, then any data contained in it will be deleted by the sample program. If the table does not exist the sample program will create it for you with columns (GID NUMBER) and (GEOMETRY MDSYS.SDO_GEOMETRY).

Generate XML geometries from Oracle Spatial data
   SampleSDOtoXML reads instances of type mdsys.sdo_geometry from an Oracle 8.1.6 instance and creates an XML document based on DTD shown in geoxml.dtd

  • Run the sample, specifying 2 parameters

    java sample.SampleSDOtoXML <Oracle8i table name> <XML filename >

    for example...
    java sample.SampleSDOtoXML USSTATES USStates.xml

Create geometry objects and insert them into specified Oracle Spatial table
   SampleNewToSDO illustrates how to create Java Geometry objects and insert them into a Oracle 8.1.6 table that has a column of type mdsys.sdo_geometry

  • Run the sample, specifying 2 parameters

    java sample.SampleNewToSDO <Oracle8i table name>

    for example...
    java sample.SampleNewToSDO TESTDATA

       IMPORTANT: If the table specified in the Run command exists, then any data contained in it will be deleted by the sample program. If the table does not exist the sample program will create it for you with columns (GID NUMBER) and (GEOMETRY MDSYS.SDO_GEOMETRY).

Transform geometries from one coordinate system to another
   SampleTransforms uses the Spatial Coordinate Systems beta feature, therefore the results of this sample are not guaranteed.

  • Run the sample, specifying 2 parameters

    java sample.SampleTransforms <Oracle8i origin table name> <Oracle8i destination table name>

    for example...
    java sample.SampleTransforms USSTATES USSTATES1

       IMPORTANT: If the destination table specified in the Run command exists, then any data contained in it will be deleted by the sample program. If the table does not exist the sample program will create it for you with columns (GID NUMBER) and (GEOMETRY MDSYS.SDO_GEOMETRY).

Writing a shapefile adapter
   AdapterShapefile is sample code that illustrate how to use the oracle.sdoapi.adapter package to write your own geometry adapters. Feel free to update the sample to work with the latest shapefile format.

Writing a XML geometry adapter 
   AdapterXML. is sample code using this version of geoxml.dtd illustrating how to use the oracle.sdoapi.adapter package to write your own geometry adapters. Because the OpenGIS Geoxml DTD is still evolving, newer version of the DTD will not work with this sample program.

Accessing a geometry object
  geometry.htm includes sample code that illustrates how to access the coordinate data in a Java Geometry, which amy be helpful if you wish to write an application that display or modify geometries.
 

 

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy