I am fairly new to the topic of Geo Transforms etc. After reading the tutorials, the mail list and generally googling my life away I developed the code below.
I am attempting to convert a GPS co-ordinate (WGS84) to an OSGB Easting and Northing (or UTM easting and northing)
The result I am getting : 1.4560519391270995E8, -2.111675354068688E7 does not seem to reflect any of the expected results
Have I missed a pre or post step ?
Andrew
=========================================================================================================================================================
public class transform01
{
private static String WGS84_WKT = "GEOGCS[\"WGS84\", DATUM[\"WGS84\", SPHEROID[\"WGS84\", 6378137.0, 298.257223563]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\",0.017453292519943295], AXIS[\"Longitude\",EAST], AXIS[\"Latitude\",NORTH]]";
private static String UTM_WKT = "PROJCS[\"UTM Zone 14N\", GEOGCS[\"WGS84\", DATUM[\"WGS84\", SPHEROID[\"WGS84\", 6378137.0, 298.257223563]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\",0.017453292519943295], AXIS[\"Longitude\",EAST], AXIS[\"Latitude\",NORTH]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"central_meridian\", -99.0], PARAMETER[\"latitude_of_origin\", 0.0], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000.0], PARAMETER[\"false_northing\", 0.0], UNIT[\"metre\",1.0], AXIS[\"x\",EAST], AXIS[\"y\",NORTH]]";
private static String OSGB_WKT = "PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],TOWGS84[375,-111,431,0,0,0,0],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4277\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",49],PARAMETER[\"central_meridian\",-2],PARAMETER[\"scale_factor\",0.999601272],PARAMETER[\"false_easting\",400000],PARAMETER[\"false_northing\",-100000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"E\",EAST],AXIS[\"N\",NORTH],AUTHORITY[\"EPSG\",\"27700\"]]";
public transform01()
{
try
{
CRSFactory crsFactory = FactoryFinder.getCRSFactory(null);
CoordinateOperationFactory coFactory = FactoryFinder.getCoordinateOperationFactory(null);
CoordinateReferenceSystem inCRS = crsFactory.createFromWKT(WGS84_WKT);
CoordinateReferenceSystem outCRS = crsFactory.createFromWKT(UTM_WKT);
CoordinateOperation co = coFactory.createOperation(inCRS, outCRS);
MathTransform mTransform = co.getMathTransform();
// Location from a GPS (WGS84)
//
// 53°23'53.24" N
// 1°26'30.06" W
//
// This should give a UTM Zone of 30, Easting of 603610 and Northing of 5917691
// This should give an OSG Easting and northing around 434902, 390849
//
DirectPosition oldPoint = new DirectPosition2D(53.398122, -1.441685); // Location above
DirectPosition newPoint = new DirectPosition2D();
System.err.println("Old Point: " + oldPoint.toString());
try
{
newPoint = mTransform.transform(oldPoint, null);
System.out.println("New Point :" + newPoint.toString());
}
catch (TransformException e) { }
}
catch (FactoryException e) { }
}
Internet communications are not secure and therefore South Yorkshire Police cannot accept responsibility for any changes made to this message after it was sent. This e-mail and any attachments may be confidential. They may contain privileged information and are intended for the intended recipient, if you are not the intended recipient please notify us immediately and delete the message and any attachments from your computer. Do not disclose, distribute, or retain this e-mail or any part of it. In the case of a privately generated e-mail, the opinion expressed may not be the opinion of the South Yorkshire Police We believe but do not warrant that this e- mail and any attachments are virus free. You must therefore take full responsibility for virus checking. South Yorkshire Police reserves the right to monitor all e-mail communications through their networks
