<div>Hi John,</div>
<div>&nbsp;</div>
<div>You in fact can do the intersection, and other spatial functions on the fly with the present version of MapServer ... &nbsp;if your data is held in PostGIS.</div>
<div>&nbsp;</div>
<div>I use the Windows CGI flavour of MapServer 4.4.2.&nbsp; The trick is to parse the proper SQL query together and use it in the DATA string for the layer.</div>
<div>&nbsp;</div>
<div>One way to&nbsp;do it is by creating a dummy map layer where the DATA string contains a query that returns nothing, and has the variable used in the substitution within the string.&nbsp; Then&nbsp;use some javascript/asp/whatever to alter the value of the substitute variable to use the function and the polygons of interest.
</div>
<div>&nbsp;</div>
<div>For example, I have a data string that looks like this:</div>
<div>&nbsp;</div>
<div>DATA &quot;the_geom from (SELECT * from surf_terrain&nbsp;%terrainname%) as foo using unique gid using SRID=26910&quot;</div>
<div>&nbsp;</div>
<div>The value of terrainname defaults to a value that does not exist in the table, so the layer is blank.&nbsp; terrainname='WHERE type=XXX'</div>
<div>&nbsp;</div>
<div>The user can make the website highlight polygons in that layer by using a tool on the website that changes the value of terrainname, which is submitted in the html form, or through URL encoding.</div>
<div>&nbsp;</div>
<div>My example is simple,&nbsp; you could place the intersection function or whatever you want within that variable.</div>
<div>&nbsp;</div>
<div>We have another layer that on the fly shows forest fires that cross a pipeline. In this case the DATA string uses the 'crosses' function in PostGIS, and looks like:</div>
<div>&nbsp;</div>
<div>DATA &quot;the_geom from (SELECT nt_FFIRES_a.* from nt_ffires_a, pipelin_l where nt_ffires_a.the_geom &amp;&amp; pipelin_l.the_geom AND crosses(nt_ffires_a.the_geom, pipelin_l.the_geom)) as foo using unique gid using SRID=26910&quot;
</div>
<div>&nbsp;</div>
<div>Be warned!&nbsp; If you are going to do this, use spatial indexes where ever possible to improve performance, and even using spatial indexes, you may still find you've made queries that bog your website down too much if you aren't careful.
</div>
<div>&nbsp;</div>
<div>The forest fire query above, running on an old P3 1ghz machine takes 2.6 seconds with the index,&nbsp; 17.6 seconds without!&nbsp;&nbsp; ... and only 0.6 seconds on our new P4 server, using spatial indexes.</div>
<div><br>I'm sure those PHP'ers have great ways to do things too, but this method has worked well for us.</div>
<div>&nbsp;</div>
<div>Cheers,<br>Ken Lord</div>
<div>Vancouver BC</div>
<div><br>&nbsp;</div>
<div><span class="gmail_quote">On 5/26/05, <b class="gmail_sendername">Steve Lime</b> &lt;<a href="mailto:steve.lime@dnr.state.mn.us">steve.lime@dnr.state.mn.us</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">You can't do that with MapServer as it sits. The GEOS support added for 4.6 will allow this sort of stuff via MapScript although I haven't added the intersection operator yet (only buffers and convex hulls are supported at the moment). Are you using MapScript? If so, I could look into quickly exposing an intersection method for a shapeObj.
<br><br>e.g. $intersection = $shape1-&gt;intersect($shape2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$intersection-&gt;draw(...);<br><br>Steve<br><br>&gt;&gt;&gt; John Kim &lt;<a href="mailto:jkim@SCIENCES.SDSU.EDU">jkim@SCIENCES.SDSU.EDU</a>&gt; 05/26/05 12:34 PM &gt;&gt;&gt;
<br>Is it possible to use Mapserver to display an intersection between two polygons? I have two polygon shape files, and I'd like to display the intersection of a polygon from one shape file with the polygon from the other shape file. (The specific polygons are chosen on the fly according to input from our network of sensors).
<br><br>Thanks.<br><br>-John<br></blockquote></div><br>