/* {{{ proto point __construct() Create a new pointObj instance. */ PHP_METHOD(pointObj, __construct) { php_point_object *php_point; PHP_MAPSCRIPT_ERROR_HANDLING(TRUE); if (zend_parse_parameters_none() == FAILURE) { PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); return; } PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); php_point = (php_point_object *)zend_object_store_get_object(getThis() TSRMLS_CC); if ((php_point->point = pointObj_new()) == NULL) { mapscript_throw_exception("Unable to construct pointObj." TSRMLS_CC); return; } php_point->point->x = 0; php_point->point->y = 0; #ifdef USE_POINT_Z_M php_point->point->z = 0; php_point->point->m = 0; #endif }
/* {{{ 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); }