long long msudf_isRing(UDF_INIT *initid,UDF_ARGS *args,char *is_null, char *error) { GEOSGeom geom; long long result; DEBUG("msudf_isRing"); geom = msudf_getGeometry((unsigned char *)args->args[0],args->lengths[0]); if (geom == NULL) { strcpy(error,"Invalid geometry."); *is_null = 1; return 0; } result = GEOSisRing(geom); if (geom != NULL) GEOSGeom_destroy(geom); if (result >1) { *is_null = 1; return 0; } else { return result; } }
static shapeObj *msGEOSGeometry2Shape_polygon(GEOSGeom g) { shapeObj *shape=NULL; lineObj line; int numPoints, numRings; int i, j; GEOSCoordSeq coords; GEOSGeom ring; if(!g) return NULL; shape = (shapeObj *) malloc(sizeof(shapeObj)); msInitShape(shape); shape->type = MS_SHAPE_POLYGON; shape->geometry = (GEOSGeom) g; /* exterior ring */ ring = (GEOSGeom) GEOSGetExteriorRing(g); numPoints = GEOSGetNumCoordinates(ring); coords = (GEOSCoordSeq) GEOSGeom_getCoordSeq(ring); line.point = (pointObj *) malloc(sizeof(pointObj)*numPoints); line.numpoints = numPoints; for(i=0; i<numPoints; i++) { GEOSCoordSeq_getX(coords, i, &(line.point[i].x)); GEOSCoordSeq_getY(coords, i, &(line.point[i].y)); /* GEOSCoordSeq_getZ(coords, i, &(line.point[i].z)); */ } msAddLineDirectly(shape, &line); /* interior rings */ numRings = GEOSGetNumInteriorRings(g); for(j=0; j<numRings; j++) { ring = (GEOSGeom) GEOSGetInteriorRingN(g, j); if(GEOSisRing(ring) != 1) continue; /* skip it */ numPoints = GEOSGetNumCoordinates(ring); coords = (GEOSCoordSeq) GEOSGeom_getCoordSeq(ring); line.point = (pointObj *) malloc(sizeof(pointObj)*numPoints); line.numpoints = numPoints; for(i=0; i<numPoints; i++) { GEOSCoordSeq_getX(coords, i, &(line.point[i].x)); GEOSCoordSeq_getY(coords, i, &(line.point[i].y)); /* GEOSCoordSeq_getZ(coords, i, &(line.point[i].z)); */ } msAddLineDirectly(shape, &line); } msComputeBounds(shape); return shape; }