Personal tools
You are here: Home Documentation References PHP/Mapscript Class Reference Classes ShapeObj Class

4.22. ShapeObj Class

Document Actions
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:

  ShapeObj ms_newShapeObj(int type)
       'type' is one of MS_SHAPE_POINT, MS_SHAPE_LINE, MS_SHAPE_POLYGON or
       MS_SHAPE_NULL

  ShapeObj ms_shapeObjFromWkt(string wkt)
       Creates new shape object from WKT string.

Members:

  string  text
  int     classindex
  int     type      (read-only)
  int     numlines  (read-only)
  int     index     
  int     tileindex (read-only)
  rectObj bounds    (read-only)
  int     numvalues (read-only)
  array   values    (read-only)

  The values array is an associative array with the attribute values for
  this shape.  It is set only on shapes obtained from layer->getShape().
  The key to the values in the array is the attribute name, e.g. 
    $population = $shape->values["Population"];

Methods:

  int set(string property_name, new_value)
       Set object property to a new value. Returns -1 on error.

  int add(lineObj line)
       Add a line (i.e. a part) to the shape.

  LineObj line(int i)
       Returns a reference to line number i.  Reference is valid only
       during the life of the shapeObj that contains the point.

  int draw(mapObj map, layerObj layer, imageObj img)
       Draws the individual shape using layer.
       Returns MS_SUCCESS/MS_FAILURE.

  boolean contains(pointObj point)
       Returns MS_TRUE if the point is inside the shape, MS_FALSE otherwise.

  boolean intersects(shapeObj shape)
       Returns MS_TRUE if the two shapes intersect, MS_FALSE otherwise.
    
  int project(projectionObj in, projectionObj out)
       Project the shape from "in" projection (1st argument) to "out" 
       projection (2nd argument).  Returns MS_SUCCESS/MS_FAILURE.

  pointObj getpointusingmeasure(double m)
       Apply only on Measured shape files. Given a measure m, retun the 
       corresponding XY location on the shapeobject.
  
  pointObj  getmeasureusingpoint(pointObject point)
      Apply only on Measured shape files. Given an XY Location, find the 
      nearest point on the shape object. Return a point object
      of this point with the m value set.

  void free()
       Destroys resources used by a shape object.  


  string getvalue(layerObj layer, string filedname)
       Returns the value for a given field name.

  shapeobj buffer(width)
       Returns a new buffered shapeObj based on the supplied distance (given
       in the coordinates of the existing shapeObj). 
       Only available if php/mapscript is built with GEOS library.   

  shapeobj convexhull()
       Returns a shape object representing the convex hull of shape.
       Only available if php/mapscript is built with GEOS 
       library.

  shapeobj boundary()
       Returns the boundary of the shape.
       Only available if php/mapscript is built with GEOS library.

  int containsShape(shapeobj shape2)
       Returns true if shape2 passed as argument is entirely within the shape. 
       Else return false.
       Only available if php/mapscript is built with GEOS 
       library.

  shapeobj union(shapeobj shape)
       Returns a shape object representing the union of the shape object 
       with the one passed as parameter. 
       Only available if php/mapscript is built with GEOS 
       library

  shapeobj union_geos(shapeobj shape) : (Deprecated in v5.2. Use union instead)
       Returns a shape object representing the union of the shape object 
       with the one passed as parameter. 
       Only available if php/mapscript is built with GEOS 
       library.

  shapeobj intersection(shapeobj shape)
       Returns a shape object representing the intersection of the shape 
       object with the one passed as parameter. 
       Only available if php/mapscript is built with GEOS library.

  shapeobj difference(shapeobj shape)
       Returns a shape object representing the difference of the
       shape object with the one passed as parameter. 
       Only available if php/mapscript is built with GEOS library.

  shapeobj symdifference(shapeobj shape)
       Returns the computed symmetric difference of the supplied and existing
       shape.
       Only available if php/mapscript is built with GEOS library.
 
  int overlaps(shapeobj shape)  
      Returns true if the shape passed as argument overlaps the shape.
      Else returns false.
      Only available if php/mapscript is built with GEOS library.

  int within(shapeobj shape2) 
      Returns true if the shape is entirely within the shape2 passed as argument. 
      Else returns false. 
      Only available if php/mapscript is built with GEOS library.

  int crosses(shapeobj shape)  
      Returns true if the shape passed as argument crosses the shape.
      Else return false.
      Only available if php/mapscript is built with GEOS library.

  int touches(shapeobj shape)  
      Returns true if the shape passed as argument touches the shape.
      Else return false.
      Only available if php/mapscript is built with GEOS library.

  int equals(shapeobj shape)  
      Returns true if the shape passed as argument is equal to the 
      shape (geometry only). Else return false.
      Only available if php/mapscript is built with GEOS library.
   
  int disjoint(shapeobj shape)  
      Returns true if the shape passed as argument is disjoint to the 
      shape. Else return false.
      Only available if php/mapscript is built with GEOS library.

  pointObj getCentroid()  
      Returns a point object representing the centroid of the shape.
      Only available if php/mapscript is built with GEOS library.

  double getArea()  
      Returns the area of the shape (if applicable).
      Only available if php/mapscript is built with GEOS library.

  double getLength()  
      Returns the length (or perimeter) of the shape.
      Only available if php/mapscript is built with GEOS library.

  pointObj getLabelPoint()  
      Returns a point object with coordinates suitable for labelling 
      the shape.

  string toWkt()
       Returns WKT representation of the shape's geometry.

  int setBounds()    
   Updates the bounds property of the shape.
   Must be called to calculate new bounding box after new parts have been
   added.   Returns true if successful. Else return false.
by Jeff McKenna last modified 2008-07-15 10:11

Powered by Plone