geoserver2.18(7):添加WPS(Web处理服务)扩展及前端开发调用

0 安装WPS扩展

1 geoserver管理界面关于wps服务的界面

    

服务管理界面、处理历史界面、WPS request builder界面(具体略......)

 2 WPS服务说明

  • GetCapabilities:请求提供服务的详细信息,包括服务元数据和描述可用流程的元数据。响应是一个称为功能文档的 XML 文档。

//service:服务;version:版本;request:请求;
http://localhost:8080/geoserver/ows?
  service=WPS&
  version=1.0.0&
  request=GetCapabilities
  • DescribeProcess:请求描述通过服务可用的 WPS 进程。

//service:服务;version:版本;request:请求;identifier:操作标识
http://localhost:8080/geoserver/ows?
  service=WPS& 
  version=1.0.0&
  request=DescribeProcess&
  identifier=JTS:buffer
  • Execute:执行服务(以缓冲区分析为例,datainputs为缓冲区操作的输入参数,其格式规则是重点,详情见 OGC Web Processing Service 05-007r7很重要

http://localhost:8081/geoserver/ows?
service=WPS&
version=1.0.0&
request=Execute&
identifier=JTS:buffer&
datainputs=
  geom=point(0%200)@mimetype=application/wkt;
  distance=10;
  quadrantSegments=1;
  capStyle=Square

3 Vue中开发调用

 this.$axios({
      method: "get",
      url: "http://127.0.0.1:8081/geoserver/ows",
      params: {
        service: "WPS",
        version: "1.0.0",
        request: "Execute",
        identifier: "JTS:buffer",
        datainputs:
          "geom=point(0 0)@mimetype=application/wkt;distance=10;quadrantSegments=1;capStyle=Square",
        // ResponseDocument: "BufferedPolygon",
      },
    }).then(function (response) {
      const x2js = new X2JS();
      const jsonObj = x2js.xml2js(response.data);
      console.info(jsonObj);
      // console.info(response.data.json());
    });


 结果:

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个示例代码,演示如何使用GeoServer 2.18版的REST API向PostGIS图层表中插入数据: ```java import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.Base64; public class GeoServerRESTClient { // GeoServer的地址 private static final String GEOSERVER_URL = "http://localhost:8080/geoserver"; // GeoServer的用户名和密码 private static final String USERNAME = "admin"; private static final String PASSWORD = "geoserver"; // PostGIS图层名称 private static final String LAYER_NAME = "public:my_postgis_layer"; public static void main(String[] args) throws Exception { // Base64编码用户名和密码 String auth = Base64.getEncoder().encodeToString((USERNAME + ":" + PASSWORD).getBytes()); // 构造插入数据的请求 URL url = new URL(GEOSERVER_URL + "/rest/workspaces/public/datastores/my_postgis_datastore/featuretypes/" + LAYER_NAME + "/insert.xml"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Authorization", "Basic " + auth); conn.setRequestProperty("Content-Type", "text/xml"); // 插入的数据 String data = "<wfs:Transaction service=\"WFS\" version=\"1.0.0\"\n" + " xmlns:wfs=\"http://www.opengis.net/wfs\"\n" + " xmlns:" + LAYER_NAME.split(":")[0] + "=\"" + GEOSERVER_URL + "/workspaces/public/" + LAYER_NAME.split(":")[0] + "\"\n" + " xmlns:gml=\"http://www.opengis.net/gml\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://www.opengis.net/wfs\n" + " http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">\n" + " <wfs:Insert>\n" + " <" + LAYER_NAME + ">\n" + " <geom>\n" + " <gml:Point>\n" + " <gml:coordinates>-122.3352,47.6374</gml:coordinates>\n" + " </gml:Point>\n" + " </geom>\n" + " <name>My Point</name>\n" + " </" + LAYER_NAME + ">\n" + " </wfs:Insert>\n" + "</wfs:Transaction>"; // 发送请求并获取响应 conn.getOutputStream().write(data.getBytes()); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } reader.close(); conn.disconnect(); } } ``` 需要注意的是,该示例代码假设你已经创建了一个名为`my_postgis_datastore`的PostGIS数据存储,并在其中创建了一个名为`my_postgis_layer`的图层。如果你的数据存储和图层名称不同,需要相应地修改代码。此外,代码中的插入数据也是一个示例,需要根据实际情况进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

碰碰qaq

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值