From cb85033879c74f34925a303402c1ad3e4a8646f2 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期一, 10 五月 2021 17:03:54 +0800
Subject: [PATCH] 搜索更换为geoserver wfs,图层顺序,弹窗定位等

---
 src/components/helpers/WfsHelper.js |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/components/helpers/WfsHelper.js b/src/components/helpers/WfsHelper.js
index 20093e6..9f9b781 100644
--- a/src/components/helpers/WfsHelper.js
+++ b/src/components/helpers/WfsHelper.js
@@ -1,14 +1,14 @@
 /**
  * 鍔犺浇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.params = {
     REQUEST: 'getfeature',
-    OUTPUTFORMAT: 'JSON',
+    OUTPUTFORMAT: 'application/json',
     maxFeatures: 20000,
     version: '1.0.0'
   }
@@ -17,16 +17,19 @@
     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 +37,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 +49,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 +76,8 @@
     if (filterParam) {
       params += '&' + filterParam
     }
-    return encodeURI(params)
+    // return encodeURI(params)
+    return params
   }
 
   this.getUrl = () => {

--
Gitblit v1.8.0