예제 #1
0
/* {{{ proto int label.removebinding(const bindingid)
   Remove attribute binding for a specfiled label property. Returns MS_SUCCESS on success. */
PHP_METHOD(labelObj, removeBinding)
{
  zval *zobj = getThis();
  long bindingId;
  php_label_object *php_label;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
                            &bindingId) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);

  if (bindingId < 0 || bindingId > MS_LABEL_BINDING_LENGTH) {
    mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
    return;
  }


  if(php_label->label->bindings[bindingId].item) {
    msFree(php_label->label->bindings[bindingId].item);
    php_label->label->bindings[bindingId].item =  NULL;
    php_label->label->bindings[bindingId].index = -1;
    php_label->label->numbindings--;
  }

  RETURN_LONG(MS_SUCCESS);

}
예제 #2
0
/* {{{ proto shapefile __construct(string filename, int type)
   Create a new shapeFileObj instance. */
PHP_METHOD(shapeFileObj, __construct)
{
  zval *zobj = getThis();
  php_shapefile_object *php_shapefile;
  char *filename;
  long filename_len = 0;
  long type;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl",
                            &filename, &filename_len, &type) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_shapefile = (php_shapefile_object *)zend_object_store_get_object(zobj TSRMLS_CC);

  php_shapefile->shapefile = shapefileObj_new(filename, type);

  if (php_shapefile->shapefile == NULL) {
    mapscript_throw_mapserver_exception("Failed to open shapefile %s" TSRMLS_CC, filename);
    return;
  }
}
예제 #3
0
PHP_METHOD(referenceMapObj, __get)
{
    char *property;
    long property_len = 0;
    zval *zobj = getThis();
    php_referencemap_object *php_referencemap;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                              &property, &property_len) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    IF_GET_STRING("image", php_referencemap->referencemap->image)
    else IF_GET_LONG("width", php_referencemap->referencemap->width)
        else IF_GET_LONG("height", php_referencemap->referencemap->height)
            else IF_GET_LONG("status", php_referencemap->referencemap->status)
                else IF_GET_LONG("marker", php_referencemap->referencemap->marker)
                    else IF_GET_STRING("markername", php_referencemap->referencemap->markername)
                        else IF_GET_LONG("markersize", php_referencemap->referencemap->markersize)
                            else IF_GET_LONG("maxboxsize", php_referencemap->referencemap->maxboxsize)
                                else IF_GET_LONG("minboxsize", php_referencemap->referencemap->minboxsize)
                                    else IF_GET_OBJECT("extent", mapscript_ce_rect, php_referencemap->extent, &php_referencemap->referencemap->extent)
                                        else IF_GET_OBJECT("color", mapscript_ce_color, php_referencemap->color, &php_referencemap->referencemap->color)
                                            else IF_GET_OBJECT("outlinecolor", mapscript_ce_color, php_referencemap->outlinecolor, &php_referencemap->referencemap->outlinecolor)
                                                else {
                                                    mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
                                                }
}
예제 #4
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto int shape.contains(shapeobj shape)
   Return true or false if the given shape in argument 1 is contained
   in the shape. Use3d underlying msGEOSContains GEOS library*/
PHP_METHOD(shapeObj, containsShape)
{
    zval *zobj =  getThis();
    zval *zshape;
    php_shape_object *php_shape, *php_shape2;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O",
                              &zshape, mapscript_ce_shape) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
    php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);

    if (shapeObj_contains_geos(php_shape->shape, php_shape2->shape))
    {
      RETURN_TRUE;
    }
    else
      RETURN_FALSE; 

}
예제 #5
0
PHP_METHOD(shapeFileObj, __set)
{
  char *property;
  long property_len = 0;
  zval *value;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
                            &property, &property_len, &value) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  if ( (STRING_EQUAL("numshapes", property)) ||
       (STRING_EQUAL("type", property)) ||
       (STRING_EQUAL("source", property)) ||
       (STRING_EQUAL("isopen", property)) ||
       (STRING_EQUAL("lastshape", property)) ||
       (STRING_EQUAL("bounds", property)) ) {
    mapscript_throw_exception("Property '%s' is read-only and cannot be set." TSRMLS_CC, property);
  } else {
    mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
  }
}
예제 #6
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto int shape.getpointusingmeasure(double measure)
   Given a shape and a mesure, return a point object containing the XY
   location corresponding to the measure */
