Download the PHP package daandesmedt/phpwktadapter without Composer
On this page you can find all versions of the php package daandesmedt/phpwktadapter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phpwktadapter
PHPWKTParser
Well-known text (WKT) is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects and transformations between spatial reference systems.
EWKT (Extended Well-Known Text), a PostGIS-specific format that includes the spatial reference system identifier (SRID) and up to 4 ordinate values (XYZM), is also supported (ex: SRID=31370;POINT(44 60)
).
PHPWKTParser
provides a simple usage helper class to read WKT and EWKT and parse this text representation to a workable PHP array holding the parsed WKT/EWKT definition. Read and parse 2D, 3D and 4D WKT (Well Known Text) / EWKT (Extended Well-Known Text) object strings into geometry objects with this simple WKT PHP adapter library.
Installation
Install the package through composer:
Make sure, that you include the composer autoloader somewhere in your codebase.
Supported geometry
Geometry Type | Example |
---|---|
POINT | POINT(30 10) |
LNESTRING | LINESTRING(30 10, 10 30, 40 40) |
POLYGON | POLYGON((0 0,10 0,10 10,0 10,0 0)) |
MULTIPOINT | MULTIPOINTZM(0 0 10 10,10 0 0 0,10 10 0 0,20 20 0 10) |
MULTILINESTRING | MULTILINESTRING((0 0,10 0,10 10,0 10)) |
MULTIPOLYGON | MULTIPOLYGON(((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))) |
GEOMETRYCOLLECTION | GEOMETRYCOLLECTION(POINT(10 20),LINESTRING(0 0,10 0)) |
PHPWKTParser parsed and returned geometry array response
The read($wkt)
function of the PHPWKTParser
adapter will return a associative array as representation of the parsed WKT/EWKT (in case of valid).
Working examples
Working examples can be found in the examples
folder.
Sample usage
Handling exceptions
Invalid format in the specified WKT / EWKT will result in a UnexpectedValueException
thrown by the WKTAdapter
.