You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
670 B

  1. <?php
  2. namespace OSM;
  3. class Point {
  4. public float $latitude;
  5. public float $longitude;
  6. public static function createFromArray(array $array)
  7. {
  8. $hasLat = isset($array['lat']);
  9. $hasLon = isset($array['lon']);
  10. assert($hasLat and $hasLon);
  11. $instance = new self();
  12. $instance->latitude = (float) $array['lat'];
  13. $instance->longitude = (float) $array['lon'];
  14. return $instance;
  15. }
  16. public function isSame(Point $other): bool {
  17. $isSame = (
  18. ($other->latitude === $this->latitude)
  19. and ($other->longitude === $this->longitude)
  20. );
  21. return $isSame;
  22. }
  23. }