我正在尝试编写一个 Shapefile:
File shapefile = new File(....);
Map<String, Serializable> map = new HashMap();
map.put("url", shapefile.toURI().toURL());
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("MultiPolygonFeatureType");
CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84
builder.setCRS(crs);
builder.add("location", MultiPolygon.class);
builder.add("name", String.class);
SimpleFeatureType featureType = builder.buildFeatureType();
ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
ShapefileDataStore dataStore = (ShapefileDataStore) factory.createNewDataStore(map);
dataStore.createSchema(featureType);
SimpleFeatureWriter writer = (SimpleFeatureWriter)
dataStore.getFeatureWriterAppend(dataStore.getTypeNames()[0], new DefaultTransaction());
但这给了我错误:
java.lang.ClassCastException: 类 org.geotools.data.InProcessLockingManager$1 不能转换为类 org.geotools.data.simple.SimpleFeatureWriter(org.geotools.data.InProcessLockingManager$1 和 org.geotools.data.simple.SimpleFeatureWriter 位于加载器“app”的未命名模块中)
我这里遗漏了什么部分?