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

相关文章

Nginx中配置HTTP/2协议的详细指南

《Nginx中配置HTTP/2协议的详细指南》HTTP/2是HTTP协议的下一代版本,旨在提高性能、减少延迟并优化现代网络环境中的通信效率,本文将为大家介绍Nginx配置HTTP/2协议想详细步骤,需... 目录一、HTTP/2 协议概述1.HTTP/22. HTTP/2 的核心特性3. HTTP/2 的优

AJAX请求上传下载进度监控实现方式

《AJAX请求上传下载进度监控实现方式》在日常Web开发中,AJAX(AsynchronousJavaScriptandXML)被广泛用于异步请求数据,而无需刷新整个页面,:本文主要介绍AJAX请... 目录1. 前言2. 基于XMLHttpRequest的进度监控2.1 基础版文件上传监控2.2 增强版多

在React中引入Tailwind CSS的完整指南

《在React中引入TailwindCSS的完整指南》在现代前端开发中,使用UI库可以显著提高开发效率,TailwindCSS是一个功能类优先的CSS框架,本文将详细介绍如何在Reac... 目录前言一、Tailwind css 简介二、创建 React 项目使用 Create React App 创建项目

SpringBoot3实现Gzip压缩优化的技术指南

《SpringBoot3实现Gzip压缩优化的技术指南》随着Web应用的用户量和数据量增加,网络带宽和页面加载速度逐渐成为瓶颈,为了减少数据传输量,提高用户体验,我们可以使用Gzip压缩HTTP响应,... 目录1、简述2、配置2.1 添加依赖2.2 配置 Gzip 压缩3、服务端应用4、前端应用4.1 N

使用Jackson进行JSON生成与解析的新手指南

《使用Jackson进行JSON生成与解析的新手指南》这篇文章主要为大家详细介绍了如何使用Jackson进行JSON生成与解析处理,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1. 核心依赖2. 基础用法2.1 对象转 jsON(序列化)2.2 JSON 转对象(反序列化)3.

go中空接口的具体使用

《go中空接口的具体使用》空接口是一种特殊的接口类型,它不包含任何方法,本文主要介绍了go中空接口的具体使用,具有一定的参考价值,感兴趣的可以了解一下... 目录接口-空接口1. 什么是空接口?2. 如何使用空接口?第一,第二,第三,3. 空接口几个要注意的坑坑1:坑2:坑3:接口-空接口1. 什么是空接

Java利用JSONPath操作JSON数据的技术指南

《Java利用JSONPath操作JSON数据的技术指南》JSONPath是一种强大的工具,用于查询和操作JSON数据,类似于SQL的语法,它为处理复杂的JSON数据结构提供了简单且高效... 目录1、简述2、什么是 jsONPath?3、Java 示例3.1 基本查询3.2 过滤查询3.3 递归搜索3.4

Spring Boot结成MyBatis-Plus最全配置指南

《SpringBoot结成MyBatis-Plus最全配置指南》本文主要介绍了SpringBoot结成MyBatis-Plus最全配置指南,包括依赖引入、配置数据源、Mapper扫描、基本CRUD操... 目录前言详细操作一.创建项目并引入相关依赖二.配置数据源信息三.编写相关代码查zsRArly询数据库数

SpringBoot启动报错的11个高频问题排查与解决终极指南

《SpringBoot启动报错的11个高频问题排查与解决终极指南》这篇文章主要为大家详细介绍了SpringBoot启动报错的11个高频问题的排查与解决,文中的示例代码讲解详细,感兴趣的小伙伴可以了解一... 目录1. 依赖冲突:NoSuchMethodError 的终极解法2. Bean注入失败:No qu

SpringBoot使用OkHttp完成高效网络请求详解

《SpringBoot使用OkHttp完成高效网络请求详解》OkHttp是一个高效的HTTP客户端,支持同步和异步请求,且具备自动处理cookie、缓存和连接池等高级功能,下面我们来看看SpringB... 目录一、OkHttp 简介二、在 Spring Boot 中集成 OkHttp三、封装 OkHttp