#2587, CompoundCurve with empties parses differently from WKB and WKT

git-svn-id: http://svn.osgeo.org/postgis/trunk@13452 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Paul Ramsey 2015-04-27 17:07:55 +00:00
parent 3accb5ffbd
commit d4f3799570
5 changed files with 226 additions and 186 deletions

View file

@ -707,6 +707,41 @@ LWGEOM* wkt_parser_collection_new(LWGEOM *geom)
}
LWGEOM* wkt_parser_compound_new(LWGEOM *geom)
{
LWCOLLECTION *col;
LWGEOM **geoms;
static int ngeoms = 1;
LWDEBUG(4,"entered");
/* Toss error on null geometry input */
if( ! geom )
{
SET_PARSER_ERROR(PARSER_ERROR_OTHER);
return NULL;
}
/* Elements of a compoundcurve cannot be empty, because */
/* empty things can't join up and form a ring */
if ( lwgeom_is_empty(geom) )
{
lwgeom_free(geom);
SET_PARSER_ERROR(PARSER_ERROR_INCONTINUOUS);
return NULL;
}
/* Create our geometry array */
geoms = lwalloc(sizeof(LWGEOM*) * ngeoms);
geoms[0] = geom;
/* Make a new collection */
col = lwcollection_construct(COLLECTIONTYPE, SRID_UNKNOWN, NULL, ngeoms, geoms);
/* Return the result. */
return lwcollection_as_lwgeom(col);
}
LWGEOM* wkt_parser_compound_add_geom(LWGEOM *col, LWGEOM *geom)
{
LWDEBUG(4,"entered");

View file

@ -46,6 +46,7 @@ LWGEOM* wkt_parser_polygon_finalize(LWGEOM *poly, char *dimensionality);
LWGEOM* wkt_parser_curvepolygon_new(LWGEOM *ring);
LWGEOM* wkt_parser_curvepolygon_add_ring(LWGEOM *poly, LWGEOM *ring);
LWGEOM* wkt_parser_curvepolygon_finalize(LWGEOM *poly, char *dimensionality);
LWGEOM* wkt_parser_compound_new(LWGEOM *element);
LWGEOM* wkt_parser_compound_add_geom(LWGEOM *col, LWGEOM *geom);
LWGEOM* wkt_parser_collection_new(LWGEOM *geom);
LWGEOM* wkt_parser_collection_add_geom(LWGEOM *col, LWGEOM *geom);

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.0.2. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -97,7 +97,7 @@ extern int wkt_yydebug;
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 106 "lwin_wkt_parse.y" /* yacc.c:1909 */
@ -111,6 +111,8 @@ union YYSTYPE
#line 113 "lwin_wkt_parse.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif

View file

@ -388,11 +388,11 @@ compound_list :
compound_list COMMA_TOK linestring_untagged
{ $$ = wkt_parser_compound_add_geom($1,$3); WKT_ERROR(); } |
circularstring
{ $$ = wkt_parser_collection_new($1); WKT_ERROR(); } |
{ $$ = wkt_parser_compound_new($1); WKT_ERROR(); } |
linestring
{ $$ = wkt_parser_collection_new($1); WKT_ERROR(); } |
{ $$ = wkt_parser_compound_new($1); WKT_ERROR(); } |
linestring_untagged
{ $$ = wkt_parser_collection_new($1); WKT_ERROR(); } ;
{ $$ = wkt_parser_compound_new($1); WKT_ERROR(); } ;
multicurve :
MCURVE_TOK LBRACKET_TOK curve_list RBRACKET_TOK