I have got some javascript code and I'd like to convert this to C#. I have no idea of the best way to structure this or if there is an easy way to convert the code.
A sample of this code is shown below.
// ellipse parameters
var e = { WGS84: { a: 6378137, b: 6356752.3142, f: 1/298.257223563 },
Airy1830: { a: 6377563.396, b: 6356256.910, f: 1/299.3249646 },
Airy1849: { a: 6377340.189, b: 6356034.447, f: 1/299.3249646 } };
// helmert transform parameters
var h = { WGS84toOSGB36: { tx: -446.448, ty: 125.157, tz: -542.060, // m
rx: -0.1502, ry: -0.2470, rz: -0.8421, // sec
s: 20.4894 }, // ppm
OSGB36toWGS84: { tx: 446.448, ty: -125.157, tz: 542.060,
rx: 0.1502, ry: 0.2470, rz: 0.8421,
s: -20.4894 } };
function convertOSGB36toWGS84(p1) {
var p2 = convert(p1, e.Airy1830, h.OSGB36toWGS84, e.WGS84);
return p2;
}
The full code can be downloaded from: Javascript Grid Code
EDIT: Thank you all so far for your help; I guess the second requirement is that the reminder of the code in the link can be converted. The focus of the snippet was on the Anonymous Types.
Your JavaScript snippet is creating anonymous types. You can do the same thing in C#:
var e = new
{
WGS84 = new { a = 6378137, b = 6356752.3142, f = 1 / 298.257223563 },
Airy1830 = new { a = 6377563.396, b = 6356256.910, f = 1 / 299.3249646 },
Airy1849 = new { a = 6377340.189, b = 6356034.447, f = 1 / 299.3249646 }
};
var h = new
{
WGS84toOSGB36 = new
{
tx = -446.448, ty = 125.157, tz = -542.060, // m
rx = -0.1502, ry = -0.2470, rz = -0.8421, // sec
s = 20.4894 // ppm
},
OSGB36toWGS84 = new
{
tx = 446.448,
ty = -125.157,
tz = 542.060,
rx = 0.1502,
ry = 0.2470,
rz = 0.8421,
s = -20.4894
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With