PHP_METHOD(shapeObj, getPointUsingMeasure)
{
    zval *zobj =  getThis();
    double measure;
    pointObj *point = NULL;
    php_shape_object *php_shape;
    parent_object parent;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d",
                              &measure) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    point = shapeObj_getpointusingmeasure(php_shape->shape, measure);
    if (point == NULL)
        RETURN_FALSE;
    
    MAPSCRIPT_MAKE_PARENT(zobj, NULL);
    mapscript_create_point(point, parent, return_value TSRMLS_CC);
}
예제 #7
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto string shape.getValue(layerObj layer, string fieldName)
   Returns value for specified field name. */
PHP_METHOD(shapeObj, getValue)
{
    zval *zobj =  getThis();
    zval *zlayer;
    char *fieldName;
    long fieldName_len;
    int i;
    php_layer_object *php_layer;
    php_shape_object *php_shape;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os",
                              &zlayer, mapscript_ce_layer,
                              &fieldName, &fieldName_len) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
    php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);

    if (php_shape->shape->numvalues != php_layer->layer->numitems)
        RETURN_STRING("", 1);

    for(i=0; i<php_layer->layer->numitems; i++)
    {
        if (strcasecmp(php_layer->layer->items[i], fieldName)==0)
        {
            RETURN_STRING(php_shape->shape->values[i], 1);
        }
    }
}
예제 #8
0
/* {{{ proto int hashtable.remove(string key)
   Remove one item from hash table. Returns MS_FAILURE on error. */
PHP_METHOD(hashtableObj, remove)
{
  char *key;
  long key_len = 0;
  zval *zobj = getThis();
  int status = MS_FAILURE;
  php_hashtable_object *php_hashtable;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                            &key, &key_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);

  if ((status = hashTableObj_remove(php_hashtable->hashtable, key)) != MS_SUCCESS) {
    mapscript_throw_mapserver_exception("" TSRMLS_CC);
    return;
  }

  RETURN_LONG(status);
}
예제 #9
0
/* {{{ proto int hashtable.nextkey(string previousKey)
   Return the next key or first key if previousKey == NULL.
   Returns NULL if no item is in the hashTable or end of hashTable reached */
PHP_METHOD(hashtableObj, nextKey)
{
  char *key;
  long key_len = 0;
  zval *zobj = getThis();
  const char *value = NULL;
  php_hashtable_object *php_hashtable;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!",
                            &key, &key_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);

  value = hashTableObj_nextKey(php_hashtable->hashtable, key);

  if (value == NULL)
    RETURN_NULL();

  MAPSCRIPT_RETURN_STRING(value, 1);
}
예제 #10
0
/* {{{ proto int hashtable.get(string key)
   Get a value from item by its key. Returns empty string if not found. */
PHP_METHOD(hashtableObj, get)
{
  char *key;
  long key_len = 0;
  zval *zobj = getThis();
  const char *value = NULL;
  php_hashtable_object *php_hashtable;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                            &key, &key_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  value = hashTableObj_get(php_hashtable->hashtable, key);
  if (value == NULL) {
    RETURN_STRING("",1);
  }

  RETURN_STRING((char *)value, 1);
}
예제 #11
0
/* {{{ proto int hashtable.set(string key, string value)
   Set a hash item given key and value. Returns MS_FAILURE on error. */
PHP_METHOD(hashtableObj, set)
{
  char *key, *value;
  long key_len, value_len = 0;
  zval *zobj = getThis();
  int status = MS_FAILURE;
  php_hashtable_object *php_hashtable;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
                            &key, &key_len, &value, &value_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  if ((status = hashTableObj_set(php_hashtable->hashtable, key, value)) != MS_SUCCESS) {
    mapscript_throw_mapserver_exception("" TSRMLS_CC);
    return;
  }

  RETURN_LONG(status);
}
예제 #12
0
/* {{{ proto int setText(string text)
   Set the text string for a label object. */
PHP_METHOD(labelObj, setText)
{
  char *text;
  long text_len;
  zval *zobj = getThis();
  php_label_object *php_label;
  php_layer_object *php_layer;
  int status = MS_FAILURE;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                            &text, &text_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
  php_layer = MAPSCRIPT_OBJ(php_layer_object, php_label->parent.val);

  status = labelObj_setText(php_label->label, php_layer->layer, text);

  if (status != MS_SUCCESS) {
    mapscript_throw_mapserver_exception("" TSRMLS_CC);
    return;
  }


  RETURN_LONG(status);
}
예제 #13
0
/* {{{ proto int setExpression(string exression)
   Set the expression string for a label object. */
PHP_METHOD(labelObj, setExpression)
{
  char *expression;
  long expression_len;
  zval *zobj = getThis();
  php_label_object *php_label;
  int status = MS_FAILURE;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                            &expression, &expression_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);

  status = labelObj_setExpression(php_label->label, expression);

  if (status != MS_SUCCESS) {
    mapscript_throw_mapserver_exception("" TSRMLS_CC);
    return;
  }


  RETURN_LONG(status);
}
예제 #14
0
/* {{{ proto int getstyle(int index)
   return the style object. */
PHP_METHOD(labelObj, getStyle)
{
  long index;
  zval *zobj = getThis();
  php_label_object *php_label;
  styleObj *style = NULL;
  parent_object parent;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
                            &index) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);

  if (index < 0 || index >= php_label->label->numstyles) {
    mapscript_throw_exception("Invalid style index." TSRMLS_CC);
    return;
  }

  style = php_label->label->styles[index];

  MAPSCRIPT_MAKE_PARENT(zobj, NULL);
  mapscript_create_style(style, parent, return_value TSRMLS_CC);
}
예제 #15
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto int shape.line(int i)
   Returns line (part) number i.  First line is number 0. */
PHP_METHOD(shapeObj, line)
{
    zval *zobj =  getThis();
    long index;
    php_shape_object *php_shape;
    parent_object parent;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
                              &index) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    
    if (index < 0 || index >= php_shape->shape->numlines)
    {
        mapscript_throw_exception("Line '%d' does not exist in this object." TSRMLS_CC, index);
        return;
    }
    
    MAPSCRIPT_MAKE_PARENT(zobj, NULL);
    mapscript_create_line(&(php_shape->shape->line[index]), parent, return_value TSRMLS_CC);
}
예제 #16
0
파일: line.c 프로젝트: AdRiley/mapserver
/* {{{ proto int line.addXYZ(double x, double y, double z, double m)
   4th argument m is used for Measured shape files. It is not mandatory.
   Adds a point to the end of a line */
PHP_METHOD(lineObj, addXYZ)
{
  zval *zobj = getThis();
  pointObj point;
  double x, y, z, m = 0;
  int status = MS_FAILURE;
  php_line_object *php_line;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|d",
                            &x, &y, &z, &m) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  point.x = x;
  point.y = y;

#ifdef USE_LINE_Z_M
  point.z = z;
  point.m = m;
#endif

  status = lineObj_add(php_line->line, &point);

  RETURN_LONG(status);
}
예제 #17
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto int shape.project(projectionObj in, projectionObj out)
   Project a Shape. Returns MS_SUCCESS/MS_FAILURE */
PHP_METHOD(shapeObj, project)
{
    zval *zobj_proj_in, *zobj_proj_out;
    zval *zobj =  getThis();
    php_shape_object *php_shape;
    php_projection_object *php_proj_in, *php_proj_out;
    int status = MS_FAILURE;
    
    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO",
                              &zobj_proj_in, mapscript_ce_projection,
                              &zobj_proj_out, mapscript_ce_projection) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
    php_proj_in = (php_projection_object *) zend_object_store_get_object(zobj_proj_in TSRMLS_CC);
    php_proj_out = (php_projection_object *) zend_object_store_get_object(zobj_proj_out TSRMLS_CC);
    
    status = shapeObj_project(php_shape->shape, php_proj_in->projection, php_proj_out->projection);
    if (status != MS_SUCCESS)
    {
        mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
    }

    RETURN_LONG(status);
}
예제 #18
0
파일: line.c 프로젝트: AdRiley/mapserver
/* {{{ proto int line.set(int, index, pointObj point)
   Set the point values at the specified index */
