<?php

namespace OSM;

class Point {

    public float $latitude;
    public float $longitude;

    public static function createFromArray(array $array)
    {
        $hasLat = isset($array['lat']);
        $hasLon = isset($array['lon']);
        assert($hasLat and $hasLon);

        $instance = new self();
        $instance->latitude = (float) $array['lat'];
        $instance->longitude = (float) $array['lon'];

        return $instance;
    }

    public function isSame(Point $other): bool {
        $isSame = (
            ($other->latitude === $this->latitude)
            and ($other->longitude === $this->longitude)
        );
        return $isSame;
    }
}