]> granicus.if.org Git - postgis/commitdiff
Added a third argument to the buffer() function.
authorSandro Santilli <strk@keybit.net>
Wed, 13 Oct 2004 18:39:39 +0000 (18:39 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 13 Oct 2004 18:39:39 +0000 (18:39 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@993 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgeom_geos.c
lwgeom/lwgeom_geos_wrapper.cpp
lwgeom/lwpostgis.sql.in

index 9eb7de1b6dff9f989777670b723dec8d3f14c23b..80c1df11110a9b3e597d9acec44313ba5ed9e13b 100644 (file)
@@ -70,7 +70,7 @@ extern char *GEOSversion();
 extern char *GEOSjtsport();
 extern char GEOSisvalid(Geometry *g1);
 extern Geometry *GEOSIntersection(Geometry *g1, Geometry *g2);
-extern Geometry *GEOSBuffer(Geometry *g1,double width);
+extern Geometry *GEOSBuffer(Geometry *g1,double width, int quadsegs);
 extern Geometry *GEOSConvexHull(Geometry *g1);
 extern Geometry *GEOSDifference(Geometry *g1,Geometry *g2);
 extern Geometry *GEOSBoundary(Geometry *g1);
@@ -552,6 +552,7 @@ Datum buffer(PG_FUNCTION_ARGS)
        double  size;
        Geometry *g1,*g3;
        PG_LWGEOM *result;
+       int quadsegs = 8; // the default
 
 #ifdef PROFILE
        profstart(PROF_QRUN);
@@ -559,13 +560,14 @@ Datum buffer(PG_FUNCTION_ARGS)
 
        geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        size = PG_GETARG_FLOAT8(1);
+       if ( PG_NARGS() > 2 ) quadsegs = PG_GETARG_INT32(3);
 
        initGEOS(MAXIMUM_ALIGNOF);
 
 #ifdef PROFILE
        profstart(PROF_P2G1);
 #endif
-       g1 = POSTGIS2GEOS(geom1 );
+       g1 = POSTGIS2GEOS(geom1);
 #ifdef PROFILE
        profstop(PROF_P2G1);
 #endif
@@ -573,7 +575,7 @@ Datum buffer(PG_FUNCTION_ARGS)
 #ifdef PROFILE
        profstart(PROF_GRUN);
 #endif
-       g3 = GEOSBuffer(g1,size);
+       g3 = GEOSBuffer(g1,size,quadsegs);
 #ifdef PROFILE
        profstop(PROF_GRUN);
 #endif
index 8be8739029a40e62f5ed4e06a4ef6fee54791457..950e6efea27a6d8c142f7f6ae95f06e01cc7718d 100644 (file)
@@ -123,7 +123,7 @@ extern "C" int GEOSGeometryTypeId(Geometry *g1);
 extern "C" char *throw_exception(Geometry *g);
 
 extern "C" Geometry *GEOSIntersection(Geometry *g1,Geometry *g1);
-extern "C" Geometry *GEOSBuffer(Geometry *g1,double width);
+extern "C" Geometry *GEOSBuffer(Geometry *g1,double width,int quadsegs);
 extern "C" Geometry *GEOSConvexHull(Geometry *g1);
 extern "C" Geometry *GEOSDifference(Geometry *g1,Geometry *g2);
 extern "C" Geometry *GEOSBoundary(Geometry *g1);
@@ -1113,11 +1113,12 @@ Geometry *GEOSIntersection(Geometry *g1,Geometry *g2)
        }
 }
 
-Geometry *GEOSBuffer(Geometry *g1,double width)
+Geometry *
+GEOSBuffer(Geometry *g1, double width, int quadrantsegments)
 {
        try
        {
-               Geometry *g3 = g1->buffer(width);
+               Geometry *g3 = g1->buffer(width, quadrantsegments);
                return g3;
        }
        catch (GEOSException *ge)
index 4d9abfd2083b079cfabf9d954b954657609e4f1c..2f0b3586ac077ef1dc919126b705c346b39b5636 100644 (file)
@@ -2857,6 +2857,11 @@ CREATEFUNCTION buffer(geometry,float8)
    RETURNS geometry
    AS '@MODULE_FILENAME@','buffer'
    LANGUAGE 'C' WITH (isstrict);
+
+CREATEFUNCTION buffer(geometry,float8,integer)
+   RETURNS geometry
+   AS '@MODULE_FILENAME@','buffer'
+   LANGUAGE 'C' WITH (isstrict);
    
 CREATEFUNCTION convexhull(geometry)
        RETURNS geometry