[nona.net home]
not logged inlog in
> home> software> ext_shapelib> usage> shp_add
functions
adding a shape

ext_shapelib - shp_add()

shp_add() - adding shapes ::
shp_add() adds a shape to an existing, previously opened/created shape file. Additonally, attribute values of the shape are written to the dbf attribute database. shp_add() returns the id of the shape added in case of success, or 0 in case of failure.
$id = shp_add($shapehandle, $attributearray, $verticesarray);
$shapehandle - handle of previously opened/created file ::
$shapehandle must contain a shapefile handle, eg. the return value of a successful shp_create().
$attributearray - name/value pairs of attributes ::
$attributearray contains an array of attribute key/value pairs. The attribute name must be given as hash key. Example:
$attributearray = (
    "NAME" => "test entry", 
    "AGE"  => 30
);
attribute names must match the names given when the shapefile was created, non-existant fields are skipped. If no $attributearray is given, an empty record is added to the dbf file.
$verticesarray ::
$verticesarray contains an array of (x, y, [z]) arrays, each sub-array describing a vertex of the shape. Z values are optional. Some shape types (eg. point type shapes) do not accept multiple vertices in a single shape. Example:
$verticesarray = (  // a simple square
    array( 1, 1),
    array( 1, 3),
    array( 3, 3),
    array( 3, 1)
);