[GRASS-SVN] r65710 - grass/trunk/vector/v.buffer
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 20 08:46:34 PDT 2015
Author: martinl
Date: 2015-07-20 08:46:34 -0700 (Mon, 20 Jul 2015)
New Revision: 65710
Added:
grass/trunk/vector/v.buffer/v_buffer_area.png
grass/trunk/vector/v.buffer/v_buffer_area_s.png
grass/trunk/vector/v.buffer/v_buffer_line.png
grass/trunk/vector/v.buffer/v_buffer_line_c.png
grass/trunk/vector/v.buffer/v_buffer_line_s.png
Modified:
grass/trunk/vector/v.buffer/geos.c
grass/trunk/vector/v.buffer/local_proto.h
grass/trunk/vector/v.buffer/main.c
grass/trunk/vector/v.buffer/v.buffer.html
Log:
v.buffer: implement -c -s flags also for GEOS
Modified: grass/trunk/vector/v.buffer/geos.c
===================================================================
--- grass/trunk/vector/v.buffer/geos.c 2015-07-20 15:04:47 UTC (rev 65709)
+++ grass/trunk/vector/v.buffer/geos.c 2015-07-20 15:46:34 UTC (rev 65710)
@@ -142,7 +142,7 @@
struct spatial_index *si,
struct line_cats *Cats,
struct buf_contours **arr_bc,
- int *buffers_count, int *arr_bc_alloc)
+ int *buffers_count, int *arr_bc_alloc, int flat, int no_caps)
{
GEOSGeometry *IGeom = NULL;
GEOSGeometry *OGeom = NULL;
@@ -158,11 +158,22 @@
* A value of 8 gives less than 2% max error in the buffer distance.
* For a max error of < 1%, use QS = 12.
* For a max error of < 0.1%, use QS = 18. */
- OGeom = GEOSBuffer(IGeom, da, 12);
+ if (flat || no_caps) {
+ GEOSBufferParams* geos_params = GEOSBufferParams_create();
+ GEOSBufferParams_setEndCapStyle(geos_params,
+ no_caps ? GEOSBUF_CAP_FLAT : GEOSBUF_CAP_SQUARE);
- if (!OGeom)
- G_warning(_("Buffering failed"));
+ OGeom = GEOSBufferWithParams(IGeom, geos_params, da);
+ GEOSBufferParams_destroy(geos_params);
+ }
+ else {
+ OGeom = GEOSBuffer(IGeom, da, 12);
+ }
+ if (!OGeom) {
+ G_fatal_error(_("Buffering failed"));
+ }
+
geom2ring(OGeom, Out, Buf, si, Cats, arr_bc, buffers_count, arr_bc_alloc);
if (IGeom)
Modified: grass/trunk/vector/v.buffer/local_proto.h
===================================================================
--- grass/trunk/vector/v.buffer/local_proto.h 2015-07-20 15:04:47 UTC (rev 65709)
+++ grass/trunk/vector/v.buffer/local_proto.h 2015-07-20 15:46:34 UTC (rev 65710)
@@ -19,6 +19,6 @@
struct spatial_index *,
struct line_cats *,
struct buf_contours **,
- int *, int *);
+ int *, int *, int, int);
#endif
Modified: grass/trunk/vector/v.buffer/main.c
===================================================================
--- grass/trunk/vector/v.buffer/main.c 2015-07-20 15:04:47 UTC (rev 65709)
+++ grass/trunk/vector/v.buffer/main.c 2015-07-20 15:46:34 UTC (rev 65710)
@@ -543,7 +543,8 @@
#ifdef HAVE_GEOS
if (use_geos)
geos_buffer(&In, &Out, &Buf, area, GV_AREA, da,
- &si, CCats, &arr_bc, &buffers_count, &arr_bc_alloc);
+ &si, CCats, &arr_bc, &buffers_count, &arr_bc_alloc,
+ straight_flag->answer, nocaps_flag->answer);
#endif
if (!use_geos) {
Vect_area_buffer2(&In, area, da, db, dalpha,
@@ -667,7 +668,8 @@
#ifdef HAVE_GEOS
if (use_geos)
geos_buffer(&In, &Out, &Buf, line, type, da,
- &si, CCats, &arr_bc, &buffers_count, &arr_bc_alloc);
+ &si, CCats, &arr_bc, &buffers_count, &arr_bc_alloc,
+ straight_flag->answer, nocaps_flag->answer);
#endif
if (!use_geos) {
Vect_line_buffer2(Points, da, db, dalpha,
Modified: grass/trunk/vector/v.buffer/v.buffer.html
===================================================================
--- grass/trunk/vector/v.buffer/v.buffer.html 2015-07-20 15:04:47 UTC (rev 65709)
+++ grass/trunk/vector/v.buffer/v.buffer.html 2015-07-20 15:46:34 UTC (rev 65710)
@@ -21,11 +21,40 @@
Buffers for lines and areas are generated using the algorithms from
the GEOS library.
-<!-- built-in buffer algorithm no longer desired, we use GEOS:
-If GRASS is not compiled with GEOS support or environmental
-variable <tt>GRASS_VECTOR_BUFFER</tt> is defined, then GRASS generates
-buffers using built-in buffering algorithm (which is still buggy for
-some input data).
+<p>
+<i>For advanced users:</i> built-in buffer algorithm no longer
+desired, we use GEOS: If GRASS is not compiled with GEOS support
+or <a href="variables.html">environmental
+variable</a> <tt>GRASS_VECTOR_BUFFER</tt> is defined, then GRASS
+generates buffers using built-in buffering algorithm (which is still
+buggy for some input data).
+
+<h3>Corner settings</h3>
+
+By default <em>v.buffer</em> creates rounded buffers (blue color on
+figure below):
+
+<center>
+ <img src="v_buffer_line.png">
+</center>
+
+Straight corners with caps are created by <b>-s</b> flag (red color on
+the figure below), while <b>-c</b> flag doesn't make caps at the ends of
+polylines (green color on the figure below):
+
+<center>
+ <img src="v_buffer_line_s.png">
+ <img src="v_buffer_line_c.png">
+</center>
+
+<!-- Only support by GRASS buffer
+Flag <b>-s</b> also influences corners around polygons (see red color
+on the figure below):
+
+<center>
+ <img src="v_buffer_area.png">
+ <img src="v_buffer_area_s.png">
+</center>
-->
<h2>EXAMPLES</h2>
Added: grass/trunk/vector/v.buffer/v_buffer_area.png
===================================================================
(Binary files differ)
Property changes on: grass/trunk/vector/v.buffer/v_buffer_area.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass/trunk/vector/v.buffer/v_buffer_area_s.png
===================================================================
(Binary files differ)
Property changes on: grass/trunk/vector/v.buffer/v_buffer_area_s.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass/trunk/vector/v.buffer/v_buffer_line.png
===================================================================
(Binary files differ)
Property changes on: grass/trunk/vector/v.buffer/v_buffer_line.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass/trunk/vector/v.buffer/v_buffer_line_c.png
===================================================================
(Binary files differ)
Property changes on: grass/trunk/vector/v.buffer/v_buffer_line_c.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass/trunk/vector/v.buffer/v_buffer_line_s.png
===================================================================
(Binary files differ)
Property changes on: grass/trunk/vector/v.buffer/v_buffer_line_s.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
More information about the grass-commit
mailing list