PHPackages                             rvwoens/geometry - 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. rvwoens/geometry

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

rvwoens/geometry
================

Geometry 2D shapes helper functions

v1.0.59(1y ago)01.6kMITPHPPHP ^7.1||^8CI passing

Since Aug 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rvwoens/geometry)[ Packagist](https://packagist.org/packages/rvwoens/geometry)[ RSS](/packages/rvwoens-geometry/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (60)Used By (0)

geometry
========

[](#geometry)

[![GitHub Release](https://camo.githubusercontent.com/086a6f125440abd8e9c4c40058e78f6443ac456375304cef97b35d9a7145fb86/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f7276776f656e732f67656f6d657472792e7376673f7374796c653d666c6174)](//packagist.org/packages/rvwoens/geometry)[![GitHub Release](https://camo.githubusercontent.com/911c79865463180e388f6aae425fd62c3bec40e4e2af5ad4a0a3f02bc7fe8ee0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7276776f656e732f67656f6d657472792e7376673f7374796c653d666c6174)](//packagist.org/packages/rvwoens/geometry)[![Total Downloads](https://camo.githubusercontent.com/99c01ac096d5045c01cf5561158335fecde9adf3f76611d9034af84a3bd44bc6/68747470733a2f2f706f7365722e707567782e6f72672f7276776f656e732f67656f6d657472792f646f776e6c6f616473)](//packagist.org/packages/rvwoens/geometry)[![License](https://camo.githubusercontent.com/512ab5d13e4028fe8a113eac95792f26774eb0990245fd2e537f2849498b1e01/68747470733a2f2f706f7365722e707567782e6f72672f7276776f656e732f67656f6d657472792f6c6963656e7365)](//packagist.org/packages/rvwoens/geometry)[![Actions Status](https://github.com/rvwoens/geometry/workflows/CI/badge.svg)](https://github.com/rvwoens/geometry/actions)

Geometry 2D shapes helper functions

### Coord

[](#coord)

A coord is a simple latitude / longitude coordinate class with some calculation and manipulation methods

```
// instantiation
$coord = new Coord(52.40010210009, 4.5776320002);

// properties
$lat=$coord->latitude;                  // latitude property
$lng=$coord->longitude;                 // longitude property

// methods
round(5)                                - round lat/long to a precision (default 6 = approx 10 cm)
movedClone(50, 180)                     - make a clone and move it 50 meter southwards (bearing 180)
toString()                              - "52.400102,4.577632"  6 digits significant (approx 10 cm)
toWktString()                           - "4.577632 52.400102"  WKT (Well Known Text format)
equals($coord2)                         - a coord is equal when within a millimeter of another coord
distance($coord3)                       - calculate distance between coords in meters
bearing($coordTo)                       - Bearing (degrees) between 2 coords (vector TOWARDS coordTo, 0=north)
move($distance,$bearing);               - move of coord (use movedclone for immutable variant)
isRDcoord()                             - true if the coord is a RD (dutch: Rijksdriehoeksmeting) coordinate
makeWGS84fromRD()                       - Factory to create a converted Wgs84 coordinate from a RD coordiante

```

### Polygon

[](#polygon)

A polygon is a number of locations on a map defining an area.

```
// instantiation. The last segment is automatically closed using the first coordinate
$polygon = new Polygon( [ [52.1,4.2], [52.2,4.2], [52.2,4.3] ]);                // define with simple lat/lng array
$polygon = new Polygon( [   ['lat'=>52.1,'lng'=>4.2],
                            ['lat'=>52.2,'lng'=>4.2],
                            ['lat'=>52.2,'lng'=>4.3] ]);                        // or using this format
$c1=new Coord(52.1,4.2);
$c2=new Coord(52.2,4.2);
$c3=new Coord(52.2,4.3);
$polygon = new Polygon( [ $c1,$c2,$c3 ]);                                       // or using an array of Coords
$polygon = new Polygon("POLYGON ((4.2 52.1, 52.2 4.2, 4.3 52.2, 4.2 52.1))");   // or using a WKT definition
$polygon = new Polygon("52.1,4.2|52.2,4.2|52.2,4.3");                           // or using the internal serialisation

// methods
valid()                         - a polygon is valid when it is at least a triangle with 3 valid Coords
size()                          - number of sides of the polygon or n of the n-gon.
polyString()                    - to internal serialisation string "52.1,4.2|52.2,4.2|52.2,4.3"
polyWktString()                 - to WKT definition "POLYGON ((4.2 52.1, 52.2 4.2, 4.3 52.2, 4.2 52.1))"
polyGeoJsonArray()              - convert to Geojson but in php array format
polyGeoJsonString()             - convert to Geojson json string
polyLatLngArray()               - convert to array format [ ['lat'=>lat,'lng'=>lng]...]
equals($polyon2)                - true when each node is within 1mm of the other
farAway($coord)                 - true when polygon is "far away" from the coord (fast!) to speed up some calculations
distance($coord | $polygon)     - closest distance to a point or another polygon
round($precision)               - round each node of the polygon to a certain precision (default 6 approx 10cm)

contains($coord)                - true when Coord is inside the polygon
areaSquareMeters()              - returns area of polygon in square meters using earth projection
center()                        - calculate the center of mass of the polygon as a Coord

// note: smallest outer circle and largest inner circle are simplifications. Both use polygon center
smallestOuterCircleRadius()     - calculate the smallest outer circle (simple version)
largestInnerCircleRadius()      - calculate the smallest inner circle (simple version)

// Each method creates a clone. Polygon is immutable
expand(10)                      - create an expanded (inflated) polygon by x meters (negative values will deflate the polygon)
movedClone($distance,$bearing)  - create a moved copy of the polygon
simplify($distance,$highQuality)- create a simplified polygon by removing coordinates but keeping shape
makeCombined(Polygon $add)      - add a polygon, create a connection between both (for converting multipolygons)
makeWgsFromRd()                 - convert polygon to Wgs84

```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance42

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~28 days

Recently: every ~0 days

Total

59

Last Release

468d ago

PHP version history (5 changes)v1.0.1PHP ^7.0.0

v1.0.36PHP ^7.1

v1.0.40PHP ^7.1|^8.0

v1.0.43PHP ^7.1||^8.0

v1.0.55PHP ^7.1||^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/b5d4682983676b85852e58e6c6cc98bf4d5c49c3f83ddb8d3e2939a025bd831f?d=identicon)[rvwoens](/maintainers/rvwoens)

---

Top Contributors

[![rvwoens](https://avatars.githubusercontent.com/u/97624?v=4)](https://github.com/rvwoens "rvwoens (81 commits)")

---

Tags

librarygeometry

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rvwoens-geometry/health.svg)

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

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

70036.3M116](/packages/league-iso3166)[spinen/laravel-geometry

Wrapper over the geoPHP Class to make it integrate with Laravel better.

42470.7k1](/packages/spinen-laravel-geometry)[dekor/php-array-table

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

296.6M2](/packages/dekor-php-array-table)

PHPackages © 2026

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