geoservergeotoolsopengis

How to output features into a tile with geotools


I'm sorry to ask a question here. I'm new to geotools. Now I need a function to output features into a tile. Function is defined as follows:

public Image getTile(FeatureCollection features,Style style,double minX,double minY,double maxX,double maxY,double resolution){

    return ;
}

Can someone give me some sample code or advice? Thanks in advance.


Solution

  • Basically you'll need to generate an Image that is the right size and pass it's graphic2D to the renderer in the same way that any other rendering is done. So you'll need to calculate the bounding box and call GTRenderer.paint().

    There is a whole bunch of other stuff you'll really want to consider like metatiling, label caching etc.

    You may well find looking at GeoWebCache useful either to create your tiles or at least to give you some clues as to how to proceed.