Skip to content

Commit

Permalink
Merge pull request #6086 from jbo-ads/multilinestring-offset
Browse files Browse the repository at this point in the history
Fix issue #5529 about GEOS error with offset on MULTILINESTRING
  • Loading branch information
jmckenna committed Jun 4, 2020
2 parents a7d4ec3 + bd75e25 commit 7115363
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mapgeos.c
Expand Up @@ -804,7 +804,22 @@ shapeObj *msGEOSOffsetCurve(shapeObj *p, double offset) {
g1 = (GEOSGeom) p->geometry;
if(!g1) return NULL;

g2 = GEOSOffsetCurve_r(handle,g1, offset, 4, GEOSBUF_JOIN_MITRE, fabs(offset*1.5));
if (GEOSGeomTypeId_r(handle,g1) == GEOS_MULTILINESTRING)
{
GEOSGeom *lines = malloc(p->numlines*sizeof(GEOSGeom));
if (!lines) return NULL;
for(int i=0; i<p->numlines; i++)
{
lines[i] = GEOSOffsetCurve_r(handle, GEOSGetGeometryN_r(handle,g1,i),
offset, 4, GEOSBUF_JOIN_MITRE, fabs(offset*1.5));
}
g2 = GEOSGeom_createCollection_r(handle,GEOS_MULTILINESTRING, lines, p->numlines);
free(lines);
}
else
{
g2 = GEOSOffsetCurve_r(handle,g1, offset, 4, GEOSBUF_JOIN_MITRE, fabs(offset*1.5));
}
return msGEOSGeometry2Shape(g2);
#else
msSetError(MS_GEOSERR, "GEOS Offset Curve support is not available.", "msGEOSingleSidedBuffer()");
Expand Down

0 comments on commit 7115363

Please sign in to comment.