function national_to_wgs84($e, $n, $reference_index, $usehermert = true)
 {
     require_once 'geograph/conversionslatlong.class.php';
     $conv = new ConversionsLatLong();
     $latlong = array();
     if ($reference_index == 1) {
         $latlong = $conv->osgb36_to_wgs84($e, $n);
     } else {
         if ($reference_index == 2) {
             $latlong = $conv->irish_to_wgs84($e, $n, $usehermert);
         }
     }
     return $latlong;
 }
Beispiel #2
0
function reproject($x, $y, $inProj, $outProj)
{
    // Project to wgs84 latlon
    $inProj = strtoupper($inProj);
    $outProj = strtoupper($outProj);
    switch ($inProj) {
        case 'GOOGLE':
        case 'EPSG:900913':
        case '900913':
        case '3785':
        case 'EPSG:3785':
        case '3857':
        case 'EPSG:3857':
            $ll = sphmerc_to_ll($x, $y);
            break;
        case 'OSGB':
        case '27700':
        case 'EPSG:27700':
            /*
            $ll = gr_to_wgs84_ll($x,$y);
            $ref = new OSRef($x,$y);
            $latlng = OSRefToLatLng($ref);
            $ll = array("lon"=>$latlng->lng,"lat"=>$latlng->lat);
            */
            // 17/4/13 now use Barry Hunter's geograph code, seems to be
            // most accurate of these
            $c = new ConversionsLatLong();
            $ll0 = $c->osgb36_to_wgs84($x, $y);
            $ll = array("lon" => $ll0[1], "lat" => $ll0[0]);
            break;
        default:
            $ll = array("lon" => $x, "lat" => $y);
    }
    // Project from wgs84 latlon to output format
    switch ($outProj) {
        case 'GOOGLE':
        case 'EPSG:900913':
        case '900913':
        case '3785':
        case 'EPSG:3785':
        case '3857':
        case 'EPSG:3857':
            $sm = ll_to_sphmerc($ll['lon'], $ll['lat']);
            $x = $sm['e'];
            $y = $sm['n'];
            break;
        case 'OSGB':
        case '27700':
        case 'EPSG:27700':
            /*
            $gr = wgs84_ll_to_gr($ll['lon'],$ll['lat']);
            $x = $gr['e'];
            $y = $gr['n'];
            $ll = new LatLng($ll['lat'],$ll['lon']);
            $gr = LatLngToOSRef($ll);
            $x = $gr->easting;
            $y = $gr->northing;
            */
            // 17/4/13 now use Barry Hunter's geograph code, seems to be
            // most accurate of these
            $c = new ConversionsLatLong();
            $gr = $c->wgs84_to_osgb36($ll['lat'], $ll['lon']);
            $x = $gr[0];
            $y = $gr[1];
            break;
        default:
            $x = $ll['lon'];
            $y = $ll['lat'];
            break;
    }
    return array($x, $y);
}
Beispiel #3
0
 function national_to_wgs84($e, $n, $reference_index, $usehermert = true)
 {
     $conv = new ConversionsLatLong();
     $latlong = array();
     if ($reference_index == 1) {
         $latlong = $conv->osgb36_to_wgs84($e, $n);
     } elseif ($reference_index == 2) {
         $latlong = $conv->irish_to_wgs84($e, $n, $usehermert);
     }
     return $latlong;
 }
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
require_once 'geograph/global.inc.php';
require_once 'geograph/conversions.class.php';
require_once 'geograph/conversionslatlong.class.php';
init_session();
$conv = new ConversionsLatLong();
$smarty = new GeographPage();
$template = 'stuff_conversion.tpl';
$cacheid = '';
if ($_GET['To']) {
    //to lat/long
    if ($_GET['datum'] == 'osgb36') {
        $latlong = $conv->osgb36_to_wgs84($_GET['e'], $_GET['n']);
    } else {
        if ($_GET['datum'] == 'irish') {
            list($usec, $sec) = explode(' ', microtime());
            $querytime_before = (double) $usec + (double) $sec;
            for ($q = 0; $q < 200; $q++) {
                $latlong = $conv->irish_to_wgs84($_GET['e'], $_GET['n'], $_GET['usehermert']);
            }
            $latlong = $conv->irish_to_wgs84($_GET['e'], $_GET['n'], $_GET['usehermert']);
            list($usec, $sec) = explode(' ', microtime());
            $querytime_after = (double) $usec + (double) $sec;
            $smarty->assign('querytime', "200 conversions took " . number_format($querytime_after - $querytime_before, 4) . " Seconds");
        } else {
            //todo: make an educated guess - basically if could be irish then use that otherwise gb ?!? - probably not...
        }
    }