forked from CrunchyData/pg_tileserv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dr-jts-add-filter-cql'
- Loading branch information
Showing
14 changed files
with
7,205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
# CQL2 Antlr grammar, with small modifications. | ||
# - Additions: ILIKE | ||
# Build: in this dir: antlr -Dlanguage=Go -package cql CQL.g4 CqlLexer.g4 | ||
# | ||
# See examples: | ||
# https://portal.ogc.org/files/96288#cql-bnf | ||
# https://github.com/interactive-instruments/xtraplatform-spatial/tree/master/xtraplatform-cql/src/main/antlr/de/ii/xtraplatform/cql/infra | ||
*/ | ||
parser grammar CQLParser; | ||
options { tokenVocab=CqlLexer; contextSuperClass=CqlContext; } | ||
|
||
/*============================================================================ | ||
# A CQL filter is a logically connected expression of one or more predicates. | ||
#============================================================================*/ | ||
|
||
cqlFilter : booleanValueExpression EOF; | ||
booleanValueExpression : booleanTerm | booleanValueExpression OR booleanTerm; | ||
booleanTerm : booleanFactor | booleanTerm AND booleanFactor; | ||
booleanFactor : ( NOT )? booleanPrimary; | ||
booleanPrimary : predicate | ||
| LEFTPAREN booleanValueExpression RIGHTPAREN; | ||
|
||
/*============================================================================ | ||
# CQL supports scalar, spatial, temporal and existence predicates. | ||
#============================================================================*/ | ||
|
||
predicate : binaryComparisonPredicate | ||
| likePredicate | ||
| betweenPredicate | ||
| isNullPredicate | ||
| inPredicate | ||
| spatialPredicate | ||
| distancePredicate | ||
// | temporalPredicate | ||
// | arrayPredicate | ||
// | existencePredicate | ||
; | ||
|
||
/*============================================================================ | ||
# A comparison predicate evaluates if two scalar expression statisfy the | ||
# specified comparison operator. The comparion operators include an operator | ||
# to evaluate regular expressions (LIKE), a range evaluation operator and | ||
# an operator to test if a scalar expression is NULL or not. | ||
#============================================================================*/ | ||
|
||
binaryComparisonPredicate : scalarExpression ComparisonOperator scalarExpression; | ||
|
||
likePredicate : propertyName (NOT)? ( LIKE | ILIKE ) characterLiteral; | ||
|
||
betweenPredicate : propertyName (NOT)? BETWEEN | ||
scalarExpression AND scalarExpression ; | ||
// (scalarValue | temporalExpression) AND (scalarValue | temporalExpression); | ||
|
||
isNullPredicate : propertyName IS (NOT)? NULL; | ||
|
||
/*============================================================================ | ||
# Scalar expressions | ||
# | ||
# Note: does not enforce type consistency. | ||
# That occurs when transpiled expression is evaluated. | ||
#============================================================================*/ | ||
|
||
scalarExpression : scalarValue | ||
| LEFTPAREN scalarExpression RIGHTPAREN | ||
| scalarExpression ArithmeticOperator scalarExpression | ||
; | ||
|
||
scalarValue : propertyName | ||
| characterLiteral | ||
| numericLiteral | ||
| booleanLiteral | ||
// | function | ||
; | ||
|
||
propertyName: Identifier; | ||
characterLiteral: CharacterStringLiteral; | ||
numericLiteral: NumericLiteral; | ||
booleanLiteral: BooleanLiteral; | ||
|
||
/*============================================================================ | ||
# A spatial predicate evaluates if two spatial expressions satisfy the | ||
# specified spatial operator. | ||
#============================================================================*/ | ||
|
||
spatialPredicate : SpatialOperator LEFTPAREN geomExpression COMMA geomExpression RIGHTPAREN; | ||
|
||
distancePredicate : DistanceOperator LEFTPAREN geomExpression COMMA geomExpression COMMA NumericLiteral RIGHTPAREN; | ||
|
||
/* | ||
# A geometric expression is a property name of a geometry-valued property, | ||
# a geometric literal (expressed as WKT) or a function that returns a | ||
# geometric value. | ||
*/ | ||
geomExpression : propertyName | ||
| geomLiteral | ||
/*| function*/; | ||
|
||
/*============================================================================ | ||
# Definition of GEOMETRIC literals | ||
#============================================================================*/ | ||
|
||
geomLiteral: point | ||
| linestring | ||
| polygon | ||
| multiPoint | ||
| multiLinestring | ||
| multiPolygon | ||
| geometryCollection | ||
| envelope; | ||
|
||
point : POINT pointList; | ||
pointList : LEFTPAREN coordinate RIGHTPAREN; | ||
linestring : LINESTRING coordList; | ||
polygon : POLYGON polygonDef; | ||
polygonDef : LEFTPAREN coordList (COMMA coordList)* RIGHTPAREN; | ||
multiPoint : MULTIPOINT LEFTPAREN pointList (COMMA pointList)* RIGHTPAREN; | ||
multiLinestring : MULTILINESTRING LEFTPAREN coordList (COMMA coordList)* RIGHTPAREN; | ||
multiPolygon : MULTIPOLYGON LEFTPAREN polygonDef (COMMA polygonDef)* RIGHTPAREN; | ||
geometryCollection : GEOMETRYCOLLECTION LEFTPAREN geomLiteral (COMMA geomLiteral)* RIGHTPAREN; | ||
|
||
envelope: ENVELOPE LEFTPAREN NumericLiteral COMMA NumericLiteral COMMA NumericLiteral COMMA NumericLiteral RIGHTPAREN; | ||
|
||
coordList: LEFTPAREN coordinate (COMMA coordinate)* RIGHTPAREN; | ||
coordinate : NumericLiteral NumericLiteral; | ||
|
||
/*============================================================================ | ||
# A temporal predicate evaluates if two temporal expressions satisfy the | ||
# specified temporal operator. | ||
#============================================================================*/ | ||
/* | ||
temporalPredicate : temporalExpression (TemporalOperator | ComparisonOperator) temporalExpression; | ||
temporalExpression : propertyName | ||
| temporalLiteral | ||
//| function | ||
; | ||
temporalLiteral: TemporalLiteral; | ||
*/ | ||
|
||
/*============================================================================ | ||
# The IN predicate | ||
#============================================================================*/ | ||
|
||
inPredicate : propertyName NOT? IN LEFTPAREN ( | ||
characterLiteral (COMMA characterLiteral)* | ||
| numericLiteral (COMMA numericLiteral)* | ||
) RIGHTPAREN; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
ComparisonOperator=1 | ||
LT=2 | ||
EQ=3 | ||
GT=4 | ||
NEQ=5 | ||
GTEQ=6 | ||
LTEQ=7 | ||
BooleanLiteral=8 | ||
AND=9 | ||
OR=10 | ||
NOT=11 | ||
LIKE=12 | ||
ILIKE=13 | ||
BETWEEN=14 | ||
IS=15 | ||
NULL=16 | ||
IN=17 | ||
ArithmeticOperator=18 | ||
SpatialOperator=19 | ||
DistanceOperator=20 | ||
POINT=21 | ||
LINESTRING=22 | ||
POLYGON=23 | ||
MULTIPOINT=24 | ||
MULTILINESTRING=25 | ||
MULTIPOLYGON=26 | ||
GEOMETRYCOLLECTION=27 | ||
ENVELOPE=28 | ||
NumericLiteral=29 | ||
Identifier=30 | ||
IdentifierStart=31 | ||
IdentifierPart=32 | ||
ALPHA=33 | ||
DIGIT=34 | ||
OCTOTHORP=35 | ||
DOLLAR=36 | ||
UNDERSCORE=37 | ||
DOUBLEQUOTE=38 | ||
PERCENT=39 | ||
AMPERSAND=40 | ||
QUOTE=41 | ||
LEFTPAREN=42 | ||
RIGHTPAREN=43 | ||
LEFTSQUAREBRACKET=44 | ||
RIGHTSQUAREBRACKET=45 | ||
ASTERISK=46 | ||
PLUS=47 | ||
COMMA=48 | ||
MINUS=49 | ||
PERIOD=50 | ||
SOLIDUS=51 | ||
COLON=52 | ||
SEMICOLON=53 | ||
QUESTIONMARK=54 | ||
VERTICALBAR=55 | ||
BIT=56 | ||
HEXIT=57 | ||
UnsignedNumericLiteral=58 | ||
SignedNumericLiteral=59 | ||
ExactNumericLiteral=60 | ||
ApproximateNumericLiteral=61 | ||
Mantissa=62 | ||
Exponent=63 | ||
SignedInteger=64 | ||
UnsignedInteger=65 | ||
Sign=66 | ||
WS=67 | ||
CharacterStringLiteral=68 | ||
QuotedQuote=69 | ||
'<'=2 | ||
'='=3 | ||
'>'=4 | ||
'#'=35 | ||
'$'=36 | ||
'_'=37 | ||
'"'=38 | ||
'%'=39 | ||
'&'=40 | ||
'('=42 | ||
')'=43 | ||
'['=44 | ||
']'=45 | ||
'*'=46 | ||
'+'=47 | ||
','=48 | ||
'-'=49 | ||
'.'=50 | ||
'/'=51 | ||
':'=52 | ||
';'=53 | ||
'?'=54 | ||
'|'=55 | ||
'\'\''=69 |
Oops, something went wrong.