SQL function to convert UK OS coordinates from easting/northing to longitude and latitude

前端 未结 6 1227
南方客
南方客 2021-02-10 10:51

Please can someone post a SQL function to convert easting/northing to longitude/latitude. I know it\'s incredibly complicated but I haven\'t found anyone who has documented it i

6条回答
  •  被撕碎了的回忆
    2021-02-10 11:35

    If anyone's interested in non-SQL solution I strongly recommend using this http://www.howtocreate.co.uk/php/gridref.php PHP/JavaScript class.

    One important thing to mention here is the library supports Helmert transformation.

    PHP

    $grutoolbox = Grid_Ref_Utils::toolbox();
    $source_coords = Array(54.607720,-6.411990);
    //get the ellipsoids that will be used
    $Airy_1830 = $grutoolbox->get_ellipsoid('Airy_1830');
    $WGS84 = $grutoolbox->get_ellipsoid('WGS84');
    $Airy_1830_mod = $grutoolbox->get_ellipsoid('Airy_1830_mod');
    //get the transform parameters that will be used
    $UK_to_GPS = $grutoolbox->get_transformation('OSGB36_to_WGS84');
    $GPS_to_Ireland = $grutoolbox->get_transformation('WGS84_to_Ireland65');
    //convert to GPS coordinates
    $gps_coords = $grutoolbox->Helmert_transform($source_coords,$Airy_1830,$UK_to_GPS,$WGS84);
    //convert to destination coordinates
    print $grutoolbox->Helmert_transform($source_coords,$WGS84,$GPS_to_Ireland,$Airy_1830_mod,$grutoolbox->HTML);
    

    JavaScript

    var grutoolbox = gridRefUtilsToolbox();
    var sourceCoords = [54.607720,-6.411990];
    //get the ellipsoids that will be used
    var Airy1830 = grutoolbox.getEllipsoid('Airy_1830');
    var WGS84 = grutoolbox.getEllipsoid('WGS84');
    var Airy1830Mod = grutoolbox.getEllipsoid('Airy_1830_mod');
    //get the transform parameters that will be used
    var UKToGPS = grutoolbox.getTransformation('OSGB36_to_WGS84');
    var GPSToIreland = grutoolbox.getTransformation('WGS84_to_Ireland65');
    //convert to GPS coordinates
    var gpsCoords = grutoolbox.HelmertTransform(sourceCoords,Airy1830,UKToGPS,WGS84);
    //convert to destination coordinates
    element.innerHTML = grutoolbox.HelmertTransform(sourceCoords,WGS84,GPSToIreland,Airy1830Mod,grutoolbox.HTML);
    

提交回复
热议问题