PHPackages                             tuupola/trilateration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tuupola/trilateration

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tuupola/trilateration
=====================

Trilateration for PHP

0.2.1(7y ago)24631↓100%6[2 issues](https://github.com/tuupola/trilateration/issues)MITPHP

Since May 24Pushed 7y ago4 watchersCompare

[ Source](https://github.com/tuupola/trilateration)[ Packagist](https://packagist.org/packages/tuupola/trilateration)[ Docs](https://github.com/tuupola/trilateration)[ RSS](/packages/tuupola-trilateration/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

Trilateration
=============

[](#trilateration)

[![Latest Version](https://camo.githubusercontent.com/d7a50ef8c5a4a5392fb23ddd98df994e4de9efc73dea35c4b0d78c328aed7ecb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f747575706f6c612f7472696c617465726174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tuupola/trilateration)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ee919361c16a74e8f514c300b13994448fd5a77da1c38195fc929a6d11843848/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f747575706f6c612f7472696c617465726174696f6e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tuupola/trilateration)[![Coverage](https://camo.githubusercontent.com/187426f6455396a60be008e04f3fb9a1c75e11ed4cfd1aa383a97ac637bcdfd1/687474703a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f747575706f6c612f7472696c617465726174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/tuupola/trilateration)

PHP implementation of [Trilateration](https://en.wikipedia.org/wiki/Trilateration) algorithm. See [Wifi Trilateration With Three or More Points](https://appelsiini.net/2017/trilateration-with-n-points/) for walkthrough.

Install
-------

[](#install)

Install the library using [Composer](https://getcomposer.org/).

```
$ composer require tuupola/trilateration
```

Usage
-----

[](#usage)

### Pure PHP Version

[](#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.

```
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 'Open in map';
```

[Open in map](https://appelsiini.net/circles/?c=60.1695,24.9354,81175&c=58.3806,26.7251,162311&c=58.3859,24.4971,116932&m=59.418775152143,24.753287172291%22)

### Non Linear Least Squares Using R

[](#non-linear-least-squares-using-r)

R version uses [non linear least squares fitting](http://mathworld.wolfram.com/NonlinearLeastSquaresFitting.html). 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](https://www.r-project.org/) and [geosphere](https://cran.r-project.org/web/packages/geosphere/index.html) package.

```
$ 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 'Open in map';
```

[Open in map](https://appelsiini.net/circles/?c=60.1695,24.9354,81175&c=58.3806,26.7251,162311&c=58.3859,24.4971,116932&m=59.4355408765689,24.7747644991839)

Testing
-------

[](#testing)

You can run tests either manually or automatically on every code change. Automatic tests require [entr](http://entrproject.org/) to work.

```
$ make test
```

```
$ brew install entr
$ make watch
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~268 days

Total

3

Last Release

2735d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3325405a7d8a43bc40dd0e760a4b7f268fba32a7150cf0327f64f13d1661df0b?d=identicon)[tuupola](/maintainers/tuupola)

---

Top Contributors

[![tuupola](https://avatars.githubusercontent.com/u/21913?v=4)](https://github.com/tuupola "tuupola (34 commits)")

---

Tags

trilaterationwifigeoposition

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/tuupola-trilateration/health.svg)

```
[![Health](https://phpackages.com/badges/tuupola-trilateration/health.svg)](https://phpackages.com/packages/tuupola-trilateration)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[shivas/versioning-bundle

Symfony application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

1121.2M1](/packages/shivas-versioning-bundle)[eclipxe/cfdiutils

PHP Common utilities for Mexican CFDI 3.2, 3.3 &amp; 4.0

141129.9k6](/packages/eclipxe-cfdiutils)[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)[vaimo/composer-changelogs

Provide information about package changes based on changelog files that are bundled with releases; provide tools for generating documentation files from changelog sources

11150.5k10](/packages/vaimo-composer-changelogs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
