Skip to content

Commit

Permalink
Merge pull request #17 from nijel/dbf-header
Browse files Browse the repository at this point in the history
Correctly work withou configured dbf header
  • Loading branch information
nijel authored Nov 16, 2016
2 parents a6a4661 + b5cff4a commit 3425cba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ShapeFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions tests/ShapeFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3425cba

Please sign in to comment.