Wednesday, July 30, 2008

JGeometry (Oracle Spatial Java API Reference)

oracle.spatial.geometry
Class JGeometry

/// reading a geometry from database
     ResultSet rs = statement.executeQuery("SELECT geometry FROM states where name='Florida'");
STRUCT st = (oracle.sql.STRUCT) rs.getObject(1);
//convert STRUCT into geometry
JGeometry j_geom = JGeometry.load(st);

// ... manipulate the geometry or create a new JGeometry ...

/// writing a geometry back to database
PreparedStatement ps = connection.prepareStatement("UPDATE states set geometry=? where name='Florida'");
//convert JGeometry instance to DB STRUCT
STRUCT obj = JGeometry.store(j_geom, connection);
ps.setObject(1, obj);
ps.execute();

No comments:

Post a Comment