为什么我不能将 WFSFeatureSource 转换为 SimpleFeatureStore?

发布于 2024-11-04 05:00:50 字数 428 浏览 3 评论 0原文

在 GeoTools Javadoc for Transaction(以及其他一些地方,例如博客等)中,他们建议使用这样的行来在数据库上执行事务:

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

其中“store”,据我所知,是一个 DataStore。该方法返回一个 WFSFeatureStore,它希望将其转换为 SimpleFeatureStore。然而,在运行时,它说它无法转换它,并停止程序。 WFSFeatureStore 是一个类,SimpleFeatureStore 是一个接口。两者都实现了 SimpleFeatureSource 接口。

描述中一定有什么地方丢失了,因为所有这些地方都暗示了这一点,但它不起作用。谁能启发我吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缘字诀 2024-11-11 05:00:50

如果所选目标不可写,DataStore 将返回 SimpleFeatureSource 而不是 SimpleFeatureStore。对于 WFS,远程 WFS 服务器可能不允许 WFS-T,或者 WFS 存储无法正确解析功能。
另一种可能性是服务器支持 WFS-T,但它是 1.1,据我所知,GeoTools 具有仅针对 WFS 1.0 服务器执行事务的代码。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文