From: Sandro Santilli Date: Tue, 7 Jul 2009 15:03:50 +0000 (+0000) Subject: For buffer parameters: accept 'butt' as a synonim for 'flat', 'miter' for 'mitre... X-Git-Tag: 1.5.0b1~591 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=73bfa93284c139eeef5f4af72acf4eb5b1289dcc;p=postgis For buffer parameters: accept 'butt' as a synonim for 'flat', 'miter' for 'mitre' and 'miter_limit' for 'mitre_limit'. git-svn-id: http://svn.osgeo.org/postgis/trunk@4266 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference.xml b/doc/reference.xml index e0cc9ca47..ab9e7687c 100644 --- a/doc/reference.xml +++ b/doc/reference.xml @@ -11598,13 +11598,13 @@ The optional third parameter can either specify number of segments used to appro 'quad_segs=#' : number of segments used to approximate a quarter circle (defaults to 8). -'endcap=round|flat|square' : endcap style (defaults to "round", needs GEOS-3.2 or higher for a different value). +'endcap=round|flat|square' : endcap style (defaults to "round", needs GEOS-3.2 or higher for a different value). 'butt' is also accepted as a synonim for 'flat'. -'join=round|mitre|bevel' : join style (defaults to "round", needs GEOS-3.2 or higher for a different value). +'join=round|mitre|bevel' : join style (defaults to "round", needs GEOS-3.2 or higher for a different value). 'miter' is also accepted as a synonim for 'mitre'. -'mitre_limit=#.#' : mitre ratio limit (only affects mitred join style). +'mitre_limit=#.#' : mitre ratio limit (only affects mitred join style). 'miter_limit' is also accepted as a synonim for 'mitre_limit'. diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index eb785c31a..bb5e9c640 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -911,7 +911,8 @@ Datum buffer(PG_FUNCTION_ARGS) { endCapStyle = ENDCAP_ROUND; } - else if ( !strcmp(val, "flat") ) + else if ( !strcmp(val, "flat") || + !strcmp(val, "butt") ) { endCapStyle = ENDCAP_FLAT; } @@ -923,7 +924,8 @@ Datum buffer(PG_FUNCTION_ARGS) { lwerror("Invalid buffer end cap " "style: %s (accept: " - "'round', 'flat' or 'square'" + "'round', 'flat', 'butt' " + "or 'square'" ")", val); break; } @@ -935,7 +937,8 @@ Datum buffer(PG_FUNCTION_ARGS) { joinStyle = JOIN_ROUND; } - else if ( !strcmp(val, "mitre") ) + else if ( !strcmp(val, "mitre") || + !strcmp(val, "miter") ) { joinStyle = JOIN_MITRE; } @@ -947,12 +950,14 @@ Datum buffer(PG_FUNCTION_ARGS) { lwerror("Invalid buffer end cap " "style: %s (accept: " - "'round', 'mitre' or 'bevel'" + "'round', 'mitre', 'miter' " + " or 'bevel'" ")", val); break; } } - else if ( !strcmp(key, "mitre_limit") ) + else if ( !strcmp(key, "mitre_limit") || + !strcmp(key, "miter_limit") ) { /* mitreLimit is a float */ mitreLimit = atof(val); @@ -965,7 +970,8 @@ Datum buffer(PG_FUNCTION_ARGS) else { lwerror("Invalid buffer parameter: %s (accept: " - "'endcap', 'join', 'mitre_limit' and " + "'endcap', 'join', 'mitre_limit', " + "'miter_limit and " "'quad_segs')", key); break; } diff --git a/regress/regress_buffer_params.sql b/regress/regress_buffer_params.sql index 211d2dba3..6f66e00e1 100644 --- a/regress/regress_buffer_params.sql +++ b/regress/regress_buffer_params.sql @@ -8,9 +8,11 @@ SELECT 'point quadsegs=2', astext(SnapToGrid(st_buffer('POINT(0 0)', 1, 'quad_segs=2'), 1.0e-6)); SELECT 'line quadsegs=2', astext(SnapToGrid(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2'), 1.0e-6)); SELECT 'line quadsegs=2 endcap=flat', astext(SnapToGrid(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2 endcap=flat'), 1.0e-6)); +SELECT 'line quadsegs=2 endcap=butt', astext(SnapToGrid(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2 endcap=butt'), 1.0e-6)); SELECT 'line quadsegs=2 endcap=square', astext(SnapToGrid(st_buffer('LINESTRING(0 0, 10 0)', 2, 'quad_segs=2 endcap=square'), 1.0e-6)); SELECT 'poly quadsegs=2 join=round', astext(SnapToGrid(st_buffer('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 2, 'quad_segs=2 join=round'), 1.0e-6)); SELECT 'poly quadsegs=2 join=bevel', astext(SnapToGrid(st_buffer('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 2, 'quad_segs=2 join=bevel'), 1.0e-6)); SELECT 'poly quadsegs=2 join=mitre', astext(SnapToGrid(st_buffer('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 2, 'quad_segs=2 join=mitre'), 1.0e-6)); SELECT 'poly quadsegs=2 join=mitre mitre_limit=1', astext(SnapToGrid(st_buffer('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 2, 'quad_segs=2 join=mitre mitre_limit=1'), 1.0e-6)); +SELECT 'poly quadsegs=2 join=miter miter_limit=1', astext(SnapToGrid(st_buffer('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 2, 'quad_segs=2 join=miter miter_limit=1'), 1.0e-6)); diff --git a/regress/regress_buffer_params_expected b/regress/regress_buffer_params_expected index 12129110d..0a8866308 100644 --- a/regress/regress_buffer_params_expected +++ b/regress/regress_buffer_params_expected @@ -1,8 +1,10 @@ point quadsegs=2|POLYGON((1 0,0.707107 -0.707107,0 -1,-0.707107 -0.707107,-1 0,-0.707107 0.707107,0 1,0.707107 0.707107,1 0)) line quadsegs=2|POLYGON((10 2,11.414214 1.414214,12 0,11.414214 -1.414214,10 -2,0 -2,-1.414214 -1.414214,-2 0,-1.414214 1.414214,0 2,10 2)) line quadsegs=2 endcap=flat|POLYGON((10 2,10 -2,0 -2,0 2,10 2)) +line quadsegs=2 endcap=butt|POLYGON((10 2,10 -2,0 -2,0 2,10 2)) line quadsegs=2 endcap=square|POLYGON((10 2,12 2,12 -2,0 -2,-2 -2,-2 2,10 2)) poly quadsegs=2 join=round|POLYGON((-2 0,-2 10,-1.414214 11.414214,0 12,10 12,11.414214 11.414214,12 10,12 0,11.414214 -1.414214,10 -2,0 -2,-1.414214 -1.414214,-2 0)) poly quadsegs=2 join=bevel|POLYGON((-2 0,-2 10,0 12,10 12,12 10,12 0,10 -2,0 -2,-2 0)) poly quadsegs=2 join=mitre|POLYGON((-2 -2,-2 12,12 12,12 -2,-2 -2)) poly quadsegs=2 join=mitre mitre_limit=1|POLYGON((-1.828427 -1,-1.828427 11,-1 11.828427,11 11.828427,11.828427 11,11.828427 -1,11 -1.828427,-1 -1.828427,-1.828427 -1)) +poly quadsegs=2 join=miter miter_limit=1|POLYGON((-1.828427 -1,-1.828427 11,-1 11.828427,11 11.828427,11.828427 11,11.828427 -1,11 -1.828427,-1 -1.828427,-1.828427 -1))