/* {{{ 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); }
/* {{{ 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); }
/* {{{ 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); }
/* {{{ 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); }
/* {{{ 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); }
/* {{{ 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); }
/* {{{ 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); }
/* {{{ proto int shape.boundary() Returns the boundary of the shape. Only available if php/mapscript is built with GEOS library.*/ PHP_METHOD(shapeObj, boundary) { zval *zobj = getThis(); shapeObj *shape = NULL; php_shape_object *php_shape; parent_object parent; PHP_MAPSCRIPT_ERROR_HANDLING(TRUE); if (zend_parse_parameters_none() == 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_boundary(php_shape->shape); if (shape == NULL) RETURN_FALSE; MAPSCRIPT_MAKE_PARENT(NULL, NULL); mapscript_create_shape(shape, parent, NULL, return_value TSRMLS_CC); }
/* {{{ proto styleObj removeStyle(int index) return the styleObj removed. */ PHP_METHOD(labelObj, removeStyle) { zval *zobj = getThis(); long index; styleObj *style; php_label_object *php_label; 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); style = msRemoveLabelStyle(php_label->label, index); /* Return a copy of the class object just removed */ MAPSCRIPT_MAKE_PARENT(NULL, NULL); mapscript_create_style(style, parent, return_value TSRMLS_CC); }
/* {{{ 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); }