Generate an allocated geometry string for shapefile object obj using the state parameters.
This function basically deals with the polygon case. It sorts the polys in order of outer, inner,inner, so that inners always come after outers they are within.
Definition at line 616 of file shp2pgsql-core.c.
References _, shp_loader_state::config, FindPolygons(), FLAGS_SET_M, FLAGS_SET_Z, shp_loader_state::from_srid, shp_loader_state::has_m, shp_loader_state::has_z, struct_ring::list, LW_TRUE, lwcollection_as_lwgeom(), lwcollection_construct(), lwfree(), lwgeom_free(), lwgeom_to_hexwkb(), lwgeom_to_wkt(), lwpoly_add_ring(), lwpoly_as_lwgeom(), lwpoly_construct_empty(), struct_point::m, POINT4D::m, malloc(), shp_loader_state::message, MULTIPOLYGONTYPE, struct_ring::n, struct_ring::next, ptarray_append_point(), ptarray_construct_empty(), ReleasePolygons(), SHPLOADERERR, SHPLOADERMSGLEN, SHPLOADEROK, shp_loader_config::simple_geometries, shp_loader_config::use_wkt, WKB_EXTENDED, WKT_EXTENDED, WKT_PRECISION, struct_point::x, POINT4D::x, struct_point::y, POINT4D::y, struct_point::z, and POINT4D::z.
Referenced by ShpLoaderGenerateSQLRowStatement().
619 int polygon_total, ring_total;
639 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"We have a Multipolygon with %d parts, can't use -S switch!"), polygon_total);
648 for (pi = 0; pi < polygon_total; pi++)
657 polyring = Outer[pi];
661 polyring = polyring->
next;
665 polyring = Outer[pi];
672 for (vi = 0; vi < polyring->
n; vi++)
675 point4d.
x = polyring->
list[vi].
x;
676 point4d.
y = polyring->
list[vi].
y;
679 point4d.
z = polyring->
list[vi].
z;
681 point4d.
m = polyring->
list[vi].
m;
689 polyring = polyring->
next;
704 lwgeom = lwpolygons[0];
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
#define FLAGS_SET_Z(flags, value)
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.
int FindPolygons(SHPObject *obj, Ring ***Out)
#define LW_TRUE
Return types for functions with status returns.
struct struct_ring * next
char message[SHPLOADERMSGLEN]
void ReleasePolygons(Ring **polys, int npolys)
LWPOLY * lwpoly_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 FLAGS_SET_M(flags, value)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)