PHPackages                             longitude-one/wkt-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. longitude-one/wkt-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

longitude-one/wkt-parser
========================

Parser for well-known text (WKT) object strings

3.0.1(1w ago)91.2M↓45.4%41MITPHPPHP ^8.1CI passing

Since Apr 4Pushed 1w ago1 watchersCompare

[ Source](https://github.com/longitude-one/wkt-parser)[ Packagist](https://packagist.org/packages/longitude-one/wkt-parser)[ RSS](/packages/longitude-one-wkt-parser/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (6)Dependencies (4)Versions (10)Used By (1)

Well-known text parser: longitude-one/wkt-parser
================================================

[](#well-known-text-parser-longitude-onewkt-parser)

[![longitude-one/wkt-parser](https://camo.githubusercontent.com/afe37fca03eb8223bf459b5f7ab07b7d0bcd079e0232d4d5927bd824dd0213e2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6f6e6769747564652d2d6f6e652d776b742d2d7061727365722d626c7565)](https://camo.githubusercontent.com/afe37fca03eb8223bf459b5f7ab07b7d0bcd079e0232d4d5927bd824dd0213e2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6f6e6769747564652d2d6f6e652d776b742d2d7061727365722d626c7565)[![Stable release](https://camo.githubusercontent.com/deb8b9b99c2883294ddd40d2f870f4e6a78010986bc6c0a621f568de3a852033/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c6f6e6769747564652d6f6e652f776b742d706172736572)](https://camo.githubusercontent.com/deb8b9b99c2883294ddd40d2f870f4e6a78010986bc6c0a621f568de3a852033/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c6f6e6769747564652d6f6e652f776b742d706172736572)[![Packagist License](https://camo.githubusercontent.com/26f89e4c2e6102494360d32aa12b6c9a538c64562fcc5e00a6b86bfb2e8dfff4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6f6e6769747564652d6f6e652f776b742d706172736572)](https://github.com/longitude-one/wkt-parser/blob/main/LICENSE)

Lexer and parser library for 2D, 3D, and 4D WKT/EWKT spatial object strings.

[![PHP CI](https://github.com/longitude-one/wkt-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/longitude-one/wkt-parser/actions/workflows/ci.yml)[![Maintainability](https://camo.githubusercontent.com/1931dbcd5f33b9ffc09d397f4bc784d53d4a29b3bd92302c775000dcf6ca25f0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39663566633333373431373566333662623134322f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/longitude-one/wkt-parser/maintainability)[![Test Coverage](https://camo.githubusercontent.com/3b5d66900057ee26ab6354d2a4aa390f0454b2a55e91c3b97ab5e8eb5fe9360e/68747470733a2f2f636f6465636f762e696f2f67682f6c6f6e6769747564652d6f6e652f776b742d7061727365722f67726170682f62616467652e7376673f746f6b656e3d3146555236424c4e3235)](https://codecov.io/gh/longitude-one/wkt-parser)[![Minimum PHP Version](https://camo.githubusercontent.com/16778a9ba978c2df3d1c27e75175962fef7b5d23606d1d9680e36cf9b52eac3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c6f6e6769747564652d6f6e652f776b742d7061727365722e7376673f6d61784167653d33363030)](https://camo.githubusercontent.com/16778a9ba978c2df3d1c27e75175962fef7b5d23606d1d9680e36cf9b52eac3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c6f6e6769747564652d6f6e652f776b742d7061727365722e7376673f6d61784167653d33363030)

[![CI](https://github.com/longitude-one/wkt-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/longitude-one/wkt-parser/actions/workflows/ci.yml)[![Downloads](https://camo.githubusercontent.com/3a177eef4cdfdc4f608993c01d45205c2ae8fe2370eb71478bfe3f83f468b49a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c6f6e6769747564652d6f6e652f776b742d7061727365722e737667)](https://packagist.org/packages/longitude-one/wkt-parser)

Note

This package is the continuation of the now abandoned [creof/wkt-parser](https://github.com/creof/wkt-parser) package.

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

[](#installation)

```
composer require longitude-one/wkt-parser
```

Usage
-----

[](#usage)

There are two use patterns for the parser. The value to be parsed can be passed into the constructor, then parse() called on the returned `Parser` object:

```
$input = 'POLYGON((0 0,10 0,10 10,0 10,0 0))';

$parser = new Parser($input);

$value = $parser->parse();
```

If many values need to be parsed, a single `Parser` instance can be used:

```
$input1 = 'POLYGON((0 0,10 0,10 10,0 10,0 0))';
$input2 = 'POINT(0,0)';

$parser = new Parser();

$value1 = $parser->parse($input1);
$value2 = $parser->parse($input2);
```

Return
------

[](#return)

The parser will return an array with the keys `type`, `value`, `srid`, and `dimension`.

- `type` string, the spatial object type (POINT, LINESTRING, etc.) without any dimension.
- `value` array, contains integer or float values for points, or nested arrays containing these based on spatial object type.
- `srid` integer, the SRID if EWKT value was parsed, `null` otherwise.
- `dimension` string, will contain `Z`, `M`, or `ZM` for the respective 3D and 4D objects, `null` otherwise.

Exceptions
----------

[](#exceptions)

The `Lexer` and `Parser` will throw exceptions implementing interface `LongitudeOne\Geo\WKT\Exception\ExceptionInterface`.

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance98

Actively maintained with recent releases

Popularity48

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 89.9% 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 ~235 days

Recently: every ~204 days

Total

6

Last Release

8d ago

Major Versions

v1.0.0 → 2.0.02024-03-30

2.1.0 → 3.0.0.RC2024-03-31

PHP version history (2 changes)v1.0.0PHP &gt;=8.1

2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5101481?v=4)[Alexandre Tranchant](/maintainers/Alexandre-T)[@Alexandre-T](https://github.com/Alexandre-T)

---

Top Contributors

[![Alexandre-T](https://avatars.githubusercontent.com/u/5101481?v=4)](https://github.com/Alexandre-T "Alexandre-T (80 commits)")[![ellisgl](https://avatars.githubusercontent.com/u/94559?v=4)](https://github.com/ellisgl "ellisgl (8 commits)")[![kcassam](https://avatars.githubusercontent.com/u/150823?v=4)](https://github.com/kcassam "kcassam (1 commits)")

---

Tags

stringparserlexertextgeometrygeographyspatialwktewkt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/longitude-one-wkt-parser/health.svg)

```
[![Health](https://phpackages.com/badges/longitude-one-wkt-parser/health.svg)](https://phpackages.com/packages/longitude-one-wkt-parser)
```

###  Alternatives

[creof/wkt-parser

Parser for well-known text (WKT) object strings

545.0M16](/packages/creof-wkt-parser)[creof/geo-parser

Parser for geography coordinate strings

624.6M15](/packages/creof-geo-parser)[creof/wkb-parser

Parser for well-known binary (WKB/EWKB) object data

605.3M16](/packages/creof-wkb-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k959.8M160](/packages/doctrine-lexer)[cerbero/json-parser

Zero-dependencies pull parser to read large JSON from any source in a memory-efficient way.

806588.3k5](/packages/cerbero-json-parser)[geo-io/wkb-parser

Well-known binary (WKB) Parser.

786.3M53](/packages/geo-io-wkb-parser)

PHPackages © 2026

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