[geotk] Sample application
Doug Kunzman
dkunzman at usgs.gov
Fri Aug 3 11:30:54 PDT 2012
I'm trying to use the Geotoolkit 3.19 with Java 1.6 x64 to create a
shapefile on Windows 7 PC.
After considerable frustration I executed the sample and am getting a
similar error that I'm getting in my code.
Does anyone have any ideas what could be wrong?
The error is as follows,
ug 3, 2012 2:24:25 PM
org.geotoolkit.referencing.factory.epsg.ThreadedEpsgFactory
createBackingStore
INFO: Connected to EPSG database
?jdbc:hsqldb:C:\Users\dkunzman\Application
Data\Geotoolkit.org\EPSG\HSQL/7.09? on ?HSQL Database Engine?.
Aug 3, 2012 2:24:25 PM org.geotoolkit.data.shapefile.StorageFile
replaceOriginals
SEVERE: Unable to delete the file: \tmp\test.shx when attempting to
replace with temporary copy.
Aug 3, 2012 2:24:25 PM org.geotoolkit.data.shapefile.StorageFile
replaceOriginals
SEVERE: The problem is almost certainly caused by the fact that there are
still locks being held on the shapefiles. Probably a reader or writer was
left unclosed
Aug 3, 2012 2:24:25 PM org.geotoolkit.data.shapefile.ShpFiles
logCurrentLockers
SEVERE: The following locker still has a lock? write on file:/tmp/test.shp
by StorageFile: test5109458120423620803.shp
it was created with the following stack trace
org.geotoolkit.data.shapefile.ShpFilesLocker$Trace: Locking
at org.geotoolkit.data.shapefile.ShpFilesLocker.setTraceException(
ShpFilesLocker.java:50)
at org.geotoolkit.data.shapefile.ShpFilesLocker.<init>(
ShpFilesLocker.java:45)
at org.geotoolkit.data.shapefile.ShpFiles.acquireWrite(
ShpFiles.java:468)
at org.geotoolkit.data.shapefile.StorageFile.getSrcURLForWrite(
StorageFile.java:167)
at org.geotoolkit.data.shapefile.StorageFile.replaceOriginals(
StorageFile.java:103)
at org.geotoolkit.data.shapefile.ShapefileFeatureWriter.clean(
ShapefileFeatureWriter.java:204)
at org.geotoolkit.data.shapefile.ShapefileFeatureWriter.close(
ShapefileFeatureWriter.java:260)
at org.geotoolkit.data.DataUtilities.write(DataUtilities.java:165)
at
org.geotoolkit.data.AbstractDataStore.handleAddWithFeatureWriter(
AbstractDataStore.java:576)
at org.geotoolkit.data.shapefile.ShapefileDataStore.addFeatures(
ShapefileDataStore.java:298)
at org.geotoolkit.data.AbstractDataStore.addFeatures(
AbstractDataStore.java:232)
at gov.usgs.bip.bisn.core.view.CreateShapefileDemo.main(
CreateShapefileDemo.java:37)
Aug 3, 2012 2:24:25 PM org.geotoolkit.data.shapefile.ShpFiles
logCurrentLockers
SEVERE: The following locker still has a lock? write on file:/tmp/test.shx
by StorageFile: test8028264144081471416.shx
it was created with the following stack trace
org.geotoolkit.data.shapefile.ShpFilesLocker$Trace: Locking
at org.geotoolkit.data.shapefile.ShpFilesLocker.setTraceException(
ShpFilesLocker.java:50)
at org.geotoolkit.data.shapefile.ShpFilesLocker.<init>(
ShpFilesLocker.java:45)
at org.geotoolkit.data.shapefile.ShpFiles.acquireWrite(
ShpFiles.java:468)
at org.geotoolkit.data.shapefile.StorageFile.getSrcURLForWrite(
StorageFile.java:167)
at org.geotoolkit.data.shapefile.StorageFile.replaceOriginals(
StorageFile.java:103)
at org.geotoolkit.data.shapefile.ShapefileFeatureWriter.clean(
ShapefileFeatureWriter.java:204)
at org.geotoolkit.data.shapefile.ShapefileFeatureWriter.close(
ShapefileFeatureWriter.java:260)
at org.geotoolkit.data.DataUtilities.write(DataUtilities.java:165)
at
org.geotoolkit.data.AbstractDataStore.handleAddWithFeatureWriter(
AbstractDataStore.java:576)
at org.geotoolkit.data.shapefile.ShapefileDataStore.addFeatures(
ShapefileDataStore.java:298)
at org.geotoolkit.data.AbstractDataStore.addFeatures(
AbstractDataStore.java:232)
at gov.usgs.bip.bisn.core.view.CreateShapefileDemo.main(
CreateShapefileDemo.java:37)
and the code is here,
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.geotoolkit.data.shapefile.ShapefileDataStore;
import org.geotoolkit.feature.FeatureTypeBuilder;
import org.geotoolkit.feature.FeatureUtilities;
import org.geotoolkit.referencing.CRS;
import org.geotoolkit.storage.DataStoreException;
import org.opengis.feature.Feature;
import org.opengis.feature.type.FeatureType;
public class CreateShapefileDemo {
public static void main(String[] args) throws Exception {
// create a datastore toward the wanted path
final ShapefileDataStore store = new
ShapefileDataStore(new URL(
"file:/tmp/test.shp"));
// create the feature type needed
final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
ftb.setName("River");
ftb.add("the_geom", Point.class, CRS.decode("EPSG:4326"));
ftb.add("name", String.class);
final FeatureType type = ftb.buildFeatureType();
// add this model in the datastore
store.createSchema(type.getName(), type);
// create and store a feature
final List<Feature> features = new ArrayList<Feature>();
final Feature f = FeatureUtilities.defaultFeature(type,
"id-0");
f.getProperty("the_geom").setValue(
new GeometryFactory().createPoint(new
Coordinate(15, 20)));
f.getProperty("name").setValue("long river");
features.add(f);
store.addFeatures(type.getName(), features);
}
}
Douglas Kunzman
12201 Sunrise Valley Drive
Reston, VA 20192
Phone: 703 648-4234
dkunzman at usgs.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20120803/d8f84fd5/attachment.html>
More information about the Geotoolkit
mailing list