refactor WKT generator to retain geometry type for empty geometries (avoid short-cutting to POINT EMPTY)

For example:

| in |   | out   |
|`POINT EMPTY` |  <--> | 'POINT EMPTY`|
|`LINESTRING EMPTY` |  --> | 'POINT EMPTY`|

| in |   | out   |
|`POINT EMPTY` |  <--> | 'POINT EMPTY`|
|`LINESTRING EMPTY` |  <--> | 'LINESTRING EMPTY`|
etc.
This commit is contained in:
artemp 2017-03-21 12:43:42 +00:00
parent d9063db0a0
commit b4b5e33b05

View file

@ -49,36 +49,51 @@ wkt_generator_grammar<OutputIterator, Geometry>::wkt_generator_grammar()
lit("POINT EMPTY") // special case for geometry_empty
;
point = lit("POINT(") << coordinate << lit(' ') << coordinate << lit(")")
point = lit("POINT(") << point_coord << lit(")")
;
linestring = lit("LINESTRING(") << linestring_coord << lit(")")
linestring = lit("LINESTRING") << (linestring_coord | lit(" EMPTY"))
;
polygon = lit("POLYGON(") << polygon_coord << lit(")")
polygon = lit("POLYGON") << (polygon_coord | lit(" EMPTY"))
;
multi_point = lit("MULTIPOINT(") << multi_point_coord << lit(")")
multi_point = lit("MULTIPOINT") << (multi_point_coord | lit(" EMPTY"))
;
multi_linestring = lit("MULTILINESTRING(") << multi_linestring_coord << lit(")")
multi_linestring = lit("MULTILINESTRING") << (multi_linestring_coord | lit(" EMPTY"))
;
multi_polygon = lit("MULTIPOLYGON(") << multi_polygon_coord << lit(")")
multi_polygon = lit("MULTIPOLYGON") << (multi_polygon_coord | lit(" EMPTY"))
;
geometry_collection = lit("GEOMETRYCOLLECTION(") << geometries << lit(")")
geometry_collection = lit("GEOMETRYCOLLECTION") << (lit("(") << geometries << lit(")") | lit(" EMPTY"))
;
point_coord = coordinate << lit(' ') << coordinate
;
linestring_coord = point_coord % lit(',')
linestring_coord = lit("(") << point_coord % lit(',') << lit(")")
;
polygon_coord = lit('(') << exterior_ring_coord << lit(')') << interior_ring_coord
polygon_coord = lit("(") << exterior_ring_coord << interior_ring_coord << lit(")")
;
exterior_ring_coord = linestring_coord.alias()
;
interior_ring_coord = *(lit(",(") << exterior_ring_coord << lit(')'))
interior_ring_coord = *(lit(",") << exterior_ring_coord)
;
multi_point_coord = linestring_coord.alias()
;
multi_linestring_coord = (lit('(') << linestring_coord << lit(')')) % lit(',')
multi_linestring_coord = lit("(") << linestring_coord % lit(',') << lit(")")
;
multi_polygon_coord = (lit('(') << polygon_coord << lit(')')) % lit(',')
multi_polygon_coord = lit("(") << polygon_coord % lit(',') << lit(")")
;
geometries = geometry % lit(',')
;