Coordinate Conversion

Topics: General Topics
Aug 10, 2006 at 8:52 PM
I think there is a "correct" way to do this coordinate conversion using well known text, but I can't figure out how. Everything I'm setting in the parameters I copied from the well known text string at the bottom.

Could someone show me how to make the conversion without hacking the sources?

(To make this work I changed TransverseMercator and MapProjection from internal to public.)

private void btProject_Click(object sender, EventArgs e)
//CoordinateSystemFactory cFac = new CoordinateSystemFactory();
//ICoordinateSystem bermuda = cFac.CreateFromWkt(txtWKT.Text);

List<ProjectionParameter> parameters = new List<ProjectionParameter>(5);
parameters.Add(new ProjectionParameter("latitudeoforigin", 32));
parameters.Add(new ProjectionParameter("central_meridian", -64.75));
parameters.Add(new ProjectionParameter("scale_factor", 1));
parameters.Add(new ProjectionParameter("false_easting", 550000));
parameters.Add(new ProjectionParameter("false_northing", 100000));
//gleened from Ellipsoid
//_SemiMinorAxis = (1.0 - (1.0 / InverseFlattening)) * semiMajorAxis
parameters.Add(new ProjectionParameter("semi_minor", (1.0 - (1.0 / 298.257223563)) * 6378137.0));
parameters.Add(new ProjectionParameter("semi_major", 6378137.0));

TransverseMercator projection = new TransverseMercator(parameters);

SharpMap.Geometries.Point inpt = new SharpMap.Geometries.Point(Convert.ToDouble(txtLon.Text),Convert.ToDouble(txtLat.Text));
SharpMap.Geometries.Point outpt = projection.DegreesToMeters(inpt);
this.txtNorthing.Text = outpt.Y.ToString();
this.txtEasting.Text = outpt.X.ToString();



Aug 14, 2006 at 5:04 PM
You must use the factories to make a projection, but use the corrent name of the mercator projection (no need to hack it).
The correct projection names are listed in the last column here:

What was wrong with using the WKT parsers that you have commented out? Using that will save you a lot of troubles.

Furthermore, you might want to check the Wiki regarding transformations here: