Java Program Operation Geometry Object

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.