Zoo Project学习 02

ZOO-Kernel

ZOO-Kernel 是ZOO-Project WPS 平台的核心. 是WPS规范的C语言实现,提供强大、可扩展的 WPS 服务.
in C language which provides a powerful and extensible WPS server.

ZOO-Kernel 是一个可扩展的 WPS 服务器,可让您的系统更加强大. 它提供运行在Linux, Mac OSX ™ 和Windows ™ 系统上的全功能处理引擎. ZOO-Kernel 是一个运行中普通web服务器 (Apache 或 IIS ™)上的 CGI 程序. 其可以与新的或现存 的web平台无缝集成. ZOO-Kernel 让你能够使用符合语法规则的 WPS请求处理空间或非空间数据. WPS 服务器能够通过加载使用不同程序语言编写的动态库和源代码来实现管理和链接WPS Services (具体查看 ZOO-Services) 。

规范支持

ZOO-Kernel 符合并实现了 WPS 1.0.0和 WPS 2.0.0规范。其可执行的操作包括:

  • GetCapablities: 返回服务级的元数据信息. 它提供一个可使用的处理服务列表.
  • DescribeProcess: 返回一个处理的描述信息,包括支持的输入和输出.
  • Execute: 启动计算并返回一个特定过程产生的输出.
  • GetStatus: 只有 WPS 2.0.0 支持, 使客户端能够获取运行中服务的运行状态。
  • GetResult: 只有 WPS 2.0.0 支持, 使客户端能够获取运行中服务的最终结果.
  • Dismiss: 只有 WPS 2.0.0 支持, 使客户端能够请求服务器停止一个运行中的服务并移除其产生的任何文件.

ZOO-Kernel 支持的测试工具:

多语言支持(Polyglot)

语言服务提供数据结构返回值类型
C /C++SharedLibrarymaps* Minteger
Java类(Class)HashMapinteger
PythonModule FileDictionaryinteger
PHP脚本文件Arrayinteger
Perl脚本文件integer
Ruby脚本文件Hashinteger
FortranShared LibraryCHARACTER*(1024) M(10,30)integer
JavaScript脚本文件Object or ArrayObject/Array

ZOO-Kernel 配置

主配置文件

