Hi all,

    For speeding up the rendering, I tried to use the
SpatialIndexFeatureSource, but encountered the following problems:

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:1973)
 at
org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:804)
at org.geotools.swing.RenderingTask.call(RenderingTask.java:106)
 at org.geotools.swing.RenderingTask.call(RenderingTask.java:41)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
 at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
 at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

I construct the SpatialIndexFeatureSource from the a shapefile, like that:

        FileDataStore store = FileDataStoreFinder.getDataStore(file);
 SimpleFeatureSource shpFeatureSource = store.getFeatureSource();
SimpleFeatureCollection oldCollection = shpFeatureSource.getFeatures();
 SpatialIndexFeatureCollection newCollection = new
SpatialIndexFeatureCollection(oldCollection);
indexedFeatureSource = new SpatialIndexFeatureSource(newCollection);

does it right? Or any other things I need to do?

    And I also have another problem with SpatialIndexFeatureCollection. I
create a empty SpatialIndexFeatureCollection and add it to layers, I will
add features later on but display first. But it throw the following
exception:

java.lang.NullPointerException
at com.vividsolutions.jts.geom.Envelope.init(Envelope.java:253)
at com.vividsolutions.jts.geom.Envelope.<init>(Envelope.java:186)
 at
org.geotools.geometry.jts.ReferencedEnvelope.<init>(ReferencedEnvelope.java:248)
at
org.geotools.data.collection.SpatialIndexFeatureCollection.getBounds(SpatialIndexFeatureCollection.java:235)
 at
org.geotools.data.collection.SpatialIndexFeatureSource.getBounds(SpatialIndexFeatureSource.java:89)
at org.geotools.map.FeatureLayer.getBounds(FeatureLayer.java:195)
 at org.geotools.map.MapContent.getMaxBounds(MapContent.java:600)
at org.geotools.map.MapContent.getViewport(MapContent.java:665)
 at
org.geotools.swing.AbstractMapPane.doSetMapContent(AbstractMapPane.java:539)
at org.geotools.swing.AbstractMapPane.<init>(AbstractMapPane.java:205)
 at org.geotools.swing.JMapPane.<init>(JMapPane.java:77)
at org.geotools.swing.JMapPane.<init>(JMapPane.java:66)
 at org.geotools.swing.JMapFrame.<init>(JMapFrame.java:196)
at edu.buaa.taxi.ui.MapMatcherUI.init(MapMatcherUI.java:240)
 at edu.buaa.taxi.ui.MapMatcherUI.<init>(MapMatcherUI.java:128)
at edu.buaa.taxi.ui.MapMatcherUI.main(MapMatcherUI.java:158)

here is some code:
        MapContent map = new MapContent();
        ...
        SimpleFeatureType locationType = builder.buildFeatureType();
        SimpleFeatureCollection layer2FeatureCollection = new
SpatialIndexFeatureCollection(locationType);
        Style style2 = styleFactory.createStyle();
        ...
        Layer layer2 = new FeatureLayer(layer2FeatureCollection, style2);
        map.layers().add(layer2);
        JMapFrame mapFrame = new JMapFrame(map);

if I use ListFeatureCollecition, there is no problem, but I think it may
reduce the performance. How to solve it?


    Thank you and best regards!

-- 
Zheng Xudong
State Key Laboratory of Software Development Environment
School of Computer Science and Engineer, BeiHang University
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to