PHP_METHOD(lineObj, set)
{
  zval *zobj =  getThis();
  zval *zobj_point;
  long index;
  php_line_object *php_line;
  php_point_object *php_point;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lO",
                            &index, &zobj_point, mapscript_ce_point) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  if ( (index < 0) || (index >= php_line->line->numpoints)) {
    mapscript_throw_exception("Point '%d' does not exist in this object." TSRMLS_CC, index);
    return;
  }

  php_point = (php_point_object *) zend_object_store_get_object(zobj_point TSRMLS_CC);

  php_line->line->point[index].x = php_point->point->x;
  php_line->line->point[index].y = php_point->point->y;

  RETURN_LONG(MS_SUCCESS);
}
예제 #19
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto int shape.getpointusingmeasure(pointObj point)
   Given a shape and a point object, return a point object containing the XY
   location of the intersection between the point and the shape. The point
   return contains also the extrapolated M value at the intersection. */
PHP_METHOD(shapeObj, getMeasureUsingPoint)
{
    zval *zobj =  getThis();
    zval *zpoint;
    pointObj *intersection = NULL;
    php_shape_object *php_shape;
    php_point_object *php_point;
    parent_object parent;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O",
                              &zpoint, mapscript_ce_point) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
    php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);

    intersection = shapeObj_getmeasureusingpoint(php_shape->shape, php_point->point);
    if (intersection == NULL)
        RETURN_FALSE;

    MAPSCRIPT_MAKE_PARENT(NULL, NULL);
    mapscript_create_point(intersection, parent, return_value TSRMLS_CC);
}
예제 #20
0
/* {{{ proto int scalebar.setImageColor(int red, int green, int blue)
   Set the imagecolor property of the scalebar. Returns -1 on error. */
PHP_METHOD(scalebarObj, setImageColor)
{
  zval *zobj = getThis();
  long red, green, blue;
  php_scalebar_object *php_scalebar;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
                            &red, &green, &blue) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  if (red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
    RETURN_LONG(MS_FAILURE);

  php_scalebar->scalebar->imagecolor.red = red;
  php_scalebar->scalebar->imagecolor.green = green;
  php_scalebar->scalebar->imagecolor.blue = blue;

  RETURN_LONG(MS_SUCCESS);
}
예제 #21
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto int shape.buffer(double width)
   Given a shape and a width, return a shape object with a buffer using
   underlying GEOS library*/
