Hi there,

I'm trying to transform a WGS84-coordinate into a Lambert-coordinate 
("LCC_Europe"?!) using GeoTools2.
The WGS84-coordinate originates from the OpenGeoDB 
(http://sourceforge.net/projects/opengeodb/) which covers the coordinates of 
German locations.

For example:

Latitude 50.7333 - Longitude 7.1 (WGS84)

  ... should be (approximately) ...

x 280982 - y 189630 (LCC)

I already studied the GeoTools-API and checked the referencing-demo 
("TransformationConsole")... but without success.
I'm no GIS-expert ... so I guess I'm missing some fundamental 
functions/principles.

I tried my luck with this code:


       try
       {
           // the default coordinate-systems ...
           DefaultGeographicCRS geographicCRS = DefaultGeographicCRS.WGS84;
           DefaultCartesianCS cartesianCS = DefaultCartesianCS.GENERIC_2D;

           // the factories ...
           DefaultMathTransformFactory mathTransformFactory = new 
DefaultMathTransformFactory();
           FactoryGroup factoryGroup = FactoryGroup.createInstance(null);
           CoordinateOperationFactory coordinateOperationFactory = 
FactoryFinder.getCoordinateOperationFactory(null);

           // prepare the transformation ...

           ParameterValueGroup lambertParameters = 
mathTransformFactory.getDefaultParameters("Lambert_Conformal_Conic_1SP");
           DefiningConversion conversion = new 
DefiningConversion("LambertConversion", lambertParameters);

           Map<String, Object> props = new HashMap<String, Object>();
           props.put(IdentifiedObject.NAME_KEY, "projected crs name");

           ProjectedCRS projectedCRS = 
factoryGroup.createProjectedCRS(props, geographicCRS, conversion, 
cartesianCS);

           CoordinateOperation coordinateOperation = 
coordinateOperationFactory.createOperation(geographicCRS, projectedCRS);

           MathTransform forward = coordinateOperation.getMathTransform();
           MathTransform inverse = forward.inverse();

           // the longitude and latitude values obtained from opengeodb
           double[] longitudeAndLatitude = new double[] { 50.7, 7.1 };

           // the converted lcc-coordinates
           double[] xAndY = new double[2];

           // transform ...

           forward.transform(longitudeAndLatitude, 0, xAndY, 0, -1);
           System.out.println("xAndY: " + Arrays.toString(xAndY));

           inverse.transform(xAndY, 0, longitudeAndLatitude, 0, -1);
           System.out.println("longitudeAndLatitude: " + 
Arrays.toString(longitudeAndLatitude));
       }
       catch (Throwable t)
       {
           
Logger.getLogger(TransformationExample.class.getName()).log(Level.INFO, 
"Caught exception: ", t);
       }


But it leads to the following exception:

       org.opengis.referencing.FactoryException: Latitudes 0°00.0'N and 
0°00.0'N are opposite.

I probably forgot to set some additional parameters?!
Could anybody help me out with this?

Any hints or even a working code-snipplet would really be much appreciated.

Thanks in advance!

Best regards,

Achim

_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit 
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! 
http://desktop.msn.de/ Jetzt gratis downloaden!


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to