Wednesday, 11 September 2013

Validation of a geometry in WKT format

Validation of a geometry in WKT format

I am new to GIS area and I need to validate a geometry in WKT format in
java, to check whether a simple polygon is a closed loop, i.e the start
and end points of the vertices should be the same. I am currently using
jGeometry class of oracle spatial(com.oracle.sdoapi), get the first and
last vertices and comparing them. also, i am using getType() method to
check whether it is a simple polygon or not. The following is the piece of
code that am using:
WKT wkt = new WKT();
JGeometry geometry = wkt.toJGeometry(wkt.getBytes());
double[] d1 = geometry.getFirstPoint();
double[] d2 = geometry.getLastPoint();
if(!jGeometry.getType() == jGeometry.GTYPE_POLYGON){
//error message for other geometries
}
Is there any simple way of doing this or is there any API available? I
dont want to reinvent the wheel, if it is already done and simple to use.
Thanks!

No comments:

Post a Comment