[mapserver-users] Querying a dynamic layer
woodbri at swoodbridge.com
woodbri at swoodbridge.com
Thu Sep 19 18:06:35 PDT 2002
Jonathan,
You need to read the gmap75 code a little closer. I think you will
find that the query code does not use the rendering code. What this
means to you is that just as you have to create the dynamic data
layer for the rendering code you need to ALSO add a similar block to
create the dynamic data layer in the appropriate place for the query
code to pick it up. It has been a while since I looked at that code,
but I'm pretty sure that it has 2 different paths for query and
render.
I hope this helps,
-Stephen Woodbridge
http://iMapTools.com
On 20 Sep 2002 at 9:01, Jonathon Coombes wrote:
> Hi All,
>
> i am relatively new to mapserver, and I have tried a number of ways to
> solve this problem, but nothing seems to work. Here is the scenario:
>
> I have a mapfile which defines a number of layers for cities, rivers
> and water areas. These are standard shape files etc, and query fine. I
> also create a dummy layer dynamically from data retrieved by sql from
> a database. This returns the lat/longitude and some other data
> relating to descriptions and numbers etc. It all seems to work fine,
> but it does not query either by point or rectangle.
>
> Here are the different approaches I have tried:
>
> * Create the metadata directly using the setMetaData function.
> * I have added the template line within the class, which I found was
> a necessary part of the query.
> * I tried adding a labelitem.
> * I created a shapefile using newShapeFileObj and adding data in. *
> Set the data to the datafile name. (Creates the data files fine)
>
> The basis of code is the standard GMap demo. It is running on a
> Windows system (not my choice :) and PHP/Mapscript. Here is the
> code I have to generate the data layer:
>
> // The query is run and it populates the sites[] array with
> // the data from the sql database.
>
> $dummy_layer = $gpoMap->getLayerByName('dummy');
> $dummyclass = ms_newClassObj($dummy_layer);
> $dummy_layer->set("labelitem", "NEAR_TOWN");
> $dummy_layer->set("template", "ttt.html");
> $dummy_layer->set("data","query");
>
> $figura = ms_newShapeObj(MS_SHAPE_LINE);
> $ponto_obj = ms_newLineObj();
> $numpoints = count($sites_1);
> for ($i=0; $i < $numpoints; $i++) {
> $point = ms_newPointObj();
> $point->setXY($sites[$i]['lon'],$sites[$i]['lat']);
> $ponto_obj->add($point);
> $figura->add($ponto_obj);
> $point->free();
> }
>
> // Create shape-file
> $shfile = ms_newShapefileObj("./data/query", MS_SHP_MULTIPOINT);
> $shfile->addShape($figura); $shfile->free();
>
> // Set all the necessary MetData for the points
> $dummy_layer->setMetaData("RESULT_FIELDS", "NEAR_TOWN NUMBER DATE");
> $dummy_layer->setMetaData("DESCRIPTION", "This is the Description");
>
> $dummy_layer = $gpoMap->getLayerByName("dummy");
> $dummy_layer->addFeature($figura);
> $dummy_layer->set("status", MS_ON);
>
> My MAP file contains the following for the dummy layer:
>
> LAYER
> NAME dummy
>
> TYPE POINT
> STATUS OFF
> CLASS
> NAME 'dummy'
> COLOR 255 0 0
> SYMBOL 'circle'
> SIZE 7
> TEMPLATE "ttt_query.html"
> END
>
> TOLERANCE 5
>
> END
>
> Also, is this the best way to do a dynamic layer? I want to be able to
> create the dynamic layer and then use it for the session without
> having to do the sql query every time the map is redrawn. Any better
> way of doing this?
>
> Any help here would be most appreciated.
>
> Regards,
> Jonathon
>
>
More information about the MapServer-users
mailing list