地理服务器进程

geoserver wps包括一些专门为与geoserver一起使用而创建的进程。这些通常是特定于地理服务器的函数,例如边界和重投影。它们使用到geoserver wfs/wcs的内部连接(而不是wps规范的一部分)来读取和写入数据。

与“geo”流程一样,这些流程的名称和定义可能会发生更改,因此此处不包括这些流程。有关特定于geoserver的进程的完整列表,请参阅geoserver WPS capabilities document (或使用 WPS请求生成器

聚合过程

聚合过程用于对向量数据执行公共聚合函数(sum、average、count)。此过程的可用输出格式为 text/xmlapplication/json .

工艺参数见下表:

Parameter

Description

Mandatory

Multiple

features

输入功能集合。

aggregationAttribute

要对其执行聚合的属性。

function

要计算的聚合函数。函数包括count、average、max、central、min、stdev和sum。

singlePass

如果为true,则在一次传递中计算所有聚合值。这将击败DBMS特定的优化。如果提供了group by属性,则此参数将被忽略。

groupByAttributes

按属性分组。

以下是使用所提供的geoserver调用此进程的一些示例 topp:states 层。

示例可以使用curl进行测试:

curl -u admin:geoserver -H 'Content-type: xml' -XPOST -d@'wps-request.xml' http://localhost:8080/geoserver/wps

在哪里? wps-request.xml 是包含请求的文件。

聚合示例

计算一个州的总数,加上所有人数,计算每个州的平均人数,并给出一个州的最大和最小人数。

请求:

<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>gs:Aggregate</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>features</ows:Identifier>
      <wps:Reference mimeType="text/xml" xlink:href="http://geoserver/wfs" method="POST">
        <wps:Body>
          <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2" xmlns:sf="http://www.openplans.org/spearfish">
            <wfs:Query typeName="topp:states"/>
          </wfs:GetFeature>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>aggregationAttribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>PERSONS</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Count</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Average</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Sum</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Min</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Max</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>singlePass</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>false</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="application/json">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

结果:

{
  "AggregationAttribute": "PERSONS",
  "AggregationFunctions": ["Max", "Min", "Average", "Sum", "Count"],
  "GroupByAttributes": [],
  "AggregationResults": [
    [29760021, 453588, 5038397.020408163, 246881454, 49]
  ]
}

价值 AggregationResults 属性应以表格方式读取。按属性分组的顺序排在第一位 GroupByAttributes 属性。after是聚合函数的结果,按它们在 AggregationFunctions 属性。在这种情况下,没有按属性分组,因此结果只包含包含聚合函数结果的行。这与SQL查询的结果非常相似。

这个结果应该这样解释:

Max

Min

Average

Sum

Count

29760021

453588

5038397.020408163

246881454

49

要获得XML格式的结果,请求 wps:ResponseForm 元素需要更改为:

<wps:ResponseForm>
  <wps:RawDataOutput mimeType="text/xml">
    <ows:Identifier>result</ows:Identifier>
  </wps:RawDataOutput>
</wps:ResponseForm>

XML格式的结果:

<?xml version="1.0" encoding="UTF-8"?>
<AggregationResults>
  <Min>453588.0</Min>
  <Max>2.9760021E7</Max>
  <Average>5038397.020408163</Average>
  <Sum>2.46881454E8</Sum>
  <Count>49</Count>
</AggregationResults>

聚合GroupBy示例

此示例计算按区域分组的状态数和总体平均数。

请求:

<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>gs:Aggregate</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>features</ows:Identifier>
      <wps:Reference mimeType="text/xml" xlink:href="http://geoserver/wfs" method="POST">
        <wps:Body>
          <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2" xmlns:sf="http://www.openplans.org/spearfish">
            <wfs:Query typeName="topp:states"/>
          </wfs:GetFeature>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>aggregationAttribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>PERSONS</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Count</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Average</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>singlePass</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>false</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>groupByAttributes</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>SUB_REGION</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="application/json">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

结果:

{
  "AggregationAttribute": "PERSONS",
  "AggregationFunctions": ["Average", "Count"],
  "GroupByAttributes": ["SUB_REGION"],
  "AggregationResults": [
    [ "N Eng", 2201157.1666666665, 6 ],
    [ "W N Cen", 2522812.8571428573, 7 ],
    [ "Pacific", 12489678, 3 ],
    [ "Mtn", 1690408.25, 8 ],
    [ "E S Cen", 3998821.25, 4 ],
    [ "S Atl", 4837695.666666667, 9 ],
    [ "Mid Atl", 12534095.333333334, 3 ],
    [ "E N Cen", 8209477.2, 5 ],
    [ "W S Cen", 6709575.75, 4 ]
  ]
}

由于存在“分组依据”属性,因此对于“分组依据”属性的每个不同值,结果都包含一行。非常类似于SQL查询的结果。如果有多个“分组依据”属性(并非如此),则它们的值将按照它们在 GroupByAttributes 属性。

这个结果应该这样解释:

子区域

Average

count

N发动机

2201157.1666666665

6

新世纪

2522812.8571428573

7

太平洋

12489678

3

MTN公司

1690408.25

8

欧洲标准化委员会

3998821.25

4

S自动变速器

4837695.666666667

9

中速自动变速器

12534095.333333334

3

欧洲中部

8209477.2

5

世界中心

6709575.75

4

XML格式的结果:

<?xml version="1.0" encoding="UTF-8"?>
<AggregationResults>
  <GroupByResult>
    <object-array>
      <string>N Eng</string>
      <double>2201157.1666666665</double>
      <int>6</int>
    </object-array>
    <object-array>
      <string>W N Cen</string>
      <double>2522812.8571428573</double>
      <int>7</int>
    </object-array>
    <object-array>
      <string>Pacific</string>
      <double>1.2489678E7</double>
      <int>3</int>
    </object-array>
    <object-array>
      <string>Mtn</string>
      <double>1690408.25</double>
      <int>8</int>
    </object-array>
    <object-array>
      <string>E S Cen</string>
      <double>3998821.25</double>
      <int>4</int>
    </object-array>
    <object-array>
      <string>S Atl</string>
      <double>4837695.666666667</double>
      <int>9</int>
    </object-array>
    <object-array>
      <string>Mid Atl</string>
      <double>1.2534095333333334E7</double>
      <int>3</int>
    </object-array>
    <object-array>
      <string>E N Cen</string>
      <double>8209477.2</double>
      <int>5</int>
    </object-array>
    <object-array>
      <string>W S Cen</string>
      <double>6709575.75</double>
      <int>4</int>
    </object-array>
  </GroupByResult>
</AggregationResults>
Previous: 几何处理