PHPackages                             chillerlan/php-geojson-helpers - 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. chillerlan/php-geojson-helpers

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

chillerlan/php-geojson-helpers
==============================

 PHP 7.2+

2.0.0(3y ago)22.2kMITPHPPHP ^7.4 || ^8.0

Since Feb 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/chillerlan/php-geojson-helpers)[ Packagist](https://packagist.org/packages/chillerlan/php-geojson-helpers)[ Docs](https://github.com/chillerlan/php-geojson-helpers)[ Fund](https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4)[ Fund](https://ko-fi.com/codemasher)[ RSS](/packages/chillerlan-php-geojson-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

chillerlan/php-geojson-helpers
==============================

[](#chillerlanphp-geojson-helpers)

[![PHP Version Support](https://camo.githubusercontent.com/4722cb355df6b6cf921da259d97d341166fdcfe2e438b4bdc8414555f54379e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6368696c6c65726c616e2f7068702d67656f6a736f6e2d68656c706572733f6c6f676f3d70687026636f6c6f723d383839324246)](https://www.php.net/supported-versions.php)[![version](https://camo.githubusercontent.com/0d5a9fa351c10138747dde4d2e5ace1b45360301b9933d14c4d0d987eac4e66a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368696c6c65726c616e2f7068702d67656f6a736f6e2d68656c706572732e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/chillerlan/php-geojson-helpers)[![license](https://camo.githubusercontent.com/419a5e99eceb090e9dee6dc1d135558f4abc1bdf9026a10a762f36998e3afeff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6368696c6c65726c616e2f7068702d67656f6a736f6e2d68656c706572732e737667)](https://github.com/chillerlan/php-geojson-helpers/blob/master/LICENSE)[![Continuous Integration](https://camo.githubusercontent.com/e572590b028326703f582e4c3612fcce5fcc6b525058d48a5ae3165018196c8d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6368696c6c65726c616e2f7068702d67656f6a736f6e2d68656c706572732f74657374732e796d6c3f6272616e63683d6d6173746572266c6f676f3d676974687562)](https://github.com/chillerlan/php-geojson-helpers/actions/workflows/tests.yml?query=branch%3Amaster)[![Coverage](https://camo.githubusercontent.com/644c52c87d15b5789ffdfb4e229ff0187b5cc87f1c0fc6edddb32dacfbfe316e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6368696c6c65726c616e2f7068702d67656f6a736f6e2d68656c706572732e7376673f6c6f676f3d636f6465636f76)](https://codecov.io/github/chillerlan/php-geojson-helpers)[![Scrunitizer](https://camo.githubusercontent.com/330b46958a6325697e82726c21bd9380fbe943dddc05df3fac1843c977ce0610/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6368696c6c65726c616e2f7068702d67656f6a736f6e2d68656c706572732e7376673f6c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/chillerlan/php-geojson-helpers)[![Packagist downloads](https://camo.githubusercontent.com/10f492a1fcc6714bb880fa15094efee94a7fa3bccc2ca54c355dc7cef4f0da71/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368696c6c65726c616e2f7068702d67656f6a736f6e2d68656c706572732e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/chillerlan/php-geojson-helpers/stats)

Documentation
=============

[](#documentation)

Requirements
------------

[](#requirements)

- PHP 7.4+
    - [`ext-json`](https://www.php.net/manual/book.json.php)

Installation
------------

[](#installation)

**requires [composer](https://getcomposer.org)**

*composer.json* (note: replace `dev-master` with a [version boundary](https://getcomposer.org/doc/articles/versions.md))

```
{
	"require": {
		"php": "^7.4 || ^8.0",
		"chillerlan/php-geojson-helpers": "dev-master"
	}
}
```

Profit!

Usage
-----

[](#usage)

### `FeatureCollection`

[](#featurecollection)

```
$featureCollection = (new FeatureCollection)->setBbox([0, 0, 1024, 1024]);

// add a single feature
$feature = new Feature([512, 512], 'Point', 1);
$featureCollection->addFeature($feature);

// add an iterable of features
$featureCollection->addFeatures([$feature, /* ... more features ... */]);

// create the GeoJSON, feed leaflet
$json = $featureCollection->toJSON();

// as of v2.x via JsonSerializable
$json = json_encode($featureCollection);
```

```
{
    "type":"FeatureCollection",
    "bbox":[0, 0, 1024, 1024],
    "features":[
        {
            "type":"Feature",
            "geometry":{
                "type":"Point",
                "coordinates":[512, 512]
            },
            "properties":{
                "id":1
            }
        }
    ]
}
```

### `PolylineSimplifyer`

[](#polylinesimplifyer)

```
$polylineCoords = [[11, 12], [21, 22], [31, 32], /* ... */];

$ps             = new PolylineSimplifyer($polylineCoords);
$simplified     = $ps->simplify(5, true);
```

API
---

[](#api)

### `Feature` methods

[](#feature-methods)

methodreturndescription`__construct(array $coords = null, string $type = null, $id = null)`-coords: `[x, y]``setGeometry(array $coords, string $type)``Feature`coords: `[x, y]`, type is one of `Feature::types``setProperties(array $properties)``Feature``setID($id)``Feature`### `FeatureCollection` methods

[](#featurecollection-methods)

methodreturndescription`__construct(iterable $features = null)`-`addFeature(Feature $feature)``FeatureCollection``addFeatures(iterable $features)``FeatureCollection``clearFeatures()``FeatureCollection`### common methods to `Feature` and `FeatureCollection`

[](#common-methods-to-feature-and-featurecollection)

methodreturndescription`setBbox(array $bbox)``Feature`/`FeatureCollection``toArray()`array`toJSON(int $options = null)`string`jsonSerialize()`arrayfrom `JsonSerializable`### `ContinentRect`

[](#continentrect)

methodreturndescription`__construct(array $continent_rect)`-NW/SE corners `[[nw_x, nw_y],[se_x, se_y]]``getBounds()`array`getCenter()`array`getPoly()`array### `PolylineSimplifyer`

[](#polylinesimplifyer-1)

methodreturndescription`__construct(array $polylineCoords)`-an array of polyline coordiantes: `[[x1, y1], [x2, y2], ...]``simplify(float $tolerance = 1, bool $highestQuality = false)`array

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

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

Total

2

Last Release

1217d ago

Major Versions

1.0.0 → 2.0.02023-01-08

PHP version history (2 changes)1.0.0PHP ^7.2

2.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![codemasher](https://avatars.githubusercontent.com/u/592497?v=4)](https://github.com/codemasher "codemasher (12 commits)")

---

Tags

geojsonphp-libraryphp7php8helpergeojson

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chillerlan-php-geojson-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/chillerlan-php-geojson-helpers/health.svg)](https://phpackages.com/packages/chillerlan-php-geojson-helpers)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M682](/packages/barryvdh-laravel-ide-helper)[jmikola/geojson

GeoJSON implementation for PHP

3109.0M77](/packages/jmikola-geojson)[bryanjhv/slim-session

Session middleware and helper for Slim framework 4.

233961.5k15](/packages/bryanjhv-slim-session)[laravelista/ekko

Framework agnostic PHP package for marking navigation items active.

278673.4k4](/packages/laravelista-ekko)[beste/json

A simple JSON helper to decode and encode JSON

4222.7M3](/packages/beste-json)[chillerlan/php-settings-container

A container class for immutable settings objects. Not a DI container.

3427.3M21](/packages/chillerlan-php-settings-container)

PHPackages © 2026

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