[Mapserver-users] Code Sharing

Stefan Schwarzer stefan.schwarzer at grid.unep.ch
Thu Mar 13 01:56:41 EST 2003


--=====================_258394481==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

Hi all,

while the discussion about splitting the list is taking shape, I would like 
to introduce another idea: A site to share code.

Almost everybody familiar with GIS will know about ESRI's Script site. 
Anyone can post his developed scripts there, with a description of what it 
is doing and how to integrate it. Ok, this is a bit different of what 
MapServer users would have to offer. But the idea, that the same procedure 
mustn't be developed several times but only once and reused by others, 
would be perhaps nice for MapServer as well.

An example would be perhaps the code below, posted today/yesterday. Or the 
Javascript code for drawing bounding boxes on the map. (This one was posted 
a couple of weeks ago. I for example reused and extended it a bit, so that 
after a rectangle-query has been send, the same rectangle will be drawn 
again on the newly generated map. So the user can see the result of his 
query and the query-area at the same time. I would be happy to share this 
piece of code..) Or some basic cut-outs of code - how one produces a query, 
how one puts up a connection to a database with related queries, how one 
re-projects his layers on-the-fly, etc.

I think that this could be useful on one side for beginners and advanced 
developers at the same time. But, right, the case is not as clear as for 
ArcView scripts....

Best wishes,

Stefan




