I wrote a simple test application. Which I would like to render in 
mercator projection.
But it does not do It!
I found US states map in geoserver installation (it consists of: 
states.dbf, states.prj, states.shp, states.shx)
On this image: http://ds.azcltd.com/quickStart/compareProjectionsUSA.gif 
you can see:
Left part - google map image
Middle part - my test program image if states.prj removed
Right part - my test program image if states.prj does NOT removed

My test application looks like this code:
===========================================================
   public static void main(String[] args) throws Throwable {
//.... skipped JFrame initialization
//.... skipping grid features creation; they are created without CRS

       ShapefileDataStore shapefileDataStore = new 
ShapefileDataStore(new URL(QuickStart.class.getResource("/").toString() 
+ "../resources/1/states.shp"));
       Style style = //....skipped  styles creation

       MapContext map = new DefaultMapContext(getCRS());
       
map.addLayer(shapefileDataStore.getFeatureSource(shapefileDataStore.getTypeNames()[0]),
 
style);
       map.addLayer(aFeatureCollection, aStyle); //this is a grid features

       StreamingRenderer renderer = new StreamingRenderer();
       renderer.setContext(map);
       renderer.paint((Graphics2D) p.getGraphics(), new Rectangle(0, 0, 
256, 256), new ReferencedEnvelope(new Envelope(-180, 0, 0, 
85.0511287798066), getCRS()));
   }

   public static CoordinateReferenceSystem getCRS() throws Throwable {
           String wkt1 = "<<--Skipped WKT of 900913 Google Mercator 
projection you can find it in my previous post:
                                                     
http://www.nabble.com/how-to-change-projection-td16494337.html-->>";
           return CRS.parseWKT(wkt1);
   }
===========================================================

I can not understand what can be wrong here. Projection file is not 
modified. I've used it "as is". I'am starting to feel my self like an idiot!
Somebody, please, help me!
Can you find a error in 10 lines of code?
How can I get Google Mercator projection?

Regards,
Dennis


Andrea Aime wrote:
> The feature source should be true to the actual data srs. So in your
> case I guess it should be 4326. You can to fix your source data.
> What is it, shapefile, postgis?
>
> Cheers
> Andrea
>
>   

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to