Geoserver的 rest、wfs、wms、wps接口请求指南

2024-08-29 14:44

本文主要是介绍Geoserver的 rest、wfs、wms、wps接口请求指南,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前言

时光如白驹过隙,不知不觉间已经干了7年的GIS开发了,一路走来跌跌撞撞的,跟随着时代的洪流行尸走肉般的生存着(此处省略n个字,全是感慨)

一、官方API地址

geoserver官方的api地址还是比较全的,我整理了下放到了下面

  1. 文档地址:传送门
  2. rest接口地址:传送门
  3. wfs服务接口地址:传送门
  4. wms服务接口地址:传送门
  5. wps服务接口地址:传送门

二、请求示例

以wfs查询为例做一个查询的示例

/*** 图层wfs查询* @param {WfsQueryParams} obj 查询条件* @returns 图层wfs结果*/
export function wfsQuery(obj: WfsQueryParams) {const { layername, cql, fid, startIndex, maxFeatures } = objconst featureRequest: { [key: string]: string | number } = {service: "WFS",version: "1.0.0",request: "GetFeature",srsName: "EPSG:4326",typename: layername,outputFormat: "application/json"}if (fid) featureRequest.featureId = fidif (cql) featureRequest.CQL_FILTER = cqlif (startIndex != null && startIndex !== undefined) featureRequest.startIndex = startIndexif (maxFeatures != null && maxFeatures !== undefined) featureRequest.maxFeatures = maxFeaturesconst params = new URLSearchParams()for (const attr in featureRequest) {params.append(attr, featureRequest[attr] as any)}return http.independentGet<WfsQueryResult>(`${MAPSERVER}/ows?${params.toString()}`)
}

在上述代码中封装了一个wfs查询的方法,最下面的请求的http用的是axios

三、geoserver-helper示例

geoserver-helper是专门封装的用于请求geoserver的wfs,mws、wps以及rest接口的帮助类

使用方法如下

1、安装依赖

# 安装依赖
npm i geoserver-helper

2、引用依赖

// 整体引入依赖
import geoserverHelper from 'geoserver-helper'// 按需引入依赖
import utils from 'geoserver-helper/utils'
import wfsHelper from 'geoserver-helper/wfs'
import wpsHelper from 'geoserver-helper/wps'
import wmsHelper from 'geoserver-helper/wms'
import restHelper from 'geoserver-helper/rest'

3.使用