>Bill,
>
>Here are the essentials:
>
>$qmode = MS_SINGLE or MS_MULTIPLE;  ### pick one
>
>$point = ms_newPointObj();
>$point->setXY($x, $y);
>
>$map = ms_newMapObj(MAPFILE);
>for ($i=0; $i<$map->numlayers; $i++) {
>
>     $layer = $map->getLayer($i);
>     $layer->set('status', MS_ON);
>     $ret = @ $layer->queryByPoint($point, $qmode, -1.0);
>     if ($ret == MS_SUCCESS) {
>     $numResults = $layer->getNumResults();
>     $layer->open($shapepath);
>
>     for ($j=0; $j<$numResults; $j++) {
>             $res = $layer->getResult($j);
>             $shp = $layer->getShape($res->tileindex, $res-
> >shapeindex);
>
>             #  add code to get attributes from the shp object
>             #  add code to get geometry from the shp object
>
>             $shp->free();
>     }
>     $layer->close();
>}
>
>MS_SINGLE gives you the close object within TOLERANCE of the $x, $y
>and MS_MULTIPLE gives you ALL objects within TOLERANCE.
>
>I use code similar to this to do my reverse geocoder. You can check
>it out at http://imaptools.com/demos1/?tab=4
>
>-Steve W.
>   http://imaptools.com
>
>On 12 Mar 2003 at 16:33, Hudspeth, Bill wrote:
>
> > Can anyone send me example code and/or and explanation of how I would
> > go about using PHP mapscript to perform single and multiple queries. I
> > know that there is an example in the GMap demonstration files that
> > uses the Rosa applet, but I would prefer at this point to avoid using
> > it and to rely exclusively on mapscript.
> >
> > Thanks, Bill
> >
> > *********************************************************************
> > *********************************************************************
> > William Hudspeth, PhD Earth Data Analysis Center 107 Bandelier Hall
> > West University of New Mexico Albuquerque, NM  87131 (505) 277-3622,
> > ext. 238 bhudspeth at edac.unm.edu wbhk at unm.edu
> >
> >
>
>
>_______________________________________________
>Mapserver-users mailing list
>Mapserver-users at lists.gis.umn.edu
>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

         _______________________________________

         Stefan Schwarzer
         Consultant on GEO

         UNEP/DEWA/GRID-Geneva
         Chemin des Anemones 11
         CH - 1219 Chatelaine
         Switzerland

         Tel: (+41) 22.917.83.49
         Fax: (+41) 22.917.80.29

         Email: stefan.schwarzer at grid.unep.ch
         Internet: http://geodata.grid.unep.ch/
         _______________________________________ 
--=====================_258394481==.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<body>
<font size=3>Hi all,<br><br>
while the discussion about splitting the list is taking shape, I would
like to introduce another idea: A site to share code. <br><br>
Almost everybody familiar with GIS will know about ESRI's Script site.
Anyone can post his developed scripts there, with a description of what
it is doing and how to integrate it. Ok, this is a bit different of what
MapServer users would have to offer. But the idea, that the same
procedure mustn't be developed several times but only once and reused by
others, would be perhaps nice for MapServer as well.<br><br>
An example would be perhaps the code below, posted today/yesterday. Or
the Javascript code for drawing bounding boxes on the map. (This one was
posted a couple of weeks ago. I for example reused and extended it a bit,
so that after a rectangle-query has been send, the same rectangle will be
drawn again on the newly generated map. So the user can see the result of
his query and the query-area at the same time. I would be happy to share
this piece of code..) Or some basic cut-outs of code - how one produces a
query, how one puts up a connection to a database with related queries,
how one re-projects his layers on-the-fly, etc.<br><br>
I think that this could be useful on one side for beginners and advanced
developers at the same time. But, right, the case is not as clear as for
ArcView scripts....<br><br>
Best wishes,<br><br>
Stefan<br><br>
<br><br>
<br>
<blockquote type=cite class=cite cite>Bill,<br><br>
Here are the essentials:<br><br>
$qmode = MS_SINGLE or MS_MULTIPLE;&nbsp; ### pick one<br><br>
$point = ms_newPointObj();<br>
$point-&gt;setXY($x, $y);<br><br>
$map = ms_newMapObj(MAPFILE);<br>
for ($i=0; $i&lt;$map-&gt;numlayers; $i++) {<br><br>
&nbsp;&nbsp;&nbsp; $layer = $map-&gt;getLayer($i);<br>
&nbsp;&nbsp;&nbsp; $layer-&gt;set('status', MS_ON);<br>
&nbsp;&nbsp;&nbsp; $ret = @ $layer-&gt;queryByPoint($point, $qmode,
-1.0);<br>
&nbsp;&nbsp;&nbsp; if ($ret == MS_SUCCESS) {<br>
&nbsp;&nbsp;&nbsp; $numResults = $layer-&gt;getNumResults();<br>
&nbsp;&nbsp;&nbsp; $layer-&gt;open($shapepath);<br><br>
&nbsp;&nbsp;&nbsp; for ($j=0; $j&lt;$numResults; $j++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $res =
$layer-&gt;getResult($j);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $shp =
$layer-&gt;getShape($res-&gt;tileindex, $res-<br>
&gt;shapeindex);<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#&nbsp; add code to get attributes from the shp object<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#&nbsp; add code to get geometry from the shp object<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$shp-&gt;free();<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; $layer-&gt;close();<br>
}<br><br>
MS_SINGLE gives you the close object within TOLERANCE of the $x, $y<br>
and MS_MULTIPLE gives you ALL objects within TOLERANCE.<br><br>
I use code similar to this to do my reverse geocoder. You can check 
<br>
it out at
<a href="http://imaptools.com/demos1/?tab=4" eudora="autourl">http://imaptools.com/demos1/?tab=4</a><br><br>
-Steve W.<br>
&nbsp;
<a href="http://imaptools.com/" eudora="autourl">http://imaptools.com</a><br><br>
On 12 Mar 2003 at 16:33, Hudspeth, Bill wrote:<br><br>
&gt; Can anyone send me example code and/or and explanation of how I
would<br>
&gt; go about using PHP mapscript to perform single and multiple queries.
I<br>
&gt; know that there is an example in the GMap demonstration files
that<br>
&gt; uses the Rosa applet, but I would prefer at this point to avoid
using<br>
&gt; it and to rely exclusively on mapscript.<br>
&gt; <br>
&gt; Thanks, Bill<br>
&gt; <br>
&gt;
*********************************************************************<br>
&gt;
*********************************************************************<br>
&gt; William Hudspeth, PhD Earth Data Analysis Center 107 Bandelier
Hall<br>
&gt; West University of New Mexico Albuquerque, NM&nbsp; 87131 (505)
277-3622,<br>
&gt; ext. 238 bhudspeth at edac.unm.edu wbhk at unm.edu<br>
&gt; <br>
&gt; <br><br>
<br>
_______________________________________________<br>
Mapserver-users mailing list<br>
Mapserver-users at lists.gis.umn.edu<br>
<a href="http://lists.gis.umn.edu/mailman/listinfo/mapserver-users" eudora="autourl">http://lists.gis.umn.edu/mailman/listinfo/mapserver-users</a>
</blockquote>
<x-sigsep><p></x-sigsep>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>_______________________________________<br><br>
</font><font size=2><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><b>Stefan Schwarzer<br>
</b><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>Consultant on GEO<br><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>UNEP/DEWA/GRID-Geneva<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>Chemin des Anemones 11<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>CH - 1219 Chatelaine<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>Switzerland<br><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>Tel: (+41) 22.917.83.49<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>Fax: (+41) 22.917.80.29<br><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>Email: stefan.schwarzer at grid.unep.ch<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>Internet: <a href="http://geodata.grid.unep.ch/" eudora="autourl">http://geodata.grid.unep.ch/</a><br>
</font><font size=3><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>_______________________________________</font></body>
</html>

--=====================_258394481==.ALT--





More information about the mapserver-users mailing list