Hi
I'm trying to export some postgis layers to shapefile:
pg = new PostGIS([schema: 'av_avwmsde_t', user: 'stefan', password: 'XXXXX'], 'rosebud')
layer = pg.get("mbfs")
Directory dir = new Directory("/home/stefan/tmp/geo/")
dir.add(layer)
This throws the following error:
Caught: java.io.IOException: Current fid index is null, next must be called before write()
java.io.IOException: Current fid index is null, next must be called before write()
at org.geotools.data.shapefile.indexed.IndexedFidWriter.write(IndexedFidWriter.java:252)
at org.geotools.data.shapefile.indexed.IndexedShapefileFeatureWriter.write(IndexedShapefileFeatureWriter.java:101)
at org.geotools.data.shapefile.ShapefileFeatureWriter.close(ShapefileFeatureWriter.java:231)
at org.geotools.data.shapefile.indexed.IndexedShapefileFeatureWriter.close(IndexedShapefileFeatureWriter.java:109)
at org.geotools.data.InProcessLockingManager$1.close(InProcessLockingManager.java:350)
at org.geotools.data.AbstractFeatureStore.addFeatures(AbstractFeatureStore.java:329)
at org.geotools.data.directory.DirectoryFeatureStore.addFeatures(DirectoryFeatureStore.java:104)
at org.geotools.data.FeatureStore$addFeatures.call(Unknown Source)
at geoscript.workspace.Workspace.add(Workspace.groovy:152)
at geoscript.workspace.Workspace.add(Workspace.groovy)
at geoscript.workspace.Workspace$add$0.callCurrent(Unknown Source)
at geoscript.workspace.Workspace.add(Workspace.groovy:127)
at geoscript.workspace.Workspace$add.call(Unknown Source)
at exportPostgisToShapefile.run(exportPostgisToShapefile.groovy:38)
I first thought that it is related to the shapefile restrictions but the attribute names are truncated fine. It seems that it has something to do with the position of the geometry column. This table definitions works:
CREATE TABLE av_avwmsde_t.mbsf_qgis_geometrie
(
ogc_fid serial NOT NULL,
geometrie geometry,
bfsnr integer,
"name" character varying(254),
CONSTRAINT mbsf_qgis_geometrie_pkey PRIMARY KEY (ogc_fid),
CONSTRAINT enforce_dims_geometrie CHECK (st_ndims(geometrie) = 2),
CONSTRAINT enforce_geotype_geometrie CHECK (geometrytype(geometrie) = 'POLYGON'::text OR geometrie IS NULL),
CONSTRAINT enforce_srid_geometrie CHECK (st_srid(geometrie) = 21781)
)
WITH (
OIDS=FALSE
);
This does *not* work:
CREATE TABLE av_avwmsde_t.mbsf
(
ogc_fid serial NOT NULL,
bfsnr integer,
"name" character varying,
geometrie geometry,
CONSTRAINT mbsf_pkey PRIMARY KEY (ogc_fid)
)
WITH (
OIDS=FALSE
);
If there is a primary key (ogc_fid in the example) the geometry column has to be the second column. If there is no primary key (e.g. a view) the geometry column has to be first. Can this be reproduced? And is this Geoscript related (or rather Geotools)?
I'm using geoscript-groovy master from github.
Best regards
Stefan
--
You received this message because you are subscribed to the GeoScript mailing list.
To post to this group, send email to geos...@googlegroups.com
To unsubscribe from this group, send email to geoscript+...@googlegroups.com
Visit this group at http://groups.google.com/group/geoscript or see http://geoscript.org