[Cartoweb-users] Highlighting objects in the map

Eduard Witteveen e.witteveen at HAWARIT.COM
Tue Oct 18 10:42:23 EDT 2005


Hello,

I want to make a plugin that highlights certain objects based upon 3 
parameters:
    - layername
    - layerfieldname
    - layerfieldvalue

In order to accomplisch this i made my own plugin, implementing 
FilterProvider and i added a filterPostRequest / filterGetRequest.
Since all the magic is supposed to happening in the filterGetRequest i 
place it here below:

>     public function filterGetRequest(FilterRequestModifier $request) {
> //        //docu: 
> http://www.cartoweb.org/doc/xhtml/dev.newplugin.html      
> //        $id = $request->getValue('id');
> //        if (!is_null($id)) {
> //            $layer = 'grid_classhilight';
> //            $request->setValue('query_layer', $layer);
> //            $request->setValue('query_maskmode', '1');
> //            $request->setValue('query_select', $id);
> //            $request->setValue('id_recenter_layer', $layer);        
> //            $request->setValue('id_recenter_ids', $id);
> //        }
>         // retrieve the values for query
>         $layername = $request->getValue('my_layername');
>         $fieldname = $request->getValue('my_fieldname');
>         $fieldvalues = $request->getValue('my_fieldvalues');
>         // check if any of the variables was set
>         if (is_null($layername) && is_null($fieldname) && 
> is_null($fieldvalues)) {
>             // not specified, return
>             return;
>         }
>         if(is_null($layername)) {
>             die ('parameter: "my_layername" was not set!');
>         }
>         if(is_null($fieldname)) {
>             die ('parameter: "my_fieldname" was not set!');
>         }
>         if(is_null($fieldvalues)) {
>             die ('parameter: "my_fieldvalues" was not set!');
>         }
>         // Query plugin
>         // layer to look for IDs
>         $request->setValue('query_layer', $layername);
>         //  IDs of objects to add to selection
>         $request->setValue('query_select', $fieldvalues);
>         //  IDs of objects to remove from selection
>         // $request->setValue('query_unselect', $fieldvalues);
>         //  selection policy: 'POLICY_XOR', 'POLICY_UNION' or 
> 'POLICY_INTERSECTION', default is 'POLICY_XOR'
>         $request->setValue('query_policy', 'POLICY_XOR');
>         // '0' or '1', default is '0'. If '1', will show selection as 
> a mask
>         $request->setValue('query_maskmode', '0');
>         // '0' or '1', default is '1'. If '0', won't shows selection 
> hilighted        
>         $request->setValue('query_hilight', '1');
>         // '0' or '1', default is '1'. If '0', won't return attributes 
> other than IDs
>         $request->setValue(' query_return_attributes', '1');
>         // '0' or '1', default is '1'. If '0', won't return any table 
> results
>         $request->setValue('query_return_table', '0');
>         // Location plugin
>          // new bounding box, comma-separated coordinates, eg. 
> "10.5,20,15.5,28"
>          // $request->setValue('recenter_bbox', '0');
>         // re-centering: new x-coordinate
>         // $request->setValue('recenter_x', '0');
>         // re-centering: new y-coordinate
>         // $request->setValue('recenter_y', '0');
>         // '0' or '1', default '0'. If '1' display a crosshair on 
> (recenter_x, recenter_y).
>         // $request->setValue('show_crosshair', '0');
>         //  new scale
>         // $request->setValue('recenter_scale', '0');
>         // re-centering on objects: layer to look for IDs
>         $request->setValue('id_recenter_layer', $layername);
>         // re-centering on objects: list of IDs, comma-separated
>         $request->setValue('id_recenter_ids', $fieldvalues);
>         // ID of the selected map size
>         // $request->setValue('shortcut_id', '0');
>     }

As you can see, im totally ignoring this $fieldname at this moment. At 
this moment it doesnt seem to work at all, since searching on "gid" (the 
id-field) doesnt work for me. I get the error:

> *Notice*: Undefined index: line in *C:\cartoweb3\common\Common.php* on 
> line *75*
>
> *Notice*: Undefined index: file in *C:\cartoweb3\common\Common.php* on 
> line *75*
>
>
>   Failure
>
>class:   SoapFault
>message:   Error [8, Undefined index:  line, C:\cartoweb3\common\Common.php, 75]
>Backtrace:
>
>file: 75 - C:\cartoweb3\common\Common.php
>call: Common::cartowebErrorHandler(8, "Undefined index:  line", "C:\cartoweb3\common\Common.php", 75, Array(5))
>
>file: 91 - C:\cartoweb3\common\Common.php
>call: CartowebException->backtrace()
>
>file: 224 - C:\cartoweb3\coreplugins\mapquery\server\ServerMapquery.php
>call: CartowebException->__construct("can't find idAttribute for layer Dubbelbestemming")
>
Well, apparently my =supposed=to=be= id field, wasnt a id field.

So basically i have 2 questions:

1) How do i define this id field? I found the following method, but is 
there also a cartoweb-method?

> METADATA
>
>  "id_attribute_string" "gid|string"
>END 
>
2) How can i search on fields other than the id field? (more important 
for me)


PS: Since i know that we are working under the gpl licence, i want to 
postback code. Please let me know where i can drop code, or should i 
place this on my own website?


-- 
Ing. Eduard Yeb Witteveen           Software Engineer
Hawar Information Technology bv   lid Dijkoraad Groep
De Wymerts 7  8701 WT                        Bolsward
Tel: +31 (0)515 570333         Fax: +31 (0)515 570335
http://www.hawarit.com/             nl_NL fy_NL en_US



More information about the Cartoweb-users mailing list