通过OGC API发布流程-流程

OGC API - Processes 以基于标准的方式(输入、输出)提供地理空间数据处理功能。

pygeoapi通过提供插件体系结构来实现OGC API进程功能,从而允许开发人员在Python中实现自定义处理工作流。

A sample hello-world 进程提供了pygeoapi默认配置。

配置

processes:
    hello-world:
        processor:
            name: HelloWorld

异步支持

默认情况下,pygeapi将进程执行(作业)实现为同步模式。也就是说,当提交作业时,将实时执行并返回该流程。某些可能需要时间执行或委托给调度器/队列的流程更适合异步设计模式。这意味着当作业以异步模式提交时,服务器会立即引用该作业进行响应,这允许客户端定期轮询服务器以获取给定作业的处理状态。

pygeapi通过提供“管理器”概念来提供异步支持,该概念可以很好地管理作业执行。管理器概念是作为pyGeoapi的一部分实现的。 自定义pygeoapi:插件 建筑。pyGeoapi提供了一个默认的管理器实现,该实现基于 TinyDB 为了简单起见。可以为更高级的作业管理功能(如Kubernetes、数据库等)开发自定义管理器插件。

为了与OGC API流程规范保持一致,可以通过包含 Prefer: respond-async 请求中的Http头

server:
    manager:
        name: TinyDB
        connection: /tmp/pygeoapi-process-manager.db
        output_dir: /tmp/

MongoDB

作为默认的替代方案,经理雇用 MongoDB 可以使用。与已安装的 MongoDB 必须在配置中提供实例。 MongoDB 默认情况下使用本地主机和端口27017。作业存储在名为JOB_MANAGER_PYEO API的集合中。

server:
    manager:
        name: MongoDB
        connection: mongodb://host:port
        output_dir: /tmp/

把这一切放在一起

要总结PyGeoapi流程和管理器如何协同工作,请执行以下操作:

* process plugins implement the core processing / workflow functionality
* manager plugins control and manage how processes are executed

处理示例

# list all processes
curl http://localhost:5000/processes

# describe the ``hello-world`` process
curl http://localhost:5000/processes/hello-world

# show all jobs
curl http://localhost:5000/jobs

# execute a job for the ``hello-world`` process
curl -X POST http://localhost:5000/processes/hello-world/execution \
    -H "Content-Type: application/json" \
    -d "{\"inputs\":{\"name\": \"hi there2\"}}"

# execute a job for the ``hello-world`` process with a raw response (default)
curl -X POST http://localhost:5000/processes/hello-world/execution \
    -H "Content-Type: application/json" \
    -d "{\"inputs\":{\"name\": \"hi there2\"}}"

# execute a job for the ``hello-world`` process with a response document
curl -X POST http://localhost:5000/processes/hello-world/execution \
    -H "Content-Type: application/json" \
    -d "{\"inputs\":{\"name\": \"hi there2\"},\"response\":\"document\"}"

# execute a job for the ``hello-world`` process in asynchronous mode
curl -X POST http://localhost:5000/processes/hello-world/execution \
    -H "Content-Type: application/json" \
    -H "Prefer: respond-async"
    -d "{\"inputs\":{\"name\": \"hi there2\"}}"

待处理

完成OAProc实现后添加更多示例