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

Function msGEOSGetCentroid

mapgeos.c:767–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

765}
766
767pointObj *msGEOSGetCentroid(shapeObj *shape)
768{
769#ifdef USE_GEOS
770 GEOSGeom g1, g2;
771 GEOSCoordSeq coords;
772 pointObj *point;
773
774 if(!shape) return NULL;
775
776 if(!shape->geometry) /* if no geometry for the shape then build one */
777 shape->geometry = (GEOSGeom) msGEOSShape2Geometry(shape);
778 g1 = (GEOSGeom) shape->geometry;
779 if(!g1) return NULL;
780
781 g2 = GEOSGetCentroid(g1);
782
783 point = (pointObj *) malloc(sizeof(pointObj));
784
785 coords = (GEOSCoordSeq) GEOSGeom_getCoordSeq(g2);
786
787 GEOSCoordSeq_getX(coords, 0, &(point->x));
788 GEOSCoordSeq_getY(coords, 0, &(point->y));
789 /* GEOSCoordSeq_getZ(coords, 0, &(point->z)); */
790
791 GEOSCoordSeq_destroy(coords);
792
793 return point;
794#else
795 msSetError(MS_GEOSERR, "GEOS support is not available.", "msGEOSGetCentroid()");
796 return NULL;
797#endif
798}
799
800shapeObj *msGEOSUnion(shapeObj *shape1, shapeObj *shape2)
801{

Callers 1

shapeObj_getcentroidFunction · 0.85

Calls 2

msGEOSShape2GeometryFunction · 0.85
msSetErrorFunction · 0.85

Tested by

no test coverage detected