Hello,

1.) I've implemented a coordinate transformation service using GeoTools 2.1 shown in the following code. It converts different CRSs to WGS84_3. Now, if I want to transform a point from "Gauß-Krüger 31", which is an Austrian CRS (EPSG:31295) using the Bessel 1841 ellipsoid, several Bursa-Wolf parameters have to be added. How can this be done using GeoTools 2.1? 2.) I also tried to tackle this problem with GeoTools 2.2 M2 by using the class "GeocentricTranslation". I also posted my (perhaps completely wrong) code below. Can I anyhow just incorporate the Bursa-Wolf parameters into my ordinary transformation service (s. ad 1.))? Or can't that be achieved by creating a CRS from a WKT?

ad 1.)
public static DirectPosition transformCoords(double x_co, double y_co, String sCRS)
{
   CoordinateReferenceSystem sourceCRS = null;
   CoordinateReferenceSystem targetCRS = null;
   MathTransform math = null;
   DirectPosition2D aPosition = new DirectPosition2D(x_co, y_co);
   DirectPosition transformedDP = null;
   try
   {
       CRSFactory crsFactory = FactoryFinder.getCRSFactory(null);

       String sourceWKT = CRSFromWKTCreator.generateWKT(sCRS);
String targetWKT = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";

       sourceCRS = crsFactory.createFromWKT(sourceWKT);
       targetCRS = crsFactory.createFromWKT(targetWKT);
DirectPosition2D transformedPos = new DirectPosition2D();

       math = CRS.transform(sourceCRS, targetCRS, true);
       transformedDP = math.transform(aPosition, null);
   }catch(NoSuchAuthorityCodeException nsace){nsace.printStackTrace();}
catch(FactoryException fe){fe.printStackTrace();}catch(TransformException te){te.printStackTrace();}

   return transformedDP;
}// transformCoords

ad 2.)
public static DirectPosition transformCoords(double x_co, double y_co, String sCRS)
{
   CoordinateReferenceSystem sourceCRS = null;
   MathTransform math = null;
   DirectPosition2D aPosition = new DirectPosition2D(x_co, y_co);
   DirectPosition transformedDP = null;

   try
   {
       CRSFactory crsFactory = FactoryFinder.getCRSFactory(null);

       String sourceWKT = CRSFromWKTCreator.generateWKT(sCRS);
String targetWKT = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";

       sourceCRS = crsFactory.createFromWKT(sourceWKT);
DefaultGeographicCRS geoCRS = org.geotools.referencing.crs.DefaultGeographicCRS.WGS84; DefaultCartesianCS cartCS = org.geotools.referencing.cs.DefaultCartesianCS.PROJECTED;

final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(targetWKT); final BursaWolfParameters toWGS84 = new BursaWolfParameters(DefaultGeodeticDatum.WGS84);
       toWGS84.dx = 577.326;
       toWGS84.dy = 90.129;
       toWGS84.dz = 463.919;
       toWGS84.ex = 5-137;
       toWGS84.ey = 1.474;
       toWGS84.ez = 5.297;
       toWGS84.ppm = 2.4232;
GeocentricTranslation geoTrans = new GeocentricTranslation(toWGS84); GeneralDirectPosition fromPos = new GeneralDirectPosition(x_co,y_co);
       GeneralDirectPosition toPos = new GeneralDirectPosition(targetCRS);

       transformedDP = geoTrans.transform(fromPos,toPos);
   }catch(NoSuchAuthorityCodeException nsace){nsace.printStackTrace();}
catch(FactoryException fe){fe.printStackTrace();}catch(TransformException te){te.printStackTrace();}

   return transformedDP;
}// transformCoords

Thank you very much for your help already in advance,
Bernd.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to