[Cartoweb-users] Passing variable to mapserver

Oliver Christen oliver.christen at camptocamp.com
Tue Mar 18 02:53:01 EDT 2008


to pass variable from client to server, there is an example there 
http://www.cartoweb.org/cwiki/HowToDisplayOnTheMapAPointFromADatabaseQuery
and also quite a lot more scatered in the past mailing list messages.

regards
Oliver



> Oliver, I have implemented this on Server side:
>
> class ServerExampleRecentering extends ClientResponderAdapter {
>
>    /**
>     * @var Logger
>     */
>    private $log;
>
>    /**
>     * @var objet
>     */
>    private $layer;
>
>
>    /**
>     * Constructor
>     */
>    function __construct() {
>        parent::__construct();
>        $this->log =& LoggerManager::getLogger(__CLASS__);
>    }
>
>
>    /**
>     * @see ClientResponder::initializeRequest()
>     */
>    function initializeRequest($requ) {
>        if ($requ)
>            $this->layer = $requ->layer;
>    }
>
>
>
>    /**
>     * Result is set in initializeRequest but Outline must be called
>     * in handlePreDrawing
>     * @see ClientResponder::handlePreDrawing()
>     */
>    function handlePreDrawing($requ) {
>        if ($requ) {
>       $layer = new LayerOverlay();
>            $layer->name = "mylayer";
>            $layer->data = "the_geom from (SELECT *, geocodifica2.the_geom 
> FROM servizi, geocodifica2 WHERE servizi.gid = geocodifica2.gid)" .
>                       "AS foo USING UNIQUE gid USING SRID=4326";
>            $layer->filter = "servizio_uno = 'Y' and indirizzo ilike 
> '%{$id}%  '";   $mapOverlay = $this->serverContext->getPluginManager()
>            if (empty($pluginManager->mapOverlay))
>                throw new CartoserverException("mapOverlay plugin not 
> loaded, "
>                                               . "and needed to draw the 
> new layer");
>            $mapOverlay->updateMap($layer);
>        }
>    }
>
> }
>
>
>
> But, how can I declare $id defined by 
> filterPostRequest(FilterRequestModifier $request) from Client side of my 
> plugin?
>
> Thanks
>
> Oliver Christen ha scritto:
>> you cant do it like that
>> you need to use mapOverlay to set the filter dynamicaly
>>
>> http://www.cartoweb.org/doc/cw3.4/xhtml/dev.mapoverlay.html#dev.mapoverlay.usage.filter 
>> (second example)
>>
>> regards
>> Oliver
>>
>>> Hi!
>>> I want to pass variable "myvar" to mapserver taken from 
>>> "filterPostRequest(FilterRequestModifier $request)" implemented in my 
>>> own cartoweb plugin.
>>>
>>> In the map file LAYER I've written:
>>>
>>>
>>> ....
>>>
>>>      CONNECTIONTYPE postgis
>>>      CONNECTION "user=******password=*****dbname=indirizzi 
>>> host=localhost port=5432"
>>>      DATA "the_geom from (SELECT *, geocodifica2.the_geom FROM servizi, 
>>> geocodifica2 WHERE servizi.gid = geocodifica2.gid) as foo using unique 
>>> gid using SRID=4326"
>>>      FILTER "servizio_uno = 'Y' and indirizzo ilike '%'\%myvar%'\ %'"
>>>
>>>
>>> ....
>>>
>>>
>>> How can I do to display my layer correctly?
>>> "ilike" and "%" are my problems....
>>>
>>> Thanks a lot !
>>>
>>> -- 
>>> Ing. Fabio D'Ovidio
>>>
>>> iQuadro - Informatica e Innovazione s.r.l.
>>> Via C. Pisacane 23, Aversa (CE) - 81031
>>> Web : www.ii2.it
>>> Tel.: 081 197 57 600
>>> mail: fabiodovidio at gmail.com
>>>
>>> _______________________________________________
>>> Cartoweb-users mailing list
>>> Cartoweb-users at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>>
>>
>>
>
> -- 
> Ing. Fabio D'Ovidio
>
> iQuadro - Informatica e Innovazione s.r.l.
> Via C. Pisacane 23, Aversa (CE) - 81031
> Web : www.ii2.it
> Tel.: 081 197 57 600
> mail: fabiodovidio at gmail.com
>
> 



More information about the Cartoweb-users mailing list