From: Jesse E. <je...@re...> - 2006-07-05 17:51:10
|
You can also use the Shapefile renderer it implements the GT2Renderer interface and is highly optimized for performance. It only works with Shapefiles though so keep that in mind. Jesse On 5-Jul-06, at 5:52 AM, Vanmeulebrouk, Bas wrote: > Hi all, > > Using GeoTools, I have written an application to view shape files. > People using this application are complaining about the performance. > Using a profiler and a fairly simple shape file, I have done some > tests > and these show it takes two seconds on average to zoom in on a small > area. According to the profiler, most of this time is spent in > org.geotools.renderer.lite.LiteRenderer.Paint. Does anyone know how I > can improve shape file performance? > > See below for the code I use to add shape files and draw the map. I am > using GeoTools 2.1. > > Kind regards, > > Bas Vanmeulebrouk. > > // Add shape file to MapContext > public void AddShapeFile(String aShapeFileName, String aName) throws > Exception { > FeatureSource fSource = CreateFeatureSource(aShapeFileName); > if (fSource != null) { > // Create a style > Style style = CreateStyleFromXML(polygonStyleXMLString); > // Create a MapLayer > MapLayer ml = new DefaultMapLayer(fSource, style, > aName); > // New layers are added on top, at index getLayerCount > > getMapContext().addLayer(getMapContext().getLayerCount(), ml); > } > } > > // Draw the map using a BufferedImage > public void RefreshBufferedImage() { > // Create a new BufferedImage to hold a new bitmap > BufferedImage bi = new BufferedImage(getMapPanel().getWidth(), > getMapPanel().getHeight(), BufferedImage.TYPE_INT_ARGB) { > { > paint((Graphics2D) getGraphics()); > } > > private void paint(final Graphics2D graphics2D) { > CreateRenderer().paint(graphics2D, new > Rectangle(0, 0, getWidth(), getHeight()), CreateTransFormation()); > } > }; > > setBufferedImage(bi); > } > > Using Tomcat but need to do more? Need to support web services, > security? > Get stuff done quickly with pre-integrated technology to make your > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel? > cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Geotools-gt2-users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |