[Mapserver-users] Shapelib, GPC, PHP, and polygon clipping

Frank Warmerdam warmerdam at pobox.com
Sat May 1 15:03:03 EDT 2004


Ryan, Adam wrote:
> Steve, Frank, etc...
> 
> A while back Steve Lime wrote in response to a request for polygon clipping
> code.
> 
> http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0201/msg00094.html
> 
> He suggested using the GPC library.  I checked this out and was able to get
> it to work.
> 
> Is it worth trying to use GPC with either PHP mapscript or shapelib directly
> and  write a little routine to grab the shapes in question, convert them to
> gpc ascii format, run the clip operation, and convert back to a shapefile
> result?  In PHP I could build the ASCII files, then call a gpc executable,
> and then translate the ASCII result back into a new shapefile.
> 
> Am I exploring old technology?  Is there a better way?  Seems like a lot of
> steps but all the really hard work has been done and it's just a matter of
> reformatting data to work with the different tools.

Adam,

Invoking GPC externally via an ascii file interface may be too slow depending
on your needs but it is certainly doable.

 From a more general point of view, it is my hope to interface the GEOS
library (http://geos.refractions.net) with OGR at some point with a convenient
mechanism to convert OGR geometries into a form usable in GEOS.  So from my
point of view a GEOS is the "future" of complex geometry operations in
OGR (and indirectly shapelib).  In fact, I would like to see a nice SWIG'ed
interface to GEOS so that it can be easily used in most/all of the mapscript
supported languages.

GEOS is the library used by PostGIS for geometry operations, but it is
independent of PostGIS.  I think it does more than GPC. I was also slightly
soured on GPC because of problematic licensing issues as I recall.

So, if you have a particular need that is satisfied by passing geometries to
GPC then by all means go ahead.  However, I don't forsee it as being of
strategic value.  If you are interested in cooperating on swigged interfaces
for GEOS and closer integration with OGR, Shapelib or MapServer geometries
then perhaps we could get something going.  I hadn't really been intending
to get started on this yet though, so you might get stuck doing quite a bit
of the heavy lifting.

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-users mailing list