If you write a geopackage out using the following code no extent is set in the geopackage: public class GeopackageWriter {
public static void main(String[] args) throws MalformedURLException, IOException {
File inFile = new File(args[0]);
File outFile = new File(args[1]);
DataStore inputDataStore = DataStoreFinder.getDataStore(
Collections.singletonMap("url", inFile.toURI().toURL()));
String inputTypeName = inputDataStore.getTypeNames()[0];
SimpleFeatureType inputType = inputDataStore.getSchema(inputTypeName);
FeatureSource<SimpleFeatureType, SimpleFeature>
source = inputDataStore.getFeatureSource(inputTypeName);
FeatureCollection<SimpleFeatureType, SimpleFeature>
inputFeatureCollection = source.getFeatures();
HashMap<String, Object> map = new HashMap<>();
map.put(GeoPkgDataStoreFactory.DBTYPE.key, "geopkg");
map.put(GeoPkgDataStoreFactory.DATABASE.key, outFile);
DataStore store = null;
try {
store = DataStoreFinder.getDataStore(map);
} catch (IOException e) {
e.printStackTrace();
}
store.createSchema(inputType);
SimpleFeatureStore out = (SimpleFeatureStore)store.getFeatureSource(inputTypeName);
out.addFeatures(inputFeatureCollection);
}
ogrinfo reports:
ogrinfo -al -so states.gpkg
INFO: Open of `states.gpkg'
using driver `GPKG' successful.
Layer name: states
Metadata:
DESCRIPTION=states
Geometry: Multi Polygon
Feature Count: 49
Extent: (0.000000, 0.000000) - (0.000000, 0.000000)
Layer SRS WKT:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
FID Column = fid
|