From bfe9005e02b2e1660d64036837047af3c85acb79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 16 Nov 2016 18:41:54 +0100 Subject: [PATCH 1/2] Correctly work withou configured dbf header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- src/ShapeFile.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ShapeFile.php b/src/ShapeFile.php index d0e256b..a5b738b 100644 --- a/src/ShapeFile.php +++ b/src/ShapeFile.php @@ -33,10 +33,7 @@ class ShapeFile { private $SHXFile = null; private $DBFFile = null; - public $DBFHeader = array( - array('ID', 'N', 19, 0), - array('DESC', 'C', 14, 0), - ); + public $DBFHeader; public $lastError = ''; @@ -430,6 +427,9 @@ private function _closeSHXFile() { */ private function _createDBFFile() { + if (count($this->DBFHeader) == 0) { + return null; + } $dbf_name = $this->_getFilename('.dbf'); $result = @dbase_create($dbf_name, $this->DBFHeader); if ($result === false) { From b5cff4acd41d4dd2d91f1788f5d919bbc8fc12e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 16 Nov 2016 18:45:22 +0100 Subject: [PATCH 2/2] Set DBF header for tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- tests/ShapeFileTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/ShapeFileTest.php b/tests/ShapeFileTest.php index 416b45a..57a729d 100644 --- a/tests/ShapeFileTest.php +++ b/tests/ShapeFileTest.php @@ -251,6 +251,10 @@ public function testShapeSaveLoad($type, $points) { $filename = "./data/test_shape-$type.*"; $shp = new ShapeFile($type); + $shp->setDBFHeader(array( + array('ID', 'N', 19, 0), + array('DESC', 'C', 14, 0), + )); $record0 = new ShapeRecord($type);