PHP Classes

File: src/Point.php

Recommend this page to a friend!
  Classes of Joseluis Laso   jlaso GPS   src/Point.php   Download  
File: src/Point.php
Role: Class source
Content type: text/plain
Description: Class source
Class: jlaso GPS
Calculate the distance between geographic points
Author: By
Last change: Update of src/Point.php
Date: 4 months ago
Size: 976 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);

namespace
JLaso\Gps;

/**
 * Class Point
 * @package JLaso\Gps
 * @author Joseluis Laso <jlaso@joseluislaso.es>
 */

class Point
{
   
/** @var float */
   
protected $longitude;
   
/** @var float */
   
protected $latitude;

    function
__construct(float $latitude, float $longitude)
    {
       
$this->latitude = $latitude;
       
$this->longitude = $longitude;
    }

    public function
setLatitude(float $latitude)
    {
       
$this->latitude = $latitude;
    }

    public function
getLatitude(): float
   
{
        return
$this->latitude;
    }

    public function
setLongitude(float $longitude)
    {
       
$this->longitude = $longitude;
    }

    public function
getLongitude(): float
   
{
        return
$this->longitude;
    }

    public function
distanceTo(Point $point): float
   
{
        return
Tools::distance($this->getLatitude(), $this->getLongitude(), $point->getLatitude(), $point->getLongitude());
    }


}