开发者

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 som开发者_Go百科ewhere, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