From: Patrick D <tru...@gm...> - 2017-03-16 11:42:18
|
Hello, I'm attempting to create a schema for some input GeoJSON so that I can store this data using PostGIS transactions. I am experiencing a problem with input that is an empty GeoJSON set. ``` {"type": "FeatureCollection", "features": []} ``` This is valid GeoJSON, so I'd like to support this case. I am retrieving a PostGIS data store and then creating a schema for this GeoJSON. ``` FeatureJSON featureJSON = new FeatureJSON(); SimpleFeatureType featureSchema = featureJSON.readFeatureCollectionSchema(inputStream, false); DataStore postGisStore = GeoToolsUtil.getPostGisDataStore(/*params*/); postGisStore.createSchema(featureSchema); ``` The final line throws an error because it cannot find the default geometry field. This is because, for my empty GeoJSON set, there's obviously no geometry and no attributes. If I turn on FINEST logging, I can see the commit statement that is failing: `FINE: Create schema: CREATE TABLE "public"."feature" ( "fid" SERIAL PRIMARY KEY, )` The SQL statement is attempting to set a primary key, but since my GeoJSON is empty, no value exists. Is there a way I can get this schema creation to succeed with an empty GeoJSON set? I would like to add more feature data to it later, but I would like to handle table creation immediately upon being provided with this initial GeoJSON. Thanks. |