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");
610 int vertices_needed = 3;
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;
LWGEOM * wkt_parser_polygon_finalize(LWGEOM *poly, char *dimensionality)
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
LWGEOM * wkt_parser_triangle_new(POINTARRAY *pa, char *dimensionality)
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...
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
LWGEOM * wkt_parser_point_new(POINTARRAY *pa, char *dimensionality)
Create a new point.
LWGEOM * wkt_parser_collection_add_geom(LWGEOM *col, LWGEOM *geom)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define PARSER_ERROR_INCONTINUOUS
LWGEOM * wkt_parser_polygon_add_ring(LWGEOM *poly, POINTARRAY *pa, char dimcheck)
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
uint8_t * serialized_lwgeom
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
LWGEOM * wkt_parser_curvepolygon_new(LWGEOM *ring)
int wkt_lexer_read_srid(char *str)
Read the SRID number from an SRID=<> string.
LWGEOM * wkt_parser_circularstring_new(POINTARRAY *pa, char *dimensionality)
Create a new circularstring.
LWGEOM * lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void lwgeom_free(LWGEOM *geom)
void ptarray_free(POINTARRAY *pa)
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
int ptarray_is_closed_z(const POINTARRAY *pa)
LWGEOM * wkt_parser_collection_new(LWGEOM *geom)
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
#define LWDEBUG(level, msg)
int lwcompound_is_closed(const LWCOMPOUND *curve)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
LWGEOM_PARSER_RESULT global_parser_result
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
#define PARSER_ERROR_MIXDIMS
int ptarray_is_closed_2d(const POINTARRAY *pa)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
LWGEOM * wkt_parser_linestring_new(POINTARRAY *pa, char *dimensionality)
Create a new linestring.
#define FLAGS_SET_Z(flags, value)
#define LW_PARSER_CHECK_ODD
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
LWCIRCSTRING * lwcircstring_construct_empty(int srid, char hasz, char hasm)
LWGEOM * wkt_parser_curvepolygon_finalize(LWGEOM *poly, char *dimensionality)
LWGEOM * wkt_parser_collection_finalize(int lwtype, LWGEOM *geom, char *dimensionality)
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, then a duplicate point will not be added.
POINTARRAY * wkt_parser_ptarray_new(POINT p)
Start a point array from the first coordinate.
POINTARRAY * wkt_parser_ptarray_add_coord(POINTARRAY *pa, POINT p)
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
#define LW_TRUE
Return types for functions with status returns.
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
static uint8_t wkt_dimensionality(char *dimensionality)
#define SRID_UNKNOWN
Unknown SRID value.
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
#define PARSER_ERROR_MOREPOINTS
LWCURVEPOLY * lwcurvepoly_construct_empty(int srid, char hasz, char hasm)
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
#define PARSER_ERROR_LESSPOINTS
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
#define PARSER_ERROR_ODDPOINTS
POINT wkt_parser_coord_2(double c1, double c2)
Build a 2d coordinate.
#define PARSER_ERROR_UNCLOSED
LWGEOM * wkt_parser_compound_add_geom(LWGEOM *col, LWGEOM *geom)
LWGEOM * wkt_parser_polygon_new(POINTARRAY *pa, char dimcheck)
const char * parser_error_messages[]
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
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...
#define PARSER_ERROR_TRIANGLEPOINTS
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
int lwline_is_closed(const LWLINE *line)
#define SET_PARSER_ERROR(errno)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
#define FLAGS_GET_M(flags)
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
Add a ring, allocating extra space if necessary.
void wkt_parser_geometry_new(LWGEOM *geom, int srid)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
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...
LWGEOM * lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj)
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
LWGEOM * wkt_parser_curvepolygon_add_ring(LWGEOM *poly, LWGEOM *ring)
#define SRID_MAXIMUM
Maximum allowed SRID value in serialized geometry.
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
#define LWDEBUGF(level, msg,...)
#define FLAGS_NDIMS(flags)
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
static int wkt_pointarray_dimensionality(POINTARRAY *pa, uint8_t flags)
Read the dimensionality from a flag, if provided.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
#define LW_PARSER_CHECK_CLOSURE
#define PARSER_ERROR_OTHER
int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom)
Add a component, allocating extra space if necessary.
POINT wkt_parser_coord_4(double c1, double c2, double c3, double c4)
#define FLAGS_SET_M(flags, value)
LWGEOM * wkt_parser_compound_new(LWGEOM *geom)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)