c# - Lambert 72 conversion to Lat/Lon pair -


i'm trying merge 2 databases consolidating 2 clients' websites. however, client has been using regular lat/lon pairs geolocation, while client b using lambert 72 (x/y) coordinates.

i've built script should convert these coordinates (as i'm not sure coordinates used in final merged database, i'm trying converting them either way). took snippets here: http://zoologie.umh.ac.be/tc/algorithms.aspx

please note coordinates mentioned below point locations in belgium.

i'm converting coordinates see if calculations correct, coordinates i'm getting seem way off. reference, center of belgium (north 50.84323737103243, east 4.355735778808594), i'd expect coordinates close these values.

i converted lambert 72 value (x: 151488250, y: 170492909) lat/lon pair, result is: (-87.538.... , -50.724....) way off expected values. if convert full circle (lambert->latlon->lambert , vice versa), same result values entered, know conversions @ least consistent , conversions perfect inversions of 1 another.

i tried online converter tools well, , give me same (-87.538.... , -50.724....) result.

since multiple sources yield same results, , conversions correct inversions of eachother, i'm figuring calculations correct, resulting values still need converted/offset further?

i consider myself sufficient in algebra, cartographic projections elude me.

can please shed light on this?

extra info

  • i hope posted in correct forum. i'm not sure put this mix of geography, mathematics , coding/conversion...
  • the mentioned lambert coordinates (x: 151488250, y: 170492909) point location in brussels, lat/lon result should very near (north 50.84323737103243, east 4.355735778808594).
  • please find conversion functions below:

    public static lambert72 latlon_to_lambert72(latlon latlon) {     var lat = latlon.lat;     var lng = latlon.lon;      double longref = 0.076042943;     //=4°21'24"983     double blamb = 6378388 * (1 - (1 / 297));     double acarre = math.pow(6378388, 2);     double ecarre = (acarre - math.pow(blamb, 2)) / acarre;     double klamb = 11565915.812935;     double nlamb = 0.7716421928;      double elamb = math.sqrt(ecarre);     double esur2 = elamb / 2;      //conversion radians     lat = (math.pi / 180) * lat;     lng = (math.pi / 180) * lng;      double esinlatitude = elamb * math.sin(lat);     double tanzdemi = (math.tan((math.pi / 4) - (lat / 2))) * (math.pow(((1 + (esinlatitude)) / (1 - (esinlatitude))), (esur2)));      double rlamb = klamb * (math.pow((tanzdemi), nlamb));      double teta = nlamb * (lng - longref);      double x = 0;     double y = 0;      x = 150000 + 0.01256 + rlamb * math.sin(teta - 0.000142043);     y = 5400000 + 88.4378 - rlamb * math.cos(teta - 0.000142043);      return new lambert72(x, y); }  public static latlon lambert72_to_latlon(lambert72 lb72) {     double x = lb72.x;     double y = lb72.y;      double longref = 0.076042943;     //=4°21'24"983     double nlamb = 0.7716421928;     double acarre = math.pow(6378388, 2);     double blamb = 6378388 * (1 - (1 / 297));     double ecarre = (acarre - math.pow(blamb, 2)) / acarre;     double klamb = 11565915.812935;      double elamb = math.sqrt(ecarre);     double esur2 = elamb / 2;      double tan1 = (x - 150000.01256) / (5400088.4378 - y);     double lambda = longref + (1 / nlamb) * (0.000142043 + math.atan(tan1));     double rlamb = math.sqrt(math.pow((x - 150000.01256), 2) + math.pow((5400088.4378 - y), 2));      double tanzdemi = math.pow((rlamb / klamb), (1 / nlamb));     double lati1 = 2 * math.atan(tanzdemi);      double esin = 0;     double mult1 = 0;     double mult2 = 0;     double mult = 0;     double latin = 0;     double diff = 0;      double lat = 0;     double lng = 0;      {         esin = elamb * math.sin(lati1);         mult1 = 1 - esin;         mult2 = 1 + esin;         mult = math.pow((mult1 / mult2), (elamb / 2));         latin = (math.pi / 2) - (2 * (math.atan(tanzdemi * mult)));         diff = latin - lati1;         lati1 = latin;     } while (math.abs(diff) > 2.77777e-08);      lat = (latin * 180) / math.pi;     lng = (lambda * 180) / math.pi;      return new latlon(lat, lng); } 

i author or page mention in post. don't know if have resolved problem lambert coordinates give not correct. think have divide them 1000. gives x=151488.250 , y=170492.909 possible coordinates , corresponding street in... brussels. careful choice of datum when converting , lat/lng values.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -