Skip to content

Commit 0d0446f

Browse files
authored
Merge pull request antlr#1654 from bigsheeper/master
add supports for geometry type in wkt
2 parents fd7d1c7 + 0e22d3e commit 0d0446f

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

wkt/examples/example1.txt

+8
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ POINT M (1 1 80)
33
POINT EMPTY
44
MULTIPOLYGON EMPTY
55
CIRCULARSTRING(1 5, 6 2, 7 3)
6+
LINESTRING EMPTY
7+
GEOMETRYCOLLECTION(POINT(1 1), LINESTRING( 1 1 , 2 2, 3 3))
8+
COMPOUNDCURVE((5 3, 5 13), CIRCULARSTRING(5 13, 7 15, 9 13), (9 13, 9 3), CIRCULARSTRING(9 3, 7 1, 5 3))
9+
POLYHEDRALSURFACE (((0 0,0 0,0 1,0 0)),((0 0,0 1,1 0,0 0)),((0 0,1 0,0 0,0 0)),((1 0,0 1,0 0,1 0)))
10+
MULTICURVE ((5 5,3 5,3 3,0 3),CIRCULARSTRING (0 0,0.2 1,0.5 1.4),COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 0),(1 0,0 1)))
11+
CURVEPOLYGON (CIRCULARSTRING (0 0,4 0,4 4,0 4,0 0),(1.8888 1.787,3 3,3 1,1.8888 1.787))
12+
MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0),(1 1, 3 3, 3 1, 1 1)))
13+
614

wkt/wkt.g4

+37-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11

22
grammar wkt;
33

4+
geometryCollection
5+
: GEOMETRYCOLLECTION ( LPAR geometry (COMMA geometry)* RPAR | EMPTY)
6+
;
7+
48
geometry
5-
: (polygonGeometry | lineStringGeometry | pointGeometry | multiPointGeometry | multiLineStringGeometry | multiPolygonGeometry | circularStringGeometry) + EOF
9+
: (polygonGeometry | lineStringGeometry | pointGeometry | compoundCurveGeometry | curvePolygonGeometry | multiSurfaceGeometry | multiCurveGeometry | multiPointGeometry | multiLineStringGeometry | multiPolygonGeometry | circularStringGeometry | multiPolyhedralSurfaceGeometry | multiTinGeometry | geometryCollection)
610
;
711

812
pointGeometry
@@ -17,18 +21,42 @@ polygonGeometry
1721
: POLYGON polygon
1822
;
1923

24+
multiCurveGeometry
25+
: MULTICURVE ((LPAR (lineString | circularStringGeometry | compoundCurveGeometry) (COMMA (circularStringGeometry | lineString | compoundCurveGeometry))* RPAR) | EMPTY)
26+
;
27+
28+
multiSurfaceGeometry
29+
: MULTISURFACE ((LPAR (polygon | curvePolygonGeometry) (COMMA (polygon | curvePolygonGeometry))* RPAR) | EMPTY)
30+
;
31+
32+
curvePolygonGeometry
33+
: CURVEPOLYGON ((LPAR (lineString | circularStringGeometry | compoundCurveGeometry) (COMMA (circularStringGeometry | lineString | compoundCurveGeometry))* RPAR) | EMPTY)
34+
;
35+
36+
compoundCurveGeometry
37+
: COMPOUNDCURVE ((LPAR (lineString | circularStringGeometry) (COMMA (circularStringGeometry | lineString))* RPAR) | EMPTY)
38+
;
39+
2040
multiPointGeometry
21-
: MULTIPOINT LPAR pointOrClosedPoint (COMMA pointOrClosedPoint)* RPAR
41+
: MULTIPOINT ((LPAR pointOrClosedPoint (COMMA pointOrClosedPoint)* RPAR) | EMPTY)
2242
;
2343

2444
multiLineStringGeometry
25-
: MULTILINESTRING LPAR lineString (COMMA lineString)* RPAR
45+
: MULTILINESTRING ((LPAR lineString (COMMA lineString)* RPAR) | EMPTY)
2646
;
2747

2848
multiPolygonGeometry
2949
: MULTIPOLYGON ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY)
3050
;
3151

52+
multiPolyhedralSurfaceGeometry
53+
: POLYHEDRALSURFACE ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY)
54+
;
55+
56+
multiTinGeometry
57+
: TIN ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY)
58+
;
59+
3260
circularStringGeometry
3361
: CIRCULARSTRING LPAR point (COMMA point)* RPAR
3462
;
@@ -39,11 +67,11 @@ pointOrClosedPoint
3967
;
4068

4169
polygon
42-
: LPAR lineString (COMMA lineString)* RPAR
70+
: LPAR lineString (COMMA lineString)* RPAR | EMPTY
4371
;
4472

4573
lineString
46-
: LPAR point (COMMA point)* RPAR
74+
: LPAR point (COMMA point)* RPAR | EMPTY
4775
;
4876

4977
point
@@ -152,6 +180,9 @@ COMPOUNDCURVE
152180
: C O M P O U N D C U R V E
153181
;
154182

183+
MULTISURFACE
184+
: M U L T I S U R F A C E
185+
;
155186

156187
CURVEPOLYGON
157188
: C U R V E P O L Y G O N
@@ -316,3 +347,4 @@ STRING
316347
WS
317348
: [ \t\r\n] + -> skip
318349
;
350+

0 commit comments

Comments
 (0)