Ejemplo n.º 1
0
 /**
  * Compare 2 coordinates. It ignores the altitude.
  *
  * @param LatLng $other          Another coordinate.
  * @param int    $maxMargin      Margin of tolerance.
  * @param bool   $ignoreAltitude If true only longitude and latitude are compared.
  *
  * @return bool
  */
 public function equals(LatLng $other, $maxMargin = null, $ignoreAltitude = true)
 {
     if ($maxMargin !== null) {
         $margin = max(abs($this->getLatitude() - $other->getLatitude()), abs($this->getLongitude() - $other->getLongitude()));
         if (!$ignoreAltitude) {
             $margin = max($margin, abs($this->getAltitude() - $other->getLongitude()));
         }
         return $margin <= $maxMargin;
     }
     if ($this->getLatitude() !== $other->getLatitude()) {
         return false;
     }
     if ($this->getLongitude() !== $other->getLongitude()) {
         return false;
     }
     if (!$ignoreAltitude && $this->getAltitude() !== $other->getAltitude()) {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Compare 2 coordinates. It ignores the altitude.
  *
  * @param LatLng $other          Another coordinate.
  * @param bool   $ignoreAltitude If true only longitude and latitude are compared.
  *
  * @return bool
  */
 public function equals(LatLng $other, $ignoreAltitude = true)
 {
     if ($this->getLatitude() !== $other->getLatitude()) {
         return false;
     }
     if ($this->getLongitude() !== $other->getLongitude()) {
         return false;
     }
     if (!$ignoreAltitude && $this->getAltitude() !== $other->getAltitude()) {
         return false;
     }
     return true;
 }