ZOO-Kernel的主配置文件为main.cfg ,其与Zoo-Kernel在同一目录下(一般为usr/lib/cgi-bin/C:\inetpub\cgi-bin

ZOO-Kernel (/usr/lib/cgi-bin/zoo_loader.cgi) 与其配置文件 (/usr/lib/cgi-bin/main.cfg) 必须位于同一目录.

# main.cfg
# define a specific HTTP Response header
[headers]
X-Powered-By=ZOO@ZOO-Project
# if allow CORS support for POST requests coming from myhost.net
Access-Control-Allow-Origin=myhost.net
Access-Control-Allow-Methods=POST
Access-Control-Allow-Headers=content-type
[main]
version=1.0.0 # Supported WPS version.
encoding=utf-8
dataPath=/var/data # directory where data files are stored (used to store mapfiles and data when MapServer support is activated).
tmpPath=/var/www/temp # directory where temporary files are stored (such as ExecuteResponse when store-ExecuteResponse is set to true).
tmpUrl: # temporary files directory (cf. tmpPath).
cacheDir=/var/www/cache # directory where cached request files are stored (optional).
sessPath=/tmp #
serverAddress=http://localhost/cgi-bin/zoo_loader.cgi # URL to the ZOO-Kernel instance
lang=en-US,zh-CN # Supported natural languages
language=en-US #
mapserverAddress=http://localhost/cgi-bin/mapserv.cgi # URL to the MapServer instance (optional).
msOgcVersion=1.0.0 # Version of all supported OGC Web Services output (optional).
servicePath: # Define a specific location to search for services rather than using the ZOO-Kernel directory. If this parameter is not defined, then the ZOO-Kernel will search for services using its directory.
tmpUrl=http:/localhost/temp/ #
cors=false # Define if support Cross-Origin Resource Sharing. If not, then the ZOO-Kernel won’t support CORS. 跨域支持
libPath: # (Optional) Path to a directory where the ZOO-kernel should search for service providers, e.g., shared libraries with service implementations (the serviceProvider parameter in the service configuration (.zcfg) file). only C/C++ or PHP
# not ZOO-Project specific
# for service metadata XML document
[identification]
keywords=t,ZOO-Project, ZOO-Kernel,WPS,GIS
title=ZOO-Project demo instance
abstract= This is ZOO-Project, the Open WPS platform.
accessConstraints=none
fees=None
[provider]
positionName=Developer
providerName=GeoLabs SARL
addressAdministrativeArea=False
addressDeliveryPoint=1280, avenue des Platanes
addressCountry=fr
phoneVoice=+33467430995
addressPostalCode=34970
role=Dev
providerSite=http://geolabs.fr
phoneFacsimile=False
addressElectronicMailAddress=gerald@geolabs.fr
addressCity=Lattes
individualName=Gerald FENOY
# specific environment variables to be set prior the loading of Services Provider and Service execution.
[env]
DISPLAY=:1 # Service requires the access to a X server running on framebuffer
[security]
attributes=Authorization,Cookie,User-Agent
hosts=localhost,127.0.0.1 # *
[database]
dbname=zoo_project
port=5432
user=username
host=127.0.0.1
type=PG # postgresql?
schema=public
# optional
# lists explicitely a set of service configuration files the the ZOO-Kernel should parse
[include]
servicename1 = /my/service/repository/service1.zcfg
servicename2 = /my/service/repository/service2.zcfg

如果一个包含的服务位于当前目录(CWD )(或子目录), 它将以其在 [include] 部分的名称作为发布后的名称。

[include]
myService = /[CWD]/name/space/myService.zcfg # myService
# 如果还存在下列配置,则上面的发布为 name.space.myService
# 下面的发布为 myService
[include]
myService = /some/other/dir/myService.zcfg
其他可选配置还包括:
# used by the ZOO-Kernel to store runtime informations before the execution of a WPS service
[lenv]
sid: # The WPS Service unique identifier ,(r),
status: # The current progress value ( a value between 0 and 100 in percent (%) ), (rw),
cwd: # The current working directory of ZOO-Kernel,(r)
message: # An error message used when SERVICE_FAILED is returned (optional), (rw)
cookie: #The cookie to be returned to the client (for example for authentication purpose). (rw)
file.pid: #The file used by the ZOO-Kernel to store process identifier. (r)
file.sid: #The file used by the ZOO-Kernel to store service identifier. (r)
file.responseInit: #The file used by the ZOO-Kernel to store the initial (then final) WPS response. (r)
file.responseFinal: # The file used by the ZOO-Kernel to temporary store the final WPS response. (r)
# automatically created by the ZOO-Kernel before the execution of a WPS service, contains all the environment variables available at runtime
[renv]
# store sessions information on the server side.
[senv]
# must contain the following parameter at least
XXX: # The session unique identifier where XXX is the name included in the cookie which is returned.

MapServer支持

利用可选的MapServer支持,可以直接将WPS结果自动发布为WMS、WFS或WCS。

工作原理

当一个包含mimeType=image/png的请求被发送给Zoo-Kernel时,后者会检测useMapServer 选项是否为true, (为true)然后自动地:

  • 利用<Default>块的定义,执行服务
  • 保存结果到硬盘([main]->dataPath配置的目录)
  • 使用MapServer的C-API生成一个mapfile文件(在[main]->dataPath配置的目录)

安装与配置

编译安装

  • 最新的ZOO-Kernel trunk版本
  • MapServer >= 6.0.1
cd <PREV_SVN_CO>
svn checkout http://svn.zoo-project.org/svn/trunk/zoo-kernel zoo-kernel-ms
# 解压 mapserver-6.0.1.tar.bz2 并编译
cd /tmp/zoo-ms-src/mapserver-6.0.1
./configure --with-ogr=/usr/bin/gdal-config --with-gdal=/usr/bin/gdal-config \
--with-proj --with-curl --with-sos --with-wfsclient --with-wmsclient \
--with-wcs --with-wfs --with-postgis --with-kml=yes --with-geos \
--with-xml --with-xslt --with-threads --with-cairo
make
cp mapserv /usr/lib/cgi-bin
# 编译 ZOO-Kernel with MapServer support
cd zoo-kernel-ms
autoconf
./configure --with-python --with-mapserver=/tmp/zoo-ms-src/mapserver-6.0.1
make
cp zoo_loader.cgi /usr/lib/cgi-bin

主配置文件

/usr/lib/cgi-bin/main.cfg中在[main] 部分添加

dataPath = /var/www/temp/
mapserverAddress=http://localhost/cgi-bin/mapserv

dataPath必须设置,并且必须属于 Apache 用户

mkdir /var/www/temp/
chown -r apache:apache /var/www/temp/

此目录下(仅)需要一个symbols.sym 文件,其内容为

SYMBOLSET
SYMBOL
NAME "circle"
TYPE ellipse
FILLED true
POINTS
1 1
END
END
END

至此,MapServer至此已经激活,别忘了在主配置文件中添加mapserverAddress 和 msOgcVersion 参数

服务配置文件

useMapserver

为了激活特定服务的 MapServer WMS/WFS/WCS输出,必须services-zcfg 文件的<Default><Supported>部分配置useMapserver 参数。

useMapserver=true意味着输出结果是兼容gdal的数据源,可以利用MapServer自动发布为WMS,WFS 或 WCS.。

相关的mimeType:

  • text/xml : 说明输出数据可以通过 WFS GetFeature请求获取 (默认 版本1.1.0)
  • image/tiff: 通过 WCS GetCoverage 请求 (默认版本2.0.0)
  • 其他 mimeType(有useMapserver 选项):WMS GetMap (1.3.0)

样式

可选的msStyle参数可被用于自定义MapServer样式块(只针对矢量数据)

msStyle = STYLE COLOR 125 0 105 OUTLINECOLOR 0 0 0 WIDTH 3 END

配置了MapServer支持的 ZOO-Service 配置文件示例:

<Default>
mimeType = text/xml
encoding = UTF-8
schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
useMapserver = true
</Default>
<Supported>
mimeType = image/png
useMapserver = true
asReference = true
msStyle = STYLE COLOR 125 0 105 OUTLINECOLOR 0 0 0 WIDTH 3 END
</Supported>
<Supported>
mimeType = application/vnd.google-earth.kmz
useMapserver = true
asReference = true
msStyle = STYLE COLOR 125 0 105 OUTLINECOLOR 0 0 0 WIDTH 3 END
</Supported>
<Supported>
mimeType = image/tif
useMapserver = true
asReference = true
<!-- 单波段栅格文件时,可设为true,以便利用ZOO-Kernel默认样式将栅格文件进行等间距分类 -->
msClassify = ....
</Supported>
文章目录
  1. 1. ZOO-Kernel
    1. 1.0.1. 规范支持
    2. 1.0.2. 多语言支持(Polyglot)
    3. 1.0.3. ZOO-Kernel 配置
      1. 1.0.3.1. 主配置文件
        1. 1.0.3.1.1. 其他可选配置还包括:
  2. 1.1. MapServer支持
    1. 1.1.1. 工作原理
    2. 1.1.2. 安装与配置
      1. 1.1.2.1. 编译安装
      2. 1.1.2.2. 主配置文件
    3. 1.1.3. 服务配置文件
      1. 1.1.3.1. useMapserver
      2. 1.1.3.2. 样式
|