Hi all,
I'm having some GeoTools projection troubles - so am going back to
first principles...
I've produced a code sample to familiarise myself with the world to
screen transforms, but I'm surprised by the results.
I'd be most grateful for a pointer on where I'm going wrong.
Here's the code:
===================
public void testOne() throws NoSuchAuthorityCodeException, FactoryException
{
MapContent mc = new MapContent();
// set a coordinate reference system
CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
mc.getViewport().setCoordinateReferenceSystem(crs);
// set a data area
DirectPosition2D tlDegs = new DirectPosition2D(5, 1);
DirectPosition2D brDegs = new DirectPosition2D(1, 5);
Envelope2D env = new Envelope2D(tlDegs, brDegs);
ReferencedEnvelope rEnv = new ReferencedEnvelope(env, crs);
mc.getViewport().setBounds(rEnv);
// set a screen area
mc.getViewport().setScreenArea(new Rectangle(0, 0, 800, 400));
// create a point to test
DirectPosition2D degs = new DirectPosition2D(3, 3);
// and results object
DirectPosition2D pixels = new DirectPosition2D();
// transform the test point
mc.getViewport().getWorldToScreen().transform(degs, pixels);
System.out.println("pixels:" + pixels);
}
===================
Surprisingly I'm getting this output:
=================
pixels:DirectPosition2D[299.0, -295.0]
=================
I would expect the location to be near the centre of the screen
coordinate space (since the supplied point is near the centre of the
data coordinate space).
Any guidance would be much appreciated,
Ian
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users