From: Martin S. <sp...@mo...> - 2005-05-30 17:13:01
|
Hello, I'm working with combined display of raster and geometry data. Until now I used GT2.1.M3 with the StyledMapPane, creating a RenderedGridCoverage from my GridCoverage and put it directly into the Renderer (received by StyledMapPane.getRenderer()). The geometries with RenderedGeometries as well. Because of different reasons (e.g. update problems after the grid changed, MapContext did not support Grids) I now want to switch to version 2.1.M5. Unfortunately the StyledMapPane isn's supported in this version anymore and trying to integrate the old 2.1.M3-StyledMapPane (from 'migrate' package) failed because of CoordinateSystem/CoordinateReferenceSystem-collisions in StyledMapRenderer.setMapContext(MapContext). So I tried to manage it without StyledMapPane: In an former email I read something about LiteRenderer and I tried the following (it's a combination of the GT-tutorial-sections "Maps and styles > RendererLite" and "Maps and styles > Putting everything together"): import java.awt.Graphics2D; import java.awt.Color; import java.awt.geom.AffineTransform; import javax.swing.JPanel; import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.map.MapContext; import org.geotools.map.DefaultMapContext; import org.geotools.renderer.lite.LiteRenderer; import org.geotools.styling.StyleBuilder; import org.geotools.styling.ColorMap; import org.geotools.styling.RasterSymbolizer; import org.geotools.styling.Style; ... JPanel mapPanel = ... // create an JPanel in a JFrame GridCoverage2D gridCoverage = ... // import the raster data which // contains only int-values from // 0 to 5 MapContext mapContext = new DefaultMapContext(); LiteRenderer renderer = new LiteRenderer(mapContext); // create a style for the grid StyleBuilder styleBuilder = new StyleBuilder(); ColorMap cm = styleBuilder.createColorMap( new double[] {0,1,2,3,4,5}, new Color[] {Color.WHITE,Color.BLUE,Color.RED,Color.YELLOW, Color.GREEN,Color.WHITE}, ColorMap.TYPE_VALUES ); RasterSymbolizer symb = styleBuilder.createRasterSymbolizer(cm,1); Style style = styleBuilder.createStyle(symb); // adding the grid and showing it mapContext.addLayer(gridCoverage,style); renderer.paint( (Graphics2D)mapPanel.getGraphics(), mapPanel.getBounds(), new AffineTransform() ); But nothing is displayed. What's wrong? The finest solution - in my opinion - is to re-integrate the StyledMapPane in version 2.1.M5. I think it is an fantastic class!! :-) Thanks for help Martin |