4.21.
ShapefileObj Class
Up one level
Constructor, members, and methods.
- Constant names and class member variable names are case-sensitive in PHP.
- Several MapScript functions (all those that access files in the back end such as ms_newMapObj(), drawMap(), etc.) will affect the value of the current working directory (CWD) in the PHP environment. This will be fixed eventually but in the meantime you should be careful about these side-effects.
Constructor:
shapefileObj ms_newShapefileObj(string filename, int type)
Opens a shapefile and returns a new object to deal with it.
Filename should be passed with no extension.
To create a new file (or overwrite an existing one), type should
be one of MS_SHP_POINT, MS_SHP_ARC, MS_SHP_POLYGON or
MS_SHP_MULTIPOINT.
Pass type as -1 to open an existing file for read-only access,
and type=-2 to open an existing file for update (append).
Members:
int numshapes (read-only)
int type (read-only)
string source (read-only)
rectObj bounds (read-only)
Methods:
shapeObj getShape(int i)
Retrieve shape by index.
shapeObj getPoint(int i)
Retrieve point by index.
shapeObj getTransformed(mapObj map, int i)
Retrieve shape by index.
rectObj getExtent(int i)
Retrieve a shape's bounding box by index.
int addShape(shapeObj shape)
Appends a shape to an open shapefile.
int addPoint(pointObj point)
Appends a point to an open shapefile.
void free()
Closes a shape file (and commits all changes in write mode) and
releases all resources used by the object.
How Can I UseShapeFileObj to insert new shapes to a shape file.
Posted by
Garry Lin
at
2007-08-09 03:58
HI,as the subject ,I want to insert new subjects to a shapefile.
And I have used addPoint(..) and addShape(..) methods and at last I use free() to submit the data.But I failed to get the result I want.
What's the problem??
And I have used addPoint(..) and addShape(..) methods and at last I use free() to submit the data.But I failed to get the result I want.
What's the problem??
About addPoint() method.
Posted by
Garry Lin
at
2007-08-09 04:11
When I past a pointObj instance to addPoint() method,it returns 5.
What dose it mean?
Dose it means MS_REGEXERR? I'm puzzled.
What dose it mean?
Dose it means MS_REGEXERR? I'm puzzled.
About addPoint() method.
Posted by
Garry Lin
at
2007-08-09 05:25
return 5 means there are 5 records in the shapefile after add a point. The problem is how to remove a record from the file.
Attribute data