Geoserver中如何将CQL转换OGC的xml过滤

Geoserver中如何将CQL转换OGC的xml过滤,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

创新互联公司是一家专业提供洛隆企业网站建设,专注与成都网站制作、成都做网站、H5高端网站建设、小程序制作等业务。10年已为洛隆众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

在Geoserver的wfs查询中,支持CQL的数据查询过滤,但是常用的OGC的查询中,是以post的形式,通过传递一个xml文件的格式,返回查询数据的结果。这在arcgis server,sfs server中都能够进行支持的,因为这些服务都支持OGC的标准查询。

CQL使用类似文本语法的格式,具有很高的可读性和适用性。

这里分享一个使用GeoTools将CQL转换为OGC过滤查询的代码样例,具体的英文网址在原文链接中。

GeoTools是一个开源的java版gis工具集,里边有许多gis方面的相关方法,可在网上直接下载编译好的jar包进行使用。

转换代码如下:


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.geotools.filter.text.cql2.CQL;
import org.geotools.filter.text.cql2.CQLException;
import org.opengis.filter.Filter;
public class CQLToOGC {  public static void main(String[] args) throws IOException {    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));    String line;    org.geotools.xml.Configuration configuration = new org.geotools.filter.v1_0.OGCConfiguration();    org.geotools.xml.Encoder encoder = new org.geotools.xml.Encoder(        configuration);    encoder.setIndenting(true);    while (!(line = reader.readLine()).isEmpty()) {      try {        Filter filter = CQL.toFilter(line);        // System.out.println("\t" + filter);        encoder.encode(filter, org.geotools.filter.v1_0.OGC.Filter, System.out);      } catch (CQLException e) {        e.printStackTrace();      }    }  }}

 转换的结果:

CQL样式

prop = 23

转换结果:

<?xml version="1.0" encoding="UTF-8"?><ogc:Filter xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
  <ogc:PropertyIsEqualTo>
    <ogc:PropertyName>prop</ogc:PropertyName>
    <ogc:Literal>23</ogc:Literal>
  </ogc:PropertyIsEqualTo></ogc:Filter>

空间查询转换的效果:

CQL语句:

INTERSECTS(SP_GEOMETRY, POLYGON ((142578.64599609 252217.79003906, 73781.897460938 141983.61767578, 287078.38037109 146764.85888672, 142578.64599609 252217.79003906)))

转换结果:

<?xml version="1.0" encoding="UTF-8"?><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml">
  <ogc:Intersects>
    <ogc:PropertyName>SP_GEOMETRY</ogc:PropertyName>
    <gml:Polygon>
      <gml:outerBoundaryIs>
        <gml:LinearRing>
          <gml:coordinates>142578.64599609,252217.79003906 73781.897460938,141983.61767578 287078.38037109,146764.85888672 142578.64599609,252217.79003906</gml:coordinates>
        </gml:LinearRing>
      </gml:outerBoundaryIs>
    </gml:Polygon>
  </ogc:Intersects></ogc:Filter>

关于Geoserver中如何将CQL转换OGC的xml过滤问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。

网站题目:Geoserver中如何将CQL转换OGC的xml过滤
URL分享:https://www.cdcxhl.com/article14/pphege.html

成都网站建设公司_创新互联,为您提供定制开发关键词优化做网站小程序开发网站策划

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都定制网站建设