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

embedded/2024/10/11 5:29:37/

前言

时光如白驹过隙,不知不觉间已经干了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)
})

http://www.ppmy.cn/embedded/102571.html

相关文章

CSS的font-stretch属性与字符胖瘦控制

font-stretch CSS 属性用于选择字体的一个更宽&#xff08;expanded&#xff09;或更窄&#xff08;condensed&#xff09;的版本&#xff0c;以控制字符的“胖瘦”。然而&#xff0c;需要注意的是&#xff0c;并非所有的字体都支持多种拉伸变体&#xff08;stretch variants&a…

(第三十八天)

1 、 harbor 软件包下载 https://github.com/search?qharbor&typerepositories 2 、出现拒绝连接错误&#xff0c;可能是由于容器没开 # 问题解决&#xff1a; [rootdocker ~] # curl localhost:5000/v2/_catalog curl : (7) Failed connect to localhost:5000; 拒绝…

使用 Spring Boot 快速构建 Java Web 应用

1. 什么是 Spring Boot? Spring Boot 是基于 Spring 框架的快速开发工具&#xff0c;它为开发人员提供了一种简单的方式来创建独立、生产级别的 Spring 应用程序&#xff0c;而不需要过多的配置。Spring Boot 通过约定大于配置的理念&#xff0c;简化了项目的搭建过程&#x…

【读点论文】Text detection and localization in scene images: a broad review

Text detection and localization in scene images: a broad review Abstract 如今&#xff0c;文本检测和定位在文本分析系统领域已广受欢迎&#xff0c;因为它们为大量实时应用铺平了道路&#xff0c;例如移动音译技术、视障人士辅助方法等。 文本检测和定位技术用于查找图…

【电控笔记z27】相对位置控制(无前馈)

相对位置控制系统&#xff08;Relative Position Control System&#xff09;是一种用于控制对象之间相对位置的控制系统。在工程应用中&#xff0c;这类系统广泛用于自动化、机器人控制、航空航天、机电设备等领域。系统通过感知和调节两个或多个物体之间的相对位置&#xff0…

Python实现分水岭图像分割算法

目录 Python实现分水岭图像分割算法的详细博客一、引言二、分水岭算法的原理三、Python实现分水岭算法四、算法步骤解析1. 图像预处理2. 计算梯度图像3. 阈值分割4. 距离变换与标记操作5. 分水岭变换五、应用场景:细胞图像分割1. 读取细胞图像2. 应用高斯模糊去除噪声3. 计算梯…

【CVPR‘24】ProxyTTA:域自适应深度补全,Test-Time Adaptation for Depth Completion

【CVPR24】域自适应深度补全:Test-Time Adaptation for Depth Completion 摘要1. 引言2. 相关工作3. 方法3.1 数据模态敏感性研究3.2 准备阶段 - 源域3.3 将代理映射部署到目标域4. 实验5. 讨论摘要 深度补全旨在利用多传感器设置,从稀疏深度图中推断出密集深度图。尽管近年…

python读取配置文件简单封装 公共配置文件 config

之前有做过把爬虫数据写到数据库中的练习,这次想把数据库信息抽离到一个ini配置文件中,这样做的好处在于可以在配置文件中添加多个数据库,方便切换(另外配置文件也可以添加诸如邮箱、url等信息) 1.configparser模块 python使用自带的configparser模块用来读取配置文件,配置…