[mapserver-dev] PostGIS "curvepolygon" support

Frank Warmerdam warmerdam at pobox.com
Mon Nov 8 11:51:54 EST 2010


Astrid Emde wrote:
> The main thing would be to get a sustainable solution with good 
> performance which bringsforward the mapServer project as maybe more and 
> more user will need this functionality.
> 
> We have mixed data (linestrings mixed with compoundcurves and 
> circularstring and on the other hand polygons mixed with CURVEPOLYGONs) 
> in one feature table. At the moment we create a second geometry column 
> where we create with st_curvetoline(the_geom)  linestrings from our 
> curves. We used this function in the mapfile itself but the performance 
> was too bad to do the processing on every request.
> 
> It would be good to define a MapServer LAYER from type LINESTRING or 
> POLYGON and display linestrings/compoundcurves/circularstring and 
> polygons/CURVEPOLYGONs.

Astrid,

In the case of approximating as lines, there would be no problem
handling them using the existing LINE and POLYGON layers as they
really would be a normal shapeObj by the time they come out of the
mappostgis.c code.

> Now about the "bigger job" to add arcs as a first class geometry type in 
> MapServer:
> * what advantages would this bring?

It offers two main advantages.

1) Speed: I believe (though I have not investigated) that the modern
rendering engines (AGG and Cairo) would have API level support for
curves and I believe it would generally be faster to render a curve
as a curve rather than as a complex (dense) linestrings.

2) Precision: Approximating arcs as lines will occasionally give
small visible artifacts unless a very high approximation density is
used.  Passing through as curves would avoid this.

> * could we be able to handle both geometry types 
> linestrings/compoundcurves/circularstring and polygons/CURVEPOLYGONs 
> within one LAYER

I believe so.

> * what about the performance

I think the performance would be best preserving the objects as
arcs, though it is not clear to me whether the difference would
be significant or not.

> What do you think?

Unfortunately, I think that adding support to the shapeObj, and the
various rendering engines to handle arcs properly would be a huge
job, and not really appropriate for this late date in the MapServer
6 release cycle.  In fact, I'm not even that confident that the
benefits of handling things as curves would be worth the long term
complication of mapserver internals.

So, I think for the time being we should stick with the approach
of approximating curves as linestrings within the mappostgis code
with the code to stroke the curves being made available to other
backends as I believe Paul suggested.  This is similar to the
approach I have taken within OGR.

 From your reply to Paul:
 > At the moment we preprocess our data and create the strokes in the
 > database in a second geom_column. So we loose no performance as we
 > access the preprocessed data in our mapfiles. Solution b) will still do
 > the "stroke-processing" on-the-fly.

Note that stroking curves to linestrings is not particularly expensive
and doing it close to the rendering engine may have better performance
that transporting dense linestrings out of the database.

 > Frank offered to implement a solution in GDAL/OGR so this would be for
 > CONNECTIONTYPE OGR and the solution you suggested would be for
 > CONNECTIONTYPE POSTGIS. Is this right?

To be clear, I was suggesting to do this for CONNECTIONTYPE POSTGIS
in mappostgis.c.  I might also pursue handling curves in the OGR
PostGIS driver but I am not suggesting that mapserver uses ought
to use the OGR approach for postgres as there is non-trivial
overhead in the extra layers of translation.

PS. stitching the mixtures of curves and linestrings together
into complete polygon rings is a bit complicated and I hadn't
considered it in my "couple hours" time estimate.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-dev mailing list