Пример #1
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);
}
Пример #2
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);
}
Пример #3
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);
}
Пример #4
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;
  }
}
Пример #5
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);
}
Пример #6
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);
}
Пример #7
0
/* {{{ proto int symbol.setimagepath(char *imagefile)
   loads a new symbol image  ) */ 
PHP_METHOD(symbolObj, setImagePath)
{
    zval *zobj = getThis();
    php_symbol_object *php_symbol;
    char *filename;
    long filename_len;
    int status = MS_FAILURE;

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

    php_symbol = (php_symbol_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    status = msLoadImageSymbol(php_symbol->symbol, filename);
    
    if (status != MS_SUCCESS)
    {
        mapscript_throw_mapserver_exception("" TSRMLS_CC);
        return;
    }

    RETURN_LONG(status);
}
Пример #8
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);
}
Пример #9
0
/* {{{ proto int setFilter(string filter)
   Set the filter expression string.  Returns MS_SUCCESS/MS_FAILURE */
PHP_METHOD(clusterObj, setFilter)
{
  char *filter = NULL;
  long filter_len = 0;
  zval *zobj = getThis();
  php_cluster_object *php_cluster;
  int status = MS_FAILURE;

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

  php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  if ((status = clusterObj_setFilter(php_cluster->cluster, filter)) != MS_SUCCESS) {
    mapscript_throw_mapserver_exception("" TSRMLS_CC);
    return;
  }

  RETURN_LONG(status);
}
Пример #10
0
/* {{{ proto int label.updateFromString(string snippet)
   Update a label from a string snippet.  Returns MS_SUCCESS/MS_FAILURE */
PHP_METHOD(labelObj, updateFromString)
{
  zval *zobj = getThis();
  char *snippet;
  long snippet_len = 0;
  int status = MS_FAILURE;
  php_label_object *php_label;

  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_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);

  if ((status = labelObj_updateFromString(php_label->label, snippet)) != MS_SUCCESS) {
    mapscript_throw_mapserver_exception("" TSRMLS_CC);
    return;
  }

  RETURN_LONG(status);
}
Пример #11
0
/* {{{ proto int saveWebImage()
   Writes image to temp directory.  Returns image URL. */
PHP_METHOD(imageObj, saveWebImage)
{
    zval *zobj = getThis();
    php_image_object *php_image;
    char *imageFile = NULL;
    char *imageFilename = NULL;
    char path[MS_MAXPATHLEN];
    char *imageUrlFull = NULL;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters_none() == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    imageFilename = msTmpFilename(php_image->image->format->extension);
    imageFile = msBuildPath(path, php_image->image->imagepath, imageFilename);

    if (msSaveImage(NULL, php_image->image, imageFile) != MS_SUCCESS)
    {
        mapscript_throw_mapserver_exception("Failed writing image to %s" TSRMLS_CC, imageFile);
        return;
    }

    imageUrlFull = msBuildPath(path, php_image->image->imageurl, imageFilename);
    msFree(imageFilename);

    RETURN_STRING(imageUrlFull, 1);
}
Пример #12
0
/* {{{ proto int shapefile.getTransformed(mapObj map, int index)
   Retrieve shape by index. */
PHP_METHOD(shapeFileObj, getTransformed)
{
  zval *zobj =  getThis();
  zval *zmap;
  long index;
  php_shapefile_object *php_shapefile;
  php_map_object *php_map;
  shapeObj *shape = NULL;
  parent_object parent;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol",
                            &zmap, mapscript_ce_map, &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);
  php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);

  /* Create a new shapeObj to hold the result
   * Note that the type used to create the shape (MS_NULL) does not matter
   * at this point since it will be set by SHPReadShape().
   */
  if ((shape = shapeObj_new(MS_SHAPE_NULL)) == NULL) {
    mapscript_throw_mapserver_exception("Failed creating new shape (out of memory?)" TSRMLS_CC);
    return;
  }

  /* Read from the file */
  if (shapefileObj_getTransformed(php_shapefile->shapefile, php_map->map,
                                  index, shape) != MS_SUCCESS) {
    shapeObj_destroy(shape);
    mapscript_throw_mapserver_exception("Failed reading shape %ld." TSRMLS_CC, index);
    return;
  }

  /* Return shape object */
  MAPSCRIPT_MAKE_PARENT(NULL, NULL);
  mapscript_create_shape(shape, parent, NULL, return_value TSRMLS_CC);
}
Пример #13
0
/* {{{ proto int shapefile.getPoint(int i)
   Retrieve a point by index. */
PHP_METHOD(shapeFileObj, getPoint)
{
  zval *zobj =  getThis();
  long index;
  pointObj *point;
  php_shapefile_object *php_shapefile;
  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_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  /* Create a new shapeObj to hold the result
   * Note that the type used to create the shape (MS_NULL) does not matter
   * at this point since it will be set by SHPReadShape().
   */
  /* Create a new PointObj to hold the result */
  if ((point = pointObj_new()) == NULL) {
    mapscript_throw_mapserver_exception("Failed creating new point (out of memory?)" TSRMLS_CC);
    return;
  }

  /* Read from the file */
  if (shapefileObj_getPoint(php_shapefile->shapefile, index, point) != MS_SUCCESS) {
    pointObj_destroy(point);
    mapscript_throw_mapserver_exception("Failed reading point %ld." TSRMLS_CC, index);
    return;
  }

  MAPSCRIPT_MAKE_PARENT(NULL, NULL);
  mapscript_create_point(point, parent, return_value TSRMLS_CC);
}
Пример #14
0
/* {{{ proto projectionObj __construct(string projString)
   Create a new projectionObj instance. */
