40 "geometry requires more points",
41 "geometry must have an odd number of points",
42 "geometry contains non-closed rings",
43 "can not mix dimensionality in a geometry",
44 "parse error - invalid geometry",
46 "incontinuous compound curve",
47 "triangle must have exactly 4 points",
48 "geometry has too many points",
49 "parse error - invalid geometry"
52 #define SET_PARSER_ERROR(errno) { \
53 global_parser_result.message = parser_error_messages[(errno)]; \
54 global_parser_result.errcode = (errno); \
55 global_parser_result.errlocation = wkt_yylloc.last_column; \
69 i = strtol(c, NULL, 10);
80 if( ! dimensionality )
84 for( i = 0; i < strlen(dimensionality); i++ )
86 if( (dimensionality[i] ==
'Z') || (dimensionality[i] ==
'z') )
88 else if( (dimensionality[i] ==
'M') || (dimensionality[i] ==
'm') )
91 else if( ! isspace(dimensionality[i]) )
break;
141 for ( i = 0; i < poly->
nrings; i++ )
154 for ( i = 0; i < poly->
nrings; i++ )
163 for ( i = 0; i < col->
ngeoms; i++ )
187 int ndims = 2 + hasz + hasm;
190 if( ! (flags && pa) )
193 LWDEBUGF(5,
"dimensionality ndims == %d", ndims);
590 if( ! (ring && poly) )
600 LWDEBUG(4,
"dimensionality does not match");
617 LWDEBUG(4,
"number of points is incorrect");
629 LWDEBUG(4,
"checking ring closure");
630 switch ( ring->
type )
646 LWDEBUG(4,
"ring is not closed");
656 LWDEBUG(4,
"failed to add ring");
702 static int ngeoms = 1;
728 static int ngeoms = 1;
764 if( ! (geom && col) )
796 if( ! (geom && col) )
822 for ( i = 0 ; i < col->
ngeoms; i++ )
867 lwerror(
"Parsed geometry is null!");
887 if ( parser_result->
geom )
890 parser_result->
geom = 0;
#define LW_PARSER_CHECK_ODD
#define PARSER_ERROR_MIXDIMS
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
LWCIRCSTRING * lwcircstring_construct_empty(int srid, char hasz, char hasm)
#define LW_PARSER_CHECK_CLOSURE
LWCURVEPOLY * lwcurvepoly_construct_empty(int srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
void lwgeom_free(LWGEOM *geom)
#define PARSER_ERROR_MOREPOINTS
#define PARSER_ERROR_INCONTINUOUS
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
#define PARSER_ERROR_OTHER
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
#define SRID_MAXIMUM
Maximum allowed SRID value in serialized geometry.
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
#define FLAGS_NDIMS(flags)
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
#define PARSER_ERROR_ODDPOINTS
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
Add a ring, allocating extra space if necessary.
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
int ptarray_is_closed_z(const POINTARRAY *pa)
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
#define FLAGS_GET_M(flags)
#define PARSER_ERROR_LESSPOINTS
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
void ptarray_free(POINTARRAY *pa)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
LWGEOM * lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj)
LWGEOM * lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
void * lwalloc(size_t size)
int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom)
Add a component, allocating extra space if necessary.
int ptarray_is_closed_2d(const POINTARRAY *pa)
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
#define PARSER_ERROR_TRIANGLEPOINTS
#define LW_TRUE
Return types for functions with status returns.
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
#define FLAGS_SET_M(flags, value)
#define SRID_UNKNOWN
Unknown SRID value.
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
#define FLAGS_SET_Z(flags, value)
#define PARSER_ERROR_UNCLOSED
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
int lwline_is_closed(const LWLINE *line)
int lwcompound_is_closed(const LWCOMPOUND *curve)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static uint8_t wkt_dimensionality(char *dimensionality)
LWGEOM * wkt_parser_circularstring_new(POINTARRAY *pa, char *dimensionality)
Create a new circularstring.
#define SET_PARSER_ERROR(errno)
LWGEOM * wkt_parser_collection_finalize(int lwtype, LWGEOM *geom, char *dimensionality)
LWGEOM * wkt_parser_triangle_new(POINTARRAY *pa, char *dimensionality)
LWGEOM * wkt_parser_polygon_finalize(LWGEOM *poly, char *dimensionality)
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
LWGEOM * wkt_parser_collection_add_geom(LWGEOM *col, LWGEOM *geom)
POINT wkt_parser_coord_2(double c1, double c2)
Build a 2d coordinate.
LWGEOM * wkt_parser_polygon_add_ring(LWGEOM *poly, POINTARRAY *pa, char dimcheck)
POINT wkt_parser_coord_4(double c1, double c2, double c3, double c4)
const char * parser_error_messages[]
LWGEOM * wkt_parser_compound_add_geom(LWGEOM *col, LWGEOM *geom)
LWGEOM * wkt_parser_curvepolygon_new(LWGEOM *ring)
static int wkt_parser_set_dims(LWGEOM *geom, uint8_t flags)
Force the dimensionality of a geometry to match the dimensionality of a set of flags (usually derived...
POINTARRAY * wkt_parser_ptarray_new(POINT p)
Start a point array from the first coordinate.
LWGEOM * wkt_parser_curvepolygon_add_ring(LWGEOM *poly, LWGEOM *ring)
LWGEOM * wkt_parser_compound_new(LWGEOM *geom)
int wkt_lexer_read_srid(char *str)
Read the SRID number from an SRID=<> string.
POINT wkt_parser_coord_3(double c1, double c2, double c3)
Note, if this is an XYM coordinate we'll have to fix it later when we build the object itself and hav...
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
LWGEOM * wkt_parser_point_new(POINTARRAY *pa, char *dimensionality)
Create a new point.
static int wkt_pointarray_dimensionality(POINTARRAY *pa, uint8_t flags)
Read the dimensionality from a flag, if provided.
void wkt_parser_geometry_new(LWGEOM *geom, int srid)
LWGEOM * wkt_parser_curvepolygon_finalize(LWGEOM *poly, char *dimensionality)
LWGEOM * wkt_parser_collection_new(LWGEOM *geom)
LWGEOM * wkt_parser_linestring_new(POINTARRAY *pa, char *dimensionality)
Create a new linestring.
POINTARRAY * wkt_parser_ptarray_add_coord(POINTARRAY *pa, POINT p)
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
LWGEOM * wkt_parser_polygon_new(POINTARRAY *pa, char dimcheck)
LWGEOM_PARSER_RESULT global_parser_result
uint8_t * serialized_lwgeom
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.