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

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

spinen/laravel-geometry
=======================

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

2.9.2(1y ago)42493.2k↓58.3%16[1 PRs](https://github.com/spinen/laravel-geometry/pulls)1MITPHPPHP ^8.1CI failing

Since Nov 10Pushed 1y ago7 watchersCompare

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

READMEChangelog (2)Dependencies (8)Versions (40)Used By (1)

SPINEN's Laravel Geometry
=========================

[](#spinens-laravel-geometry)

[![Latest Stable Version](https://camo.githubusercontent.com/9a3fa7a7a84d1cae9d746cd1048a2bbd0ac7b5d4e7767b9cfc7f4e9baa98ee14/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d67656f6d657472792f762f737461626c65)](https://packagist.org/packages/spinen/laravel-geometry)[![Total Downloads](https://camo.githubusercontent.com/a69e0ba570ae819c75853f64956f91398fa1a01c65de034902928badf9bae4a6/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d67656f6d657472792f646f776e6c6f616473)](https://packagist.org/packages/spinen/laravel-geometry)[![Latest Unstable Version](https://camo.githubusercontent.com/031f2311ab0cc5547c2d044eccee9848b935372f567b5c669c6d0a91a2bb3724/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d67656f6d657472792f762f756e737461626c65)](https://packagist.org/packages/spinen/laravel-geometry)[![License](https://camo.githubusercontent.com/c0d109f2d5edb32895bf55d2c07fd5cd1d20403daa9b384947eedd1d1091a107/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d67656f6d657472792f6c6963656e7365)](https://packagist.org/packages/spinen/laravel-geometry)

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

Build Status
------------

[](#build-status)

BranchStatusCoverageCode QualityDevelop[![Build Status](https://github.com/spinen/laravel-geometry/workflows/CI/badge.svg?branch=develop)](https://github.com/spinen/laravel-geometry/workflows/CI/badge.svg?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/84be996e048f6811ca4206fe8a94cd8de5940be77a6f1158eb25d7fa92a1f5b2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d67656f6d657472792f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-geometry/?branch=develop)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ece42382fe557e0bae4c6c0883ae0c78c0ca4d4fe549513424b99e604978b842/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d67656f6d657472792f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-geometry/?branch=develop)Master[![Build Status](https://github.com/spinen/laravel-geometry/workflows/CI/badge.svg?branch=master)](https://github.com/spinen/laravel-geometry/workflows/CI/badge.svg?branch=master)[![Code Coverage](https://camo.githubusercontent.com/f736dfb23be1f70096461d06a262c36d0806f80d0b06c0fe2e4ee6a1c419479c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d67656f6d657472792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-geometry/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/add40ffb5aa5e17eaa10f4e277d9ca9115e6676c3e4f53a69b655f04afd465c6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d67656f6d657472792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-geometry/?branch=master)---

Prerequisite
------------

[](#prerequisite)

### NOTES

[](#notes)

#### 1) If you need to use &lt; php7.2, please stay with version 1.x

[](#1-if-you-need-to-use--php72-please-stay-with-version-1x)

#### 2) Aside from Laravel &gt;= 5.5, the package below is required

[](#2-aside-from-laravel--55-the-package-below-is-required)

- [phayes/geophp](https://github.com/phayes/geoPHP)

---

Install
-------

[](#install)

Install Geometry:

```
    $ composer require spinen/laravel-geometry
```

The package uses the auto registration feature.

---

Using the package
-----------------

[](#using-the-package)

The Geometry Class exposes parseType methods where "Type" is StudlyCase of the geometry type that geoPHP supports. Here is a full list...

- parseEwkb($geometry)
- parseEwkt($geometry)
- parseGeoHash($geometry)
- parseGeoJson($geometry)
- parseGeoRss($geometry)
- parseGoogleGeocode($geometry)
- parseGpx($geometry)
- parseJson($geometry)
- parseKml($geometry)
- parseWkb($geometry)
- parseWkt($geometry)

The geometries are wrapped in a `Spinen\Geometry\Geometries` namespace with a little sugar to be able to do

- toEwkb()
- toEwkt()
- toGeoHash()
- toGeoJson()
- toGeoRss()
- toGoogleGeocode()
- toGpx()
- toJson()
- toKml()
- toWkb()
- toWkt()

In addition to the above export methods, we have added a `toArray` that gives an array from the toJson method. For convenience, we have exposed all of the properties of the geometry through a getter, so you have direct access to the property without having ask for the keys in the array.

---

Area of the polygon
-------------------

[](#area-of-the-polygon)

We are estimating the area in meters squared &amp; acres. We expect the estimation to be within 1%, so it is not very accurate. We essentially refactored a js method that Mapbox has in their [geojson-area package](https://github.com/mapbox/geojson-area/blob/v0.2.1/index.js#L55) . You get the area by calling the `getAcres` or `getSquareMeters`. There is a shortcut to them as properties, so you can read the "acres" or "square\_meters" property.

---

Example
-------

[](#example)

```
// Area of Polygon
$points = [[1,1], [2,2], [3,2], [3,4]];

$geoJson = '{"type":"Polygon", "coordinates":[' . json_encode($points) . ']}';

$geo = new geoPHP();
$mapper = new Spinen\Geometry\Support\TypeMapper();
$geometry = new Spinen\Geometry\Geometry($geo, $mapper);

$collection = $geometry->parseGeoJson($geoJson); // see above for more parse options

$squareMeters = $collection->getSquareMeters();
$acres = $collection->getAcres();
```

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance46

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 74.1% 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 ~115 days

Recently: every ~129 days

Total

31

Last Release

404d ago

Major Versions

0.7.0 → 1.0.02018-03-23

1.1.0 → 2.0.02019-02-26

PHP version history (3 changes)0.1.0PHP &gt;=5.5.0

2.0.0PHP &gt;=7.2

2.6.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/a082f934783fa6f391c37fc7e7ca71f84e17219471cadd17a8b8b85b42c2c9c1?d=identicon)[david.mathews](/maintainers/david.mathews)

![](https://www.gravatar.com/avatar/782b3ad6f100c625875d6a8f00222d0e08e0c6f0956ef757e43a38441594c013?d=identicon)[jimmypuckett](/maintainers/jimmypuckett)

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

![](https://www.gravatar.com/avatar/67cc534399c4c978cea6e58bd589c51a883c4134c20fea2f268739e8a9cc8f8a?d=identicon)[thaisonle](/maintainers/thaisonle)

---

Top Contributors

[![jimmypuckett](https://avatars.githubusercontent.com/u/3220069?v=4)](https://github.com/jimmypuckett "jimmypuckett (183 commits)")[![ssfinney](https://avatars.githubusercontent.com/u/1596394?v=4)](https://github.com/ssfinney "ssfinney (52 commits)")[![nepda](https://avatars.githubusercontent.com/u/531753?v=4)](https://github.com/nepda "nepda (6 commits)")[![riesjart](https://avatars.githubusercontent.com/u/23455176?v=4)](https://github.com/riesjart "riesjart (1 commits)")[![wertmenschen](https://avatars.githubusercontent.com/u/30001699?v=4)](https://github.com/wertmenschen "wertmenschen (1 commits)")[![apsyriodis](https://avatars.githubusercontent.com/u/74604468?v=4)](https://github.com/apsyriodis "apsyriodis (1 commits)")[![wilburpowery](https://avatars.githubusercontent.com/u/15817188?v=4)](https://github.com/wilburpowery "wilburpowery (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![MildlyTyped](https://avatars.githubusercontent.com/u/99814608?v=4)](https://github.com/MildlyTyped "MildlyTyped (1 commits)")

---

Tags

geometrygeophplaravellaravel-5-packagespinenlaravellibrarygeometryspinengeoPHP

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[moonshine/moonshine

Laravel administration panel

1.3k239.9k72](/packages/moonshine-moonshine)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40140.4k2](/packages/erlandmuchasaj-laravel-gzip)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3614.9k](/packages/linkxtr-laravel-qrcode)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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