cql_fiter

作者: xueyueshuai | 来源:发表于2023-07-31 19:31 被阅读0次
    <template>
      <div>
      </div>
    </template>
    
    <script>
    
    export default {
      name: 'xys-study-cql_filter',
      data() {
        return {}
      },
      mounted() {
        let str2Unicode = (str) => {
          let unicodeStr = '';
          for (let i = 0; i < str.length; i++) {
            const char = str.charAt(i);
            const codePoint = char.charCodeAt(0);
            if (codePoint >= 0x4e00 && codePoint <= 0x9fa5) {
              // 仅处理中文字符,其他字符保持不变
              unicodeStr += `\\u${codePoint.toString(16).toUpperCase().padStart(4, '0')}`;
            } else {
              // 非中文字符保持不变
              unicodeStr += char;
            }
          }
          return unicodeStr;
        }
    
        let test = (str) => {
          // 处理str
          str = encodeURIComponent(str2Unicode(str))
    
          // 发起请求
          let url = 'http://localhost:8899/geoserver/one/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=one:province&maxFeatures=1000000&outputFormat=application%2Fjson&cql_filter=' + str
          fetch(url).then(res => res.json()).then(jsonData => {
            jsonData.features.forEach(v => {
              console.log(v.properties)
            })
          })
        }
    
        test(`"CODE"='110000000'`)
        test(`"NAME" like '%河北%'`)
        test(`"省份名" like '%新疆%'`)
      }
    }
    </script>
    
    <style lang="scss" scoped>
    </style>
    

    相关文章

      网友评论

          本文标题:cql_fiter

          本文链接:https://www.haomeiwen.com/subject/hxalpdtx.html