class ShapeFile

ShapeFile class.

Constants

MAGIC

Properties

$FileName
$lastError
$boundingBox
$shapeType
$records

Methods

static bool
supportsDbase()

Checks whether dbase manipuations are supported.

__construct(int $shapeType, array $boundingBox = ['xmin' => 0.0, 'ymin' => 0.0, 'xmax' => 0.0, 'ymax' => 0.0], null|mixed $FileName = null)

No description

loadFromFile(string $FileName)

Loads shapefile and dbase (if supported).

saveToFile(string|null $FileName = null)

Saves shapefile.

int
addRecord(ShapeRecord $record)

Adds record to shape file.

deleteRecord(int $index)

Deletes record from shapefile.

array
getDBFHeader()

Returns array defining fields in DBF file.

setDBFHeader(array $header)

Changes array defining fields in DBF file, used in dbase_create call.

int
getIndexFromDBFData(string $field, mixed $value)

Lookups value in the DBF file and returs index.

setError(string $error)

Sets error message.

string
readSHP(int $bytes)

Reads given number of bytes from SHP file.

bool
eofSHP()

Checks whether file is at EOF.

string
getShapeName()

Returns shape name.

bool
hasMeasure()

Check whether file contains measure data.

Details

at line 59
static bool supportsDbase()

Checks whether dbase manipuations are supported.

Return Value

bool

at line 69
__construct(int $shapeType, array $boundingBox = ['xmin' => 0.0, 'ymin' => 0.0, 'xmax' => 0.0, 'ymax' => 0.0], null|mixed $FileName = null)

Parameters

int $shapeType File shape type, should be same as all records
array $boundingBox File bounding box
null|mixed $FileName File name

at line 90
loadFromFile(string $FileName)

Loads shapefile and dbase (if supported).

Parameters

string $FileName File mask to load (eg. example.*)

at line 127
saveToFile(string|null $FileName = null)

Saves shapefile.

Parameters

string|null $FileName Name of file, otherwise existing is used

at line 182
int addRecord(ShapeRecord $record)

Adds record to shape file.

Parameters

ShapeRecord $record

Return Value

int Number of added record

at line 211
deleteRecord(int $index)

Deletes record from shapefile.

Parameters

int $index

at line 229
array getDBFHeader()

Returns array defining fields in DBF file.

Return Value

array see setDBFHeader for more information

at line 243
setDBFHeader(array $header)

Changes array defining fields in DBF file, used in dbase_create call.

Parameters

array $header An array of arrays, each array describing the format of one field of the database. Each field consists of a name, a character indicating the field type, and optionally, a length, a precision and a nullable flag.

at line 261
int getIndexFromDBFData(string $field, mixed $value)

Lookups value in the DBF file and returs index.

Parameters

string $field Field to match
mixed $value Value to match

Return Value

int

at line 612
setError(string $error)

Sets error message.

Parameters

string $error

at line 624
string readSHP(int $bytes)

Reads given number of bytes from SHP file.

Parameters

int $bytes

Return Value

string

at line 634
bool eofSHP()

Checks whether file is at EOF.

Return Value

bool

at line 644
string getShapeName()

Returns shape name.

Return Value

string

at line 657
bool hasMeasure()

Check whether file contains measure data.

For some reason this is distinguished by zero bounding box in the specification.

Return Value

bool