diff --git a/.travis.yml b/.travis.yml index 9056c49..41dd149 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ php: - hhvm before_script: + - composer self-update - composer --prefer-source install script: @@ -16,3 +17,6 @@ script: after_script: - ./vendor/bin/test-reporter --coverage-report ./build/logs/clover.xml + +after_success: + - ./vendor/bin/coveralls -v --exclude-no-stmt diff --git a/CHANGELOG.md b/CHANGELOG.md index caa8208..0ec19d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,41 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added + ### Changed +### Removed + +## [2.3.0] - 2016-05-22 +### Added +- Tests for empty geometry objects. +- getCurrentPosition() and getLastPosition methods in Reader to get position in byte stream. +- Support for OCG 1.2 encoding of 3D and 4D geometry. +- Method getBadTypeInTypeMessage() in Parser to generate helpful and descriptive exception message. +- Badge and configuration for Coveralls. + +### Changed +- NaN coordinates are not returned in point value array, empty point value now array(). +- Reader::readDouble() now deprecated and calls Reader::readFloat(). +- Reader::readDoubles() now deprecated and calls Reader::readFloats(). +- unpack() errors are now caught in unpackInput() and a library exception thrown. +- Inner types (points in multipoint, etc.) are now checked for same dimensions of parent object. +- The search for 'x' in hex values beginning with 'x' or '0x' is now case-insensitive. +- Supported encoding and input formats added to documentation. +- References for encodings added to documentation. +- Lots of additional test data and cases, and cleanup. +- Library exceptions now caught in readGeometry() and rethrown appending Reader position in message. +- All thrown exceptions now have a message. +- Now a single return for all code paths in Parser::getMachineByteOrder(). +- Tweaked tests and code for 100% coverage. +- Updated travis config for coveralls. + ## [2.2.0] - 2016-05-03 ### Added - Added Tests namespace to Composer PSR-0 dev autoload. - Added 'dimension' key to returned array containing object dimensions (Z, M, or ZM). - Reader::getMachineByteOrder method to detect running platform endianness. + ### Changed - Parser property with Reader instance no longer static. - Replaced sprintf function call in Reader::unpackInput() with string concatenation. @@ -19,6 +47,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Updated documentation with new usage pattern. - Type name in returned array now contains only base type without dimensions (Z, M, and ZM). - Reader::readDouble() now checks running platform endianness before byte-swapping values instead of assuming little-endian. + ### Removed - Removed now unused TestInit diff --git a/README.md b/README.md index 47b057d..cd569e4 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,9 @@ [![Build Status](https://travis-ci.org/creof/wkb-parser.svg?branch=master)](https://travis-ci.org/creof/wkb-parser) [![Code Climate](https://codeclimate.com/github/creof/wkb-parser/badges/gpa.svg)](https://codeclimate.com/github/creof/wkb-parser) [![Test Coverage](https://codeclimate.com/github/creof/wkb-parser/badges/coverage.svg)](https://codeclimate.com/github/creof/wkb-parser/coverage) +[![Coverage Status](https://coveralls.io/repos/github/creof/wkb-parser/badge.svg?branch=master)](https://coveralls.io/github/creof/wkb-parser?branch=master) -Parser library for 2D, 3D, and 4D WKB/EWKB spatial object data. +Parser library for 2D, 3D, and 4D Open Geospatial Consortium (OGC) WKB or PostGIS EWKB spatial object data. ## Usage @@ -26,14 +27,38 @@ $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```, or ```0X``` (```'0x01010000003D0AD7A3.....'```, etc.) + ## 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. +- ```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 contain ```Z```, ```M```, or ```ZM``` 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 + diff --git a/composer.json b/composer.json index 446183f..fb4a9fd 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ }, "require-dev": { "phpunit/phpunit": ">=4.8", - "codeclimate/php-test-reporter": "dev-master" + "codeclimate/php-test-reporter": "dev-master", + "satooshi/php-coveralls": "~1.0" }, "autoload": { "psr-0": { diff --git a/lib/CrEOF/Geo/WKB/Parser.php b/lib/CrEOF/Geo/WKB/Parser.php index 2d1e9e6..ce30e38 100644 --- a/lib/CrEOF/Geo/WKB/Parser.php +++ b/lib/CrEOF/Geo/WKB/Parser.php @@ -23,6 +23,7 @@ namespace CrEOF\Geo\WKB; +use CrEOF\Geo\WKB\Exception\ExceptionInterface; use CrEOF\Geo\WKB\Exception\UnexpectedValueException; /** @@ -93,6 +94,11 @@ class Parser */ private $byteOrder; + /** + * @var int + */ + private $dimensions; + /** * @var Reader */ @@ -100,6 +106,8 @@ class Parser /** * @param string $input + * + * @throws UnexpectedValueException */ public function __construct($input = null) { @@ -136,37 +144,138 @@ public function parse($input = null) private function readGeometry() { $this->srid = null; - $this->byteOrder = $this->readByteOrder(); - $this->type = $this->readType(); - $this->pointSize = $this->getPointSize($this->type); - if ($this->hasTypeFlag($this->type, self::WKB_FLAG_SRID)) { - $this->srid = $this->readSrid(); - } + try { + $this->byteOrder = $this->readByteOrder(); + $this->type = $this->readType(); - $typeName = $this->getTypeName($this->type); + if ($this->hasFlag($this->type, self::WKB_FLAG_SRID)) { + $this->srid = $this->readSrid(); + } - return array( - 'type' => $typeName, - 'srid' => $this->srid, - 'value' => $this->$typeName(), - 'dimension' => $this->getDimension($this->type) - ); + $this->dimensions = $this->getDimensions($this->type); + $this->pointSize = 2 + strlen($this->getDimensionType($this->dimensions)); + + $typeName = $this->getTypeName($this->type); + + return array( + 'type' => $typeName, + 'srid' => $this->srid, + 'value' => $this->$typeName(), + 'dimension' => $this->getDimensionType($this->dimensions) + ); + } catch (ExceptionInterface $e) { + throw new $e($e->getMessage() . ' at byte ' . $this->reader->getLastPosition(), $e->getCode(), $e->getPrevious()); + } } /** - * Check presence flags + * Check type for flag * * @param int $type * @param int $flag * * @return bool */ - private function hasTypeFlag($type, $flag) + private function hasFlag($type, $flag) { return ($type & $flag) === $flag; } + /** + * @param int $type + * + * @return bool + */ + private function is2D($type) + { + return $type < 32; + } + + /** + * @param int $type + * + * @return int|null + */ + private function getDimensions($type) + { + if ($this->is2D($type)) { + return null; + } + + if ($type & (self::WKB_FLAG_SRID | self::WKB_FLAG_M | self::WKB_FLAG_Z)) { + return $type & (self::WKB_FLAG_M | self::WKB_FLAG_Z); + } + + return $type - ($type % 1000); + } + + /** + * @param int $dimensions + * + * @return string + * @throws UnexpectedValueException + */ + private function getDimensionType($dimensions) + { + if ($this->is2D($dimensions)) { + return null; + } + + switch ($dimensions) { + case (1000): + //no break + case (self::WKB_FLAG_Z): + return 'Z'; + case (2000): + //no break + case (self::WKB_FLAG_M): + return 'M'; + case (3000): + //no break + case (self::WKB_FLAG_M | self::WKB_FLAG_Z): + return 'ZM'; + } + + throw new UnexpectedValueException(sprintf('%s with unsupported dimensions 0x%2$X (%2$d)', $this->getTypeName($this->type), $dimensions)); + } + + /** + * @param int $type + * + * @return int + */ + private function getDimensionedPrimitive($type) + { + if (null === $this->dimensions) { + return $type; + } + + if ($this->dimensions & (self::WKB_FLAG_Z | self::WKB_FLAG_M)) { + return $type | $this->dimensions; + } + + return $type + $this->dimensions; + } + + /** + * @param int $type + * + * @return int + */ + private function getTypePrimitive($type) + { + if ($this->is2D($type)) { + return $type; + } + + if ($type > 0xFFFF) { + return $type & 0xFF; + } + + return $type % 1000; + } + /** * Get name of data type * @@ -177,7 +286,7 @@ private function hasTypeFlag($type, $flag) */ private function getTypeName($type) { - switch ($type & 0xFFFF) { + switch ($this->getTypePrimitive($type)) { case (self::WKB_TYPE_POINT): $typeName = self::TYPE_POINT; break; @@ -218,32 +327,12 @@ private function getTypeName($type) $typeName = self::TYPE_POLYHEDRALSURFACE; break; default: - throw new UnexpectedValueException(sprintf('Unsupported WKB type "%s".', $this->type)); - break; + throw new UnexpectedValueException('Unsupported WKB type "' . $this->type . '"'); } return strtoupper($typeName); } - /** - * @param int $type - * - * @return string - * @throws UnexpectedValueException - */ - private function getDimension($type) - { - switch ($type & (self::WKB_FLAG_Z | self::WKB_FLAG_M)) { - case (self::WKB_FLAG_Z): - return 'Z'; - case (self::WKB_FLAG_M): - return 'M'; - case (self::WKB_FLAG_Z | self::WKB_FLAG_M): - return 'ZM'; - } - - return null; - } /** * Parse data byte order * @@ -283,16 +372,6 @@ private function readCount() return $this->reader->readLong(); } - /** - * @param int $type - * - * @return int - */ - private function getPointSize($type) - { - return 2 + $this->hasTypeFlag($type, self::WKB_FLAG_M) + $this->hasTypeFlag($type, self::WKB_FLAG_Z); - } - /** * @param int $count * @@ -335,7 +414,7 @@ private function readLinearRings($count) */ private function point() { - return $this->reader->readDoubles($this->pointSize); + return $this->reader->readFloats($this->pointSize); } /** @@ -387,8 +466,8 @@ private function multiPoint() $type = $this->readType(); - if (self::WKB_TYPE_POINT !== ($type & 0xFFFF)) { - throw new UnexpectedValueException(); + if ($this->getDimensionedPrimitive(self::WKB_TYPE_POINT) !== $type) { + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_MULTIPOINT, array(self::WKB_TYPE_POINT))); } $values[] = $this->point(); @@ -413,8 +492,8 @@ private function multiLineString() $type = $this->readType(); - if (self::WKB_TYPE_LINESTRING !== ($type & 0xFFFF)) { - throw new UnexpectedValueException(); + if ($this->getDimensionedPrimitive(self::WKB_TYPE_LINESTRING) !== $type) { + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_MULTILINESTRING, array(self::WKB_TYPE_LINESTRING))); } $values[] = $this->readPoints($this->readCount()); @@ -439,8 +518,8 @@ private function multiPolygon() $type = $this->readType(); - if (self::WKB_TYPE_POLYGON !== ($type & 0xFFFF)) { - throw new UnexpectedValueException(); + if ($this->getDimensionedPrimitive(self::WKB_TYPE_POLYGON) !== $type) { + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_MULTIPOLYGON, array(self::WKB_TYPE_POLYGON))); } $values[] = $this->readLinearRings($this->readCount()); @@ -465,14 +544,14 @@ private function compoundCurve() $type = $this->readType(); - switch ($type & 0xFFFF) { - case (self::WKB_TYPE_LINESTRING): + switch ($type) { + case ($this->getDimensionedPrimitive(self::WKB_TYPE_LINESTRING)): // no break - case (self::WKB_TYPE_CIRCULARSTRING): + case ($this->getDimensionedPrimitive(self::WKB_TYPE_CIRCULARSTRING)): $value = $this->readPoints($this->readCount()); break; default: - throw new UnexpectedValueException(); + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_COMPOUNDCURVE, array(self::WKB_TYPE_LINESTRING, self::WKB_TYPE_CIRCULARSTRING))); } $values[] = array( @@ -500,17 +579,17 @@ private function curvePolygon() $type = $this->readType(); - switch ($type & 0xFFFF) { - case (self::WKB_TYPE_LINESTRING): + switch ($type) { + case ($this->getDimensionedPrimitive(self::WKB_TYPE_LINESTRING)): // no break - case (self::WKB_TYPE_CIRCULARSTRING): + case ($this->getDimensionedPrimitive(self::WKB_TYPE_CIRCULARSTRING)): $value = $this->readPoints($this->readCount()); break; - case (self::WKB_TYPE_COMPOUNDCURVE): + case ($this->getDimensionedPrimitive(self::WKB_TYPE_COMPOUNDCURVE)): $value = $this->compoundCurve(); break; default: - throw new UnexpectedValueException(); + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_CURVEPOLYGON, array(self::WKB_TYPE_LINESTRING, self::WKB_TYPE_CIRCULARSTRING, self::WKB_TYPE_COMPOUNDCURVE))); } $values[] = array( @@ -538,17 +617,17 @@ private function multiCurve() $type = $this->readType(); - switch ($type & 0xFFFF) { - case (self::WKB_TYPE_LINESTRING): + switch ($type) { + case ($this->getDimensionedPrimitive(self::WKB_TYPE_LINESTRING)): // no break - case (self::WKB_TYPE_CIRCULARSTRING): + case ($this->getDimensionedPrimitive(self::WKB_TYPE_CIRCULARSTRING)): $value = $this->readPoints($this->readCount()); break; - case (self::WKB_TYPE_COMPOUNDCURVE): + case ($this->getDimensionedPrimitive(self::WKB_TYPE_COMPOUNDCURVE)): $value = $this->compoundCurve(); break; default: - throw new UnexpectedValueException(); + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_MULTICURVE, array(self::WKB_TYPE_LINESTRING, self::WKB_TYPE_CIRCULARSTRING, self::WKB_TYPE_COMPOUNDCURVE))); } $values[] = array( @@ -576,15 +655,15 @@ private function multiSurface() $type = $this->readType(); - switch ($type & 0xFFFF) { - case (self::WKB_TYPE_POLYGON): + switch ($type) { + case ($this->getDimensionedPrimitive(self::WKB_TYPE_POLYGON)): $value = $this->polygon(); break; - case (self::WKB_TYPE_CURVEPOLYGON): + case ($this->getDimensionedPrimitive(self::WKB_TYPE_CURVEPOLYGON)): $value = $this->curvePolygon(); break; default: - throw new UnexpectedValueException(); + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_MULTISURFACE, array(self::WKB_TYPE_POLYGON, self::WKB_TYPE_CURVEPOLYGON))); } $values[] = array( @@ -612,13 +691,13 @@ private function polyhedralSurface() $type = $this->readType(); - switch ($type & 0xFFFF) { - case (self::WKB_TYPE_POLYGON): + switch ($type) { + case ($this->getDimensionedPrimitive(self::WKB_TYPE_POLYGON)): $value = $this->polygon(); break; // is polygon the only one? default: - throw new UnexpectedValueException(); + throw new UnexpectedValueException($this->getBadTypeInTypeMessage($type, self::WKB_TYPE_POLYHEDRALSURFACE, array(self::WKB_TYPE_POLYGON))); } $values[] = array( @@ -655,4 +734,40 @@ private function geometryCollection() return $values; } + + /** + * @param int $childType + * @param int $parentType + * @param int[] $expectedTypes + * + * @return string + */ + private function getBadTypeInTypeMessage($childType, $parentType, array $expectedTypes) + { + if ($this->type !== $parentType) { + $parentType = $this->type; + } + + $message = sprintf( + ' %s with dimensions 0x%X (%2$d) in %3$s, expected ', + $this->getTypeName($childType), + $this->getDimensions($childType), + $this->getTypeName($parentType) + ); + + if (! in_array($this->getTypePrimitive($childType), $expectedTypes, true)) { + if (1 === count($expectedTypes)) { + $message .= $this->getTypeName($expectedTypes[0]); + } else { + $last = $this->getTypeName(array_pop($expectedTypes)); + $message .= implode(array_map(array($this, 'getTypeName'), $expectedTypes), ', ') . ' or ' . $last; + } + + $message = 'Unexpected' . $message . ' with '; + } else { + $message = 'Bad' . $message; + } + + return $message . sprintf('dimensions 0x%X (%1$d)', $this->dimensions); + } } diff --git a/lib/CrEOF/Geo/WKB/Reader.php b/lib/CrEOF/Geo/WKB/Reader.php index 61e5b4d..225d458 100644 --- a/lib/CrEOF/Geo/WKB/Reader.php +++ b/lib/CrEOF/Geo/WKB/Reader.php @@ -23,6 +23,7 @@ namespace CrEOF\Geo\WKB; +use CrEOF\Geo\WKB\Exception\RangeException; use CrEOF\Geo\WKB\Exception\UnexpectedValueException; /** @@ -46,6 +47,21 @@ class Reader */ private $input; + /** + * @var int + */ + private $position; + + /** + * @var int + */ + private $previous; + + /** + * @var int + */ + private $length; + /** * @var int */ @@ -53,6 +69,8 @@ class Reader /** * @param string $input + * + * @throws UnexpectedValueException */ public function __construct($input = null) { @@ -68,19 +86,24 @@ public function __construct($input = null) */ public function load($input) { + $this->position = 0; + $this->previous = 0; + if (ord($input) < 32) { - $this->input = $input; + $this->input = $input; + $this->length = strlen($input); return; } - $position = strpos($input, 'x'); + $position = stripos($input, 'x'); if (false !== $position) { $input = substr($input, $position + 1); } - $this->input = pack('H*', $input); + $this->input = pack('H*', $input); + $this->length = strlen($this->input); } /** @@ -89,62 +112,116 @@ public function load($input) */ public function readLong() { - if (self::WKB_NDR === $this->getByteOrder()) { - return $this->unpackInput('V'); - } + $value = self::WKB_NDR === $this->getByteOrder() ? $this->unpackInput('V') : $this->unpackInput('N'); + $this->previous = 4; + $this->position += $this->previous; - return $this->unpackInput('N'); + return $value; } /** * @return float * @throws UnexpectedValueException + * @throws RangeException + * + * @deprecated use readFloat() */ public function readDouble() + { + return $this->readFloat(); + } + + /** + * @return float + * @throws RangeException + * @throws UnexpectedValueException + */ + public function readFloat() { $double = $this->unpackInput('d'); - if ($this->getMachineByteOrder() === $this->getByteOrder()) { - return $double; + if ($this->getMachineByteOrder() !== $this->getByteOrder()) { + $double = unpack('dvalue', strrev(pack('d', $double))); + $double = $double['value']; } - $double = unpack('dvalue', strrev(pack('d', $double))); + $this->previous = 8; + $this->position += $this->previous; - return $double['value']; + return $double; } /** * @param int $count * * @return float[] + * @throws RangeException * @throws UnexpectedValueException + * + * @deprecated use readFloats() */ public function readDoubles($count) { - $doubles = array(); + return $this->readFloats($count); + } + + /** + * @param int $count + * + * @return float[] + * @throws RangeException + * @throws UnexpectedValueException + */ + public function readFloats($count) + { + $floats = array(); for ($i = 0; $i < $count; $i++) { - $doubles[] = $this->readDouble(); + $float = $this->readFloat(); + + if (! is_nan($float)) { + $floats[] = $float; + } } - return $doubles; + return $floats; } /** * @return int + * @throws RangeException * @throws UnexpectedValueException */ public function readByteOrder() { $byteOrder = $this->unpackInput('C'); - if ($byteOrder !== self::WKB_XDR && $byteOrder !== self::WKB_NDR) { - throw new UnexpectedValueException(sprintf('Invalid byte order "%s"', $byteOrder)); + $this->previous = 1; + $this->position += $this->previous; + + if ($byteOrder >> 1) { + throw new UnexpectedValueException('Invalid byte order "' . $byteOrder . '"'); } return $this->byteOrder = $byteOrder; } + /** + * @return int + */ + public function getCurrentPosition() + { + return $this->position; + } + + /** + * @return int + */ + public function getLastPosition() + { + return $this->position - $this->previous; + } + /** * @return int * @throws UnexpectedValueException @@ -162,11 +239,18 @@ private function getByteOrder() * @param string $format * * @return array + * @throws RangeException */ private function unpackInput($format) { - $code = version_compare(PHP_VERSION, '5.5.0-dev', '>=') ? 'a' : 'A'; - $result = unpack($format . 'result/' . $code . '*input', $this->input); + $code = version_compare(PHP_VERSION, '5.5.0-dev', '>=') ? 'a' : 'A'; + + try { + $result = unpack($format . 'result/' . $code . '*input', $this->input); + } catch (\Exception $e) { + throw new RangeException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } + $this->input = $result['input']; return $result['result']; @@ -177,13 +261,11 @@ private function unpackInput($format) */ private function getMachineByteOrder() { - if (null !== self::$machineByteOrder) { - return self::$machineByteOrder; - } - - $result = unpack('S', "\x01\x00"); + if (null === self::$machineByteOrder) { + $result = unpack('S', "\x01\x00"); - self::$machineByteOrder = $result[1] === 1 ? self::WKB_NDR : self::WKB_XDR; + self::$machineByteOrder = $result[1] === 1 ? self::WKB_NDR : self::WKB_XDR; + } return self::$machineByteOrder; } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3a425d6..cda5801 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd" backupGlobals="false" + backupStaticAttributes="true" colors="true" bootstrap="./vendor/autoload.php" > diff --git a/tests/CrEOF/Geo/WKB/Tests/ParserTest.php b/tests/CrEOF/Geo/WKB/Tests/ParserTest.php index 5669dcc..83cb31c 100644 --- a/tests/CrEOF/Geo/WKB/Tests/ParserTest.php +++ b/tests/CrEOF/Geo/WKB/Tests/ParserTest.php @@ -1,6 +1,6 @@ * @license http://dlambert.mit-license.org MIT + * + * @covers \CrEOF\Geo\WKB\Parser */ class ParserTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \CrEOF\Geo\WKB\Exception\UnexpectedValueException - * @expectedExceptionMessage Invalid byte order "3" + * @param mixed $value + * @param string $exception + * @param string $message + * + * @dataProvider badBinaryData */ - public function testParsingBadByteOrder() + public function testBadBinaryData($value, $exception, $message) { - $value = '03010000003D0AD7A3701D41400000000000C055C0'; - $value = pack('H*', $value); - $parser = new Parser($value); + if (version_compare(\PHPUnit_Runner_Version::id(), '5.0', '>=')) { + $this->expectException($exception); + + if ('/' === $message[0]) { + $this->expectExceptionMessageRegExp($message); + } else { + $this->expectExceptionMessage($message); + } + } else { + if ('/' === $message[0]) { + $this->setExpectedExceptionRegExp($exception, $message); + } else { + $this->setExpectedException($exception, $message); + } + } + + $parser = new Parser($value); $parser->parse(); } /** - * @expectedException \CrEOF\Geo\WKB\Exception\UnexpectedValueException - * @expectedExceptionMessage Unsupported WKB type "21" + * @return array[] */ - public function testParsingBadType() + public function badBinaryData() { - $value = '01150000003D0AD7A3701D41400000000000C055C0'; - $value = pack('H*', $value); - $parser = new Parser($value); + return array( + 'badByteOrder' => array( + 'value' => pack('H*', '03010000003D0AD7A3701D41400000000000C055C0'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Invalid byte order "3" at byte 0' + ), + 'badSimpleType' => array( + 'value' => pack('H*', '01150000003D0AD7A3701D41400000000000C055C0'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Unsupported WKB type "21" at byte 1' + ), + 'shortNDRPoint' => array( + 'value' => pack('H*', '01010000003D0AD7A3701D414000000000'), + 'exception' => 'CrEOF\Geo\WKB\Exception\RangeException', + 'message' => '/Type d: not enough input, need 8, have 4 at byte 5$/' + ), + 'badPointSize' => array( + 'value' => pack('H*', '0000000FA1'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'POINT with unsupported dimensions 0xFA0 (4000) at byte 1' + ), + 'badPointInMultiPoint' => array( + 'value' => pack('H*', '0080000004000000020000000001'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Bad POINT with dimensions 0x0 (0) in MULTIPOINT, expected dimensions 0x80000000 (2147483648) at byte 10' + ), + 'unexpectedLineStringInMultiPoint' => array( + 'value' => pack('H*', '0080000004000000020000000002'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Unexpected LINESTRING with dimensions 0x0 (0) in MULTIPOINT, expected POINT with dimensions 0x80000000 (2147483648) at byte 10' + ), + 'badLineStringInMultiLineString' => array( + 'value' => pack('H*', '0000000005000000020080000002'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Bad LINESTRING with dimensions 0x80000000 (2147483648) in MULTILINESTRING, expected dimensions 0x0 (0) at byte 10' + ), + 'badPolygonInMultiPolygon' => array( + 'value' => pack('H*', '0080000006000000020000000003'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Bad POLYGON with dimensions 0x0 (0) in MULTIPOLYGON, expected dimensions 0x80000000 (2147483648) at byte 10' + ), + 'badCircularStringInCompoundCurve' => array( + 'value' => pack('H*', '0080000009000000020000000008'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Bad CIRCULARSTRING with dimensions 0x0 (0) in COMPOUNDCURVE, expected dimensions 0x80000000 (2147483648) at byte 10' + ), + 'unexpectedPointInCompoundCurve' => array( + 'value' => pack('H*', '0080000009000000020000000001'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Unexpected POINT with dimensions 0x0 (0) in COMPOUNDCURVE, expected LINESTRING or CIRCULARSTRING with dimensions 0x80000000 (2147483648) at byte 10' + ), + 'badCompoundCurveInCurvePolygon' => array( + 'value' => pack('H*', '000000000a000000010080000009'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Bad COMPOUNDCURVE with dimensions 0x80000000 (2147483648) in CURVEPOLYGON, expected dimensions 0x0 (0) at byte 10' + ), + 'badCircularStringInCurvePolygon' => array( + 'value' => pack('H*', '008000000a000000010080000009000000020000000008'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Bad CIRCULARSTRING with dimensions 0x0 (0) in CURVEPOLYGON, expected dimensions 0x80000000 (2147483648) at byte 19' + ), + 'unexpectedPolygonInMultiCurve' => array( + 'value' => pack('H*', '004000000b000000010040000003'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Unexpected POLYGON with dimensions 0x40000000 (1073741824) in MULTICURVE, expected LINESTRING, CIRCULARSTRING or COMPOUNDCURVE with dimensions 0x40000000 (1073741824) at byte 10' + ), + 'unexpectedPointInMultiSurface' => array( + 'value' => pack('H*', '008000000c000000020080000001'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Unexpected POINT with dimensions 0x80000000 (2147483648) in MULTISURFACE, expected POLYGON or CURVEPOLYGON with dimensions 0x80000000 (2147483648) at byte 10' + ), + 'unexpectedPointInPolyhedralSurface' => array( + 'value' => pack('H*', '010f000080050000000101000080'), + 'exception' => 'CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Unexpected POINT with dimensions 0x80000000 (2147483648) in POLYHEDRALSURFACE, expected POLYGON with dimensions 0x80000000 (2147483648) at byte 10' + ), + ); + } - $parser->parse(); + /** + * @param $value + * @param array $expected + * + * @dataProvider goodBinaryData + */ + public function testParserRawHex($value, array $expected) + { + $parser = new Parser($value); + $actual = $parser->parse(); + + $this->assertEquals($expected, $actual); } /** - * @expectedException \PHPUnit_Framework_Error - * @expectedExceptionMessageRegExp /Type d: not enough input, need 8, have 4$/ + * @param $value + * @param array $expected + * + * @dataProvider goodBinaryData */ - public function testParsingNDRShortPointValue() + public function testParserPrependLowerXHex($value, array $expected) { - $value = '01010000003D0AD7A3701D414000000000'; - $value = pack('H*', $value); - $parser = new Parser($value); - $expected = array( - 'srid' => null, - 'type' => 'POINT', - 'value' => array(34.23, -87) - ); + $parser = new Parser('x' . $value); + $actual = $parser->parse(); + + $this->assertEquals($expected, $actual); + } + /** + * @param $value + * @param array $expected + * + * @dataProvider goodBinaryData + */ + public function testParserPrependUpperXHex($value, array $expected) + { + $parser = new Parser('X' . $value); $actual = $parser->parse(); $this->assertEquals($expected, $actual); } + /** + * @param $value + * @param array $expected + * + * @dataProvider goodBinaryData + */ + public function testParserPrependLower0XHex($value, array $expected) + { + $parser = new Parser('0x' . $value); + $actual = $parser->parse(); + + $this->assertEquals($expected, $actual); + } + + /** + * @param $value + * @param array $expected + * + * @dataProvider goodBinaryData + */ + public function testParserPrependUpper0XHex($value, array $expected) + { + $parser = new Parser('0X' . $value); + $actual = $parser->parse(); + + $this->assertEquals($expected, $actual); + } + + /** + * @param $value + * @param array $expected + * + * @dataProvider goodBinaryData + */ + public function testParserBinary($value, array $expected) + { + $parser = new Parser(pack('H*', $value)); + $actual = $parser->parse(); + + $this->assertEquals($expected, $actual); + } + + public function testReusedParser() + { + $parser = new Parser(); + + foreach ($this->goodBinaryData() as $testData) { + $actual = $parser->parse($testData['value']); + + $this->assertEquals($testData['expected'], $actual); + + $actual = $parser->parse('x' . $testData['value']); + + $this->assertEquals($testData['expected'], $actual); + + $actual = $parser->parse('X' . $testData['value']); + + $this->assertEquals($testData['expected'], $actual); + + $actual = $parser->parse('0x' . $testData['value']); + + $this->assertEquals($testData['expected'], $actual); + + $actual = $parser->parse('0X' . $testData['value']); + + $this->assertEquals($testData['expected'], $actual); + + $actual = $parser->parse(pack('H*', $testData['value'])); + + $this->assertEquals($testData['expected'], $actual); + } + } + /** * @return array */ public function goodBinaryData() { return array( - 'testParsingNDRPointValue' => array( + 'ndrEmptyPointValue' => array( + 'value' => '0101000000000000000000F87F000000000000F87F', + 'expected' => array( + 'srid' => null, + 'type' => 'POINT', + 'value' => array(), + 'dimension' => null + ) + ), + 'ndrPointValue' => array( 'value' => '01010000003D0AD7A3701D41400000000000C055C0', 'expected' => array( 'srid' => null, @@ -94,16 +288,16 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRPointValue' => array( + 'xdrPointValue' => array( 'value' => '000000000140411D70A3D70A3DC055C00000000000', 'expected' => array( - 'srid' => null, - 'type' => 'POINT', - 'value' => array(34.23, -87), - 'dimension' => null + 'srid' => null, + 'type' => 'POINT', + 'value' => array(34.23, -87), + 'dimension' => null ) ), - 'testParsingNDRPointZValue' => array( + 'ndrPointZValue' => array( 'value' => '0101000080000000000000F03F00000000000000400000000000000840', 'expected' => array( 'srid' => null, @@ -112,7 +306,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRPointZValue' => array( + 'xdrPointZValue' => array( 'value' => '00800000013FF000000000000040000000000000004008000000000000', 'expected' => array( 'srid' => null, @@ -121,7 +315,16 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRPointMValue' => array( + 'xdrPointZOGCValue' => array( + 'value' => '00000003E94117C89F84189375411014361BA5E3540000000000000000', + 'expected' => array( + 'srid' => null, + 'type' => 'POINT', + 'value' => array(389671.879, 263437.527, 0), + 'dimension' => 'Z' + ) + ), + 'ndrPointMValue' => array( 'value' => '0101000040000000000000F03F00000000000000400000000000000840', 'expected' => array( 'srid' => null, @@ -130,7 +333,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRPointMValue' => array( + 'xdrPointMValue' => array( 'value' => '00400000013FF000000000000040000000000000004008000000000000', 'expected' => array( 'srid' => null, @@ -139,7 +342,25 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRPointZMValue' => array( + 'ndrEmptyPointZMValue' => array( + 'value' => '01010000C0000000000000F87F000000000000F87F000000000000F87F000000000000F87F', + 'expected' => array( + 'srid' => null, + 'type' => 'POINT', + 'value' => array(), + 'dimension' => 'ZM' + ) + ), + 'xdrEmptyPointZMValue' => array( + 'value' => '00C00000017FF80000000000007FF80000000000007FF80000000000007FF8000000000000', + 'expected' => array( + 'srid' => null, + 'type' => 'POINT', + 'value' => array(), + 'dimension' => 'ZM' + ) + ), + 'ndrPointZMValue' => array( 'value' => '01010000C0000000000000F03F000000000000004000000000000008400000000000001040', 'expected' => array( 'srid' => null, @@ -148,7 +369,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRPointZMValue' => array( + 'xdrPointZMValue' => array( 'value' => '00C00000013FF0000000000000400000000000000040080000000000004010000000000000', 'expected' => array( 'srid' => null, @@ -157,16 +378,16 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRPointValueWithSrid' => array( + 'ndrPointValueWithSrid' => array( 'value' => '01010000003D0AD7A3701D41400000000000C055C0', 'expected' => array( - 'srid' => null, - 'type' => 'POINT', - 'value' => array(34.23, -87), - 'dimension' => null + 'srid' => null, + 'type' => 'POINT', + 'value' => array(34.23, -87), + 'dimension' => null ) ), - 'testParsingXDRPointValueWithSrid' => array( + 'xdrPointValueWithSrid' => array( 'value' => '0020000001000010E640411D70A3D70A3DC055C00000000000', 'expected' => array( 'srid' => 4326, @@ -175,7 +396,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRPointZValueWithSrid' => array( + 'ndrPointZValueWithSrid' => array( 'value' => '01010000A0E6100000000000000000F03F00000000000000400000000000000840', 'expected' => array( 'srid' => 4326, @@ -184,7 +405,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRPointZValueWithSrid' => array( + 'xdrPointZValueWithSrid' => array( 'value' => '00A0000001000010E63FF000000000000040000000000000004008000000000000', 'expected' => array( 'srid' => 4326, @@ -193,7 +414,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRPointMValueWithSrid' => array( + 'ndrPointMValueWithSrid' => array( 'value' => '0101000060e6100000000000000000f03f00000000000000400000000000000840', 'expected' => array( 'srid' => 4326, @@ -202,7 +423,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRPointMValueWithSrid' => array( + 'xdrPointMValueWithSrid' => array( 'value' => '0060000001000010e63ff000000000000040000000000000004008000000000000', 'expected' => array( 'srid' => 4326, @@ -211,7 +432,16 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRPointZMValueWithSrid' => array( + 'ndrEmptyPointZMValueWithSrid' => array( + 'value' => '01010000E08C100000000000000000F87F000000000000F87F000000000000F87F000000000000F87F', + 'expected' => array( + 'srid' => 4236, + 'type' => 'POINT', + 'value' => array(), + 'dimension' => 'ZM' + ) + ), + 'ndrPointZMValueWithSrid' => array( 'value' => '01010000e0e6100000000000000000f03f000000000000004000000000000008400000000000001040', 'expected' => array( 'srid' => 4326, @@ -220,7 +450,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRPointZMValueWithSrid' => array( + 'xdrPointZMValueWithSrid' => array( 'value' => '00e0000001000010e63ff0000000000000400000000000000040080000000000004010000000000000', 'expected' => array( 'srid' => 4326, @@ -229,7 +459,16 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRLineStringValue' => array( + 'ndrEmptyLineStringValue' => array( + 'value' => '010200000000000000', + 'expected' => array( + 'srid' => null, + 'type' => 'LINESTRING', + 'value' => array(), + 'dimension' => null + ) + ), + 'ndrLineStringValue' => array( 'value' => '0102000000020000003D0AD7A3701D41400000000000C055C06666666666A6464000000000000057C0', 'expected' => array( 'srid' => null, @@ -241,7 +480,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRLineStringValue' => array( + 'xdrLineStringValue' => array( 'value' => '00000000020000000240411D70A3D70A3DC055C000000000004046A66666666666C057000000000000', 'expected' => array( 'srid' => null, @@ -253,7 +492,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRLineStringZValue' => array( + 'ndrLineStringZValue' => array( 'value' => '010200008002000000000000000000000000000000000000000000000000000040000000000000f03f000000000' . '000f03f0000000000000840', 'expected' => array( @@ -266,7 +505,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRLineStringZValue' => array( + 'xdrLineStringZValue' => array( 'value' => '0080000002000000020000000000000000000000000000000040000000000000003ff00000000000003ff000000' . '00000004008000000000000', 'expected' => array( @@ -279,7 +518,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRLineStringMValue' => array( + 'ndrLineStringMValue' => array( 'value' => '010200004002000000000000000000000000000000000000000000000000000040000000000000f03f000000000' . '000f03f0000000000000840', 'expected' => array( @@ -292,7 +531,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRLineStringMValue' => array( + 'xdrLineStringMValue' => array( 'value' => '0040000002000000020000000000000000000000000000000040000000000000003ff00000000000003ff000000' . '00000004008000000000000', 'expected' => array( @@ -305,7 +544,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRLineStringZMValue' => array( + 'ndrLineStringZMValue' => array( 'value' => '01020000c0020000000000000000000000000000000000000000000000000000400000000000000840000000000' . '000f03f000000000000f03f00000000000010400000000000001440', 'expected' => array( @@ -318,7 +557,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRLineStringZMValue' => array( + 'xdrLineStringZMValue' => array( 'value' => '00c00000020000000200000000000000000000000000000000400000000000000040080000000000003ff000000' . '00000003ff000000000000040100000000000004014000000000000', 'expected' => array( @@ -331,7 +570,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRLineStringValueWithSrid' => array( + 'ndrLineStringValueWithSrid' => array( 'value' => '0102000020E6100000020000003D0AD7A3701D41400000000000C055C06666666666A6464000000000000057C0', 'expected' => array( 'srid' => 4326, @@ -343,7 +582,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRLineStringValueWithSrid' => array( + 'xdrLineStringValueWithSrid' => array( 'value' => '0020000002000010E60000000240411D70A3D70A3DC055C000000000004046A66666666666C057000000000000', 'expected' => array( 'srid' => 4326, @@ -355,7 +594,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRLineStringZValueWithSrid' => array( + 'ndrLineStringZValueWithSrid' => array( 'value' => '01020000a0e610000002000000000000000000000000000000000000000000000000000040000000000000f03f0' . '00000000000f03f0000000000000840', 'expected' => array( @@ -368,7 +607,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRLineStringZValueWithSrid' => array( + 'xdrLineStringZValueWithSrid' => array( 'value' => '00a0000002000010e6000000020000000000000000000000000000000040000000000000003ff00000000000003' . 'ff00000000000004008000000000000', 'expected' => array( @@ -381,7 +620,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRLineStringMValueWithSrid' => array( + 'ndrLineStringMValueWithSrid' => array( 'value' => '0102000060e610000002000000000000000000000000000000000000000000000000000040000000000000f03f0' . '00000000000f03f0000000000000840', 'expected' => array( @@ -394,7 +633,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRLineStringMValueWithSrid' => array( + 'xdrLineStringMValueWithSrid' => array( 'value' => '0060000002000010e6000000020000000000000000000000000000000040000000000000003ff00000000000003' . 'ff00000000000004008000000000000', 'expected' => array( @@ -407,7 +646,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRLineStringZMValueWithSrid' => array( + 'ndrLineStringZMValueWithSrid' => array( 'value' => '01020000e0e61000000200000000000000000000000000000000000000000000000000004000000000000008400' . '00000000000f03f000000000000f03f00000000000010400000000000001440', 'expected' => array( @@ -420,7 +659,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRLineStringZMValueWithSrid' => array( + 'xdrLineStringZMValueWithSrid' => array( 'value' => '00e0000002000010e60000000200000000000000000000000000000000400000000000000040080000000000003' . 'ff00000000000003ff000000000000040100000000000004014000000000000', 'expected' => array( @@ -433,7 +672,16 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRPolygonValue' => array( + 'ndrEmptyPolygonValue' => array( + 'value' => '010300000000000000', + 'expected' => array( + 'srid' => null, + 'type' => 'POLYGON', + 'value' => array(), + 'dimension' => null + ) + ), + 'ndrPolygonValue' => array( 'value' => '0103000000010000000500000000000000000000000000000000000000000000000000244000000000000000000' . '00000000000244000000000000024400000000000000000000000000000244000000000000000000000000000000000', 'expected' => array( @@ -451,7 +699,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRPolygonValue' => array( + 'xdrPolygonValue' => array( 'value' => '0000000003000000010000000500000000000000000000000000000000402400000000000000000000000000004' . '02400000000000040240000000000000000000000000000402400000000000000000000000000000000000000000000', 'expected' => array( @@ -469,7 +717,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRPolygonValueWithSrid' => array( + 'ndrPolygonValueWithSrid' => array( 'value' => '0103000020E61000000100000005000000000000000000000000000000000000000000000000002440000000000' . '000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000' . '0000000', @@ -488,7 +736,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRPolygonValueWithSrid' => array( + 'xdrPolygonValueWithSrid' => array( 'value' => '0020000003000010E60000000100000005000000000000000000000000000000004024000000000000000000000' . '000000040240000000000004024000000000000000000000000000040240000000000000000000000000000000000000' . '0000000', @@ -507,7 +755,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiRingPolygonValue' => array( + 'ndrMultiRingPolygonValue' => array( 'value' => '0103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000' . '000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000' . '5000000000000000000144000000000000014400000000000001C4000000000000014400000000000001C40000000000' @@ -534,7 +782,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiRingPolygonValue' => array( + 'xdrMultiRingPolygonValue' => array( 'value' => '0000000003000000020000000500000000000000000000000000000000402400000000000000000000000000004' . '024000000000000402400000000000000000000000000004024000000000000000000000000000000000000000000000' . '000000540140000000000004014000000000000401C0000000000004014000000000000401C000000000000401C00000' @@ -561,7 +809,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiRingPolygonZValue' => array( + 'ndrMultiRingPolygonZValue' => array( 'value' => '0103000080020000000500000000000000000000000000000000000000000000000000f03f00000000000024400' . '000000000000000000000000000004000000000000024400000000000002440000000000000004000000000000000000' . '000000000002440000000000000004000000000000000000000000000000000000000000000f03f05000000000000000' @@ -590,7 +838,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiRingPolygonZValue' => array( + 'xdrMultiRingPolygonZValue' => array( 'value' => '00800000030000000200000005000000000000000000000000000000003ff000000000000040240000000000000' . '000000000000000400000000000000040240000000000004024000000000000400000000000000000000000000000004' . '0240000000000004000000000000000000000000000000000000000000000003ff000000000000000000005400000000' @@ -619,7 +867,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiRingPolygonMValue' => array( + 'ndrMultiRingPolygonMValue' => array( 'value' => '0103000040020000000500000000000000000000000000000000000000000000000000f03f00000000000024400' . '000000000000000000000000000004000000000000024400000000000002440000000000000004000000000000000000' . '000000000002440000000000000004000000000000000000000000000000000000000000000f03f05000000000000000' @@ -648,7 +896,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiRingPolygonMValue' => array( + 'xdrMultiRingPolygonMValue' => array( 'value' => '00400000030000000200000005000000000000000000000000000000003ff000000000000040240000000000000' . '000000000000000400000000000000040240000000000004024000000000000400000000000000000000000000000004' . '0240000000000004000000000000000000000000000000000000000000000003ff000000000000000000005400000000' @@ -677,7 +925,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiRingPolygonZMValue' => array( + 'ndrMultiRingPolygonZMValue' => array( 'value' => '01030000c0020000000500000000000000000000000000000000000000000000000000f03f000000000000f0bf0' . '0000000000024400000000000000000000000000000004000000000000000c0000000000000244000000000000024400' . '00000000000004000000000000000c000000000000000000000000000002440000000000000004000000000000010c00' @@ -708,7 +956,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiRingPolygonZMValue' => array( + 'xdrMultiRingPolygonZMValue' => array( 'value' => '00c00000030000000200000005000000000000000000000000000000003ff0000000000000bff00000000000004' . '02400000000000000000000000000004000000000000000c000000000000000402400000000000040240000000000004' . '000000000000000c000000000000000000000000000000040240000000000004000000000000000c0100000000000000' @@ -739,7 +987,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiRingPolygonValueWithSrid' => array( + 'ndrMultiRingPolygonValueWithSrid' => array( 'value' => '0103000020E61000000200000005000000000000000000000000000000000000000000000000002440000000000' . '000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000' . '000000005000000000000000000144000000000000014400000000000001C4000000000000014400000000000001C400' @@ -766,7 +1014,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiRingPolygonValueWithSrid' => array( + 'xdrMultiRingPolygonValueWithSrid' => array( 'value' => '0020000003000010E60000000200000005000000000000000000000000000000004024000000000000000000000' . '000000040240000000000004024000000000000000000000000000040240000000000000000000000000000000000000' . '00000000000000540140000000000004014000000000000401C0000000000004014000000000000401C0000000000004' @@ -793,7 +1041,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiRingPolygonZValueWithSrid' => array( + 'ndrMultiRingPolygonZValueWithSrid' => array( 'value' => '01030000a0e6100000020000000500000000000000000000000000000000000000000000000000f03f000000000' . '000244000000000000000000000000000000040000000000000244000000000000024400000000000000040000000000' . '00000000000000000002440000000000000004000000000000000000000000000000000000000000000f03f050000000' @@ -822,7 +1070,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiRingPolygonZValueWithSrid' => array( + 'xdrMultiRingPolygonZValueWithSrid' => array( 'value' => '00a0000003000010e60000000200000005000000000000000000000000000000003ff0000000000000402400000' . '000000000000000000000004000000000000000402400000000000040240000000000004000000000000000000000000' . '000000040240000000000004000000000000000000000000000000000000000000000003ff0000000000000000000054' @@ -851,7 +1099,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiRingPolygonMValueWithSrid' => array( + 'ndrMultiRingPolygonMValueWithSrid' => array( 'value' => '0103000060e6100000020000000500000000000000000000000000000000000000000000000000f03f000000000' . '000244000000000000000000000000000000040000000000000244000000000000024400000000000000040000000000' . '00000000000000000002440000000000000004000000000000000000000000000000000000000000000f03f050000000' @@ -880,7 +1128,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiRingPolygonMValueWithSrid' => array( + 'xdrMultiRingPolygonMValueWithSrid' => array( 'value' => '0060000003000010e60000000200000005000000000000000000000000000000003ff0000000000000402400000' . '000000000000000000000004000000000000000402400000000000040240000000000004000000000000000000000000' . '000000040240000000000004000000000000000000000000000000000000000000000003ff0000000000000000000054' @@ -909,7 +1157,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiRingPolygonZMValueWithSrid' => array( + 'ndrMultiRingPolygonZMValueWithSrid' => array( 'value' => '01030000e0e6100000020000000500000000000000000000000000000000000000000000000000f03f000000000' . '000f0bf00000000000024400000000000000000000000000000004000000000000000c00000000000002440000000000' . '0002440000000000000004000000000000000c0000000000000000000000000000024400000000000000040000000000' @@ -940,7 +1188,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiRingPolygonZMValueWithSrid' => array( + 'xdrMultiRingPolygonZMValueWithSrid' => array( 'value' => '00e0000003000010e60000000200000005000000000000000000000000000000003ff0000000000000bff000000' . '0000000402400000000000000000000000000004000000000000000c0000000000000004024000000000000402400000' . '00000004000000000000000c000000000000000000000000000000040240000000000004000000000000000c01000000' @@ -971,7 +1219,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiPointValue' => array( + 'ndrMultiPointValue' => array( 'value' => '0104000000040000000101000000000000000000000000000000000000000101000000000000000000244000000' . '00000000000010100000000000000000024400000000000002440010100000000000000000000000000000000002440', 'expected' => array( @@ -986,7 +1234,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiPointValue' => array( + 'xdrMultiPointValue' => array( 'value' => '0000000004000000040000000001000000000000000000000000000000000000000001402400000000000000000' . '00000000000000000000140240000000000004024000000000000000000000100000000000000004024000000000000', 'expected' => array( @@ -1001,7 +1249,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiPointZValue' => array( + 'ndrMultiPointZValue' => array( 'value' => '0104000080020000000101000080000000000000000000000000000000000000000000000000010100008000000' . '000000000400000000000000000000000000000f03f', 'expected' => array( @@ -1014,7 +1262,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiPointZValue' => array( + 'xdrMultiPointZValue' => array( 'value' => '0080000004000000020080000001000000000000000000000000000000000000000000000000008000000140000' . '0000000000000000000000000003ff0000000000000', 'expected' => array( @@ -1027,7 +1275,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiPointMValue' => array( + 'ndrMultiPointMValue' => array( 'value' => '0104000040020000000101000040000000000000000000000000000000000000000000000040010100004000000' . '000000000400000000000000000000000000000f03f', 'expected' => array( @@ -1040,7 +1288,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiPointMValue' => array( + 'xdrMultiPointMValue' => array( 'value' => '0040000004000000020040000001000000000000000000000000000000004000000000000000004000000140000' . '0000000000000000000000000003ff0000000000000', 'expected' => array( @@ -1053,7 +1301,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiPointZMValue' => array( + 'ndrMultiPointZMValue' => array( 'value' => '01040000c00200000001010000c00000000000000000000000000000f03f0000000000000040000000000000084' . '001010000c000000000000008400000000000000040000000000000f03f0000000000000000', 'expected' => array( @@ -1066,7 +1314,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiPointZMValue' => array( + 'xdrMultiPointZMValue' => array( 'value' => '00c00000040000000200c000000100000000000000003ff00000000000004000000000000000400800000000000' . '000c0000001400800000000000040000000000000003ff00000000000000000000000000000', 'expected' => array( @@ -1079,7 +1327,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiPointValueWithSrid' => array( + 'ndrMultiPointValueWithSrid' => array( 'value' => '0104000020E61000000400000001010000000000000000000000000000000000000001010000000000000000002' . '440000000000000000001010000000000000000002440000000000000244001010000000000000000000000000000000' . '0002440', @@ -1095,7 +1343,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiPointValueWithSrid' => array( + 'xdrMultiPointValueWithSrid' => array( 'value' => '0020000004000010E60000000400000000010000000000000000000000000000000000000000014024000000000' . '000000000000000000000000000014024000000000000402400000000000000000000010000000000000000402400000' . '0000000', @@ -1111,7 +1359,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiPointZValueWithSrid' => array( + 'ndrMultiPointZValueWithSrid' => array( 'value' => '0104000080020000000101000080000000000000000000000000000000000000000000000000010100008000000' . '000000000400000000000000000000000000000f03f', 'expected' => array( @@ -1124,7 +1372,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiPointZValueWithSrid' => array( + 'xdrMultiPointZValueWithSrid' => array( 'value' => '0080000004000000020080000001000000000000000000000000000000000000000000000000008000000140000' . '0000000000000000000000000003ff0000000000000', 'expected' => array( @@ -1137,7 +1385,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiPointMValueWithSrid' => array( + 'ndrMultiPointMValueWithSrid' => array( 'value' => '0104000040020000000101000040000000000000000000000000000000000000000000000040010100004000000' . '000000000400000000000000000000000000000f03f', 'expected' => array( @@ -1150,7 +1398,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiPointMValueWithSrid' => array( + 'xdrMultiPointMValueWithSrid' => array( 'value' => '0040000004000000020040000001000000000000000000000000000000004000000000000000004000000140000' . '0000000000000000000000000003ff0000000000000', 'expected' => array( @@ -1163,7 +1411,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiPointZMValueWithSrid' => array( + 'ndrMultiPointZMValueWithSrid' => array( 'value' => '01040000c00200000001010000c00000000000000000000000000000f03f0000000000000040000000000000084' . '001010000c000000000000008400000000000000040000000000000f03f0000000000000000', 'expected' => array( @@ -1176,7 +1424,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiPointZMValueWithSrid' => array( + 'xdrMultiPointZMValueWithSrid' => array( 'value' => '00c00000040000000200c000000100000000000000003ff00000000000004000000000000000400800000000000' . '000c0000001400800000000000040000000000000003ff00000000000000000000000000000', 'expected' => array( @@ -1189,7 +1437,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiLineStringValue' => array( + 'ndrMultiLineStringValue' => array( 'value' => '0105000000020000000102000000040000000000000000000000000000000000000000000000000024400000000' . '000000000000000000000244000000000000024400000000000000000000000000000244001020000000400000000000' . '0000000144000000000000014400000000000001C4000000000000014400000000000001C400000000000001C4000000' @@ -1214,7 +1462,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiLineStringValue' => array( + 'xdrMultiLineStringValue' => array( 'value' => '0000000005000000020000000002000000040000000000000000000000000000000040240000000000000000000' . '000000000402400000000000040240000000000000000000000000000402400000000000000000000020000000440140' . '000000000004014000000000000401C0000000000004014000000000000401C000000000000401C00000000000040140' @@ -1239,7 +1487,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiLineStringZValue' => array( + 'ndrMultiLineStringZValue' => array( 'value' => '01050000800200000001020000800200000000000000000000000000000000000000000000000000f03f0000000' . '00000004000000000000000000000000000000040010200008002000000000000000000f03f000000000000f03f00000' . '00000000840000000000000004000000000000000400000000000001040', @@ -1259,7 +1507,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiLineStringZValue' => array( + 'xdrMultiLineStringZValue' => array( 'value' => '008000000500000002008000000200000002000000000000000000000000000000003ff00000000000004000000' . '000000000000000000000000040000000000000000080000002000000023ff00000000000003ff000000000000040080' . '00000000000400000000000000040000000000000004010000000000000', @@ -1279,7 +1527,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiLineStringMValue' => array( + 'ndrMultiLineStringMValue' => array( 'value' => '01050000400200000001020000400200000000000000000000000000000000000000000000000000f03f0000000' . '00000004000000000000000000000000000000040010200004002000000000000000000f03f000000000000f03f00000' . '00000000840000000000000004000000000000000400000000000001040', @@ -1299,7 +1547,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiLineStringMValue' => array( + 'xdrMultiLineStringMValue' => array( 'value' => '004000000500000002004000000200000002000000000000000000000000000000003ff00000000000004000000' . '000000000000000000000000040000000000000000040000002000000023ff00000000000003ff000000000000040080' . '00000000000400000000000000040000000000000004010000000000000', @@ -1319,7 +1567,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiLineStringZMValue' => array( + 'ndrMultiLineStringZMValue' => array( 'value' => '01050000c00200000001020000c00200000000000000000000000000000000000000000000000000f03f0000000' . '000001440000000000000004000000000000000000000000000000040000000000000104001020000c00200000000000' . '0000000f03f000000000000f03f000000000000084000000000000008400000000000000040000000000000004000000' @@ -1340,7 +1588,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiLineStringZMValue' => array( + 'xdrMultiLineStringZMValue' => array( 'value' => '00c00000050000000200c000000200000002000000000000000000000000000000003ff00000000000004014000' . '000000000400000000000000000000000000000004000000000000000401000000000000000c0000002000000023ff00' . '000000000003ff0000000000000400800000000000040080000000000004000000000000000400000000000000040100' @@ -1361,7 +1609,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiLineStringValueWithSrid' => array( + 'ndrMultiLineStringValueWithSrid' => array( 'value' => '0105000020E61000000200000001020000000400000000000000000000000000000000000000000000000000244' . '000000000000000000000000000002440000000000000244000000000000000000000000000002440010200000004000' . '000000000000000144000000000000014400000000000001C4000000000000014400000000000001C400000000000001' @@ -1386,7 +1634,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiLineStringValueWithSrid' => array( + 'xdrMultiLineStringValueWithSrid' => array( 'value' => '0020000005000010E60000000200000000020000000400000000000000000000000000000000402400000000000' . '000000000000000004024000000000000402400000000000000000000000000004024000000000000000000000200000' . '00440140000000000004014000000000000401C0000000000004014000000000000401C000000000000401C000000000' @@ -1411,7 +1659,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiLineStringZValueWithSrid' => array( + 'ndrMultiLineStringZValueWithSrid' => array( 'value' => '01050000a0e61000000200000001020000800200000000000000000000000000000000000000000000000000f03' . 'f000000000000004000000000000000000000000000000040010200008002000000000000000000f03f000000000000f' . '03f0000000000000840000000000000004000000000000000400000000000001040', @@ -1431,7 +1679,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiLineStringZValueWithSrid' => array( + 'xdrMultiLineStringZValueWithSrid' => array( 'value' => '008000000500000002008000000200000002000000000000000000000000000000003ff00000000000004000000' . '000000000000000000000000040000000000000000080000002000000023ff00000000000003ff000000000000040080' . '00000000000400000000000000040000000000000004010000000000000', @@ -1451,7 +1699,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiLineStringMValueWithSrid' => array( + 'ndrMultiLineStringMValueWithSrid' => array( 'value' => '0105000060e61000000200000001020000400200000000000000000000000000000000000000000000000000f03' . 'f000000000000004000000000000000000000000000000040010200004002000000000000000000f03f000000000000f' . '03f0000000000000840000000000000004000000000000000400000000000001040', @@ -1471,7 +1719,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiLineStringMValueWithSrid' => array( + 'xdrMultiLineStringMValueWithSrid' => array( 'value' => '004000000500000002004000000200000002000000000000000000000000000000003ff00000000000004000000' . '000000000000000000000000040000000000000000040000002000000023ff00000000000003ff000000000000040080' . '00000000000400000000000000040000000000000004010000000000000', @@ -1491,7 +1739,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiLineStringZMValueWithSrid' => array( + 'ndrMultiLineStringZMValueWithSrid' => array( 'value' => '01050000e0e61000000200000001020000c00200000000000000000000000000000000000000000000000000f03' . 'f0000000000001440000000000000004000000000000000000000000000000040000000000000104001020000c002000' . '000000000000000f03f000000000000f03f0000000000000840000000000000084000000000000000400000000000000' @@ -1512,7 +1760,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiLineStringZMValueWithSrid' => array( + 'xdrMultiLineStringZMValueWithSrid' => array( 'value' => '00c00000050000000200c000000200000002000000000000000000000000000000003ff00000000000004014000' . '000000000400000000000000000000000000000004000000000000000401000000000000000c0000002000000023ff00' . '000000000003ff0000000000000400800000000000040080000000000004000000000000000400000000000000040100' @@ -1533,7 +1781,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiPolygonValue' => array( + 'ndrMultiPolygonValue' => array( 'value' => '0106000000020000000103000000020000000500000000000000000000000000000000000000000000000000244' . '000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000' . '0000000000000000005000000000000000000144000000000000014400000000000001C4000000000000014400000000' @@ -1573,7 +1821,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiPolygonValue' => array( + 'xdrMultiPolygonValue' => array( 'value' => '0000000006000000020000000003000000020000000500000000000000000000000000000000402400000000000' . '000000000000000004024000000000000402400000000000000000000000000004024000000000000000000000000000' . '000000000000000000000000540140000000000004014000000000000401C0000000000004014000000000000401C000' @@ -1613,7 +1861,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiPolygonZValue' => array( + 'ndrMultiPolygonZValue' => array( 'value' => '0106000080010000000103000080020000000500000000000000000000000000000000000000000000000000084' . '000000000000024400000000000000000000000000000084000000000000024400000000000002440000000000000084' . '000000000000000000000000000002440000000000000084000000000000000000000000000000000000000000000084' @@ -1644,7 +1892,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiPolygonZValue' => array( + 'xdrMultiPolygonZValue' => array( 'value' => '0080000006000000010080000003000000020000000500000000000000000000000000000000400800000000000' . '040240000000000000000000000000000400800000000000040240000000000004024000000000000400800000000000' . '000000000000000004024000000000000400800000000000000000000000000000000000000000000400800000000000' @@ -1675,7 +1923,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiPolygonMValue' => array( + 'ndrMultiPolygonMValue' => array( 'value' => '0106000040010000000103000040020000000500000000000000000000000000000000000000000000000000084' . '000000000000024400000000000000000000000000000084000000000000024400000000000002440000000000000084' . '000000000000000000000000000002440000000000000084000000000000000000000000000000000000000000000084' @@ -1706,7 +1954,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiPolygonMValue' => array( + 'xdrMultiPolygonMValue' => array( 'value' => '0040000006000000010040000003000000020000000500000000000000000000000000000000400800000000000' . '040240000000000000000000000000000400800000000000040240000000000004024000000000000400800000000000' . '000000000000000004024000000000000400800000000000000000000000000000000000000000000400800000000000' @@ -1737,7 +1985,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiPolygonZMValue' => array( + 'ndrMultiPolygonZMValue' => array( 'value' => '01060000c00100000001030000c0020000000500000000000000000000000000000000000000000000000000084' . '000000000000000400000000000002440000000000000000000000000000008400000000000000040000000000000244' . '000000000000024400000000000000840000000000000004000000000000000000000000000002440000000000000084' @@ -1770,7 +2018,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiPolygonZMValue' => array( + 'xdrMultiPolygonZMValue' => array( 'value' => '00c00000060000000100c0000003000000020000000500000000000000000000000000000000400800000000000' . '040000000000000004024000000000000000000000000000040080000000000004000000000000000402400000000000' . '040240000000000004008000000000000400000000000000000000000000000004024000000000000400800000000000' @@ -1803,7 +2051,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiPolygonValueWithSrid' => array( + 'ndrMultiPolygonValueWithSrid' => array( 'value' => '0106000020E61000000200000001030000000200000005000000000000000000000000000000000000000000000' . '000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000' . '000000000000000000000000005000000000000000000144000000000000014400000000000001C40000000000000144' @@ -1843,7 +2091,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiPolygonValueWithSrid' => array( + 'xdrMultiPolygonValueWithSrid' => array( 'value' => '0020000006000010E60000000200000000030000000200000005000000000000000000000000000000004024000' . '000000000000000000000000040240000000000004024000000000000000000000000000040240000000000000000000' . '00000000000000000000000000000000540140000000000004014000000000000401C000000000000401400000000000' @@ -1883,7 +2131,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiPolygonZValueWithSrid' => array( + 'ndrMultiPolygonZValueWithSrid' => array( 'value' => '01060000a0e61000000100000001030000800200000005000000000000000000000000000000000000000000000' . '000000840000000000000244000000000000000000000000000000840000000000000244000000000000024400000000' . '000000840000000000000000000000000000024400000000000000840000000000000000000000000000000000000000' @@ -1914,7 +2162,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiPolygonZValueWithSrid' => array( + 'xdrMultiPolygonZValueWithSrid' => array( 'value' => '00a0000006000010e60000000100800000030000000200000005000000000000000000000000000000004008000' . '000000000402400000000000000000000000000004008000000000000402400000000000040240000000000004008000' . '000000000000000000000000040240000000000004008000000000000000000000000000000000000000000004008000' @@ -1945,7 +2193,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiPolygonMValueWithSrid' => array( + 'ndrMultiPolygonMValueWithSrid' => array( 'value' => '0106000060e61000000100000001030000400200000005000000000000000000000000000000000000000000000' . '000000840000000000000244000000000000000000000000000000840000000000000244000000000000024400000000' . '000000840000000000000000000000000000024400000000000000840000000000000000000000000000000000000000' @@ -1976,7 +2224,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiPolygonMValueWithSrid' => array( + 'xdrMultiPolygonMValueWithSrid' => array( 'value' => '0060000006000010e60000000100400000030000000200000005000000000000000000000000000000004008000' . '000000000402400000000000000000000000000004008000000000000402400000000000040240000000000004008000' . '000000000000000000000000040240000000000004008000000000000000000000000000000000000000000004008000' @@ -2007,7 +2255,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiPolygonZMValueWithSrid' => array( + 'ndrMultiPolygonZMValueWithSrid' => array( 'value' => '01060000e0e61000000100000001030000c00200000005000000000000000000000000000000000000000000000' . '000000840000000000000004000000000000024400000000000000000000000000000084000000000000000400000000' . '000002440000000000000244000000000000008400000000000000040000000000000000000000000000024400000000' @@ -2040,7 +2288,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiPolygonZMValueWithSrid' => array( + 'xdrMultiPolygonZMValueWithSrid' => array( 'value' => '00e0000006000010e60000000100c00000030000000200000005000000000000000000000000000000004008000' . '000000000400000000000000040240000000000000000000000000000400800000000000040000000000000004024000' . '000000000402400000000000040080000000000004000000000000000000000000000000040240000000000004008000' @@ -2073,7 +2321,30 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRGeometryCollectionValue' => array( + 'ndrEmptyGeometryCollectionValue' => array( + 'value' => '010700000000000000', + 'expected' => array( + 'srid' => null, + 'type' => 'GEOMETRYCOLLECTION', + 'value' => array(), + 'dimension' => null + ) + ), + 'ndrGeometryCollectionValueWithEmptyPoint' => array( + 'value' => '0107000000010000000101000000000000000000F87F000000000000F87F', + 'expected' => array( + 'srid' => null, + 'type' => 'GEOMETRYCOLLECTION', + 'value' => array( + array( + 'type' => 'POINT', + 'value' => array() + ), + ), + 'dimension' => null + ) + ), + 'ndrGeometryCollectionValue' => array( 'value' => '01070000000300000001010000000000000000002440000000000000244001010000000000000000003E4000000' . '00000003E400102000000020000000000000000002E400000000000002E4000000000000034400000000000003440', 'expected' => array( @@ -2099,7 +2370,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRGeometryCollectionValue' => array( + 'xdrGeometryCollectionValue' => array( 'value' => '0000000007000000030000000001402400000000000040240000000000000000000001403E000000000000403E0' . '00000000000000000000200000002402E000000000000402E00000000000040340000000000004034000000000000', 'expected' => array( @@ -2125,7 +2396,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRGeometryCollectionZValue' => array( + 'ndrGeometryCollectionZValue' => array( 'value' => '0107000080030000000101000080000000000000000000000000000000000000000000000000010200008002000' . '000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f' . '03f010700008002000000010100008000000000000000000000000000000000000000000000000001020000800200000' @@ -2166,7 +2437,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRGeometryCollectionZValue' => array( + 'xdrGeometryCollectionZValue' => array( 'value' => '0080000007000000030080000001000000000000000000000000000000000000000000000000008000000200000' . '0020000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff0000000000' . '000008000000700000002008000000100000000000000000000000000000000000000000000000000800000020000000' @@ -2207,7 +2478,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRGeometryCollectionMValue' => array( + 'ndrGeometryCollectionMValue' => array( 'value' => '0107000040030000000101000040000000000000000000000000000000000000000000000000010200004002000' . '000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f' . '03f010700004002000000010100004000000000000000000000000000000000000000000000000001020000400200000' @@ -2248,7 +2519,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRGeometryCollectionMValue' => array( + 'xdrGeometryCollectionMValue' => array( 'value' => '0040000007000000030040000001000000000000000000000000000000000000000000000000004000000200000' . '0020000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff0000000000' . '000004000000700000002004000000100000000000000000000000000000000000000000000000000400000020000000' @@ -2289,7 +2560,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRGeometryCollectionZMValue' => array( + 'ndrGeometryCollectionZMValue' => array( 'value' => '01070000c00300000001010000c0000000000000000000000000000000000000000000000000000000000000f03' . 'f01020000c0020000000000000000000000000000000000000000000000000000000000000000000040000000000000f' . '03f000000000000f03f000000000000f03f000000000000084001070000c00200000001010000c000000000000000000' @@ -2331,7 +2602,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRGeometryCollectionZMValue' => array( + 'xdrGeometryCollectionZMValue' => array( 'value' => '00c00000070000000300c00000010000000000000000000000000000000000000000000000003ff000000000000' . '000c00000020000000200000000000000000000000000000000000000000000000040000000000000003ff0000000000' . '0003ff00000000000003ff0000000000000400800000000000000c00000070000000200c000000100000000000000000' @@ -2373,7 +2644,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRGeometryCollectionValueWithSrid' => array( + 'ndrGeometryCollectionValueWithSrid' => array( 'value' => '0107000020E61000000300000001010000000000000000002440000000000000244001010000000000000000003' . 'E400000000000003E400102000000020000000000000000002E400000000000002E40000000000000344000000000000' . '03440', @@ -2400,7 +2671,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRGeometryCollectionValueWithSrid' => array( + 'xdrGeometryCollectionValueWithSrid' => array( 'value' => '0020000007000010E6000000030000000001402400000000000040240000000000000000000001403E000000000' . '000403E000000000000000000000200000002402E000000000000402E000000000000403400000000000040340000000' . '00000', @@ -2427,7 +2698,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRGeometryCollectionZValueWithSrid' => array( + 'ndrGeometryCollectionZValueWithSrid' => array( 'value' => '01070000a0e61000000300000001010000800000000000000000000000000000000000000000000000000102000' . '08002000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f00000' . '0000000f03f0107000080020000000101000080000000000000000000000000000000000000000000000000010200008' @@ -2468,7 +2739,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRGeometryCollectionZValueWithSrid' => array( + 'xdrGeometryCollectionZValueWithSrid' => array( 'value' => '00a0000007000010e60000000300800000010000000000000000000000000000000000000000000000000080000' . '002000000020000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff00' . '000000000000080000007000000020080000001000000000000000000000000000000000000000000000000008000000' @@ -2509,7 +2780,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRGeometryCollectionMValueWithSrid' => array( + 'ndrGeometryCollectionMValueWithSrid' => array( 'value' => '0107000060e61000000300000001010000400000000000000000000000000000000000000000000000000102000' . '04002000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f00000' . '0000000f03f0107000040020000000101000040000000000000000000000000000000000000000000000000010200004' @@ -2550,7 +2821,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRGeometryCollectionMValueWithSrid' => array( + 'xdrGeometryCollectionMValueWithSrid' => array( 'value' => '0060000007000010e60000000300400000010000000000000000000000000000000000000000000000000040000' . '002000000020000000000000000000000000000000000000000000000003ff00000000000003ff00000000000003ff00' . '000000000000040000007000000020040000001000000000000000000000000000000000000000000000000004000000' @@ -2591,7 +2862,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRGeometryCollectionZMValueWithSrid' => array( + 'ndrGeometryCollectionZMValueWithSrid' => array( 'value' => '01070000e0e61000000300000001010000c00000000000000000000000000000000000000000000000000000000' . '00000f03f01020000c002000000000000000000000000000000000000000000000000000000000000000000004000000' . '0000000f03f000000000000f03f000000000000f03f000000000000084001070000c00200000001010000c0000000000' @@ -2633,7 +2904,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRGeometryCollectionZMValueWithSrid' => array( + 'xdrGeometryCollectionZMValueWithSrid' => array( 'value' => '00e0000007000010e60000000300c00000010000000000000000000000000000000000000000000000003ff0000' . '00000000000c00000020000000200000000000000000000000000000000000000000000000040000000000000003ff00' . '000000000003ff00000000000003ff0000000000000400800000000000000c00000070000000200c0000001000000000' @@ -2675,7 +2946,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRCircularStringValue' => array( + 'ndrCircularStringValue' => array( 'value' => '01080000000300000000000000000000000000000000000000000000000000f03f000000000000f03f000000000' . '00000400000000000000000', 'expected' => array( @@ -2689,7 +2960,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRCircularStringValue' => array( + 'xdrCircularStringValue' => array( 'value' => '000000000800000003000000000000000000000000000000003ff00000000000003ff0000000000000400000000' . '00000000000000000000000', 'expected' => array( @@ -2703,7 +2974,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRCircularStringZValue' => array( + 'ndrCircularStringZValue' => array( 'value' => '01080000800300000000000000000000000000000000000000000000000000f03f000000000000f03f000000000' . '000f03f000000000000f03f00000000000000400000000000000000000000000000f03f', 'expected' => array( @@ -2717,7 +2988,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRCircularStringZValue' => array( + 'xdrCircularStringZValue' => array( 'value' => '008000000800000003000000000000000000000000000000003ff00000000000003ff00000000000003ff000000' . '00000003ff0000000000000400000000000000000000000000000003ff0000000000000', 'expected' => array( @@ -2731,7 +3002,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRCircularStringMValue' => array( + 'ndrCircularStringMValue' => array( 'value' => '01080000400300000000000000000000000000000000000000000000000000f03f000000000000f03f000000000' . '000f03f000000000000f03f00000000000000400000000000000000000000000000f03f', 'expected' => array( @@ -2745,7 +3016,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRCircularStringMValue' => array( + 'xdrCircularStringMValue' => array( 'value' => '004000000800000003000000000000000000000000000000003ff00000000000003ff00000000000003ff000000' . '00000003ff0000000000000400000000000000000000000000000003ff0000000000000', 'expected' => array( @@ -2759,7 +3030,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRCircularStringZMValue' => array( + 'ndrCircularStringZMValue' => array( 'value' => '01080000c00300000000000000000000000000000000000000000000000000f03f0000000000000040000000000' . '000f03f000000000000f03f000000000000f03f000000000000004000000000000000400000000000000000000000000' . '000f03f0000000000000040', @@ -2774,7 +3045,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRCircularStringZMValue' => array( + 'xdrCircularStringZMValue' => array( 'value' => '00c000000800000003000000000000000000000000000000003ff000000000000040000000000000003ff000000' . '00000003ff00000000000003ff00000000000004000000000000000400000000000000000000000000000003ff000000' . '00000004000000000000000', @@ -2789,7 +3060,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRCompoundCurveValue' => array( + 'ndrCompoundCurveValue' => array( 'value' => '01090000000200000001080000000300000000000000000000000000000000000000000000000000f03f0000000' . '00000f03f000000000000004000000000000000000102000000020000000000000000000040000000000000000000000' . '00000001040000000000000f03f', @@ -2816,7 +3087,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRCompoundCurveValue' => array( + 'xdrCompoundCurveValue' => array( 'value' => '000000000900000002000000000800000003000000000000000000000000000000003ff00000000000003ff0000' . '000000000400000000000000000000000000000000000000002000000024000000000000000000000000000000040100' . '000000000003ff0000000000000', @@ -2843,7 +3114,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRCompoundCurveZValue' => array( + 'ndrCompoundCurveZValue' => array( 'value' => '01090000800200000001080000800300000000000000000000000000000000000000000000000000f03f0000000' . '00000f03f000000000000f03f000000000000f03f00000000000000400000000000000000000000000000f03f0102000' . '080020000000000000000000040000000000000000000000000000000000000000000001040000000000000f03f00000' @@ -2871,7 +3142,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRCompoundCurveZValue' => array( + 'xdrCompoundCurveZValue' => array( 'value' => '008000000900000002008000000800000003000000000000000000000000000000003ff00000000000003ff0000' . '0000000003ff00000000000003ff0000000000000400000000000000000000000000000003ff00000000000000080000' . '0020000000240000000000000000000000000000000000000000000000040100000000000003ff00000000000003ff00' @@ -2899,7 +3170,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRCompoundCurveMValue' => array( + 'ndrCompoundCurveMValue' => array( 'value' => '01090000400200000001080000400300000000000000000000000000000000000000000000000000f03f0000000' . '00000f03f000000000000f03f000000000000f03f00000000000000400000000000000000000000000000f03f0102000' . '040020000000000000000000040000000000000000000000000000000000000000000001040000000000000f03f00000' @@ -2927,7 +3198,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRCompoundCurveMValue' => array( + 'xdrCompoundCurveMValue' => array( 'value' => '004000000900000002004000000800000003000000000000000000000000000000003ff00000000000003ff0000' . '0000000003ff00000000000003ff0000000000000400000000000000000000000000000003ff00000000000000040000' . '0020000000240000000000000000000000000000000000000000000000040100000000000003ff00000000000003ff00' @@ -2955,7 +3226,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRCompoundCurveZMValue' => array( + 'ndrCompoundCurveZMValue' => array( 'value' => '01090000c00200000001080000c00300000000000000000000000000000000000000000000000000f03f0000000' . '000000040000000000000f03f000000000000f03f000000000000f03f000000000000004000000000000000400000000' . '000000000000000000000f03f000000000000004001020000c0020000000000000000000040000000000000000000000' @@ -2983,7 +3254,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRCompoundCurveZMValue' => array( + 'xdrCompoundCurveZMValue' => array( 'value' => '00c00000090000000200c000000800000003000000000000000000000000000000003ff00000000000004000000' . '0000000003ff00000000000003ff00000000000003ff0000000000000400000000000000040000000000000000000000' . '0000000003ff0000000000000400000000000000000c0000002000000024000000000000000000000000000000000000' @@ -3011,7 +3282,35 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRCurvePolygonValue' => array( + 'ndrCurvePolygonValue' => array( + 'value' => '010A000000020000000108000000030000000000000000000000000000000000000000000000000008400000000' + . '0000008400000000000001C400000000000001C400102000000030000000000000000001C400000000000001C4000000' + . '00000002040000000000000204000000000000022400000000000002240', + 'expected' => array( + 'srid' => null, + 'type' => 'CURVEPOLYGON', + 'value' => array( + array( + 'type' => 'CIRCULARSTRING', + 'value' => array( + array(0, 0), + array(3, 3), + array(7, 7) + ) + ), + array( + 'type' => 'LINESTRING', + 'value' => array( + array(7, 7), + array(8, 8), + array(9, 9) + ) + ) + ), + 'dimension' => null + ) + ), + 'ndrCurvePolygonCompoundCurveValue' => array( 'value' => '010a000000010000000109000000020000000108000000030000000000000000000000000000000000000000000' . '0000000f03f000000000000f03f000000000000004000000000000000000102000000030000000000000000000040000' . '0000000000000000000000000f03f000000000000f0bf00000000000000000000000000000000', @@ -3044,7 +3343,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRCurvePolygonValue' => array( + 'xdrCurvePolygonCompoundCurveValue' => array( 'value' => '000000000a00000001000000000900000002000000000800000003000000000000000000000000000000003ff00' . '000000000003ff0000000000000400000000000000000000000000000000000000002000000034000000000000000000' . '00000000000003ff0000000000000bff000000000000000000000000000000000000000000000', @@ -3077,7 +3376,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRCurvePolygonZValue' => array( + 'ndrCurvePolygonZCompoundCurveValue' => array( 'value' => '010a000080010000000109000080020000000108000080030000000000000000000000000000000000000000000' . '0000000f03f000000000000f03f000000000000f03f000000000000f03f0000000000000040000000000000000000000' . '0000000f03f01020000800300000000000000000000400000000000000000000000000000f03f000000000000f03f000' @@ -3111,7 +3410,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRCurvePolygonZValue' => array( + 'xdrCurvePolygonZCompoundCurveValue' => array( 'value' => '008000000a00000001008000000900000002008000000800000003000000000000000000000000000000003ff00' . '000000000003ff00000000000003ff00000000000003ff0000000000000400000000000000000000000000000003ff00' . '00000000000008000000200000003400000000000000000000000000000003ff00000000000003ff0000000000000bff' @@ -3145,7 +3444,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRCurvePolygonMValue' => array( + 'ndrCurvePolygonMCompoundCurveValue' => array( 'value' => '010a000040010000000109000040020000000108000040030000000000000000000000000000000000000000000' . '0000000f03f000000000000f03f000000000000f03f000000000000f03f0000000000000040000000000000000000000' . '0000000f03f01020000400300000000000000000000400000000000000000000000000000f03f000000000000f03f000' @@ -3179,7 +3478,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRCurvePolygonMValue' => array( + 'xdrCurvePolygonMCompoundCurveValue' => array( 'value' => '004000000a00000001004000000900000002004000000800000003000000000000000000000000000000003ff00' . '000000000003ff00000000000003ff00000000000003ff0000000000000400000000000000000000000000000003ff00' . '00000000000004000000200000003400000000000000000000000000000003ff00000000000003ff0000000000000bff' @@ -3213,7 +3512,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRCurvePolygonZMValue' => array( + 'ndrCurvePolygonZMCompoundCurveValue' => array( 'value' => '010a0000c00100000001090000c00200000001080000c0030000000000000000000000000000000000000000000' . '0000000f03f0000000000000040000000000000f03f000000000000f03f000000000000f03f000000000000004000000' . '000000000400000000000000000000000000000f03f000000000000004001020000c0030000000000000000000040000' @@ -3248,7 +3547,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRCurvePolygonZMValue' => array( + 'xdrCurvePolygonZMVCompoundCurvealue' => array( 'value' => '00c000000a0000000100c00000090000000200c000000800000003000000000000000000000000000000003ff00' . '0000000000040000000000000003ff00000000000003ff00000000000003ff0000000000000400000000000000040000' . '0000000000000000000000000003ff0000000000000400000000000000000c0000002000000034000000000000000000' @@ -3283,7 +3582,35 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiCurveValue' => array( + 'ndrMultiCurveValue' => array( + 'value' => '010B000000020000000108000000030000000000000000000000000000000000000000000000000008400000000' + . '0000008400000000000001C400000000000001C400102000000030000000000000000001C400000000000001C4000000' + . '00000002040000000000000204000000000000022400000000000002240', + 'expected' => array( + 'srid' => null, + 'type' => 'MULTICURVE', + 'value' => array( + array( + 'type' => 'CIRCULARSTRING', + 'value' => array( + array(0, 0), + array(3, 3), + array(7, 7) + ) + ), + array( + 'type' => 'LINESTRING', + 'value' => array( + array(7, 7), + array(8, 8), + array(9, 9) + ) + ) + ), + 'dimension' => null + ) + ), + 'ndrMultiCurveCompoundCurveValue' => array( 'value' => '010b000000010000000109000000020000000108000000030000000000000000000000000000000000000000000' . '0000000f03f000000000000f03f000000000000004000000000000000000102000000030000000000000000000040000' . '0000000000000000000000000f03f000000000000f0bf00000000000000000000000000000000', @@ -3316,7 +3643,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiCurveValue' => array( + 'xdrMultiCurveCompoundCurveValue' => array( 'value' => '000000000b00000001000000000900000002000000000800000003000000000000000000000000000000003ff00' . '000000000003ff0000000000000400000000000000000000000000000000000000002000000034000000000000000000' . '00000000000003ff0000000000000bff000000000000000000000000000000000000000000000', @@ -3349,7 +3676,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiCurveZValue' => array( + 'ndrMultiCurveZCompoundCurveValue' => array( 'value' => '010b000080010000000109000080020000000108000080030000000000000000000000000000000000000000000' . '0000000f03f000000000000f03f000000000000f03f000000000000f03f0000000000000040000000000000000000000' . '0000000f03f01020000800300000000000000000000400000000000000000000000000000f03f000000000000f03f000' @@ -3383,7 +3710,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiCurveZValue' => array( + 'xdrMultiCurveZCompoundCurveValue' => array( 'value' => '008000000b00000001008000000900000002008000000800000003000000000000000000000000000000003ff00' . '000000000003ff00000000000003ff00000000000003ff0000000000000400000000000000000000000000000003ff00' . '00000000000008000000200000003400000000000000000000000000000003ff00000000000003ff0000000000000bff' @@ -3417,7 +3744,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiCurveMValue' => array( + 'ndrMultiCurveMCompoundCurveValue' => array( 'value' => '010b000040010000000109000040020000000108000040030000000000000000000000000000000000000000000' . '0000000f03f000000000000f03f000000000000f03f000000000000f03f0000000000000040000000000000000000000' . '0000000f03f01020000400300000000000000000000400000000000000000000000000000f03f000000000000f03f000' @@ -3451,7 +3778,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiCurveMValue' => array( + 'xdrMultiCurveMCompoundCurveValue' => array( 'value' => '004000000b00000001004000000900000002004000000800000003000000000000000000000000000000003ff00' . '000000000003ff00000000000003ff00000000000003ff0000000000000400000000000000000000000000000003ff00' . '00000000000004000000200000003400000000000000000000000000000003ff00000000000003ff0000000000000bff' @@ -3485,7 +3812,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiCurveZMValue' => array( + 'ndrMultiCurveZMCompoundCurveValue' => array( 'value' => '010b0000c00100000001090000c00200000001080000c0030000000000000000000000000000000000000000000' . '0000000f03f0000000000000040000000000000f03f000000000000f03f000000000000f03f000000000000004000000' . '000000000400000000000000000000000000000f03f000000000000004001020000c0030000000000000000000040000' @@ -3520,7 +3847,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiCurveZMValue' => array( + 'xdrMultiCurveZMCompoundCurveValue' => array( 'value' => '00c000000b0000000100c00000090000000200c000000800000003000000000000000000000000000000003ff00' . '0000000000040000000000000003ff00000000000003ff00000000000003ff0000000000000400000000000000040000' . '0000000000000000000000000003ff0000000000000400000000000000000c0000002000000034000000000000000000' @@ -3555,7 +3882,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRMultiSurfaceValue' => array( + 'ndrMultiSurfaceValue' => array( 'value' => '010c00000002000000010a000000010000000109000000020000000108000000030000000000000000000000000' . '0000000000000000000000000f03f000000000000f03f000000000000004000000000000000000102000000030000000' . '0000000000000400000000000000000000000000000f03f000000000000f0bf000000000000000000000000000000000' @@ -3607,7 +3934,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingXDRMultiSurfaceValue' => array( + 'xdrMultiSurfaceValue' => array( 'value' => '000000000c00000002000000000a000000010000000009000000020000000008000000030000000000000000000' . '00000000000003ff00000000000003ff0000000000000400000000000000000000000000000000000000002000000034' . '00000000000000000000000000000003ff0000000000000bff0000000000000000000000000000000000000000000000' @@ -3659,7 +3986,7 @@ public function goodBinaryData() 'dimension' => null ) ), - 'testParsingNDRMultiSurfaceZValue' => array( + 'ndrMultiSurfaceZValue' => array( 'value' => '010c00008002000000010a000080010000000109000080020000000108000080030000000000000000000000000' . '0000000000000000000000000f03f000000000000f03f000000000000f03f000000000000f03f0000000000000040000' . '0000000000000000000000000f03f01020000800300000000000000000000400000000000000000000000000000f03f0' @@ -3713,7 +4040,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingXDRMultiSurfaceZValue' => array( + 'xdrMultiSurfaceZValue' => array( 'value' => '008000000c00000002008000000a000000010080000009000000020080000008000000030000000000000000000' . '00000000000003ff00000000000003ff00000000000003ff00000000000003ff00000000000004000000000000000000' . '00000000000003ff0000000000000008000000200000003400000000000000000000000000000003ff00000000000003' @@ -3767,7 +4094,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRMultiSurfaceMValue' => array( + 'ndrMultiSurfaceMValue' => array( 'value' => '010c00004002000000010a000040010000000109000040020000000108000040030000000000000000000000000' . '0000000000000000000000000f03f000000000000f03f000000000000f03f000000000000f03f0000000000000040000' . '0000000000000000000000000f03f01020000400300000000000000000000400000000000000000000000000000f03f0' @@ -3821,7 +4148,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingXDRMultiSurfaceMValue' => array( + 'xdrMultiSurfaceMValue' => array( 'value' => '004000000c00000002004000000a000000010040000009000000020040000008000000030000000000000000000' . '00000000000003ff00000000000003ff00000000000003ff00000000000003ff00000000000004000000000000000000' . '00000000000003ff0000000000000004000000200000003400000000000000000000000000000003ff00000000000003' @@ -3875,7 +4202,7 @@ public function goodBinaryData() 'dimension' => 'M' ) ), - 'testParsingNDRMultiSurfaceZMValue' => array( + 'ndrMultiSurfaceZMValue' => array( 'value' => '010c0000c002000000010a0000c00100000001090000c00200000001080000c0030000000000000000000000000' . '0000000000000000000000000f03f0000000000000040000000000000f03f000000000000f03f000000000000f03f000' . '000000000004000000000000000400000000000000000000000000000f03f000000000000004001020000c0030000000' @@ -3931,7 +4258,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingXDRMultiSurfaceZMValue' => array( + 'xdrMultiSurfaceZMValue' => array( 'value' => '00c000000c0000000200c000000a0000000100c00000090000000200c0000008000000030000000000000000000' . '00000000000003ff000000000000040000000000000003ff00000000000003ff00000000000003ff0000000000000400' . '0000000000000400000000000000000000000000000003ff0000000000000400000000000000000c0000002000000034' @@ -3987,7 +4314,7 @@ public function goodBinaryData() 'dimension' => 'ZM' ) ), - 'testParsingNDRPolyhedralSurfaceZValue' => array( + 'ndrPolyhedralSurfaceZValue' => array( 'value' => '010f000080050000000103000080010000000500000000000000000000000000000000000000000000000000000' . '000000000000000000000000000000000000000000000144000000000000000000000000000002e40000000000000144' . '000000000000000000000000000002e40000000000000000000000000000000000000000000000000000000000000000' @@ -4071,7 +4398,7 @@ public function goodBinaryData() 'dimension' => 'Z' ) ), - 'testParsingNDRPolyhedralSurfaceMValue' => array( + 'ndrPolyhedralSurfaceMValue' => array( 'value' => '010f000040050000000103000040010000000500000000000000000000000000000000000000000000000000000' . '000000000000000000000000000000000000000000000144000000000000000000000000000002e40000000000000144' . '000000000000000000000000000002e40000000000000000000000000000000000000000000000000000000000000000' @@ -4154,36 +4481,218 @@ public function goodBinaryData() ), 'dimension' => 'M' ) + ), + 'xdrGeometryCollectionValue2' => array( + 'value' => '01070000000600000001010000000000000000000000000000000000f03f010200000002000000000000000000004000000000000008400000000000001040000000000000144001030000000200000005000000000000000000000000000000000000000000000000000000000000000000244000000000000024400000000000002440000000000000244000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f000000000000f03f0000000000002240000000000000224000000000000022400000000000002240000000000000f03f000000000000f03f000000000000f03f01040000000200000001010000000000000000000000000000000000f03f0101000000000000000000004000000000000008400105000000020000000102000000020000000000000000000000000000000000f03f000000000000004000000000000008400102000000020000000000000000001040000000000000144000000000000018400000000000001c4001060000000200000001030000000200000005000000000000000000000000000000000000000000000000000000000000000000244000000000000024400000000000002440000000000000244000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f000000000000f03f0000000000002240000000000000224000000000000022400000000000002240000000000000f03f000000000000f03f000000000000f03f0103000000010000000500000000000000000022c0000000000000000000000000000022c00000000000002440000000000000f0bf0000000000002440000000000000f0bf000000000000000000000000000022c00000000000000000', + 'expected' => array( + 'type' => 'GEOMETRYCOLLECTION', + 'srid' => null, + 'value' => array( + array( + 'type' => 'POINT', + 'value' => array(0, 1) + ), + array( + 'type' => 'LINESTRING', + 'value' => array( + array(2, 3), + array(4, 5) + ) + ), + array( + 'type' => 'POLYGON', + 'value' => array( + array( + array(0, 0), + array(0, 10), + array(10, 10), + array(10, 0), + array(0, 0) + ), + array( + array(1, 1), + array(1, 9), + array(9, 9), + array(9, 1), + array(1, 1) + ) + ) + ), + array( + 'type' => 'MULTIPOINT', + 'value' => array( + array(0, 1), + array(2, 3) + ) + ), + array( + 'type' => 'MULTILINESTRING', + 'value' => array( + array( + array(0, 1), + array(2, 3) + ), + array( + array(4, 5), + array(6, 7) + ) + ) + ), + array( + 'type' => 'MULTIPOLYGON', + 'value' => array( + array( + array( + array(0, 0), + array(0, 10), + array(10, 10), + array(10, 0), + array(0, 0) + ), + array( + array(1, 1), + array(1, 9), + array(9, 9), + array(9, 1), + array(1, 1)) + ), + array( + array( + array(-9, 0), + array(-9, 10), + array(-1, 10), + array(-1, 0), + array(-9, 0) + ) + ) + ) + ) + ), + 'dimension' => null + ) + ), + 'xdrMultiPointValue2' => array( + 'value' => '01040000000200000001010000000000000000000000000000000000f03f010100000000000000000000400000000000000840', + 'expected' => array( + 'type' => 'MULTIPOINT', + 'value' => array(array(0, 1), array(2, 3)), + 'srid' => null, + 'dimension' => null, + ) + ), + 'xdrMultiLineStringValue2' => array( + 'value' => '0105000000020000000102000000020000000000000000000000000000000000f03f000000000000004000000000000008400102000000020000000000000000001040000000000000144000000000000018400000000000001c40', + 'expected' => array( + 'type' => 'MULTILINESTRING', + 'value' => array(array(array(0, 1), array(2, 3)), array(array(4, 5), array(6, 7))), + 'srid' => null, + 'dimension' => null, + ) + ), + 'xdrMultiPolygonValue2' => array( + 'value' => '01060000000200000001030000000200000005000000000000000000000000000000000000000000000000000000000000000000244000000000000024400000000000002440000000000000244000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f000000000000f03f0000000000002240000000000000224000000000000022400000000000002240000000000000f03f000000000000f03f000000000000f03f0103000000010000000500000000000000000022c0000000000000000000000000000022c00000000000002440000000000000f0bf0000000000002440000000000000f0bf000000000000000000000000000022c00000000000000000', + 'expected' => array( + 'type' => 'MULTIPOLYGON', + 'value' => array(array(array(array(0,0), array(0,10), array(10,10), array(10,0), array(0,0)), array(array(1,1), array(1,9), array(9,9), array(9,1), array(1,1))), array(array(array(-9,0), array(-9,10), array(-1,10), array(-1,0), array(-9,0)))), + 'srid' => null, + 'dimension' => null, + ) + ), + 'xdrMultiPointZOGCValue' => array( + 'value' => '01ec0300000200000001e90300000000000000000000000000000000f03f000000000000004001e9030000000000000000084000000000000010400000000000001440', + 'expected' => array( + 'type' => 'MULTIPOINT', + 'value'=> array(array(0, 1, 2), array(3, 4, 5)), + 'srid' => null, + 'dimension' => 'Z', + ) + ), + 'xdrMultiLineStringZOGCValue' => array( + 'value' => '01ed0300000200000001ea030000020000000000000000000000000000000000f03f000000000000004000000000000008400000000000001040000000000000144001ea0300000200000000000000000018400000000000001c400000000000002040000000000000224000000000000024400000000000002640', + 'expected' => array( + 'type' => 'MULTILINESTRING', + 'value' => array(array(array(0, 1, 2), array(3, 4, 5)), array(array(6, 7, 8), array(9, 10, 11))), + 'srid' => null, + 'dimension' => 'Z' + ) + ), + 'xdrMultiPolygonZOGCValue' => array( + 'value' => '01ee0300000200000001eb030000020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000f03f000000000000f03f0000000000005940000000000000f03f000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000f03f0000000000005940000000000000f03f000000000000f03f000000000000594001eb030000010000000500000000000000000022c00000000000000000000000000000494000000000000022c000000000000024400000000000004940000000000000f0bf00000000000024400000000000004940000000000000f0bf0000000000000000000000000000494000000000000022c000000000000000000000000000004940', + 'expected' => array( + 'type' => 'MULTIPOLYGON', + 'value' => array( + array( + array(array(0, 0, 100), array(0, 10, 100), array(10, 10, 100), array(10, 0, 100), array(0, 0, 100)), + array(array(1, 1, 100), array(1, 9, 100), array(9, 9, 100), array(9, 1, 100), array(1, 1, 100)) + ), + array( + array(array(-9, 0, 50), array(-9, 10, 50), array(-1, 10, 50), array(-1, 0, 50), array(-9, 0, 50)) + ) + ), + 'srid'=>null, + 'dimension' => 'Z' + ) + ), + 'xdrPointValue2' => array( + 'value' => '0101000000000000000000f03f0000000000000040', + 'expected' => array( + 'type' => 'POINT', + 'value' => array(1, 2), + 'srid' => null, + 'dimension' => null + ) + ), + 'xdrLineStringValue2' => array( + 'value' => '010200000002000000000000000000f03f000000000000004000000000000008400000000000001040', + 'expected' => array( + 'type' => 'LINESTRING', + 'value' => array(array(1, 2), array(3, 4)), + 'srid' => null, + 'dimension' => null + ) + ), + 'xdrPolygonValue2' => array( + 'value' => '01030000000200000005000000000000000000000000000000000000000000000000000000000000000000244000000000000024400000000000002440000000000000244000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f000000000000f03f0000000000002240000000000000224000000000000022400000000000002240000000000000f03f000000000000f03f000000000000f03f', + 'expected' => array( + 'type' => 'POLYGON', + 'value' => array( + array(array(0, 0), array(0, 10), array(10, 10), array(10, 0), array(0, 0)), + array(array(1, 1), array(1, 9), array(9, 9), array(9, 1), array(1, 1)) + ), + 'srid' => null, + 'dimension' => null + ) + ), + 'xdrPointZOGCValue2' => array( + 'value' => '01e9030000000000000000f03f00000000000000400000000000000840', + 'expected' => array( + 'type' => 'POINT', + 'value' => array(1, 2, 3), + 'srid' => null, + 'dimension' => 'Z', + ) + ), + 'xdrLineStringZOGCValue' => array( + 'value' => '01ea03000002000000000000000000f03f00000000000000400000000000000840000000000000104000000000000014400000000000001840', + 'expected' => array( + 'type' => 'LINESTRING', + 'value' => array(array(1, 2, 3), array(4, 5, 6)), + 'srid' => null, + 'dimension' => 'Z', + ) + ), + 'xdrPolygonZOGCValue' => array( + 'value' => '01eb030000020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000f03f000000000000f03f0000000000005940000000000000f03f000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000f03f0000000000005940000000000000f03f000000000000f03f0000000000005940', + 'expected' => array( + 'type' => 'POLYGON', + 'value' => array( + array(array(0, 0, 100), array(0, 10, 100), array(10, 10, 100), array(10, 0, 100), array(0, 0, 100)), + array(array(1, 1, 100), array(1, 9, 100), array(9, 9, 100), array(9, 1, 100), array(1, 1, 100)) + ), + 'srid' => null, + 'dimension' => 'Z', + ) ) ); } - - /** - * @param $value - * @param array $expected - * - * @dataProvider goodBinaryData - */ - public function testParser($value, array $expected) - { - $value = pack('H*', $value); - $parser = new Parser($value); - $actual = $parser->parse(); - - $this->assertEquals($expected, $actual); - } - - /** - */ - public function testReusedParser() - { - $parser = new Parser(); - - foreach ($this->goodBinaryData() as $testData) { - $value = pack('H*', $testData['value']); - $actual = $parser->parse($value); - - $this->assertEquals($testData['expected'], $actual); - } - } } diff --git a/tests/CrEOF/Geo/WKB/Tests/ReaderTest.php b/tests/CrEOF/Geo/WKB/Tests/ReaderTest.php index d003978..cd7e302 100644 --- a/tests/CrEOF/Geo/WKB/Tests/ReaderTest.php +++ b/tests/CrEOF/Geo/WKB/Tests/ReaderTest.php @@ -1,6 +1,6 @@ * @license http://dlambert.mit-license.org MIT + * + * @covers \CrEOF\Geo\WKB\Reader */ class ReaderTest extends \PHPUnit_Framework_TestCase { - public function testReadingBinaryByteOrder() - { - $value = '01'; - $value = pack('H*', $value); - $reader = new Reader($value); - $result = $reader->readByteOrder(); - - $this->assertEquals(1, $result); - } - - public function testReadingHexByteOrder() - { - $value = '01'; - $reader = new Reader($value); - $result = $reader->readByteOrder(); - - $this->assertEquals(1, $result); - } - - public function testReadingPrefixedHexByteOrder() - { - $value = '0x01'; - $reader = new Reader($value); - $result = $reader->readByteOrder(); - - $this->assertEquals(1, $result); - } - /** - * @expectedException \CrEOF\Geo\WKB\Exception\UnexpectedValueException - * @expectedExceptionMessage Invalid byte order "unset" + * @param mixed $value + * @param array $methods + * @param string $exception + * @param string $message + * + * @dataProvider badTestData */ - public function testReadingBinaryWithoutByteOrder() + public function testBad($value, array $methods, $exception, $message) { - $value = '0101000000'; - $value = pack('H*', $value); + if (version_compare(\PHPUnit_Runner_Version::id(), '5.0', '>=')) { + $this->expectException($exception); + + if ('/' === $message[0]) { + $this->expectExceptionMessageRegExp($message); + } else { + $this->expectExceptionMessage($message); + } + } else { + if ('/' === $message[0]) { + $this->setExpectedExceptionRegExp($exception, $message); + } else { + $this->setExpectedException($exception, $message); + } + } + $reader = new Reader($value); - $reader->readLong(); + foreach ($methods as $method) { + $reader->$method(); + } } /** - * @expectedException \CrEOF\Geo\WKB\Exception\UnexpectedValueException - * @expectedExceptionMessage Invalid byte order "unset" + * @param mixed $value + * @param array $methods + * + * @dataProvider goodTestData */ - public function testReadingHexWithoutByteOrder() - { - $value = '0101000000'; - $reader = new Reader($value); - - $reader->readLong(); - } - - public function testReadingNDRBinaryLong() - { - $value = '0101000000'; - $value = pack('H*', $value); - $reader = new Reader($value); - - $reader->readByteOrder(); - - $result = $reader->readLong(); - - $this->assertEquals(1, $result); - } - - public function testReadingXDRBinaryLong() - { - $value = '0000000001'; - $value = pack('H*', $value); - $reader = new Reader($value); - - $reader->readByteOrder(); - - $result = $reader->readLong(); - - $this->assertEquals(1, $result); - } - - public function testReadingNDRHexLong() - { - $value = '0101000000'; - $reader = new Reader($value); - - $reader->readByteOrder(); - - $result = $reader->readLong(); - - $this->assertEquals(1, $result); - } - - public function testReadingXDRHexLong() - { - $value = '0000000001'; - $reader = new Reader($value); - - $reader->readByteOrder(); - - $result = $reader->readLong(); - - $this->assertEquals(1, $result); - } - - public function testReadingNDRBinaryDouble() + public function testGood($value, array $methods) { - $value = '013D0AD7A3701D4140'; - $value = pack('H*', $value); $reader = new Reader($value); - $reader->readByteOrder(); + foreach ($methods as $test) { + list($method, $argument, $expected) = $test; - $result = $reader->readDouble(); + $actual = $reader->$method($argument); - $this->assertEquals(34.23, $result); + $this->assertSame($expected, $actual); + } } - public function testReadingXDRBinaryDouble() - { - $value = '0040411D70A3D70A3D'; - $value = pack('H*', $value); - $reader = new Reader($value); - - $reader->readByteOrder(); - - $result = $reader->readDouble(); - - $this->assertEquals(34.23, $result); - } - - public function testReadingNDRHexDouble() + /** + * @return array[] + */ + public function badTestData() { - $value = '013D0AD7A3701D4140'; - $reader = new Reader($value); - - $reader->readByteOrder(); - - $result = $reader->readDouble(); - - $this->assertEquals(34.23, $result); + return array( + 'readBinaryBadByteOrder' => array( + 'value' => pack('H*', '04'), + 'methods' => array('readByteOrder'), + 'exception' => '\CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Invalid byte order "4"' + ), + 'readBinaryWithoutByteOrder' => array( + 'value' => pack('H*', '0101000000'), + 'methods' => array('readLong'), + 'exception' => '\CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Invalid byte order "unset"' + ), + 'readHexWithoutByteOrder' => array( + 'value' => '0101000000', + 'methods' => array('readLong'), + 'exception' => '\CrEOF\Geo\WKB\Exception\UnexpectedValueException', + 'message' => 'Invalid byte order "unset"' + ), + 'readBinaryShortFloat' => array( + 'value' => pack('H*', '013D0AD'), + 'methods' => array('readByteOrder', 'readFloat'), + 'exception' => 'CrEOF\Geo\WKB\Exception\RangeException', + 'message' => '/Type d: not enough input, need 8, have 3$/' + ), + ); } - public function testReadingXDRHexDouble() + /** + * @return array[] + */ + public function goodTestData() { - $value = '0040411D70A3D70A3D'; - $reader = new Reader($value); - - $reader->readByteOrder(); - - $result = $reader->readDouble(); - - $this->assertEquals(34.23, $result); + return array( + 'readBinaryByteOrder' => array( + 'value' => pack('H*', '01'), + 'methods' => array( + array('readByteOrder', null, 1) + ) + ), + 'readHexByteOrder' => array( + 'value' => '01', + 'methods' => array( + array('readByteOrder', null, 1) + ) + ), + 'readPrefixedHexByteOrder' => array( + 'value' => '0x01', + 'methods' => array( + array('readByteOrder', null, 1) + ) + ), + 'readNDRBinaryLong' => array( + 'value' => pack('H*', '0101000000'), + 'methods' => array( + array('readByteOrder', null, 1), + array('readLong', null, 1) + ) + ), + 'readXDRBinaryLong' => array( + 'value' => pack('H*', '0000000001'), + 'methods' => array( + array('readByteOrder', null, 0), + array('readLong', null, 1) + ) + ), + 'readNDRHexLong' => array( + 'value' => '0101000000', + 'methods' => array( + array('readByteOrder', null, 1), + array('readLong', null, 1) + ) + ), + 'readXDRHexLong' => array( + 'value' => '0000000001', + 'methods' => array( + array('readByteOrder', null, 0), + array('readLong', null, 1) + ) + ), + 'readNDRBinaryFloat' => array( + 'value' => pack('H*', '013D0AD7A3701D4140'), + 'methods' => array( + array('readByteOrder', null, 1), + array('readFloat', null, 34.23) + ) + ), + 'readNDRBinaryDouble' => array( + 'value' => pack('H*', '013D0AD7A3701D4140'), + 'methods' => array( + array('readByteOrder', null, 1), + array('readDouble', null, 34.23) + ) + ), + 'readXDRBinaryFloat' => array( + 'value' => pack('H*', '0040411D70A3D70A3D'), + 'methods' => array( + array('readByteOrder', null, 0), + array('readFloat', null, 34.23) + ) + ), + 'readNDRHexFloat' => array( + 'value' => '013D0AD7A3701D4140', + 'methods' => array( + array('readByteOrder', null, 1), + array('readFloat', null, 34.23) + ) + ), + 'readXDRHexFloat' => array( + 'value' => '0040411D70A3D70A3D', + 'methods' => array( + array('readByteOrder', null, 0), + array('readFloat', null, 34.23) + ) + ), + 'readXDRBinaryFloats' => array( + 'value' => pack('H*', '0040411D70A3D70A3D40411D70A3D70A3D'), + 'methods' => array( + array('readByteOrder', null, 0), + array('readFloats', 2, array(34.23, 34.23)) + ) + ), + 'readXDRBinaryDoubles' => array( + 'value' => pack('H*', '0040411D70A3D70A3D40411D70A3D70A3D'), + 'methods' => array( + array('readByteOrder', null, 0), + array('readDoubles', 2, array(34.23, 34.23)) + ) + ), + 'readXDRPosition' => array( + 'value' => pack('H*', '0040411D70A3D70A3D40411D70A3D70A3D'), + 'methods' => array( + array('readByteOrder', null, 0), + array('getCurrentPosition', null, 1), + array('getLastPosition', null, 0), + array('readFloat', null, 34.23), + array('getCurrentPosition', null, 9), + array('getLastPosition', null, 1), + array('readFloat', null, 34.23), + array('getCurrentPosition', null, 17), + array('getLastPosition', null, 9) + ) + ), + ); } public function testReaderReuse() @@ -222,7 +274,7 @@ public function testReaderReuse() $reader->readByteOrder(); - $result = $reader->readDouble(); + $result = $reader->readFloat(); $this->assertEquals(34.23, $result); }