[mapserver-users] Drawing features dynamically

Steve Lime steve.lime at dnr.state.mn.us
Tue Mar 19 12:09:52 PST 2002


Here's the original quake mapper example in perl. It takes point data
from a USGS
ftp server and drops those points over the top of a TIF background
image. It's been
ported to the 3.5 version of MapScript. I didn't include the underlying
TIF image 
because it's a tad big. Let me know if you'd like it...

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Dan Barron <dbarron at ddive.com> 03/19/02 12:02PM >>>
Hi Ricardo,

Below is a function that will take the results from a query to mySQL
and 
draw the points on a the specified layer.  I have tested this with up
to 
10K points on a W2K machine with mySQL & Apache and it works fine.

Hope this helps.

Dan Barron
Destination Software LLC
San Diego, CA, USA

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// drawPoints - take the database query results and draw the points on
the 
map layer
//
// $results - results of the database query
// $layerName - name of the layer to draw on image
//
// return True or False
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function drawPoints( $results, $layerName ) {

   GLOBAL $map;
         GLOBAL $image;

         $layer =  $map->getLayerByName( $layerName );

   // Loop through result of point query and:
   while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) {
                 $pt = ms_newPointObj();
                 $pt->setXY( $line["longitude"], $line["latitude"] );

                 $pt->draw($map, $layer, $image, 0, "TEST");
                 $layer->set('status', MS_ON);
                 $layer->draw($image);
         }

         return True;
}


At 03:57 PM 3/18/2002 -0300, Ricardo Scachetti Pereira wrote:
>     Does anyone know how to draw features (points, lines and
polygons)
>dynamically over a base map using Perl or PHP mapscript?
>     I would like to draw data points coming from disparate (remote)
data
>sources, which are providing data as a XML documents. Each document
can
>contain a large number of features (thousands). I would like to avoid
>writing individual shapefiles for each dataset, just to display them.
I
>would like to know if mapserver has any built in mechanism to display
>dynamic features, besides the one described on the CGI documentation
>(which is designed to handle small amounts of data).
>     I've been exploring the pointObj and its methods (especially the
>draw() method), because it seems to be developed to implement the
kind
>of feature I'm looking for. However, I couldn't write anything that
does
>what I want. Mostly, I get segmentation fault errors. Does anyone
know
>any sample scripts that draw points using this object?
>
>Ricardo
>
>
>--
>Ricardo Scachetti Pereira
>Gerente de Pesquisa
>Centro de Referência em Informação Ambiental - CRIA
>http://www.cria.org.br/ 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: quakes.map
Type: application/octet-stream
Size: 1013 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020319/e5e1f8b8/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapquakes.pl
Type: application/octet-stream
Size: 6468 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020319/e5e1f8b8/attachment-0001.obj>


More information about the MapServer-users mailing list