ECQL (Extended Common Query Language) is an extension of the OGC standard query language CQL. Compared to CQL, ECQL is more powerful, flexible, and has a syntax closer to SQL. It is primarily used for filtering and querying geospatial data. You can intuitively combine SQL-style attribute filters (e.g., POPULATION > 100000) with a rich set of spatial relationship predicates (e.g., INTERSECTS, WITHIN) to precisely filter target data. Below are some commonly used ECQL syntax examples.
Note: In the SuperMap GIS environment, the level of ECQL query support is closely related to the data engine type. ECQL filter queries are only supported when using a JDBC-PostGIS connection. Starting from SuperMap 2025 R2, support for ECQL queries has also been added when using a JDBC-OracleSpatial connection. However, note that when using a JDBC-OracleSpatial connection, temporal predicates in ECQL (such as BEFORE, AFTER, DURING) and the RELATE() and BEYOND() spatial functions are not supported.
Attribute Query
| Category | Function/Operator | Syntax Example |
|---|---|---|
| Logical Operators | AND, OR, NOT | pop_2014 < 10000 AND popUrban_2014 > 5000; NOT DLMC = 'Paddy Field'; "Parcel Type" = 'Forest Land'; |
| Comparison Operators | =, <>, >, >=, <, <= | PERSONS > 15000000; STATE_NAME = 'California'; |
| Range Query | BETWEEN ... AND ... | PERSONS BETWEEN 1000000 AND 3000000; |
| Fuzzy Matching | LIKE / ILIKE | STATE_NAME LIKE 'N%'; cityName ILIKE 'new%'; |
| Set Membership | IN (...) | STATE_NAME IN ('New York', 'California'); |
| Null Check | IS NULL / IS NOT NULL | Name IS NULL; centroid(the_geom) IS NULL; |
Spatial Query
| Function | Syntax Example | Description |
|---|---|---|
| INTERSECTS | INTERSECTS(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)); INTERSECTS(geom, SRID=4326, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)); |
Determines whether two spatial objects intersect. |
| DISJOINT | DISJOINT(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)); DISJOINT(geom, SRID=4326, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)); |
Determines whether two spatial objects are disjoint. |
| CONTAINS | CONTAINS(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)) | Determines whether the POLYGON spatial object completely contains the geom spatial object. |
| WITHIN | WITHIN(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)) | Determines whether the geom object is completely within the POLYGON spatial object. |
| TOUCHES | TOUCHES(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)) | Determines whether the boundaries of two spatial objects touch. |
| CROSSES | CROSSES(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)) | Determines whether two spatial objects cross (e.g., a line crossing a polygon). |
| OVERLAPS | OVERLAPS(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)) | Determines whether two spatial objects overlap. |
| EQUALS | EQUALS(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9)) | Determines whether two spatial objects are topologically equal. |
| DWITHIN | DWITHIN(geom, POINT(116.4 39.9), 10, kilometers) // Finds spatial objects within 10 kilometers of the point. | Finds geometries within a specified distance. |
| BEYOND | BEYOND(geom, POINT(116.4 39.9), 10, kilometers) // Finds spatial objects beyond 10 kilometers from the point. | Finds geometries beyond a specified distance. |
| BBOX | BBOX(geom, minX, minY, maxX, maxY); BBOX(geom, 103.4,39.9,104.5,40.6,'EPSG:4326'); |
Queries geometries that intersect the given bounding box. |
| RELATE | RELATE(geom, POLYGON(116.4 39.9,116.4 40.3,117.4 40.3,117.4 39.9,116.4 39.9), 'T****FF') | Determines the topological relationship between two geometric objects based on the DE-9IM (Dimensionally Extended 9-Intersection Model). |
Note: In the above examples, "geom" refers to the geometry field of the spatial data.
Temporal Query
| Function | Syntax Example | Description |
|---|---|---|
| BEFORE | lastEarthQuake BEFORE 2006-11-30T01:30:00Z | Determines whether a time point is before a specified moment. |
| AFTER | lastEarthQuake AFTER 2006-11-30T01:30:00Z | Determines whether a time point is after a specified moment. |
| TEQUALS | ATTR1 TEQUALS 2006-11-30T01:30:00Z | Determines whether a time point equals a specified moment. |
| DURING | lastEarthQuake DURING 1700-01-01T00:00:00/2011-01-01T00:00:00 | Determines whether a time point or time period is contained within another time period. |