I have tried 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 SpatialIndexFeatureCollection, 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?

On Tue, Feb 28, 2012 at 4:00 AM, Andrea Aime
<[email protected]>wrote:

> On Mon, Feb 27, 2012 at 4:36 PM, Zheng Xudong <[email protected]> wrote:
> > Hi all,
> >
> >     I use GeoTools 8.0M4 to load a shapefile contains about 10,000+
> >  geometries (each is a multiline). The code is just like the demo in
> > quickstart. But I found the rendering is a little slow, especially when I
> > zoom in/out or drag the map, and even sometimes the rendering couldn't
> > completed (leave some blank area).  What can I do to optimize the
> > performance of rendering, or the demo is already the best solution?
> The CPU
> > of my PC is Core Duo E6550, the memory is 2G, and the graphics card
> is ATI
> > Radeon HD 2400.
>
> If you can manage to load all features in memory there is, among the
> samples,
> one that loads all geometries in a in memory spatial index.
> Look for SpatialIndexFeatureSource
>
> Cheers
> Andrea
>
>
> --
> -------------------------------------------------------
> Ing. Andrea Aime
> GeoSolutions S.A.S.
> Tech lead
>
> Via Poggio alle Viti 1187
> 55054  Massarosa (LU)
> Italy
>
> phone: +39 0584 962313
> fax:      +39 0584 962313
> mob:    +39 339 8844549
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://www.youtube.com/user/GeoSolutionsIT
> http://www.linkedin.com/in/andreaaime
> http://twitter.com/geowolf
>
> -------------------------------------------------------


-- 
Zheng Xudong
State Key Laboratory of Software Development Environment
School of Computer Science and Engineer, BeiHang University
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to