creof / wkb-parser
Parser for well-known binary (WKB/EWKB) object data
Installs: 3 998 244
Dependents: 17
Suggesters: 0
Security: 0
Stars: 59
Watchers: 4
Forks: 14
Open Issues: 5
Requires
- php: >=5.3.3
- ext-spl: *
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpunit/phpunit: >=4.8
- satooshi/php-coveralls: ~1.0
This package is auto-updated.
Last update: 2024-11-24 23:33:04 UTC
README
Parser library for 2D, 3D, and 4D Open Geospatial Consortium (OGC) WKB or PostGIS EWKB spatial object data.
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:
$parser = new Parser($input); $value = $parser->parse();
If many values need to be parsed, a single Parser
instance can be used:
$parser = new Parser(); $value1 = $parser->parse($input1); $value2 = $parser->parse($input2);
Input value
Encoding
The parser currently supports 3 WKB encodings:
- OGC v1.1
- OGC v1.2
- PostGIS EWKB
Format
The parser supports a number of input formats:
- Binary string (as returned from database or
pack('H*', $hexString)
) - Bare hexadecimal text string (
'01010000003D0AD7A3.....'
) - Hexadecimal test string prepended with
x
,X
,0x
, or0X
('0x01010000003D0AD7A3.....'
, etc.)
Return
The parser will return an array with the keys type
, value
, srid
, and dimension
.
type
string, the uppercase spatial object type (POINT
,LINESTRING
, etc.) without any dimension.value
array, contains integer or float values for points, nested arrays containing these based on spatial object type, or empty array for EMPTY geometry.srid
integer, the SRID if present in EWKB value,null
otherwise.dimension
string, will containZ
,M
, orZM
for the respective 3D and 4D objects,null
otherwise.
Exceptions
The Reader
and Parser
will throw exceptions implementing interface CrEOF\Geo\WKB\Exception\ExceptionInterface
.
References
- PostGIS EWKB - https://github.com/postgis/postgis/blob/svn-trunk/doc/ZMSgeoms.txt
- OGC Simple Feature Access, Part 1 - http://www.opengeospatial.org/standards/sfa
- OGC Simple Feature Access, Part 2 - http://www.opengeospatial.org/standards/sfs