GEOS integration questions

Stephen Lime steve.lime at DNR.STATE.MN.US
Fri Jan 20 01:28:48 EST 2006


Well, a nice bottle of scotch would be a good start. ;-)

For grins I added the conains operator to the geos wrapper and to Swig-based
mapscript. That support is in CVS head (not 4.8, too late for that, sorry).
I hesitate to touch the PHP wrapper though. You'll have to convince one of
the other developers to make that change (or have them ok me doing it).

Anyway in a language like Perl you can do:

shape1 = mapscript::shapeObj::fromWKT('POLYGON((0.0 0.0, 0.0 2.0, 2.0 2.0,
2.0 0.0, 0.0 0.0))') or die("Shape 1: ". mapscript::msGetErrorString("\n")
."\n");
$shape2 = mapscript::shapeObj::fromWKT('POLYGON((0.5 0.5,0.5 1.5,1.5 1.5,1.5
0.5,0.5 0.5))') or die("Shape 2:". mapscript::msGetErrorString("\n") ."\n");

print $shape1->contains($shape2) ."\n";
print $shape2->contains($shape1) ."\n";
print $shape2->contains($shape2) ."\n";

Which outputs:

1
0
1

as expected. This is only exposing the operator. Nothing is itegrated into
the MapServer query functions. However, in MapScript you could:

1) use the bounds of shape 1 to do a rect-based query and then
2) loop through the result set doing contains

I'm not going to do a full implementation of GEOS until I convert the cpp
interface to c (sometime soon). However, it seems like contains might be
interesting to folks in the meantime so...

Steve

On Thu, 19 Jan 2006 19:21:26 -0600, Mark Adams <markadams at CUESTASYS.COM> wrote:

>This is a timely discussion for me. I urgently need to provide support for
>a "contains" query specifically in an application I am developing (other
>GEOS supported operators would be great, but the contains query is
>critical). What would it take to add this functionality into mapserver and
>mapscript? (We use PHP Mapscript here.)
>
>Thanks.
>
>------------------------------
>Mark Adams
>Senior Analyst & Project Manager
>Cuesta Systems (DPRA Canada)
>5230 South Service Road
>Burlington, ON L7L 5K2
>Phone: 905-333-4544 x14
>Fax: 905-333-0455
>Email: mark.adams at dpra.com
>
>
>On Thu, 19 Jan 2006 10:34:39 -0600, Steve Lime
><steve.lime at DNR.STATE.MN.US> wrote:
>
>>The only GEOS methods exposed are convex hull and a buffer. I didn't
>>want to go nuts until I received some feedback about the usefulness of
>>that type of functionality. They are not difficult to add. Are there
>specific
>>operators you are interested in and would be willing to test? Let me know
>>if so and we can work in the 4.9 branch.
>>
>>A full list of operators supported by GEOS is available at
>geos.refractions.net.
>>
>>As for mapfile integration. My idea was to expose a few operators that
>>work of a single shape (e.g. buffer, convex hull, etc...) via the
>PROCESSING
>>block that is currently used for defining raster operations. That way you
>>could basically apply a GEOS operator to all features of a particular
>layer as
>>they are read from the data source- for any data source.
>>
>>Steve
>>
>>>>> listuser HH <listuser at HERZSYS.DE> 01/19/06 5:49 AM >>>
>>Hello all,
>>
>>I would like to know how much of the GEOS functions (and which) are
>>already available in the MapScript API and in PHP MapScript. I found
>>only intersects and cointains for both. The shapeObj in PHP Mapscript
>>also has buffer and convexhull.
>>
>>Can someone tell me what the plans for including more of the GEOS
>>functions are?
>>
>>Are there plans to use some functions (i.e. buffer) directly in the
>mapfile?
>>
>>Are there any docs that give some more information?
>>
>>Regards
>>
>>Norbert



More information about the mapserver-users mailing list