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) { 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);