locationtech / geogig

GeoGig project
Other
402 stars 80 forks source link

Table with boolean field not exported to GeoPackage #407

Open MarkusHesse42 opened 7 years ago

MarkusHesse42 commented 7 years ago

I created a little test table with a boolean field in postgres like this:

CREATE TABLE ga.test_bool
(
  system_id bigint NOT NULL,
  material character varying(15),
  bezugslinie_darstellen_ boolean,
  d_leitung_in_betrieb geometry(LineString,31468)
)

and filled it with some example data. The import of this table to a geogig repository was successful. But when I try to export it to GeoPackage, I get an error message:

geogig geopkg export -i test_bool test_bool

Exporting from test_bool to test_bool...
Could not export. Error:UNABLE_TO_ADD

The error message in geogig.log is:

2017-11-23 12:17:21,760 ERROR [main] o.l.g.c.GeogigCLI [GeogigCLI.java:390] Could not export. Error:UNABLE_TO_ADD
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Integer
        at org.geotools.jdbc.PreparedStatementSQLDialect.setValue(PreparedStatementSQLDialect.java:146) ~[gt-jdbc-18.0.jar:na]
        at org.geotools.geopkg.GeoPkgDialect.setValue(GeoPkgDialect.java:466) ~[gt-geopkg-18.0.jar:na]
        at org.geotools.jdbc.JDBCDataStore.insertPS(JDBCDataStore.java:1763) ~[gt-jdbc-18.0.jar:na]
        at org.geotools.jdbc.JDBCDataStore.insert(JDBCDataStore.java:1697) ~[gt-jdbc-18.0.jar:na]
        at org.geotools.jdbc.JDBCInsertFeatureWriter.flush(JDBCInsertFeatureWriter.java:128) ~[gt-jdbc-18.0.jar:na]
        at org.geotools.jdbc.JDBCInsertFeatureWriter.write(JDBCInsertFeatureWriter.java:100) ~[gt-jdbc-18.0.jar:na]
        at org.geotools.data.InProcessLockingManager$1.write(InProcessLockingManager.java:337) ~[gt-main-18.0.jar:na]
        at org.geotools.data.store.ContentFeatureStore.addFeature(ContentFeatureStore.java:308) ~[gt-data-18.0.jar:na]
        at org.geotools.data.store.ContentFeatureStore.addFeatures(ContentFeatureStore.java:259) ~[gt-data-18.0.jar:na]
        at org.locationtech.geogig.geotools.plumbing.ExportOp._call(ExportOp.java:194) ~[geogig-geotools-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.geotools.plumbing.ExportOp._call(ExportOp.java:82) ~[geogig-geotools-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.repository.AbstractGeoGigOp.call(AbstractGeoGigOp.java:154) ~[geogig-api-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.geotools.cli.DataStoreExport.exportInternal(DataStoreExport.java:167) ~[geogig-geotools-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.geotools.cli.DataStoreExport.runInternal(DataStoreExport.java:99) ~[geogig-geotools-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.geotools.cli.geopkg.GeopkgExport.runInternal(GeopkgExport.java:75) ~[geogig-geotools-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.cli.AbstractCommand.run(AbstractCommand.java:68) ~[geogig-cli-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.cli.GeogigCLI.executeInternal(GeogigCLI.java:532) ~[geogig-cli-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.cli.GeogigCLI.execute(GeogigCLI.java:368) ~[geogig-cli-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.cli.app.CLI.run(CLI.java:95) [geogig-cli-app-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]
        at org.locationtech.geogig.cli.app.CLI.main(CLI.java:113) [geogig-cli-app-1.3-SNAPSHOT.jar:1.3-SNAPSHOT]

The table is created in the GeoPackage in the following form:

CREATE TABLE "test_bool" ( "fid" INTEGER PRIMARY KEY AUTOINCREMENT, "system_id" INTEGER NOT NULL , "material" TEXT, "bezugslinie_darstellen_" INTEGER, "d_leitung_in_betrieb" LINESTRING );

So it seems, the transition from the boolean in postgres to Integer in SQLite is not done well.

sebastian-r-schmidt commented 6 years ago

With the current master branch, this issue does not occur anymore. Can you confirm that?