Geometry spatial geographic objects, the field type of Geometry objects stored in Oracle is Mdsys. Sdo_geometry, the method of building the GEOMETRY object in the database:
V_pointarray Mdsys.sdo_ordinate_array; Mdsys. Sdo_geometry (2003, 20131028, null, Mdsys. Sdo_elem_info_array (110031), V_pointarray);
20131028 of them are spatial reference systems.
How to read and write a table with geometry objects in a Java program, a common Geotools toolkit. Referencing the jar package Jts-1.13.jar in the MAVEN project
Reading Geometry objects
Add the Geometry type to the field in the Java Mapped database table entity class object, as follows:
@Column (name = "GEOM")
Private Geometry Geom;
This will be able to read the Geometry object, Geometry has a lot of space calculation method, the specific can view the source code.
Write Geometry Object
Relative to the reading, the writing is relatively troublesome, first to construct a geometry object, the construction of the point line surface:
Private Geometryfactory geometryfactory = Jtsfactoryfinder.getgeometryfactory (null);
Point of construction
Envelope e = new Envelope (new coordinate (x, y));
The construction of the line
LineString line = geometryfactory.createlinestring (coordinate[]);
Line.setsrid (20131028);
Rb.setgeometry (line);
Where the geometry of the RB entity class object is defined in the following format:
@Column (name = "Pkg_convex", Jdbctype = jdbctype.struct)
Private Geometry Geometry;
Be sure to specify the Jdbctype type, and the Geometry object in the Oracle database receives only the data of the struct type.
Java Program Operation Geometry Object