[mapserver-users] PHP mapscript $shape->buffer() takes a long time

Ludwig Kniprath ludwig at kni-online.de
Wed Nov 18 03:01:10 EST 2009


We had the same problem. In deed the buffer-algorithm is very expensive, especially with large polygons and a large buffer-radius. If you use Postgis, you can simplify the Polygon with ST_Simplify or ST_SimplifyPreserveTopology in dependency from scale and buffer-radius, this will make the buffer-process much faster without significant loss of quality. You can do this on runtime on your original data with dynamic PostGIS-queries. If you don't use PostGis, you have to create simplified layers.

Pseudo-PHP-PostGIS-SQL:
SELECT ... ST_SetSRID(ST_BUFFER(ST_SIMPLIFY($geometery_field,$simplify_tolerance),$buffer_radius, $number_of_segments),$srid)::geometry ...FROM...

And don't use the buffered polygon for geo-queries, there are faster ways in PostGIS and Mapserver.

Regards
Ludwig Kniprath 

>
>I'm trying to buffer a shape returned from a point query on a polygon layer
>of parcels.
>
> 
>
>When I try to use:
>
> 
>
>$bufferedShape = $shape->buffer(200);
>
> 
>
>I get back a fatal error: Maximum execution time of 30 seconds exceeded.
>
>I know that this is a php error message and that I could increase the
>allowable execution time.
>
> 
>
>If I use a buffer distance of 175 I get results.
>
> 
>
>Should it take such a long time to but a buffer around this parcel?  It is a
>large parcel with one corner being a long curve like a quarter of a circle
>and another section on one side being a half circle.


More information about the mapserver-users mailing list