2017 © Pedro Peláez
 

library trilateration

Trilateration for PHP

image

tuupola/trilateration

Trilateration for PHP

  • Sunday, August 20, 2017
  • by tuupola
  • Repository
  • 2 Watchers
  • 8 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 4 Versions
  • 33 % Grown

The README.md

Trilateration

Latest Version Software License Build Status Coverage, (*1)

PHP implementation of Trilateration algorithm. See Wifi Trilateration With Three or More Points for walkthrough., (*2)

Install

Install the library using Composer., (*3)

``` bash $ composer require tuupola/trilateration, (*4)


## Usage ### Pure PHP Version Pure PHP implementation calculates the position by finding the intersection of three spheres using traditional algebra. If the spheres do not intersect algorithm enlarges the spheres until they do intersect. ```php use Tuupola\Trilateration\Intersection; use Tuupola\Trilateration\Sphere; $sphere1 = new Sphere(60.1695, 24.9354, 81175); $sphere2 = new Sphere(58.3806, 26.7251, 162311); $sphere3 = new Sphere(58.3859, 24.4971, 116932); $trilateration = new Intersection($sphere1, $sphere2, $sphere3); $point = $trilateration->position(); print_r($point); /* Tuupola\Trilateration\Point Object ( [latitude:protected] => 59.418775152143 [longitude:protected] => 24.753287172291 ) */ $url = "https://appelsiini.net/circles/" . "?c={$sphere1}&c={$sphere2}&c={$sphere3}&m={$point}"; print '<a href="{$url}">Open in map</a>';

Open in map, (*5)

Non Linear Least Squares Using R

R version uses non linear least squares fitting. It can use three or more locations for the calculation and gives better results when given data is less accurate. Before using this version you must install the R language and geosphere package., (*6)

$ sudo yum -y install R
$ sudo su - -c "R -e \"install.packages('geosphere', repos='http://cran.rstudio.com/')\""
use Tuupola\Trilateration\NonLinearLeastSquares;
use Tuupola\Trilateration\Sphere;

$sphere1 = new Sphere(60.1695, 24.9354, 81175);
$sphere2 = new Sphere(58.3806, 26.7251, 162311);
$sphere3 = new Sphere(58.3859, 24.4971, 116932);

$trilateration = new NonLinearLeastSquares($sphere1, $sphere2, $sphere3);
$point = $trilateration->position();

print_r($point);

/*
Tuupola\Trilateration\Point Object
(
    [latitude:protected] => 59.4355408765689
    [longitude:protected] => 24.7747644991839

)
*/

$url = "https://appelsiini.net/circles/"
     . "?c={$sphere1}&c={$sphere2}&c={$sphere3}&m={$point}";

print '<a href="{$url}">Open in map</a>';

Open in map, (*7)

Testing

You can run tests either manually or automatically on every code change. Automatic tests require entr to work., (*8)

``` bash $ make test, (*9)

``` bash
$ brew install entr
$ make watch

Contributing

Please see CONTRIBUTING for details., (*10)

Security

If you discover any security related issues, please email tuupola@appelsiini.net instead of using the issue tracker., (*11)

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions

20/08 2017
22/06 2017
19/06 2017
24/05 2017