[GRASS-SVN] r51585 - grass/trunk/vector/v.buffer

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 1 14:19:30 EDT 2012


Author: mmetz
Date: 2012-05-01 11:19:30 -0700 (Tue, 01 May 2012)
New Revision: 51585

Modified:
   grass/trunk/vector/v.buffer/Makefile
   grass/trunk/vector/v.buffer/geos.c
   grass/trunk/vector/v.buffer/local_proto.h
   grass/trunk/vector/v.buffer/main.c
Log:
v.buffer: compile with GEOS < 3.3.x

Modified: grass/trunk/vector/v.buffer/Makefile
===================================================================
--- grass/trunk/vector/v.buffer/Makefile	2012-05-01 12:15:30 UTC (rev 51584)
+++ grass/trunk/vector/v.buffer/Makefile	2012-05-01 18:19:30 UTC (rev 51585)
@@ -5,7 +5,7 @@
 LIBES = $(VECTORLIB) $(DBMILIB) $(GISLIB) $(MATHLIB) $(GEOSLIBS)
 DEPENDENCIES = $(VECTORDEP) $(DBMIDEP) $(GISDEP)
 EXTRA_INC = $(VECT_INC)
-EXTRA_CFLAGS = $(VECT_CFLAGS)
+EXTRA_CFLAGS = $(VECT_CFLAGS) $(GEOSCFLAGS)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 

Modified: grass/trunk/vector/v.buffer/geos.c
===================================================================
--- grass/trunk/vector/v.buffer/geos.c	2012-05-01 12:15:30 UTC (rev 51584)
+++ grass/trunk/vector/v.buffer/geos.c	2012-05-01 18:19:30 UTC (rev 51585)
@@ -139,7 +139,6 @@
 
 int geos_buffer(struct Map_info *In, struct Map_info *Out,
                 struct Map_info *Buf, int id, int type, double da,
-                GEOSBufferParams *buffer_params,
 		struct spatial_index *si,
 		struct line_cats *Cats,
 		struct buf_contours **arr_bc,
@@ -155,8 +154,12 @@
     else
 	IGeom = Vect_read_line_geos(In, id, &type);
 
-    OGeom = GEOSBufferWithParams(IGeom, buffer_params, da);
-    
+    /* GEOS code comment on the number of quadrant segments:
+     * 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 (!OGeom)
 	G_warning(_("Buffering failed"));
     

Modified: grass/trunk/vector/v.buffer/local_proto.h
===================================================================
--- grass/trunk/vector/v.buffer/local_proto.h	2012-05-01 12:15:30 UTC (rev 51584)
+++ grass/trunk/vector/v.buffer/local_proto.h	2012-05-01 18:19:30 UTC (rev 51585)
@@ -16,7 +16,6 @@
 #ifdef HAVE_GEOS
 int geos_buffer(struct Map_info *, struct Map_info *,
                 struct Map_info *, int, int, double,
-                GEOSBufferParams *,
 		struct spatial_index *,
 		struct line_cats *,
 		struct buf_contours **,

Modified: grass/trunk/vector/v.buffer/main.c
===================================================================
--- grass/trunk/vector/v.buffer/main.c	2012-05-01 12:15:30 UTC (rev 51584)
+++ grass/trunk/vector/v.buffer/main.c	2012-05-01 18:19:30 UTC (rev 51585)
@@ -213,7 +213,7 @@
     double size_val, scale;
 
 #ifdef HAVE_GEOS
-    GEOSBufferParams *buffer_params = NULL;
+    /* TODO: use GEOSBufferParams * */
 #endif
 
     module = G_define_module();
@@ -437,9 +437,6 @@
 
 #ifdef HAVE_GEOS
     initGEOS(G_message, G_fatal_error);
-    buffer_params = GEOSBufferParams_create();
-    GEOSBufferParams_setEndCapStyle(buffer_params, GEOSBUF_CAP_ROUND);
-    GEOSBufferParams_setJoinStyle(buffer_params, GEOSBUF_JOIN_ROUND);
 #else
     if (da < 0. || db < 0.) {
 	G_warning(_("Negative distances for internal buffers are not supported "
@@ -537,8 +534,7 @@
 	    else {
 
 #ifdef HAVE_GEOS
-		GEOSBufferParams_setMitreLimit(buffer_params, unit_tolerance);
-		geos_buffer(&In, &Out, &Buf, line, type, da, buffer_params,
+		geos_buffer(&In, &Out, &Buf, line, type, da,
 			    &si, CCats, &arr_bc, &buffers_count, &arr_bc_alloc);
 #else
 		Vect_line_buffer2(Points, da, db, dalpha,
@@ -629,9 +625,7 @@
 	    }
 
 #ifdef HAVE_GEOS
-	    GEOSBufferParams_setSingleSided(buffer_params, 1);
-	    GEOSBufferParams_setMitreLimit(buffer_params, fabs(unit_tolerance));
-	    geos_buffer(&In, &Out, &Buf, area, GV_AREA, da, buffer_params,
+	    geos_buffer(&In, &Out, &Buf, area, GV_AREA, da,
 	                &si, CCats, &arr_bc, &buffers_count, &arr_bc_alloc);
 #else
 	    if (da < 0. || db < 0.) {
@@ -672,7 +666,6 @@
     }
 
 #ifdef HAVE_GEOS
-    GEOSBufferParams_destroy(buffer_params);
     finishGEOS();
 #endif
 



More information about the grass-commit mailing list