class ShapeFile (View source)

ShapeFile class.

Constants

MAGIC

Properties

string $lastError
ShapeRecord> $records

Methods

static bool
supportsDbase()

Checks whether dbase manipulations are supported.

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

No description

bool
loadFromFile(string $fileName)

Loads shapefile and dbase (if supported).

bool
saveToFile(string|null $fileName = null)

Saves shapefile.

int
addRecord(ShapeRecord $record)

Adds record to shape file.

void
deleteRecord(int $index)

Deletes record from shapefile.

array|null
getDBFHeader()

Returns array defining fields in DBF file.

void
setDBFHeader(array $header)

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

int
getIndexFromDBFData(string $field, string $value)

Lookups value in the DBF file and returns index.

void
setError(string $error)

Sets error message.

string|false
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

static bool supportsDbase()

Checks whether dbase manipulations are supported.

Return Value

bool

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

No description

Parameters

int $shapeType

File shape type, should be same as all records

array $boundingBox

File bounding box

string|null $fileName

File name

bool loadFromFile(string $fileName)

Loads shapefile and dbase (if supported).

Parameters

string $fileName

File mask to load (eg. example.*)

Return Value

bool

bool saveToFile(string|null $fileName = null)

Saves shapefile.

Parameters

string|null $fileName

Name of file, otherwise existing is used

Return Value

bool

int addRecord(ShapeRecord $record)

Adds record to shape file.

Parameters

ShapeRecord $record

Return Value

int

Number of added record

void deleteRecord(int $index)

Deletes record from shapefile.

Parameters

int $index

Return Value

void

array|null getDBFHeader()

Returns array defining fields in DBF file.

Return Value

array|null

see setDBFHeader for more information

void 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.

Return Value

void

int getIndexFromDBFData(string $field, string $value)

Lookups value in the DBF file and returns index.

Parameters

string $field
string $value

Return Value

int

void setError(string $error)

Sets error message.

Parameters

string $error

Return Value

void

string|false readSHP(int $bytes)

Reads given number of bytes from SHP file.

Parameters

int $bytes

Return Value

string|false

bool eofSHP()

Checks whether file is at EOF.

Return Value

bool

string getShapeName()

Returns shape name.

Return Value

string

bool hasMeasure()

Check whether file contains measure data.

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

Return Value

bool