Я не могу конвертировать kml в geojson, кто-то может поставить пример кода, а также библиотеки, используемые в pom.xml. Все, что я нашел, устарело, и я не могу найти библиотеки.
Я использую Java 8
, ближе всего я получил этот код, но я не могу найти KMLConfiguration
FileInputStream reader = new FileInputStream(args[0]);
KMLConfiguration kmlConfiguration = new KMLConfiguration();
PullParser parser = new PullParser(kmlConfiguration, reader, SimpleFeature.class);
ArrayList<SimpleFeature> features = new ArrayList<>();
SimpleFeature simpleFeature = (SimpleFeature) parser.parse();
while (simpleFeature != null) {
// System.out.println(simpleFeature);
features.add(simpleFeature);
simpleFeature = (SimpleFeature) parser.parse();
}
SimpleFeatureCollection fc = DataUtilities.collection(features);
int count = 0;
try (SimpleFeatureIterator itr = fc.features()) {
while (itr.hasNext()) {
System.out.println("feature " + (count++));
SimpleFeature feature = itr.next();
Collection<Property> attribs = feature.getProperties();
for (Property p : attribs) {
if (p.getValue() != null)
System.out.println(p.getName() + ": \"" + p.getValue() + "\"");
}
System.out.println("Extended Data");
Map<Object, Object> userData = feature.getUserData();
for (java.util.Map.Entry<Object, Object> e : userData.entrySet()) {
System.out.println(e.getKey() + ":" + e.getValue());
}
}
}
Я просто хотел бы преобразовать файл .kml в geojson