MCPcopy Create free account
hub / github.com/MapServer/MapServer / msGEOSShape2Geometry_polygon

Function msGEOSShape2Geometry_polygon

mapgeos.c:212–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212static GEOSGeom msGEOSShape2Geometry_polygon(shapeObj *shape)
213{
214 int i, j;
215 GEOSGeom *polygons;
216 int *outerList, numOuterRings=0, lastOuterRing=0;
217 GEOSGeom g;
218
219 outerList = msGetOuterList(shape);
220 for(i=0; i<shape->numlines; i++) {
221 if(outerList[i] == MS_TRUE) {
222 numOuterRings++;
223 lastOuterRing = i; /* save for the simple case */
224 }
225 }
226
227 if(numOuterRings == 1) {
228 g = msGEOSShape2Geometry_simplepolygon(shape, lastOuterRing, outerList);
229 } else { /* a true multipolygon */
230 polygons = malloc(numOuterRings*sizeof(GEOSGeom));
231 if(!polygons) return NULL;
232
233 j = 0; /* part counter */
234 for(i=0; i<shape->numlines; i++) {
235 if(outerList[i] == MS_FALSE) continue;
236 polygons[j] = msGEOSShape2Geometry_simplepolygon(shape, i, outerList); /* TODO: account for NULL return values */
237 j++;
238 }
239
240 g = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, polygons, numOuterRings);
241 }
242
243 free(outerList);
244 return g;
245}
246
247GEOSGeom msGEOSShape2Geometry(shapeObj *shape)
248{

Callers 1

msGEOSShape2GeometryFunction · 0.85

Calls 2

msGetOuterListFunction · 0.85

Tested by

no test coverage detected