This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository php-geos.
commit f39afa6b3981dc696543146f43f1be6c98f78f7c Author: Bas Couwenberg <[email protected]> Date: Mon Dec 12 18:15:54 2016 +0100 Imported Upstream version 1.0.0~rc2 --- README.md | 2 +- geos.c | 2 +- tests/005_WKBReader.phpt | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1de3193..a7318e7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ PHP module for GEOS [![build status] (https://drone.osgeo.kbt.io/api/badges/geos/php-geos/status.svg?branch=master)] -(https://drone.osgeo.kbt.io/geos/php-geos?branch=master, alt=build status) +(https://drone.osgeo.kbt.io/geos/php-geos?branch=master) The code in this directory provides a PHP module to make use of functionalities of the [GEOS library] (http://geos.osgeo.org). diff --git a/geos.c b/geos.c index 3f449f6..2c81428 100755 --- a/geos.c +++ b/geos.c @@ -2969,7 +2969,7 @@ PHP_METHOD(WKBReader, read) } #if PHP_VERSION_ID >= 70000 - wkblen = strlen(ZSTR_VAL(wkb)); + wkblen = ZSTR_LEN(wkb); #endif geom = GEOSWKBReader_read_r(GEOS_G(handle), reader, (unsigned char*)ZSTR_VAL(wkb), wkblen); diff --git a/tests/005_WKBReader.phpt b/tests/005_WKBReader.phpt new file mode 100644 index 0000000..f5acf5a --- /dev/null +++ b/tests/005_WKBReader.phpt @@ -0,0 +1,89 @@ +--TEST-- +WKBReader tests +--SKIPIF-- +<?php if (!extension_loaded('geos')) { print "geos extension not loaded\n"; exit(1); } ?> +--FILE-- +<?php + +require './tests/TestHelper.php'; + +class WKBReaderTest extends GEOSTest +{ + public function testValidWKB() + { + $reader = new GEOSWKBReader(); + $writer = new GEOSWKTWriter(); + $writer->setRoundingPrecision(1); + $writer->setOutputDimension(3); + + foreach ($this->providerValidWKB() as $test) { + list ($wkb, $wkt, $srid) = $test; + + $geometry = $reader->readHEX($wkb); + $this->assertEquals($wkt, $writer->write($geometry)); + $this->assertEquals($srid, $geometry->getSRID()); + + $geometry = $reader->read(hex2bin($wkb)); + $this->assertEquals($wkt, $writer->write($geometry)); + $this->assertEquals($srid, $geometry->getSRID()); + } + } + + private function providerValidWKB() + { + return array( + array('0101000020e6100000000000000000f03f0000000000000040', 'POINT (1.0 2.0)', 4326), + array('01010000a0e6100000333333333333f33f3333333333330b406666666666661640', 'POINT Z (1.2 3.4 5.6)', 4326), + array('0104000000030000000101000000000000000000f03f0000000000000040010100000000000000000008400000000000001040010100000000000000000014400000000000001840', 'MULTIPOINT (1.0 2.0, 3.0 4.0, 5.0 6.0)', 0), + array('0104000080030000000101000080000000000000f03f00000000000000400000000000000840010100008000000000000010400000000000001440000000000000184001010000800000000000001c4000000000000020400000000000002240', 'MULTIPOINT Z (1.0 2.0 3.0, 4.0 5.0 6.0, 7.0 8.0 9.0)', 0), + array('01040000207b00000000000000', 'MULTIPOINT EMPTY', 123), + array('0102000020c801000003000000000000000000f03f00000000000000400000000000000840000000000000104000000000000008400000000000000040', 'LINESTRING (1.0 2.0, 3.0 4.0, 3.0 2.0)', 456), + array('01020000a0db03000003000000000000000000f03f000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001c4000000000000020400000000000002240', 'LINESTRING Z (1.0 2.0 3.0, 4.0 5.0 6.0, 7.0 8.0 9.0)', 987), + array('01020000201503000000000000', 'LINESTRING EMPTY', 789), + array('0105000020d204000002000000010200000002000000000000000000f03f0000000000000000000000000000044000000000000000400102000000020000009a9999999999174000000000000020409a99999999990d40000000000000f03f', 'MULTILINESTRING ((1.0 0.0, 2.5 2.0), (5.9 8.0, 3.7 1.0))', 1234), + array('01050000a0e110000002000000010200008002000000000000000000f03f0000000000000000000000000000f03f00000000000004400000000000000040000000000000f03f0102000080020000009a99999999991740000000000000204000000000000008409a99999999990d40000000000000f03f0000000000000840', 'MULTILINESTRING Z ((1.0 0.0 1.0, 2.5 2.0 1.0), (5.9 8.0 3.0, 3.7 1.0 3.0))', 4321), + array('01050000203930000000000000', 'MULTILINESTRING EMPTY', 12345), + array('0103000020f40100000100000004000000000000000000f03f000000000000f03f000000000000f03f000000000000f83f000000000000f83f000000000000f03f000000000000f03f000000000000f03f', 'POLYGON ((1.0 1.0, 1.0 1.5, 1.5 1.0, 1.0 1.0))', 500), + array('0103000020f30100000200000005000000000000000000000000000000000000000000000000000000000000000000084000000000000008400000000000000840000000000000084000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f000000000000f03f0000000000000040000000000000004000000000000000400000000000000040000000000000f03f000000000000f03f000000000000f03f', 'POLYGON ((0.0 0.0, 0.0 3.0, 3.0 3.0, 3.0 0.0, 0.0 0.0), (1.0 1.0, 1.0 2.0, 2.0 2.0, 2.0 1.0, 1.0 1.0))', 499), + array('01030000a06300000001000000040000009a9999999999f13f9a9999999999014000000000000000009a999999999901403333333333331d409a9999999999f13f00000000000021409a999999999901409a9999999999f13f9a9999999999f13f9a999999999901400000000000000000', 'POLYGON Z ((1.1 2.2 0.0, 2.2 7.3 1.1, 8.5 2.2 1.1, 1.1 2.2 0.0))', 99), + array('01030000200100000000000000', 'POLYGON EMPTY', 1), + array('0106000020020000000100000001030000000200000005000000000000000000000000000000000000000000000000000000000000000000084000000000000008400000000000000840000000000000084000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f000000000000f03f0000000000000040000000000000004000000000000000400000000000000040000000000000f03f000000000000f03f000000000000f03f', 'MULTIPOLYGON (((0.0 0.0, 0.0 3.0, 3.0 3.0, 3.0 0.0, 0.0 0.0), (1.0 1.0, 1.0 2.0, 2.0 2.0, [...] + array('01060000a003000000010000000103000080020000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000840000000000000000000000000000008400000000000000840000000000000000000000000000008400000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000f03f000000000000f03f9a9999999999f13f000000000000f03f00000000000000409a9999999999f13f000000000000004000000000000000409a9999999999f13f0000000000000040000000000000f [...] + array('01060000200400000000000000', 'MULTIPOLYGON EMPTY', 4), + array('01070000200f270000060000000101000000000000000000f03f00000000000000400104000000030000000101000000000000000000f03f0000000000000040010100000000000000000008400000000000001040010100000000000000000014400000000000001840010200000003000000000000000000f03f00000000000000400000000000000840000000000000104000000000000008400000000000000040010500000002000000010200000002000000000000000000f03f0000000000000000000000000000044000000000000000400102000000020000009a999999999917400000000000002 [...] + array('01070000200903000000000000', 'GEOMETRYCOLLECTION EMPTY', 777), + ); + } + + public function testBogusWKB() + { + $reader = new GEOSWKBReader(); + + try { + $reader->read(hex2bin('1234567890abcdef')); + $this->assertTrue(FALSE); # this is just to fail if we get here + } catch (Exception $e) { + $this->assertContains('ParseException', $e->getMessage()); + } + } + + public function testBogusHexWKB() + { + $reader = new GEOSWKBReader(); + + try { + $reader->readHEX('1234567890abcdef'); + $this->assertTrue(FALSE); # this is just to fail if we get here + } catch (Exception $e) { + $this->assertContains('ParseException', $e->getMessage()); + } + } +} + +WKBReaderTest::run(); + +?> +--EXPECT-- +WKBReaderTest->testValidWKB OK +WKBReaderTest->testBogusWKB OK +WKBReaderTest->testBogusHexWKB OK -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/php-geos.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

