PHP图形脚本

作者

杰夫麦克纳

联系

jmckenna在gatewaygeomatics.com

上次更新时间

2019-05-25

介绍

这是一个 PHP 使MapServer的MapScript功能在PHP动态可加载库中可用的模块。简单来说,此模块将允许您使用强大的PHP脚本语言在MapServer中动态创建和修改地图图像。

支持的版本

PHP 5.2.0或更高版本是必需的;从MapServer 7.4.0开始,php7可以通过 SWIG API ,并且鼓励所有现有的MapServer用户更新其脚本以使用新的SWIG语法;请参见 MapServer迁移指南 例如语法。

从MapServer 6.0开始,对PHP 4、PHP 5.0和php5.1的支持被删除。PHP MapScript最初是为PHP 3.0.14开发的,在mapserver3.5放弃了对php3的支持之后。

该模块已在Linux、Solaris、*BSD和Windows上测试和使用。

备注

如果您使用的是MapServer 5.6及更高版本,请参阅 PHP MapScript 5.6 documentation 相反。

备注

如果要将基于MapServer 5.6或更高版本的现有应用程序迁移到MapServer 7.4或更高版本,请阅读 PHP MapScript Migration Guide 重要变化。

二进制代码包

PHP 7+mapscript包含在 MS4W ,网关Geomatics维护的流行安装程序。您还可以在 MS4W wiki .

如何获取有关php mapscript的更多信息

内存管理

通常,您不必担心内存管理,因为PHP有一个垃圾收集器,可以为您释放资源。如果只写一些不需要做大量处理的小脚本,那么就不值得去关心它。脚本结束时,所有内容都将被释放。

但是,如果脚本执行许多任务,则在执行期间释放资源可能很有用。为此,您必须调用mapscript对象的**free()**方法并取消设置php变量。自由方法的目的是打破对象与其属性之间的循环引用,以允许Zend引擎释放资源。

下面是一个脚本示例(使用传统语法,而不是 SWIG API 语法)在执行期间不会释放内容:

$map = new mapObj("mapfile.map");
$of = $map->outputformat;
echo $map->extent->minx." - ".$map->extent->miny." - ".
                 $map->extent->maxx." - ".$map->extent->maxy."\n";
echo "Outputformat name: $of->name\n";
unset($of);
unset($map); // Even if we unset the php variables, resources
             // won't be freed.  Resources will be only freed
             // at the end of the script

以及尽可能快地释放资源的相同脚本

$map = new mapObj("mapfile.map");
$of = $map->outputformat;
echo $map->extent->minx." - ".$map->extent->miny." - ".
                 $map->extent->maxx." - ".$map->extent->maxy."\n";
echo "Outputformat name: $of->name\n";
unset($of);
$map->free(); // break the circular references
// at this place, the outputformat ($of) and the rect object
// ($map->extent) resources are freed
unset($map);
// the map object is immediately freed after the unset (before the
// end of the script)