发布于2024-11-23 21:58 阅读(619) 评论(0) 点赞(8) 收藏(0)
出于性能原因,我遵循了http://docs.geotools.org/latest/userguide/library/main/collection.html#performance-options的建议,使用 SpatialIndexFeatureCollection。
当呈现这些功能时,会抛出 UnsupportedOperationException。
该层的初始化如下
File shpFile = ...;
FileDataStore dataStore = FileDataStoreFinder.getDataStore(shpFile);
SimpleFeatureSource featureSource = dataStore.getFeatureSource();
SpatialIndexFeatureCollection collection = new SpatialIndexFeatureCollection(featureSource.getSchema());
collection.addAll(featureSource.getFeatures());
FeatureLayer layer = new FeatureLayer
( new SpatialIndexFeatureSource(collection)
, ... // create SLD here
, "Title");
抛出的异常是
06.06.2013 13:04:56 org.geotools.renderer.lite.StreamingRenderer fireErrorEvent
SCHWERWIEGEND: null
java.lang.UnsupportedOperationException
at org.geotools.data.collection.SpatialIndexFeatureCollection.subCollection(SpatialIndexFeatureCollection.java:128)
at org.geotools.data.collection.SpatialIndexFeatureSource.getFeatureCollection(SpatialIndexFeatureSource.java:142)
at org.geotools.data.collection.SpatialIndexFeatureSource.getFeatures(SpatialIndexFeatureSource.java:115)
at org.geotools.data.collection.SpatialIndexFeatureSource.getFeatures(SpatialIndexFeatureSource.java:65)
at org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:2023)
at org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:829)
at org.geotools.swt.SwtMapPane.handleEvent(SwtMapPane.java:1186)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1564)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4585)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at de.viate.matiyari.rcp.ui.application.DefaultApplication.start(DefaultApplication.java:158)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Geotools 版本是 9.2。
出了什么问题?
谢谢
迈克尔
这虽然不能解决您的问题,但可以解释以下原因:
从SpatialIndexFeatureCollection.java中提取:
public SimpleFeatureCollection subCollection(Filter filter) {
throw new UnsupportedOperationException();
}
我猜这个方法还没有实现。
编辑:我所做的如下:
File = ...;//the shapefile
Map<Object, Object> map = new HashMap<>();
map.put( "url", file.toURI().toURL() );
DataStore dataStore = DataStoreFinder.getDataStore(map);
List<Name> names = dataStore.getNames();
SimpleFeatureSource featureSource = dataStore.getFeatureSource(names.get(0));
SimpleFeatureCollection collection = featureSource.getFeatures(filter);
SpatialIndexFeatureCollection spatialCollection = new SpatialIndexFeatureCollection(collection);
// Fast spatial Access
SimpleFeatureSource source = DataUtilities.source( spatialCollection );
SimpleFeatureCollection features = source.getFeatures();
// use features.features();
作者:黑洞官方问答小能手
链接:http://www.javaheidong.com/blog/article/693955/dcad7713b575cd937850/
来源:java黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 java黑洞网 All Rights Reserved 版权所有,并保留所有权利。京ICP备18063182号-2
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!