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.
617{
619 int polygon_total, ring_total;
620 int pi, vi;
621
624
626
627 int dims = 0;
628
629 char *mem;
630 size_t mem_length;
631
634
636
638 {
639 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"We have a Multipolygon with %d parts, can't use -S switch!"), polygon_total);
640
642 }
643
644
646
647
648 for (pi = 0; pi < polygon_total; pi++)
649 {
651
653 int ring_index = 0;
654
655
656 ring_total = 0;
657 polyring = Outer[pi];
658 while (polyring)
659 {
660 ring_total++;
661 polyring = polyring->
next;
662 }
663
664
665 polyring = Outer[pi];
666
667 while (polyring)
668 {
669
671
672 for (vi = 0; vi < polyring->
n; vi++)
673 {
674
675 point4d.
x = polyring->
list[vi].
x;
676 point4d.
y = polyring->
list[vi].
y;
677
679 point4d.
z = polyring->
list[vi].
z;
681 point4d.
m = polyring->
list[vi].
m;
682
684 }
685
686
688
689 polyring = polyring->
next;
690 ring_index++;
691 }
692
693
695 }
696
697
699 {
701 }
702 else
703 {
704 lwgeom = lwpolygons[0];
706 }
707
710 else
712
713 if ( !mem )
714 {
715
717
720 }
721
722
724
725
727
728
729 *geometry = mem;
730
732}
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
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(), 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().