Open JoolsMcFly opened 1 month ago
Hi.
Just checking if you have any thoughts on this?
bump after editing my original post.
Thoughts @MauricioFauth ?
Changing that return type is a BC break. Maybe adding an option to allow a missing file is better.
Indeed.
I'm thinking either a second param (boolean) to public function loadFromFile(string $fileName): bool
which would be passed to openDBFFile
OR
a method to set allowNoDbf
to true
.
Something like
$shp = new ShapeFile(0);
$shp->setAllowNoDbf(true);
private setAllowNoDbf(bool $allowNoDbf): void
{
$this->allowNoDbf = $allowNoDbf;
}
private function openDBFFile(): bool
{
if (! self::supportsDbase()) {
$this->dbfFile = null;
return true;
}
$dbfName = $this->getFilename('.dbf');
if (! is_readable($dbfName)) {
// changes start here
if ($this->allowNoDbf) {
return true;
}
// and end here
$this->setError(sprintf('It wasn\'t possible to find the DBase file "%s"', $dbfName));
return false;
}
What do you think?
Hi.
This lib handles shape files with no dbf files if
dbase
is not installed on the server. Ifdbase
is installed and no dbf is found then lib bails out and doesn't process the shape file.dbase
is installed on our server but some of our clients do not include a dbf file so we cannot process their Shape file. Bit of a bummer!It would be better, IMHO, to just proceed without
dbf
just like what happens withoutdbase
.So it basically boilds down to changing the following code
so that it returns
true;
What do you think?