dms_buffer_multi_polygon
Geometric functions > dms_buffer_multi_polygon
dms_buffer_multi_polygon grows or shrinks every polygon by a distance, with rounded corners, on the sweep that GeoDMS implements itself: the dms_ counterpart of geos_buffer_multi_polygon, with the same arguments.
syntax
- dms_buffer_multi_polygon(polygon_data_item, buffer_distance, quadrantSegments)
description
dms_buffer_multi_polygon(polygon_data_item, buffer_distance, quadrantSegments) results in a polygon data item with, per element, the area within buffer_distance of the element, after the simplification described below: every edge shifted outward by buffer_distance, and every convex corner rounded. A negative buffer_distance shrinks the element instead; distance 0 gives the element cleaned.
quadrantSegments is the number of segments per quarter circle, as geos_buffer_multi_polygon takes its third argument: a corner of 90 degrees gets that many segments, a sharper or blunter corner proportionally more or fewer (the corner’s turn divided by a quarter turn, times quadrantSegments, rounded), each of equal angle. 0 cuts a corner off straight. This is where GEOS puts the points too, so a configuration can switch between the geos_ and the dms_ buffer with the same arguments and get results that agree to far below a millimetre:
parameter<string> buffer_expr := GeoEngine == 'dms'
? 'dms_buffer_multi_polygon(pand/geometry, 0.2, 8b)'
: 'geos_buffer_multi_polygon(pand/geometry, 0.2, 8b)';
Like the other dms polygon operators, it reads its argument under the even-odd rule, so it accepts polygons that are not valid: rings that cross or touch themselves, overlap each other, are wound either way or are not closed. The geometry is cleaned first, then buffered in one sweep per element; a convex element needs no sweep at all. Results are on the same lattice as the rest of the family: for float coordinates a power of two derived from the extent of the element and the distance, far below any real precision.
Before the buffer, every ring of the cleaned element is simplified as GEOS simplifies the input of its buffer, with a tolerance of a hundredth of buffer_distance. When the element grows, a dent that lies within that tolerance of the line between its neighbours is filled; when it shrinks, such a bump is cut off. The result can therefore be slightly larger than the exact buffer, or slightly smaller when the element shrinks, by up to about the tolerance, as with GEOS. A detailed outline keeps far fewer edges this way when the distance is large compared to its edges, and that is what keeps such a buffer fast; with a small distance, few or no vertices are removed.
A hole that the buffer fills is gone from the result, as with GEOS. An element that shrinks to nothing results in an empty polygon; an undefined distance gives an empty polygon too.
applies to
- Attribute polygon_data_item with a point Value type and composition polygon; all six point types: Spoint, Ipoint, Wpoint, Upoint, Fpoint and Dpoint.
- buffer_distance with value type Float64, a Parameter or an attribute on the domain of polygon_data_item.
- quadrantSegments with value type Uint8, a parameter or an attribute on the domain of polygon_data_item.
conditions
- The composition type of polygon_data_item must be polygon.
- For integer coordinates the corner points are rounded to whole coordinates, so a distance of a few units gives coarse corners; use float coordinates for small distances.
since version
20.24.0
examples
// grow every building by 20 cm, 8 segments per quarter circle
attribute<rdc> pand_buffer (pand, polygon) := dms_buffer_multi_polygon(pand/geometry, 0.2, 8b);
// shrink every parcel by 1 metre
attribute<rdc> parcel_core (parcel, polygon) := dms_buffer_multi_polygon(parcel/geometry, -1.0, 8b);
see also
- geos_buffer_multi_polygon - the same buffer through GEOS, which needs valid input
- minkowski_sum - grow by a kernel of your own shape; dms_minkowski_sum with a regular polygon is a buffer whose corners have fixed directions
- dms polygon operators