Using GeoTools v13.2 I need to add features to a GeoPackage from KML. So far I can get the features in a SimpleFeatureCollection which can be added to the GeoPackage:
public void addFeaturesToGeoPackage(InputStream featuresKML, GeoPackage geopackage){ Parser parser = new Parser(new KMLConfiguration()); SimpleFeature f = (SimpleFeature) parser.parse(featuresKML); Collection placemarks = (Collection) f.getAttribute("Feature"); List featureList = new ArrayList(placemarks); //Get SimpleFeatureCollection SimpleFeatureCollection featureCollection = DataUtilities.collection(features); //Get the feature schema SimpleFeatureType schema = featureCollection.getSchema(); //TODO: Create FeatureEntry from schema FeatureEntry featureEntry = createFeatureEntry(schema); //Create the geometry table geopackage.create(featureEntry, schema); //Add all the features geopackage.add(featureEntry, featureCollection);}I'm not sure how to create the FeatureEntry as what I'm currently using gives an arbitrary name to the "geometryColumnName" attribute which causes a java.lang.IllegalArgumentException:
Caused by: java.lang.IllegalArgumentException: Geometry column featureVectors does not exist in schemaThis is what I was able to come up with based on the documentation and examples I could find through some Google searches but I would like to know the right way to accomplish this/get the FeatureEntry.
أكثر...
public void addFeaturesToGeoPackage(InputStream featuresKML, GeoPackage geopackage){ Parser parser = new Parser(new KMLConfiguration()); SimpleFeature f = (SimpleFeature) parser.parse(featuresKML); Collection placemarks = (Collection) f.getAttribute("Feature"); List featureList = new ArrayList(placemarks); //Get SimpleFeatureCollection SimpleFeatureCollection featureCollection = DataUtilities.collection(features); //Get the feature schema SimpleFeatureType schema = featureCollection.getSchema(); //TODO: Create FeatureEntry from schema FeatureEntry featureEntry = createFeatureEntry(schema); //Create the geometry table geopackage.create(featureEntry, schema); //Add all the features geopackage.add(featureEntry, featureCollection);}I'm not sure how to create the FeatureEntry as what I'm currently using gives an arbitrary name to the "geometryColumnName" attribute which causes a java.lang.IllegalArgumentException:
Caused by: java.lang.IllegalArgumentException: Geometry column featureVectors does not exist in schemaThis is what I was able to come up with based on the documentation and examples I could find through some Google searches but I would like to know the right way to accomplish this/get the FeatureEntry.
أكثر...