简体   繁体   中英

Why can't I cast WFSFeatureSource into SimpleFeatureStore?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM