[Chameleon] Querying dynamic built layers
Ken Sanderson
ken at rockies.ca
Wed Mar 16 15:05:58 EST 2005
Yes, here is the phpmapscript chunk of my script.
Ken
$poLayer = ms_newLayerObj($this->moMapSession->oMap);
$poLayer->set("name", "Your Point Summary");
$poLayer->set("status", MS_OFF);
$poLayer->set("type", MS_LAYER_POINT);
$poLayer->set("labelcache", MS_OFF);
$poLayer->set("labelmaxscale",30000.0);
$poLayer->set("labelminscale",1.0);
$poLayer->set("template","ttt_query.html");
$poClass = ms_newClassObj($poLayer);
$poClass->set("name", "dynamic point summary class");
$poClass->label->set("font","sans");
$poClass->label->set("type","truetype");
$poClass->label->set("size",7);
$poClass->label->set("position","auto");
$poClass->label->set("force","TRUE");
$poClass->label->color->setRGB(0,0,0);
$poClass->label->outlinecolor->setRGB(225,240,180);
$poClass->label->shadowcolor->setRGB(225,240,180);
$poClass->label->set("offsetx",1);
$poClass->label->set("offsety",1);
$poClass->label->set("buffer",10);
$poClass->set("template","ttt_query.html");
$poStyle = ms_newStyleObj($poClass);
$poStyle->set("symbolname","star");
$poStyle->set("size", 15);
$poStyle->color->setRGB(250, 160, 5);
$poStyle->outlinecolor->setRGB(0,0,0);
//go through point array and use each item
for ($i=0;$i<count($pointsarray);$i++){
$pt = ms_newPointObj();
$ln = ms_newLineObj();
$shp = ms_newShapeObj(MS_SHAPE_POINT);
$pt->setXY($pointsarray[$i][2],$pointsarray[$i][3]);
$ln->add($pt);
$shp->add($ln);
$shp->set("text",$pointsarray[$i][1]);
$shp->set("index",$i);
$poLayer->addFeature($shp);
}
Eric Bridger wrote:
> Are you calling $layer->addFeature() as well?
>
>
> On Wed, 2005-03-16 at 14:40, Ken Sanderson wrote:
>
>>Thanks Eric for the reply.
>>
>>I am not sure I understand the issue with chameleon. I added the layer
>>to the session map object so that it would remain between map draws,
>>basically for the life of the session. How would this conflict with the
>>query attempt?
>>
>>Basically I have done the equiv of the perl script you have linked, only
>>I did it with PHP mapscript, now possible thanks to them making index a
>>write-able property for php mapscript.
>>
>>So I have a layer loaded to the map, I have points being displayed, with
>> appropriate labels, I just cant use the query widget on that layer, or
>>rather it always returns 0 records.
>>
>>Ken
>>
>>Eric Bridger wrote:
>>
>>>There is a work around that I have used for this type of thing using
>>>mapscript (Perl). I call $point->draw() and then create a single point
>>>line shape from that point (setting the $shape->index to my numeric key
>>>value and call $layer-addFeature($shape). This adds the point as a
>>>feature to the layer and it is queryable and should return the index you
>>>used. There is a Perl example of this here:
>>>http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PerlMapScriptExamples42ex1
>>>
>>>
>>>BUT there is a problem with this approach when using Chameleon. In
>>>Chameleon the map object is cached in your session and I've found that
>>>all features added to the map are retained between map draws.
>>>
>>>You might be able to get around this by calling $map->removeLayer() but
>>>I have not tested this.
>>>
>>>
>>>On Wed, 2005-03-16 at 13:05, Ken Sanderson wrote:
>>>
>>>
>>>>Hello all.
>>>>
>>>>I have setup a script that queries a database and retrieves a bunch of
>>>>points. I then create a layer object that I added to the map object for
>>>>these points. Each of these points shows up on the map, each has a
>>>>label, and I have used the new change to the index property to add an
>>>>index value for each point, sequentially. All works, no errors.
>>>>
>>>>I 'thought' that I could just add the template value and then this layer
>>>>would be queryable using the query tool. Obviously it will not return
>>>>any data other than the shape_index and other inherient values, but for
>>>>now thats all I wanted to check.
>>>>
>>>>However this is not the case. The query returns the layer in the list of
>>>> layers that didnt return results, but never returns any values.
>>>>
>>>>Any ideas why this is?
>>>>
>>>
>>>
>>>_______________________________________________
>>>Chameleon mailing list
>>>Chameleon at lists.maptools.org
>>>http://lists.maptools.org/mailman/listinfo/chameleon
>>>
>>
>
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
>
More information about the Chameleon
mailing list