0

我在使用 geotools wfs-ng 数据存储插件和 geoserver 实例时遇到了很大的麻烦(geoserver 在这里不是问题,它只是一个 wfs 实现和数据提供者)。用例看起来很简单:

  • 作为底层 wfs 的代理的自定义 Web 服务
  • 在我的 Web 服务应用程序启动时创建 wfs 数据存储:
final URL wfsUrl = new URL(url);
final WFSConfig wfsConfig = WFSConfig.fromParams(Map.of(
    WFSDataAccessFactory.AXIS_ORDER.key, WFSDataAccessFactory.AXIS_ORDER_EAST_NORTH));
final SimpleHttpClient httpClient = new SimpleHttpClient();
return new WFSDataStore(new WFSClient(wfsUrl, httpClient, wfsConfig));
  • 在对代理底层 wfs 的连续自定义 api 调用中重用它,许多下面的调用是在多个线程中完成的
final SimpleFeatureSource eventsSource = dataStore.getFeatureSource(typeName);
final String geometryColumn = dataStore.getSchema(typeName).getGeometryDescriptor().getLocalName();
final Filter filter = filterOf(parameters, geometryColumn);
final SimpleFeatureCollection eventsFeatures = eventsSource.getFeatures(new Query(typeName, filter));
final SimpleFeatureIterator features = eventsFeatures.features();
try {
    while (features.hasNext()) {
        final SimpleFeature next = features.next();
        //do something
    }
} finally {
    features.close();
}

试用版 geotools wfs-ng 数据存储插件:22.3、23.5

症状:

  • wfs-ng 插件的奇怪行为是每个 wfs GetFeature 调用都会释放 DescribeFeatureType 调用(对于似乎失败的架构,可能来自 org.geotools.xsd.impl PullParser),为什么一个还不够?
  • 在多线程 wfs 调用次数之后(有时更少,有时更多)
Caused by: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 94 out of bounds for object array[93]
    at java.base/java.lang.System.arraycopy(Native Method) ~[na:na]
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.ensureSafety(BasicNotifierImpl.java:214) ~[org.eclipse.emf.common-2.15.0.jar!/:na]
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.remove(BasicNotifierImpl.java:244) ~[org.eclipse.emf.common-2.15.0.jar!/:na]
    at org.geotools.xsd.impl.SchemaIndexImpl.destroy(SchemaIndexImpl.java:93) ~[gt-xsd-core-22.3.jar!/:na]
    at org.geotools.xsd.Encoder.encode(Encoder.java:1119) ~[gt-xsd-core-22.3.jar!/:na]
    at org.geotools.filter.v2_0.bindings.BinarySpatialOpTypeBinding$1.encode(BinarySpatialOpTypeBinding.java:70) ~[gt-xsd-fes-22.3.jar!/:na]
    at org.geotools.xsd.Encoder.encode(Encoder.java:727) ~[gt-xsd-core-22.3.jar!/:na]
    ... 103 common frames omitted

4

0 回答 0