Browse Source

v.buffer: compile with GEOS < 3.3.x

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51585 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 13 năm trước cách đây
mục cha
commit
0525c53e99
4 tập tin đã thay đổi với 10 bổ sung15 xóa
  1. 1 1
      vector/v.buffer/Makefile
  2. 6 3
      vector/v.buffer/geos.c
  3. 0 1
      vector/v.buffer/local_proto.h
  4. 3 10
      vector/v.buffer/main.c

+ 1 - 1
vector/v.buffer/Makefile

@@ -5,7 +5,7 @@ PGM = v.buffer
 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
 

+ 6 - 3
vector/v.buffer/geos.c

@@ -139,7 +139,6 @@ static int geom2ring(GEOSGeometry *geom, struct Map_info *Out,
 
 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 @@ int geos_buffer(struct Map_info *In, struct Map_info *Out,
     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"));
     

+ 0 - 1
vector/v.buffer/local_proto.h

@@ -16,7 +16,6 @@ struct buf_contours_pts
 #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 **,

+ 3 - 10
vector/v.buffer/main.c

@@ -213,7 +213,7 @@ int main(int argc, char *argv[])
     double size_val, scale;
 
 #ifdef HAVE_GEOS
-    GEOSBufferParams *buffer_params = NULL;
+    /* TODO: use GEOSBufferParams * */
 #endif
 
     module = G_define_module();
@@ -437,9 +437,6 @@ int main(int argc, char *argv[])
 
 #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 @@ int main(int argc, char *argv[])
 	    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 @@ int main(int argc, char *argv[])
 	    }
 
 #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 @@ int main(int argc, char *argv[])
     }
 
 #ifdef HAVE_GEOS
-    GEOSBufferParams_destroy(buffer_params);
     finishGEOS();
 #endif