const restHelperInstance = new restHelper({url: "http://localhost:8080/geoserver"
})
const wpsHelper = new geoserverRest.wpsHelper("/geoserver/ows",);
const wfsHelperInstance = new wfsHelper({url: "/geoserver/wfs",workspace: "test",
});
const wmsHelperInstance = new wmsHelper({url: "/geoserver/wms",workspace: "test",
});//查询所有的图层列表
const res = await restHelperInstance.getLayerListApi()
console.log(res.layers)
//查询所有的工作空间列表
const res = await restHelperInstance.getWorkspaceListApi()
console.log(res.workspaces)
//查询所有的样式列表
restHelperInstance.getStylesListApi().then(res => {debuggerconsole.log(res)
})
//查询单个图层详情
restHelperInstance.getLayerInfoApi("test:xzqh_shi").then(res => {debuggerres.layerconsole.log(res)
})
//查询单个工作空间详情
restHelperInstance.getWorkspaceInfoApi("qhd").then(res => {debuggerconsole.log(res)
})const currentLayerModifyInfo: ILayer.LayerModifyInfo = {defaultStyle: {name: "test:xzqh_shi",// name: "polygon",},
}
//修改图层信息
restHelperInstance.modifyLayerApi("xzqh_shi",currentLayerModifyInfo,"test",
).then(res => {debugger
}).catch(e => {debugger
})
//用post请求要素
wfsHelperInstance.GetFeatureByPost({// "workspace": "test", // "workspaceUri": "http://test", "typename": "test:基本农田","startIndex": 0,"maxFeatures": 10,"cql": "type = '种植非粮食作' AND INTERSECTS (the_geom, MULTIPOLYGON(((119.149559 40.60191,119.1549 40.597565,119.176018 40.609817,119.220772 40.604893。。。))))"
}).then(res => {debuggerconsole.log(res)
})
//要素查询
wfsHelperInstance.GetFeature({propertyname: "name,gb",typename: "qhd:xzqh_xian",}).then(res => {debuggerconsole.log(res)
})
//获取图层字段描述信息
wfsHelperInstance.DescribeFeatureType({typeName: "topp:states",
}).then(res => {debuggerconsole.log(res)
})
//获取wfs能力集合
wfsHelperInstance.GetCapabilities({version: "1.0.0",
}).then(res => {debuggerconsole.log(res)
})
//获取单属性属性表
wfsHelperInstance.GetPropertyValue({typeNames: "topp:states",valueReference: "STATE_NAME"
}).then(res => {debuggerconsole.log(res)
})
//获取wms能量集合
wmsHelperInstance.GetCapabilities({version: "1.0.0"
}).then(res => {debuggerconsole.log(res)
})
//获取要素(多用于点选查询)
wmsHelperInstance.GetFeatureInfo({layers: "ellip_visual:1000510942192095232",version: "1.1.1",bbox: "118.85559,39.47113,119.17419,39.776",srs: "EPSG:4326"
}).then(res => {debuggerconsole.log(res)
})
//获取图例
wmsHelperInstance.GetLegendGraphic({layer: "ellip_visual:1000510942192095232",
}).then(res => {debuggerconsole.log(res)
})
//获取wps能力集
wpsHelper.GetCapabilities().then(res => {debuggerconsole.log(res)
})
//获取某个算子的详情信息
wpsHelper.DescribeProcess({identifier: "JTS:buffer"
}).then(res => {debuggerconsole.log(res)
})

这篇关于Geoserver的 rest、wfs、wms、wps接口请求指南的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1118156

相关文章

Java controller接口出入参时间序列化转换操作方法(两种)

《Javacontroller接口出入参时间序列化转换操作方法(两种)》:本文主要介绍Javacontroller接口出入参时间序列化转换操作方法,本文给大家列举两种简单方法,感兴趣的朋友一起看... 目录方式一、使用注解方式二、统一配置场景:在controller编写的接口,在前后端交互过程中一般都会涉及

SpringBoot整合OpenFeign的完整指南

《SpringBoot整合OpenFeign的完整指南》OpenFeign是由Netflix开发的一个声明式Web服务客户端,它使得编写HTTP客户端变得更加简单,本文为大家介绍了SpringBoot... 目录什么是OpenFeign环境准备创建 Spring Boot 项目添加依赖启用 OpenFeig

SpringBoot请求参数接收控制指南分享

《SpringBoot请求参数接收控制指南分享》:本文主要介绍SpringBoot请求参数接收控制指南,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Spring Boot 请求参数接收控制指南1. 概述2. 有注解时参数接收方式对比3. 无注解时接收参数默认位置

Spring 请求之传递 JSON 数据的操作方法

《Spring请求之传递JSON数据的操作方法》JSON就是一种数据格式,有自己的格式和语法,使用文本表示一个对象或数组的信息,因此JSON本质是字符串,主要负责在不同的语言中数据传递和交换,这... 目录jsON 概念JSON 语法JSON 的语法JSON 的两种结构JSON 字符串和 Java 对象互转

usb接口驱动异常问题常用解决方案

《usb接口驱动异常问题常用解决方案》当遇到USB接口驱动异常时,可以通过多种方法来解决,其中主要就包括重装USB控制器、禁用USB选择性暂停设置、更新或安装新的主板驱动等... usb接口驱动异常怎么办,USB接口驱动异常是常见问题,通常由驱动损坏、系统更新冲突、硬件故障或电源管理设置导致。以下是常用解决

CentOS7更改默认SSH端口与配置指南

《CentOS7更改默认SSH端口与配置指南》SSH是Linux服务器远程管理的核心工具,其默认监听端口为22,由于端口22众所周知,这也使得服务器容易受到自动化扫描和暴力破解攻击,本文将系统性地介绍... 目录引言为什么要更改 SSH 默认端口?步骤详解:如何更改 Centos 7 的 SSH 默认端口1

SpringBoot多数据源配置完整指南

《SpringBoot多数据源配置完整指南》在复杂的企业应用中,经常需要连接多个数据库,SpringBoot提供了灵活的多数据源配置方式,以下是详细的实现方案,需要的朋友可以参考下... 目录一、基础多数据源配置1. 添加依赖2. 配置多个数据源3. 配置数据源Bean二、JPA多数据源配置1. 配置主数据

python中各种常见文件的读写操作与类型转换详细指南

《python中各种常见文件的读写操作与类型转换详细指南》这篇文章主要为大家详细介绍了python中各种常见文件(txt,xls,csv,sql,二进制文件)的读写操作与类型转换,感兴趣的小伙伴可以跟... 目录1.文件txt读写标准用法1.1写入文件1.2读取文件2. 二进制文件读取3. 大文件读取3.1

SpringBoot中配置Redis连接池的完整指南

《SpringBoot中配置Redis连接池的完整指南》这篇文章主要为大家详细介绍了SpringBoot中配置Redis连接池的完整指南,文中的示例代码讲解详细,具有一定的借鉴价值,感兴趣的小伙伴可以... 目录一、添加依赖二、配置 Redis 连接池三、测试 Redis 操作四、完整示例代码(一)pom.

Linux内核参数配置与验证详细指南

《Linux内核参数配置与验证详细指南》在Linux系统运维和性能优化中,内核参数(sysctl)的配置至关重要,本文主要来聊聊如何配置与验证这些Linux内核参数,希望对大家有一定的帮助... 目录1. 引言2. 内核参数的作用3. 如何设置内核参数3.1 临时设置(重启失效)3.2 永久设置(重启仍生效