Ejemplo n.º 1
0
 /**
  * Convert a latitude, longitude height to x, y, z
  * Formula for transformation is taken from OS document
  * "A Guide to Coordinate Systems in Great Britain"
  *
  * @param LatLng $latLng
  * @return Cartesian
  */
 public static function fromLatLong(LatLng $latLng)
 {
     $a = $latLng->getRefEll()->getMaj();
     $eSquared = $latLng->getRefEll()->getEcc();
     $phi = deg2rad($latLng->getLat());
     $lambda = deg2rad($latLng->getLng());
     $v = $a / sqrt(1 - $eSquared * pow(sin($phi), 2));
     $x = ($v + $latLng->getH()) * cos($phi) * cos($lambda);
     $y = ($v + $latLng->getH()) * cos($phi) * sin($lambda);
     $z = ((1 - $eSquared) * $v + $latLng->getH()) * sin($phi);
     return new static($x, $y, $z, $latLng->getRefEll());
 }