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.

32 lines
674 B

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