派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-04-07 48f5ceebb86c2341010cc17d2298eb694afa0822
src/components/helpers/WfsHelper.js
@@ -1,10 +1,11 @@
/**
 * 加载WMS,拼接FILTER,LAYERS参数等
 */
import MapConfig from '../../conf/MapConfig'
function WfsHelper () {
  this.filters = []
  this.typeNames = []
  this.url = 'http://xearth.cn:6289/server/ogcserver/PipeLine/wfs'
  this.url = MapConfig.BLUEMAP_HOST + '/server/ogcserver/PipeLine/wfs'
  this.params = {
    REQUEST: 'getfeature',
    OUTPUTFORMAT: 'JSON',
@@ -16,11 +17,20 @@
    this.typeNames.push(typeName)
  }
  this.appendEquals = (property, literal) => {
  this.addEquals = (property, literal) => {
    var filter = '<PropertyIsEqualTo><PropertyName>' + property + '</PropertyName><Literal>' + literal + '</Literal></PropertyIsEqualTo>'
    this.filters.push(filter)
  }
  this.addLike = (property, literal) => {
    var filter = '<PropertyIsLike><PropertyName>' + property + '</PropertyName><Literal>*' + literal + '*</Literal></PropertyIsLike>'
    this.filters.push(filter)
  }
  /**
   * 得到filter参数值
   * @returns {string|null}
   */
  this.getFilterParams = () => {
    var head = '<Filter xmlns="http://www.opengis.net/ogc">'
    var end = '</Filter>'
@@ -29,6 +39,10 @@
      for (var i = 0; i < this.filters.length; i++) {
        filter += this.filters[i]
      }
      // 当条件数 > 1时,需要用and标签包裹
      if (this.filters.length > 1) {
        return ('FILTER=' + head + '<And>' + filter + '</And>' + end)
      }
      return ('FILTER=' + head + filter + end)
    }
    return null