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

Function msGEOSGeometry2Shape_polygon

mapgeos.c:423–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

421}
422
423static shapeObj *msGEOSGeometry2Shape_polygon(GEOSGeom g)
424{
425 shapeObj *shape=NULL;
426 lineObj line;
427 int numPoints, numRings;
428 int i, j;
429
430 GEOSCoordSeq coords;
431 GEOSGeom ring;
432
433 if(!g) return NULL;
434
435 shape = (shapeObj *) malloc(sizeof(shapeObj));
436 msInitShape(shape);
437 shape->type = MS_SHAPE_POLYGON;
438 shape->geometry = (GEOSGeom) g;
439
440 /* exterior ring */
441 ring = (GEOSGeom) GEOSGetExteriorRing(g);
442 numPoints = GEOSGetNumCoordinates(ring);
443 coords = (GEOSCoordSeq) GEOSGeom_getCoordSeq(ring);
444
445 line.point = (pointObj *) malloc(sizeof(pointObj)*numPoints);
446 line.numpoints = numPoints;
447
448 for(i=0; i<numPoints; i++) {
449 GEOSCoordSeq_getX(coords, i, &(line.point[i].x));
450 GEOSCoordSeq_getY(coords, i, &(line.point[i].y));
451 /* GEOSCoordSeq_getZ(coords, i, &(line.point[i].z)); */
452 }
453 msAddLineDirectly(shape, &line);
454
455 /* interior rings */
456 numRings = GEOSGetNumInteriorRings(g);
457 for(j=0; j<numRings; j++) {
458 ring = (GEOSGeom) GEOSGetInteriorRingN(g, j);
459 if(GEOSisRing(ring) != 1) continue; /* skip it */
460
461 numPoints = GEOSGetNumCoordinates(ring);
462 coords = (GEOSCoordSeq) GEOSGeom_getCoordSeq(ring);
463
464 line.point = (pointObj *) malloc(sizeof(pointObj)*numPoints);
465 line.numpoints = numPoints;
466
467 for(i=0; i<numPoints; i++) {
468 GEOSCoordSeq_getX(coords, i, &(line.point[i].x));
469 GEOSCoordSeq_getY(coords, i, &(line.point[i].y));
470 /* GEOSCoordSeq_getZ(coords, i, &(line.point[i].z)); */
471 }
472 msAddLineDirectly(shape, &line);
473 }
474
475 msComputeBounds(shape);
476
477 return shape;
478}
479
480static shapeObj *msGEOSGeometry2Shape_multipolygon(GEOSGeom g)

Callers 1

msGEOSGeometry2ShapeFunction · 0.85

Calls 3

msInitShapeFunction · 0.85
msAddLineDirectlyFunction · 0.85
msComputeBoundsFunction · 0.85

Tested by

no test coverage detected