简体   繁体   English

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

[英]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:在 GeoTools Javadoc for Transaction(以及其他一些地方,例如博客等)中,他们建议使用这样的行来在数据库上执行事务:

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.该方法返回一个 WFSFeatureStore,它希望将其转换为 SimpleFeatureStore。 However, at runtime, it says that it can't cast this, and halts the program.但是,在运行时,它说它不能强制转换,并停止程序。 WFSFeatureStore is a class, SimpleFeatureStore is an interface. WFSFeatureStore 是一个 class,SimpleFeatureStore 是一个接口。 Both implement the SimpleFeatureSource interface.两者都实现了 SimpleFeatureSource 接口。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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