Wegpunktprojektion

Dieses PHP-Script berechnet einen neuen Punkt, ausgehend von Startkoordinaten (Latitude/Breitengrad & Longitude/Längengrad), einem Winkel und einer Distanz in Kilometern.

<?php
/*
    This Software calculates a new point by given start lat/lon, angle and distance in km

    Copyright (C) 2020  Guido Richter / tintenkobold.de

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License [http://www.gnu.org/licenses/] for more details.
*/

// calculate destination point, starting from $x=LON $y=LAT, distance of $distance_in_km km with angle of $angle

function waypointprojection($x,$y,$distance_in_km,$angle)
{
	$lat1 	= deg2rad($y);
	$lon1 	= deg2rad($x);
	$alpha 	= deg2rad($angle);
	$dist 	= ($distance_in_km/1.852)*M_PI/(180*60);
	$lat 	= asin(sin($lat1)*cos($dist)+cos($lat1)*sin($dist)*cos($alpha));
	$lon 	= ($lon1-asin(sin($alpha)*sin($dist)/cos($lat))+M_PI % 2*M_PI)-M_PI;
	return array(rad2deg($lon),rad2deg($lat));
}

?>

Schreibe einen Kommentar