I am trying to create tiles given a collection of features.
Let's say I got two tiles per zoom level 1 and my features are about a small area near Berlin. I expect one of the two tiles empty and the other one filled with all the features with proper dimension (I expect to see something like a point because features are about a small area). What I get is an empty tile (correct) and a image 256 x 256 representing the features like it was a thumbnail, not a tile.
This is what I did so far to render features in a tile:
... MapContent content = new MapContent(); GTRenderer renderer = new StreamingRenderer(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); ReferencedEnvelope mapArea = featureCollection.getBounds(); Style shpStyle = SLD.createSimpleStyle(featureCollection.getSchema()); Layer layer = new FeatureLayer(featureCollection, shpStyle); content.addLayer(layer); renderer.setMapContent(content); Rectangle tileArea = new Rectangle(0, 0, 256, 256); renderer.paint(graphics, tileArea, mapArea); File fileToSave = File.createTempFile("mytesttile.png"); ImageIO.write(image, "png", fileToSave); ...
but this code produces a small (256 x 256) image of the given collection, not a tile. I am in short of time and I can't find some good docs or a working example. Can you point me to the right direction? I am using geotools version