From cf5ab6da9ff676fab8a10d4299bd5a04a07bf50f Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期一, 17 五月 2021 10:05:53 +0800
Subject: [PATCH] 修复默认选中图层时出现的BUG
---
src/components/helpers/WfsHelper.js | 65 ++++++++++++++++++++++++++------
1 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/src/components/helpers/WfsHelper.js b/src/components/helpers/WfsHelper.js
index 20093e6..8505070 100644
--- a/src/components/helpers/WfsHelper.js
+++ b/src/components/helpers/WfsHelper.js
@@ -1,32 +1,45 @@
/**
* 鍔犺浇WMS,鎷兼帴FILTER,LAYERS鍙傛暟绛�
*/
-import { PIPELINE_WFS } from '../../conf/Constants'
+import { WFS_URL } from '../../conf/Constants'
function WfsHelper () {
this.filters = []
this.typeNames = []
- this.url = 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) => {
+ this.typeNames = typeName
+ }
+
+ 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) => {
- if (property && literal) {
- var filter = '<PropertyIsLike><PropertyName>' + property + '</PropertyName><Literal>*' + literal + '*</Literal></PropertyIsLike>'
- this.filters.push(filter)
- }
+ // 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)
}
/**
@@ -34,7 +47,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) {
@@ -46,8 +59,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 = () => {
@@ -62,7 +86,8 @@
if (filterParam) {
params += '&' + filterParam
}
- return encodeURI(params)
+ // return encodeURI(params)
+ return params
}
this.getUrl = () => {
@@ -74,6 +99,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