I have we have to develop a GIS web application from the scratch using
geotools library 2.6
I developed a servlet dispatching png e openlayers like client.
I noticed sometimes my map is rotated,  so using a geotools example I tried
to save the png on the fylesystem
and the map still looks rotated (flipped horizontally and rotated 90°) while
on JMapFrame looks good , this is the code I use. Please help !! :-)

public class Quickstart {

    


    public static void main(String[] args) throws Exception {
     
        java.util.Map<Object,Object> params = new
java.util.HashMap<Object,Object>();
        params.put(PostgisDataStoreFactory.DBTYPE.key, "postgis");
        params.put(PostgisDataStoreFactory.HOST.key, "localhost");
        params.put(PostgisDataStoreFactory.PORT.key, 5432);
        params.put(PostgisDataStoreFactory.SCHEMA.key, "public");
        params.put(PostgisDataStoreFactory.DATABASE.key, "IPER_MOB");
        params.put(PostgisDataStoreFactory.USER.key, "postgres");
        params.put(PostgisDataStoreFactory.PASSWD.key, "password");
        DataStore dataStore=DataStoreFinder.getDataStore(params);
        FeatureSource aa = dataStore.getFeatureSource("pisa_linee");
       
        MapContext map2 = new CustomMapContext();        
        map2.setTitle("Quickstart");
        map2.addLayer(aa, null);
       
        
        ReferencedEnvelope bbox = new
ReferencedEnvelope(10.2744388580322,10.5848665237427,43.4382019042969,43.7542610168457,CRS.decode("EPSG:4269"));
       
map2.setAreaOfInterest((ReferencedEnvelope)bbox,CRS.decode("EPSG:4269"));   
        GTRenderer renderer = new StreamingRenderer();                
        renderer.setContext( map2);        
        Rectangle imageBounds=null;
        try{
            int imageWidth = 800;
            imageBounds = new Rectangle(0, 0, imageWidth, 600);                 
         
        }catch(Exception e){
            System.out.println("Eccezione "+e);
        }               
        BufferedImage image = new
BufferedImage(imageBounds.width,imageBounds.height,BufferedImage.BITMASK);
        Graphics2D gr           = image.createGraphics();
        gr.setPaint(Color.WHITE);
        gr.fill(imageBounds);
       
      
        try {
                renderer.paint(gr, imageBounds, map2.getAreaOfInterest());      
        
            File fileToSave = new File("c:\\daddexstuff\\tmp\\test.jpg");
            ImageIO.write(image, "jpeg", fileToSave);
        }catch(IOException e){
            
        }        
        JMapFrame.showMap(map2);
        
    }
}       



-- 
View this message in context: 
http://n2.nabble.com/image-problem-tp4512874p4512874.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to