Hi;

I am trying to generate image according to the tile coordinate by geotools,
this is the code:

* public static void main(String[] args) throws IOException,
FactoryException, CQLException {*
* long st = System.currentTimeMillis();*
 * FileDataStore store = new ShapefileDataStore(new
File("data/landuase.shp").toURI().toURL());*

* Style style = createPolygonStyle();*
* Layer layer = new FeatureLayer(store.getFeatureSource(), style);*

* MapContent map = new MapContent();*
* map.addLayer(layer);*


* double[] box = getWGS84LngLat(9275, 21747, 16);*
* ReferencedEnvelope bbox = new ReferencedEnvelope(box[0], box[2], box[1],
box[3], CRS.decode("EPSG:4326"));*


 * //arender*
* Rectangle paintArea = new Rectangle(0, 0, 256, 256);*
* BufferedImage image = new BufferedImage(paintArea.width,
paintArea.height, BufferedImage.TYPE_INT_RGB);*
* Graphics2D gr = image.createGraphics();*
* gr.setPaint(Color.WHITE);*
* gr.fill(paintArea);*


* GTRenderer renderer = new StreamingRenderer();*
* renderer.setMapContent(map);*
* renderer.paint(gr, paintArea, bbox);*


 * File fileToSave = new File("D:/t.png");*
* ImageIO.write(image, "png", fileToSave);*

* long ed = System.currentTimeMillis();*
* System.out.println("complete:" + (ed - st));*
* }*
 * private static double[] getWGS84LngLat(int x, int y, int zoom) {*
* double padding = 0;*
* double left = (x - padding) * (360.0 / (1 << (zoom + 1))) - 180;*
* double right = (x + 1 + padding) * (360.0 / (1 << (zoom + 1))) - 180;*
* double top = 90 - (y - padding) * (180.0 / (1 << zoom));*
* double bottom = 90 - (y + 1 + padding) * (180.0 / (1 << zoom));*
* return new double[]{left, bottom, right, top};*
* }*

However the above code does not work for the calculated bbox. Once I set:

bbox = map.getMaxBounds()

I will get the correct result.

What's the problem?
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to