本文讲述了如何使用CQL and ECQL查询语言,文章摘自GeoServer官网。在GeoServer的WMS和WFS动态渲染图层,并通过不同的例子具体说明。其中CQL and ECQL查询语言放置在定义WMS和WFS图层的params中,示例代码如下:
var WMSsource = new ol.source.ImageWMS({
ratio: 1,
url: 'http://wangxch:8081/geoserver/QHH/wms',
params: {
'FORMAT': format,
'VERSION': '1.1.1',
"LAYERS": 'QHH:p242landownershipP',
"exceptions": 'application/vnd.ogc.se_inimage',
'CQL_FILTER': "province=xining" //过滤条件
}
});
CQL (Common Query Language) is a query language created by the OGC for the Catalogue Web Services specification. Unlike the XML-based Filter Encoding language, CQL is written using a familiar text-based syntax. It is thus more readable and better-suited for manual authoring.
However, CQL has some limitations. For example it cannot encode id filters, and it requires an attribute to be on the left side of any comparison operator. For this reason, GeoServer provides an extended version of CQL called ECQL. ECQL removes the limitations of CQL, providing a more flexible language with stronger similarities with SQL.
GeoServer supports the use of both CQL and ECQL in WMS and WFS requests, as well as in GeoServer’s SLD dynamic symbolizers. Whenever the documentation refers to CQL, ECQL syntax can be used as well (and if not, please report that as a bug!).
This tutorial introduces the CQL/ECQL language by example. For a full reference, refer to the ECQL Reference.
Getting started
The following examples use the topp:states sample layer shipped with GeoServer. They demonstrate how CQL filters work by using the WMS CQL_FILTER vendor parameter to alter the data displayed by WM