PHP_METHOD(shapeObj, buffer)
{
    zval *zobj =  getThis();
    double width;
    shapeObj *shape = NULL;
    php_shape_object *php_shape;
    parent_object parent;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d",
                              &width) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    shape = shapeObj_buffer(php_shape->shape, width);
    if (shape == NULL)
        RETURN_FALSE;

    MAPSCRIPT_MAKE_PARENT(NULL, NULL);
    mapscript_create_shape(shape, parent, NULL, return_value TSRMLS_CC);
}
예제 #22
0
PHP_METHOD(scalebarObj, __get)
{
  char *property;
  long property_len;
  zval *zobj = getThis();
  php_scalebar_object *php_scalebar;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                            &property, &property_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  IF_GET_LONG("height", php_scalebar->scalebar->height)
  else IF_GET_LONG("width", php_scalebar->scalebar->width)
    else IF_GET_LONG("style", php_scalebar->scalebar->style)
      else IF_GET_LONG("intervals", php_scalebar->scalebar->intervals)
        else IF_GET_LONG("units", php_scalebar->scalebar->units)
          else IF_GET_LONG("status", php_scalebar->scalebar->status)
            else IF_GET_LONG("position", php_scalebar->scalebar->position)
              else IF_GET_LONG("postlabelcache", php_scalebar->scalebar->postlabelcache)
                else IF_GET_LONG("align", php_scalebar->scalebar->align)
                  else IF_GET_OBJECT("color", mapscript_ce_color, php_scalebar->color, &php_scalebar->scalebar->color)
                    else IF_GET_OBJECT("backgroundcolor", mapscript_ce_color, php_scalebar->backgroundcolor, &php_scalebar->scalebar->backgroundcolor)
                      else IF_GET_OBJECT("outlinecolor", mapscript_ce_color, php_scalebar->outlinecolor, &php_scalebar->scalebar->outlinecolor)
                        else IF_GET_OBJECT("label", mapscript_ce_label, php_scalebar->label, &php_scalebar->scalebar->label)
                          else IF_GET_OBJECT("imagecolor", mapscript_ce_color, php_scalebar->imagecolor, &php_scalebar->scalebar->imagecolor)
                            else {
                              mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
                            }
}
예제 #23
0
PHP_METHOD(shapeFileObj, __get)
{
  char *property;
  long property_len = 0;
  zval *zobj = getThis();
  php_shapefile_object *php_shapefile;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                            &property, &property_len) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  IF_GET_LONG("numshapes", php_shapefile->shapefile->numshapes)
  else IF_GET_LONG("type", php_shapefile->shapefile->type)
    else IF_GET_LONG("isopen", php_shapefile->shapefile->isopen)
      else IF_GET_LONG("lastshape", php_shapefile->shapefile->lastshape)
        else IF_GET_STRING("source", php_shapefile->shapefile->source)
          else IF_GET_OBJECT("bounds", mapscript_ce_rect, php_shapefile->bounds, &php_shapefile->shapefile->bounds)
            else {
              mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
            }
}
예제 #24
0
파일: shape.c 프로젝트: bradh/mapserver
/* {{{ proto shape __construct(int type)
   Create a new shapeObj instance. */
PHP_METHOD(shapeObj, __construct)
{
    zval *zobj = getThis();
    php_shape_object *php_shape;
    long type;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
                              &type) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_shape = (php_shape_object *)zend_object_store_get_object(zobj TSRMLS_CC);
    
    if ((php_shape->shape = shapeObj_new(type)) == NULL)
    {
        mapscript_throw_exception("Unable to construct shapeObj." TSRMLS_CC);
        return;
    }

    MAKE_STD_ZVAL(php_shape->values);
    array_init(php_shape->values);    
}
예제 #25
0
PHP_METHOD(shapeFileObj, getExtent)
{
  zval *zobj =  getThis();
  long index;
  rectObj *rect;
  php_shapefile_object *php_shapefile;
  parent_object p;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
                            &index) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  /* Create a new rectObj to hold the result */
  if ((rect = rectObj_new()) == NULL) {
    mapscript_throw_mapserver_exception("Failed creating new rectObj (out of memory?)" TSRMLS_CC);
    return;
  }

  /* Read from the file
   * shapefileObj_getExtent() has no return value!  How do we catch errors?
   */
  shapefileObj_getExtent(php_shapefile->shapefile, index, rect);

  /* Return rectObj */
  MAPSCRIPT_INIT_PARENT(p);
  mapscript_create_rect(rect, p, return_value TSRMLS_CC);
}
예제 #26
0
파일: shape.c 프로젝트: bradh/mapserver
PHP_METHOD(shapeObj, __get)
{
    char *property;
    long property_len;
    zval *zobj = getThis();
    php_shape_object *php_shape;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                              &property, &property_len) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    
    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    IF_GET_STRING("text", php_shape->shape->text)
    else IF_GET_LONG("classindex", php_shape->shape->classindex) 
    else IF_GET_LONG("index", php_shape->shape->index) 
    else IF_GET_LONG("tileindex", php_shape->shape->tileindex) 
    else IF_GET_LONG("numlines", php_shape->shape->numlines) 
    else IF_GET_LONG("numvalues", php_shape->shape->numvalues) 
    else IF_GET_LONG("type", php_shape->shape->type) 
    else IF_GET_OBJECT("bounds", mapscript_ce_rect, php_shape->bounds, &php_shape->shape->bounds) 
    else IF_GET_OBJECT("values", NULL, php_shape->values, NULL) 
    else 
    {
        mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
    }
}
예제 #27
0
/* {{{ proto int referencemap.updateFromString(string snippet)
   Update a referencemap from a string snippet.  Returns MS_SUCCESS/MS_FAILURE */
