Skip to content

Commit 3425cba

Browse files
authored
Merge pull request #17 from nijel/dbf-header
Correctly work withou configured dbf header
2 parents a6a4661 + b5cff4a commit 3425cba

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/ShapeFile.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ class ShapeFile {
3333
private $SHXFile = null;
3434
private $DBFFile = null;
3535

36-
public $DBFHeader = array(
37-
array('ID', 'N', 19, 0),
38-
array('DESC', 'C', 14, 0),
39-
);
36+
public $DBFHeader;
4037

4138
public $lastError = '';
4239

@@ -430,6 +427,9 @@ private function _closeSHXFile() {
430427
*/
431428
private function _createDBFFile()
432429
{
430+
if (count($this->DBFHeader) == 0) {
431+
return null;
432+
}
433433
$dbf_name = $this->_getFilename('.dbf');
434434
$result = @dbase_create($dbf_name, $this->DBFHeader);
435435
if ($result === false) {

tests/ShapeFileTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ public function testShapeSaveLoad($type, $points)
251251
{
252252
$filename = "./data/test_shape-$type.*";
253253
$shp = new ShapeFile($type);
254+
$shp->setDBFHeader(array(
255+
array('ID', 'N', 19, 0),
256+
array('DESC', 'C', 14, 0),
257+
));
254258

255259
$record0 = new ShapeRecord($type);
256260

0 commit comments

Comments
 (0)