1

In the GeoTools Javadoc for Transaction (and in a few other places, such as blogs and so forth) they suggest lines like this for performing transactions on the database:

SimpleFeatureStore road = (SimpleFeatureStore) store.getFeatureSource("road");

where "store", as far as I can work out, is a DataStore. The method returns a WFSFeatureStore, which it wants to cast into a SimpleFeatureStore. However, at runtime, it says that it can't cast this, and halts the program. WFSFeatureStore is a class, SimpleFeatureStore is an interface. Both implement the SimpleFeatureSource interface.

There must be something lost in the description somewhere, because all these places suggest it, but it doesn't work. Can anyone enlighten me?

4

1 回答 1

1

A DataStore will return a SimpleFeatureSource instead of a SimpleFeatureStore if the chosen target is not writable. In the case of WFS maybe the remote WFS server does not allow WFS-T or the WFS store is not able to properly parse the capabilities. Another possibility is that the server supports WFS-T but it is a 1.1, as far as I know GeoTools has code to do transactions only against a WFS 1.0 server.

于 2011-04-29T19:31:15.100 回答