Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

What is the best way to programatically convert WKT String to GML String? Every reasonable library (at best available in some Maven repository) can be used.

Till now I came up with this solution using JTS. Its written in Java:

public String wktToGml(String wktGeometry) {
   WKTReader wktR = new WKTReader();
   Geometry geom = wktR.read(wktGeometry);

   // write JTS to string
   GMLWriter gmlW = new GMLWriter(true);
   String gml = gmlW.write(geom);
   return gml;
}

But I'm not sure if it's correct and most effective way. There are probably some problems with LF (linefeed) symbols. Probably there should be also solution using geotools library.

I'm new to this field, I'm trying to gain some overview.

share|improve this question
    
do you want a full GML document or just the gml:Polygon (or whatever) fragment? –  iant Mar 8 '13 at 10:07
    
probably just gml:Polygon –  Infragile Mar 8 '13 at 10:12
    
then you are probably fine with what you have –  iant Mar 8 '13 at 10:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.