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

server/2024/10/11 5:26:10/

前言

时光如白驹过隙,不知不觉间已经干了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/server/111082.html

相关文章

爬虫基础简介

爬虫基础简介 爬虫的定义&#xff1a; 通过编写程序&#xff0c;模拟浏览器上网&#xff0c;然后让其去互联网上抓取数据的过程。 爬虫的价值&#xff1a; -实际应用 -就业 爬虫的合法性&#xff1a; -在法律中不被禁止 -具有违法风险 爬虫带来的风险可以体现在如下2个方…

驾驭Python与MySQL的桥梁:pymysql的神秘面纱

文章目录 **驾驭Python与MySQL的桥梁&#xff1a;pymysql的神秘面纱**背景&#xff1a;为何选择pymysql&#xff1f;库的简介安装指南简单的库函数使用方法场景应用常见问题与解决方案总结 驾驭Python与MySQL的桥梁&#xff1a;pymysql的神秘面纱 背景&#xff1a;为何选择pym…

【RabbitMQ之一:windows环境下安装RabbitMQ】

目录 一、下载并安装Erlang1、下载Erlang2、安装Erlang3、配置环境变量4、验证erlang是否安装成功 二、下载并安装RabbitMQ1、下载RabbitMQ2、安装RabbitMQ3、配置环境变量4、验证RabbitMQ是否安装成功5、启动RabbitMQ服务&#xff08;安装后服务默认自启动&#xff09; 三、安…

SpringBoot 多环境日志配置

SpringBoot 默认使用 LogBack 日志系统 默认情况下&#xff0c;SpringBoot 项目的日志只会在控制台输入。 如果想查询历史日志则无法找到&#xff0c;我们需要一个日志系统来统一管理日志。 一般正式项目会有单独日志系统&#xff0c;将日志操作存入数据库。 第一种方式是 …

AI预测体彩排3采取888=3策略+和值012路或胆码测试9月2日升级新模型预测第70弹

经过近70期的测试&#xff0c;当然有很多彩友也一直在观察我每天发的预测结果&#xff0c;得到了一个非常有价值的信息&#xff0c;那就是9码定位的命中率非常高&#xff0c;已到达90%的命中率&#xff0c;这给喜欢打私菜的朋友提供了极高价值的预测结果~当然了&#xff0c;大部…

Qt:玩转QPainter序列九(文本,文本框,填充)

前言 继续承接序列八 正文 1. drawImage系列函数 绘制图像 inline void drawImage(const QPoint &p, const QImage &image); 作用: 在指定的点 p 上绘制 QImage 图像。图像的左上角将对齐到 p 点。 inline void drawImage(int x, int y, const QImage &image,…

语义补全学习笔记

自动驾驶 VoxFormer VoxFromer仅通过2D图像&#xff0c;不依赖点云数据&#xff0c;能预测完整的3D几何形状和语义信息 GitHub - NVlabs/VoxFormer: Official PyTorch implementation of VoxFormer [CVPR 2023 Highlight]

【mysql】mysql目录结构和源码和mysql基础练习

mysql目录结构和源码的说明&#xff1a; 也就是之前说四个位置有提到的两个位置&#xff0c; 1软件安装位置bin 把bin目录加入环境变量就可以直接在命令行调用&#xff0c; "***\MySQL\MySQL Installer for Windows\bin" 2还有一个数据库文件的安装位置 &#…