From: Zheng X. <do...@gm...> - 2012-02-28 06:07:12
|
Say about the SpatialIndexFeatureSource, I encountered another problem. I create a empty SpatialIndexFeatureCollection for another layer, and will add features later on but display first. 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 main 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); Why? If I use ListFeatureCollecition, there is no problem, but I think it may reduce the performance. How to solve it? On Tue, Feb 28, 2012 at 4:00 AM, Andrea Aime <and...@ge...>wrote: > On Mon, Feb 27, 2012 at 4:36 PM, Zheng Xudong <do...@gm...> 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 |