Skip to main content
added note about fix
Source Link
Ian Turton
  • 83.2k
  • 6
  • 89
  • 189

This seems to be a bug in the OGR KML drivers - I've raised a bug.

UPDATE This is fixed in GDAL 2.2.2

In the meantime a temporary work around is to remove the kml: from the output.

SimpleFeatureCollection featureCollection = DataUtilities.collection(list);

Encoder encoder = new Encoder(new KMLConfiguration());
encoder.setIndenting(true);
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
  encoder.encode(featureCollection, KML.kml, os );
  String out = os.toString().replaceAll("kml:", "");
  System.out.println(out);
} catch (Exception e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
} 

This seems to be a bug in the OGR KML drivers - I've raised a bug.

In the meantime a temporary work around is to remove the kml: from the output.

SimpleFeatureCollection featureCollection = DataUtilities.collection(list);

Encoder encoder = new Encoder(new KMLConfiguration());
encoder.setIndenting(true);
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
  encoder.encode(featureCollection, KML.kml, os );
  String out = os.toString().replaceAll("kml:", "");
  System.out.println(out);
} catch (Exception e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
} 

This seems to be a bug in the OGR KML drivers - I've raised a bug.

UPDATE This is fixed in GDAL 2.2.2

In the meantime a temporary work around is to remove the kml: from the output.

SimpleFeatureCollection featureCollection = DataUtilities.collection(list);

Encoder encoder = new Encoder(new KMLConfiguration());
encoder.setIndenting(true);
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
  encoder.encode(featureCollection, KML.kml, os );
  String out = os.toString().replaceAll("kml:", "");
  System.out.println(out);
} catch (Exception e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
} 
Source Link
Ian Turton
  • 83.2k
  • 6
  • 89
  • 189

This seems to be a bug in the OGR KML drivers - I've raised a bug.

In the meantime a temporary work around is to remove the kml: from the output.

SimpleFeatureCollection featureCollection = DataUtilities.collection(list);

Encoder encoder = new Encoder(new KMLConfiguration());
encoder.setIndenting(true);
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
  encoder.encode(featureCollection, KML.kml, os );
  String out = os.toString().replaceAll("kml:", "");
  System.out.println(out);
} catch (Exception e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}