From c065531c87e7dc199c7fc4d35e4f6fbedf26167d Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期三, 19 五月 2021 15:40:37 +0800
Subject: [PATCH] 定位、弹窗信息、排口查询BUG修复
---
src/components/helpers/WfsHelper.js | 90 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 80 insertions(+), 10 deletions(-)
diff --git a/src/components/helpers/WfsHelper.js b/src/components/helpers/WfsHelper.js
index 3208ca8..d590b0a 100644
--- a/src/components/helpers/WfsHelper.js
+++ b/src/components/helpers/WfsHelper.js
@@ -1,29 +1,73 @@
/**
* 鍔犺浇WMS,鎷兼帴FILTER,LAYERS鍙傛暟绛�
*/
-import MapConfig from '../../conf/MapConfig'
+import { WFS_URL } from '../../conf/Constants'
+import { lrtrim } from '../../utils/utils'
function WfsHelper () {
this.filters = []
this.typeNames = []
- this.url = MapConfig.BLUEMAP_HOST + '/server/ogcserver/PipeLine/wfs'
+ this.url = WFS_URL
+ this.page = 1
+ this.pageSize = 10
this.params = {
REQUEST: 'getfeature',
- OUTPUTFORMAT: 'JSON',
- maxFeatures: 20000,
+ OUTPUTFORMAT: 'application/json',
+ maxFeatures: 10,
version: '1.0.0'
+ }
+
+ this.setTypeName = (typeName) => {
+ if (typeof typeName === 'string' || typeName instanceof String) {
+ const comma = typeName.indexOf(',')
+ if (comma >= 0) {
+ const typeNameArr = typeName.split(',')
+ for (let i = 0; i < typeNameArr.length; i++) {
+ this.addTypeName(lrtrim(typeNameArr[i]))
+ }
+ }
+ } else if (Array.isArray(typeName)) {
+ this.typeNames = typeName
+ }
+ }
+
+ this.setFilter = (filter) => {
+ console.log(filter)
+ if (typeof filter === 'string' || filter instanceof String) {
+ const eq = filter.indexOf('=')
+ const lk = filter.indexOf('like')
+ if (eq >= 0) {
+ const filterArr = filter.split('=')
+ this.addEquals(lrtrim(filterArr[0]), lrtrim(filterArr[1]))
+ }
+ if (lk >= 0) {
+ const filterArr = filter.split('like')
+ this.addLike(lrtrim(filterArr[0]), lrtrim(filterArr[1]))
+ }
+ } else if (Array.isArray(filter)) {
+ this.filters = filter
+ }
+ }
+
+ this.clearFilter = () => {
+ this.filters = []
}
this.addTypeName = (typeName) => {
this.typeNames.push(typeName)
}
- this.addEquals = (property, literal) => {
- var filter = '<PropertyIsEqualTo><PropertyName>' + property + '</PropertyName><Literal>' + literal + '</Literal></PropertyIsEqualTo>'
+ this.addEquals = (property, equals) => {
+ // var filter = '<PropertyIsEqualTo><PropertyName>' + property + '</PropertyName><Literal>' + literal + '</Literal></PropertyIsEqualTo>'
+ var filter = property + '=' + equals
this.filters.push(filter)
}
this.addLike = (property, literal) => {
- var filter = '<PropertyIsLike><PropertyName>' + property + '</PropertyName><Literal>' + literal + '</Literal></PropertyIsLike>'
+ // if (property && literal) {
+ // var filter = '<PropertyIsLike><PropertyName>' + property + '</PropertyName><Literal>*' + literal + '*</Literal></PropertyIsLike>'
+ // this.filters.push(filter)
+ // }
+ var filter = property + ' like \'%' + literal + '%\''
this.filters.push(filter)
}
@@ -32,7 +76,7 @@
* @returns {string|null}
*/
this.getFilterParams = () => {
- var head = '<Filter xmlns="http://www.opengis.net/ogc">'
+ /* var head = '<Filter xmlns="http://www.opengis.net/ogc">'
var end = '</Filter>'
var filter = ''
if (this.filters.length > 0) {
@@ -44,8 +88,19 @@
return ('FILTER=' + head + '<And>' + filter + '</And>' + end)
}
return ('FILTER=' + head + filter + end)
+ } */
+ var filter = ''
+ if (this.filters.length > 0) {
+ filter = 'CQL_FILTER='
+ for (var i = 0; i < this.filters.length; i++) {
+ filter += this.filters[i]
+ if (i !== this.filters.length - 1) {
+ filter += ' AND '
+ }
+ }
+ return filter
}
- return null
+ return filter
}
this.getUrlParams = () => {
@@ -60,7 +115,8 @@
if (filterParam) {
params += '&' + filterParam
}
- return encodeURI(params)
+ // return encodeURI(params)
+ return params
}
this.getUrl = () => {
@@ -72,6 +128,20 @@
}
return url + this.getUrlParams()
}
+
+ this.setPage = (page) => {
+ const startIndex = page * this.pageSize
+ this.params.startIndex = startIndex
+ this.page = page
+ }
+
+ this.setPageSize = (pageSize) => {
+ this.pageSize = pageSize
+ }
+
+ this.setMaxFeatures = (maxFeatures) => {
+ this.params.maxFeatures = maxFeatures
+ }
}
export default WfsHelper
--
Gitblit v1.8.0