The objective of this tutorial is to demonstrate how to use ESQL/C and the Client-side Java™ API to create and use geometry objects.
The client-side Java API consists of Java classes that you can use to work with Geodetic objects from Java client-side programs.
javac
If
a Java JDK is installed, usage
information is displayed. If it is not installed, you receive a command
not found message. If a Java JDK
is not installed, you must locate and install a copy to run the tutorial.The following programs are included in the ESQL/C demonstration directory:
Program name | Description |
---|---|
load_shapes.ec | Uses the SE_GeomFromShape function to create a table with an ST_Geometry column, and then insert examples of all geometry types in ESRI shape format |
load_wkb.ec | Uses the ST_GeomFromWKB function to create a table with an ST_Geometry column and insert examples of all geometry types in OGIS WKB format |
geomfromshape.ec | Uses the SE_GeomFromShape function to insert a polygon into a table in ESRI shape format |
geomfromwkb.ec | Uses the ST_GeomFromWKB function to insert a polygon into a table in OGIS WKB format |
asbinary.ec | Retrieves data in OGIS WKB format |
asshape.ec | Retrieves data in ESRI shape format |
Program name | Description |
---|---|
GeometryToWKT | Reads geometry objects from an IBM® Informix® spatial table and converts them into WKT (well-known text) strings. The program first creates a table, inserts geometry data, then queries the table. The output of this program shows the well-known text representation of sample geometries. |
GeometryToArray | Uses a geometry factory to create new geometries, and then reads coordinate data out of the geometry objects. The program first creates several geometry objects, stores them in a Java vector, then uses two techniques to read coordinate data out of the geometry objects,IfxGeometry.toCoordArray() and IfxGeometry.toPointArray() |
CoordRefCreate | Creates new coordinate reference objects and inserts them into the SPATIAL_REFERENCES table. The program creates a new CoordRef object, then serializes it as a new SRS row into the SPATIAL_REFERENCES table. The output of this program shows the result of a query to retrieve the new spatial reference systems from the database. |
$INFORMIXDIR/extend/spatial.8.21.xxx/examples
The xxx in
the directory name depends upon the version of the IBM Informix Virtual
Appliance you are using. To find the version you have installed, change
to the $INFORMIXDIR/extend directory and note
the directory name that begins with spatial. This information
is required for the examples in the rest of this tutorial wherever xxx is
displayed.Both the ESQL/C and the Java API examples assume that you are logged in to the informix account. If you are logged in as user developer, switch to informix account using the su command.
onstat -
startDemo
dbaccess <<EOF
create database geodemodb with log;
EOF
You build the sample programs by running the make utility.
cd /opt/IBM/informix/extend/spatial.8.21.xxx/examples/esqlc
make
./load_shapes geodemodb
export CLASSPATH=/opt/IBM/informix/extend/spatial.8.21.xxx/spatial.jar:
$CLASSPATH
cd $INFORMIXDIR/extend/spatial.8.21.xxx/examples/java
javac -Xlint:unchecked *.java
java program_name "connection_URL"
In the example, program_name is the name of the example program to run and connection_URL specifies the JDBC driver, the server name and port number, the database to use, and the user name and password for the database. For example, the following demonstrates the command syntax for VMware environments:
java CoordRefCreate "jdbc:informix-sqli://informixva:9088/
geodemodb:informixserver=demo_on;user=informix;password=informix"
For
cloud environments, specify the IP address or the public DNS name
of your IBM Informix Virtual Appliance instance instead
of informixva, and substitute the password that you
selected when the instance was provisioned.