PHP_METHOD(projectionObj, __construct)
{
  char *projString;
  long projString_len = 0;
  php_projection_object *php_projection;

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

  php_projection = (php_projection_object *)zend_object_store_get_object(getThis() TSRMLS_CC);

  if ((php_projection->projection = projectionObj_new(projString)) == NULL) {
    mapscript_throw_mapserver_exception("Unable to construct projectionObj." TSRMLS_CC);
    return;
  }
}
Пример #15
0
/* {{{ proto int draw(mapObj map, layerObj layer, imageObj img, string class_name, string text)
   Draws the individual rect using layer. Returns MS_SUCCESS/MS_FAILURE. */
PHP_METHOD(rectObj, draw)
{
    zval *zobj =  getThis();
    zval *zmap, *zlayer, *zimage;
    char *text;
    long text_len;
    long classIndex;
    int status = MS_FAILURE;
    php_rect_object *php_rect;
    php_map_object *php_map;
    php_layer_object *php_layer;
    php_image_object *php_image;
    
    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OOOls",
                              &zmap, mapscript_ce_map,
                              &zlayer, mapscript_ce_layer,
                              &zimage, mapscript_ce_image,
                              &classIndex, &text, &text_len) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC);
    php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);
    php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
    php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);

    if ((status = rectObj_draw(php_rect->rect, php_map->map, php_layer->layer, php_image->image, 
                               classIndex, text)) != MS_SUCCESS)
    {
        mapscript_throw_mapserver_exception("" TSRMLS_CC);
        return;
    }

    RETURN_LONG(status);
}
Пример #16
0
/* {{{ proto owsrequest __construct()
   Create a new OWSRequestObj instance. */
PHP_METHOD(OWSRequestObj, __construct)
{
    zval *zobj = getThis();
    php_owsrequest_object *php_owsrequest;
    cgiRequestObj *request;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters_none() == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    
    php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
 
    if ((request = cgirequestObj_new()) == NULL)
    {
        mapscript_throw_mapserver_exception("" TSRMLS_CC);
        return;
    }
    
    php_owsrequest->cgirequest = request;
}
Пример #17
0
/* {{{ proto void __construct(mapObj map, string symbolname)
   Create a new symbolObj instance. */
PHP_METHOD(symbolObj, __construct)
{
    zval *zmap;
    char *symbolName;
    long symbolName_len;
    int symbolId = -1;
    php_symbol_object *php_symbol;
    php_map_object *php_map;
    parent_object parent;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os",
                              &zmap, mapscript_ce_map, 
                              &symbolName, &symbolName_len) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    
    php_symbol = (php_symbol_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
    php_map = (php_map_object *)zend_object_store_get_object(zmap TSRMLS_CC);
    
    symbolId = msAddNewSymbol(php_map->map, symbolName);

    if (symbolId == -1)
    {
        mapscript_throw_mapserver_exception("Unable to construct symbolObj" TSRMLS_CC);
        return;
    }
    
    php_symbol->symbol = php_map->map->symbolset.symbol[symbolId];

    MAPSCRIPT_MAKE_PARENT(zmap, NULL);
    php_symbol->parent = parent;
    MAPSCRIPT_ADDREF(zmap);    
}
Пример #18
0
PHP_METHOD(imageObj, saveImage)
{
    zval *zobj = getThis();
    zval *zmap = NULL;
    char *filename = NULL;
    long filename_len = 0;
    php_image_object *php_image;
    php_map_object *php_map;
    int status = MS_SUCCESS;
    /* stdout specific vars */
    int size=0;
    void *iptr=NULL;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO",
                              &filename, &filename_len,
                              &zmap, mapscript_ce_map) == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

    php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);
    if (zmap)
        php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);

    if(filename_len > 0)
    {
        if ((status = msSaveImage((zmap ? php_map->map:NULL), php_image->image, filename) != MS_SUCCESS))
        {
            mapscript_throw_mapserver_exception("Failed writing image to %s" TSRMLS_CC, filename);
            return;
        }

        RETURN_LONG(status);
    }

    /* no filename - read stdout */

    /* if there is no output buffer active, set the header */
    //handle changes in PHP 5.4.x
    #if PHP_VERSION_ID < 50399
      if (OG(ob_nesting_level)<=0)
      {
          php_header(TSRMLS_C);
      }
    #else
      if (php_output_get_level(TSRMLS_C)<=0)
      {
          php_header(TSRMLS_C);
      }
    #endif

    if (MS_RENDERER_PLUGIN(php_image->image->format))
    {
        iptr = (void *)msSaveImageBuffer(php_image->image, &size, php_image->image->format);
    }
    else if (php_image->image->format->name && (strcasecmp(php_image->image->format->name, "imagemap")==0))
    {
        iptr = php_image->image->img.imagemap;
        size = strlen(php_image->image->img.imagemap);
    }

    if (size == 0) {
        mapscript_throw_mapserver_exception("Failed writing image to stdout" TSRMLS_CC);
        return;
    }
    else
    {
        php_write(iptr, size TSRMLS_CC);
        status = MS_SUCCESS;
        /* status = size;  why should we return the size ?? */
        msFree(iptr);
    }

    RETURN_LONG(status);
}