[Cartoweb-users] How to keep the drawing from Quey_by_polygon ?

Oliver Christen oliver.christen at camptocamp.com
Tue May 25 02:29:14 EST 2010


Hi Jérémie

The query plugin is not designed to keep displaying the area selected after 
the query.

If you want to have such behavior, you will need to extend the query plugin 
(server side) so the area selected is drawn with the help of the outline 
plugin.

Fortunately the user selection is already passed from client side to server 
side, so all you have to do is add some code, for example in the 
handlePreDrawing function:

class ServerQueryExtended extends ServerQuery {

public function replacePlugin() {
    return 'query';
}

public function handlePreDrawing($requ) {

/* this call the outline plugin and draw the user selection */
$outline= $this->serverContext->getPluginManager()->outline;
$shape = new StyledShape();
$shape->shape = $requ->shape;
$outline->draw(array($shape));

/* dont forget to COPY THE WHOLE handlePreDrawing FUNCTION content from the 
original ServerQuery.php */

}

}

this example DOESNT STORE THE SELECTION IN SESSION!
so the selection will disappear after the next user action.

if you want to keep the area selected, you will need to modify the client 
side of the query plugin so it store the shape (you can access the user 
selection using $this->shape on client side, but only when the user does the 
selection) in the session object and transfer that shape to server side. If 
you do that, I would advice you to set your own object and not use the 
already existing "shape" object, to avoid any side effect with the Query 
server side code:

on client side in buildRequest:
if (!is_null($this->shape)) {
$this->queryState->theUserSelectionShape = $this->shape;
}
if (!is_null($this->queryState->theUserSelectionShape )) {
$queryRequest->theUserSelectionShape = 
$this->queryState->theUserSelectionShape;
}

and use $requ->theUserSelectionShape instead of $requ->shape on server side

regards
Oliver

> In fact I have no problem with the results either the attributes tables 
> (it's OK), neither the highlight of selected object (it's OK).
>
> I need to keep displayed on the map, the polygon drawn by user from the 
> query_by_polygon tool !
> ... even when the results is displayed.
>
> But in your exemple www.geojb.ch, this polygon disappear once the results 
> are displayed.
> So I am still not sure that I can do what I want.
>
> Jeremie
>
>
> -----Message d'origine-----
> De : cartoweb-users-bounces at lists.maptools.org 
> [mailto:cartoweb-users-bounces at lists.maptools.org] De la part de Bruno 
> Friedmann
> Envoyé : jeudi 20 mai 2010 19:21
> À : cartoweb-users at lists.maptools.org
> Objet : Re: [Cartoweb-users] How to keep the drawing from Quey_by_polygon 
> ?
>
> On 05/20/2010 11:12 AM, JOALLAND jérémie wrote:
>> My problem detailed below is quite urgent…
>>
>> Could somebody tell me at least if there is a solution, and if it’s 
>> simple
>> or complex to do it ??
>>
>
> Hi Jeremie, if I understand your needs, they are totally different of what 
> the highlight ?
> (Make queried object visible by highlight them with another color)
>
> You want something like the yellow query zone is visible during the load 
> of result from the server ?
> something like that : http://imagebin.ca/view/1CNc7Q.html
>
> If yes, know's that it work ...
>
>
>
>> Thank you.
>>
>>
>>
>> Jeremie
>>
>>
>>
>> De : cartoweb-users-bounces at lists.maptools.org
>> [mailto:cartoweb-users-bounces at lists.maptools.org] De la part de JOALLAND
>> jérémie
>> Envoyé : mercredi 19 mai 2010 10:35
>> À : cartoweb-users at lists.maptools.org
>> Objet : [Cartoweb-users] How to keep the drawing from Quey_by_polygon ?
>>
>>
>>
>> My web site is unsing CartoWeb 3.5.0 :
>>
>>
>>
>> When I am using the ‘query_by_polygon’ tool on the map, after drawing a
>> polygon, the cartoweb page is reloaded with the Results, but my polygon
>> disappear. So the user cannot remember the area used for his query…
>>
>>
>>
>> How can I keep my polygon as drawing on the map ?? (means the polygon 
>> from
>> query must be visible on the map until the Results are displayed under 
>> the
>> map)
>>
>>
>>
>> Then, how can I remove this polygon ? Is the ‘clean query’ button doing 
>> that
>> ?
>>
>>
>>
>> Thank you.
>>
>>
>>
>> Jérémie
>>
>>
>>
>>
>>
>> _______________________________________________
>> Cartoweb-users mailing list
>> Cartoweb-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>
>
> -- 
>
>     Bruno Friedmann
>
> Ioda-Net Sàrl
>  2830 Vellerat - Switzerland
>  Tél : ++41 32 435 7171
>  Fax : ++41 32 435 7172
>  gsm : ++41 78 802 6760
>  www.ioda-net.ch
>
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
> 



More information about the Cartoweb-users mailing list