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 618 of file shp2pgsql-core.c.
619{
621 int polygon_total, ring_total;
622 int pi, vi;
623
626
628
629 int dims = 0;
630
631 char *mem;
632 size_t mem_length;
633
636
638
640 {
641 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"We have a Multipolygon with %d parts, can't use -S switch!"), polygon_total);
642
644 }
645
646
648
649
650 for (pi = 0; pi < polygon_total; pi++)
651 {
653
655 int ring_index = 0;
656
657
658 ring_total = 0;
659 polyring = Outer[pi];
660 while (polyring)
661 {
662 ring_total = ring_total + 1;
663 polyring = polyring->
next;
664 }
665
666
667 polyring = Outer[pi];
668
669 while (polyring)
670 {
671
673
674 for (vi = 0; vi < polyring->
n; vi++)
675 {
676
677 point4d.
x = polyring->
list[vi].
x;
678 point4d.
y = polyring->
list[vi].
y;
679
681 point4d.
z = polyring->
list[vi].
z;
683 point4d.
m = polyring->
list[vi].
m;
684
686 }
687
688
690
691 polyring = polyring->
next;
692 ring_index = ring_index + 1;
693 }
694
695
697 }
698
699
701 {
703 }
704 else
705 {
706 lwgeom = lwpolygons[0];
708 }
709
712 else
714
715 if ( !mem )
716 {
717
719
722 }
723
724
726
727
729
730
731 *geometry = mem;
732
734}
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().