LWKT is a WKT parser under the LGPL license. It have not dependencies: it is pure Java compiled with 1.5 or 1.6 version. The output can be as GML 2 or 3 version, optionally setting a SRS name.
Supported inputs are:
- POINT
- MULTIPOINT
- LINESTRING
- MULTILINESTRING
- POLYGON
- MULTIPOLYGON
For each of them, are handled both 2D inputs like:
POINT(2.4 12.66)
and 3D inputs like:
POINT Z(2.4 12.66 0.0)
At the following URL:
http://95.110.227.201:8080/lwkt
is exposed a minimal web interface in order to test it.
Following, a code snippet as example of usage:
String wkt= "POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))";
try {
//To get output as GML version 2:
String output1 = WKTParser.parseToGML2(wkt);
//To get output as GML version 3;
String output2 = WKTParser.parseToGML3(wkt);
//To get output as GML version 3, setting EPSG:4326 as srs-name;
String output3 = WKTParser.parseToGML3(wkt, "EPSG:4326");
}
catch(Exception e) {
e.printStackTrace();
}
To do:
-add the possibility to parse the input as XY(Z) or YX(Z)