[Mapserver-users] Code Sharing
Stefan Schwarzer
stefan.schwarzer at grid.unep.ch
Wed Mar 12 22:56:41 PST 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; ### pick one<br><br>
$point = ms_newPointObj();<br>
$point->setXY($x, $y);<br><br>
$map = ms_newMapObj(MAPFILE);<br>
for ($i=0; $i<$map->numlayers; $i++) {<br><br>
$layer = $map->getLayer($i);<br>
$layer->set('status', MS_ON);<br>
$ret = @ $layer->queryByPoint($point, $qmode,
-1.0);<br>
if ($ret == MS_SUCCESS) {<br>
$numResults = $layer->getNumResults();<br>
$layer->open($shapepath);<br><br>
for ($j=0; $j<$numResults; $j++) {<br>
$res =
$layer->getResult($j);<br>
$shp =
$layer->getShape($res->tileindex, $res-<br>
>shapeindex);<br><br>
# add code to get attributes from the shp object<br>
# add code to get geometry from the shp object<br><br>
$shp->free();<br>
}<br>
$layer->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>
<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>
> Can anyone send me example code and/or and explanation of how I
would<br>
> go about using PHP mapscript to perform single and multiple queries.
I<br>
> know that there is an example in the GMap demonstration files
that<br>
> uses the Rosa applet, but I would prefer at this point to avoid
using<br>
> it and to rely exclusively on mapscript.<br>
> <br>
> Thanks, Bill<br>
> <br>
>
*********************************************************************<br>
>
*********************************************************************<br>
> William Hudspeth, PhD Earth Data Analysis Center 107 Bandelier
Hall<br>
> West University of New Mexico Albuquerque, NM 87131 (505)
277-3622,<br>
> ext. 238 bhudspeth at edac.unm.edu wbhk at unm.edu<br>
> <br>
> <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> </x-tab>_______________________________________<br><br>
</font><font size=2><x-tab> </x-tab><b>Stefan Schwarzer<br>
</b><x-tab> </x-tab>Consultant on GEO<br><br>
<x-tab> </x-tab>UNEP/DEWA/GRID-Geneva<br>
<x-tab> </x-tab>Chemin des Anemones 11<br>
<x-tab> </x-tab>CH - 1219 Chatelaine<br>
<x-tab> </x-tab>Switzerland<br><br>
<x-tab> </x-tab>Tel: (+41) 22.917.83.49<br>
<x-tab> </x-tab>Fax: (+41) 22.917.80.29<br><br>
<x-tab> </x-tab>Email: stefan.schwarzer at grid.unep.ch<br>
<x-tab> </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> </x-tab>_______________________________________</font></body>
</html>
--=====================_258394481==.ALT--
More information about the MapServer-users
mailing list