PHP_METHOD(referenceMapObj, updateFromString)
{
    char *snippet;
    long snippet_len = 0;
    zval *zobj = getThis();
    php_referencemap_object *php_referencemap;
    int status = MS_FAILURE;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                              &snippet, &snippet_len) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    status =  referenceMapObj_updateFromString(php_referencemap->referencemap, snippet);

    if (status != MS_SUCCESS) {
        mapscript_throw_mapserver_exception("" TSRMLS_CC);
        return;
    }

    RETURN_LONG(status);
}
예제 #28
0
파일: shape.c 프로젝트: bradh/mapserver
PHP_METHOD(shapeObj, __set)
{
    char *property;
    long property_len;
    zval *value;
    zval *zobj = getThis();
    php_shape_object *php_shape;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
                              &property, &property_len, &value) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    
    php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    IF_SET_STRING("text", php_shape->shape->text, value)
    else IF_SET_LONG("classindex", php_shape->shape->classindex, value) 
    else IF_SET_LONG("index", php_shape->shape->index, value) 
    else if ( (STRING_EQUAL("type", property)) ||
              (STRING_EQUAL("numlines", property)) ||
              (STRING_EQUAL("tileindex", property)) ||
              (STRING_EQUAL("bounds", property)) ||
              (STRING_EQUAL("values", property)) ||
              (STRING_EQUAL("numvalues", property)) )
    {
        mapscript_throw_exception("Property '%s' is read-only and cannot be set." TSRMLS_CC, property);
    }
    else 
    {
        mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
    }
}
예제 #29
0
PHP_METHOD(referenceMapObj, __set)
{
    char *property;
    long property_len = 0;
    zval *value;
    zval *zobj = getThis();
    php_referencemap_object *php_referencemap;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
                              &property, &property_len, &value) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    IF_SET_STRING("image", php_referencemap->referencemap->image, value)
    else IF_SET_LONG("width", php_referencemap->referencemap->width, value)
        else IF_SET_LONG("height", php_referencemap->referencemap->height, value)
            else IF_SET_LONG("status", php_referencemap->referencemap->status, value)
                else IF_SET_LONG("marker", php_referencemap->referencemap->marker, value)
                    else IF_SET_STRING("markername", php_referencemap->referencemap->markername, value)
                        else IF_SET_LONG("markersize", php_referencemap->referencemap->markersize, value)
                            else IF_SET_LONG("maxboxsize", php_referencemap->referencemap->maxboxsize, value)
                                else IF_SET_LONG("minboxsize", php_referencemap->referencemap->minboxsize, value)
                                    else if ( (STRING_EQUAL("extent", property)) ||
                                              (STRING_EQUAL("color", property)) ||
                                              (STRING_EQUAL("outlinecolor", property))) {
                                        mapscript_throw_exception("Property '%s' is an object and can only be modified through its accessors." TSRMLS_CC, property);
                                    } else {
                                        mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
                                    }
}
예제 #30
0
/* {{{ proto int label.getbinding(const bindingid)
   Get the value of a attribute binding for a specfiled label property.
   Returns the string value if exist, else null. */
PHP_METHOD(labelObj, getBinding)
{
  zval *zobj = getThis();
  long bindingId;
  char *value = NULL;
  php_label_object *php_label;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
                            &bindingId) == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);

  if (bindingId < 0 || bindingId > MS_LABEL_BINDING_LENGTH) {
    mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
    return;
  }

  if( (value = php_label->label->bindings[bindingId].item) != NULL) {
    MAPSCRIPT_RETURN_STRING(value, 1);
  }

  RETURN_NULL();

}