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 622 of file shp2pgsql-core.c.
623{
625 int polygon_total, ring_total;
626 int pi, vi;
627
630
632
633 int dims = 0;
634
635 char *mem;
636 size_t mem_length;
637
640
642
644 {
645 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"We have a Multipolygon with %d parts, can't use -S switch!"), polygon_total);
646
648 }
649
650
652
653
654 for (pi = 0; pi < polygon_total; pi++)
655 {
657
659 int ring_index = 0;
660
661
662 ring_total = 0;
663 polyring = Outer[pi];
664 while (polyring)
665 {
666 ring_total = ring_total + 1;
667 polyring = polyring->
next;
668 }
669
670
671 polyring = Outer[pi];
672
673 while (polyring)
674 {
675
677
678 for (vi = 0; vi < polyring->
n; vi++)
679 {
680
681 point4d.
x = polyring->
list[vi].
x;
682 point4d.
y = polyring->
list[vi].
y;
683
685 point4d.
z = polyring->
list[vi].
z;
687 point4d.
m = polyring->
list[vi].
m;
688
690 }
691
692
694
695 polyring = polyring->
next;
696 ring_index = ring_index + 1;
697 }
698
699
701 }
702
703
705 {
707 }
708 else
709 {
710 lwgeom = lwpolygons[0];
712 }
713
716 else
718
719 if ( !mem )
720 {
721
723
726 }
727
728
730
731
733
734
735 *geometry = mem;
736
738}
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
char * lwgeom_to_hexwkb_buffer(const LWGEOM *geom, uint8_t variant)
void lwgeom_free(LWGEOM *geom)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
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,...
#define LW_TRUE
Return types for functions with status returns.
#define FLAGS_SET_M(flags, value)
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
#define FLAGS_SET_Z(flags, value)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
int FindPolygons(SHPObject *obj, Ring ***Out)
void ReleasePolygons(Ring **polys, int npolys)
char message[SHPLOADERMSGLEN]
struct struct_ring * next
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_buffer(), lwgeom_to_wkt(), lwpoly_add_ring(), lwpoly_as_lwgeom(), lwpoly_construct_empty(), POINT4D::m, struct_point::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, POINT4D::x, struct_point::x, POINT4D::y, struct_point::y, POINT4D::z, and struct_point::z.
Referenced by ShpLoaderGenerateSQLRowStatement().