Thanks for the contrib. I will test it soon and see how it can be 
implemented.

Just a question as you mentioned that the default function was slow: 
When you tried, did you have set an index on the OID field? Without that 
index it can be very slow with Postgis layers as it has to do a seq scan 
to retrieve all features with the defined id. PG without indexes is 
really slow...

armin



Gail Long wrote:
> I bugged Armin a lot and he has always been very helpful.  I'd be happy to 
> help out with some contributions.
> 
> Here is a good way to do the hilighting so that you don't have to add all of 
> the lines to each shapes.  It scales better and works much much faster.  It 
> works best with POSTGIS layers, but thats mostly what I deal with.  My users 
> rarely ever query shape file based layers.
> 
> I based this off of a VERY modified 1.0.8 p.mapper.  In incphp/map.php 
> replace pmap_checkResultLayers function and the the highlighting function 
> that follows it with this.  On the older p.mapper versions you should be 
> able to just drop it in.
> 
> All it does is create a dynamic layer by cloning the one that will be 
> highlighted.  Then it writes it over the one being queried.  This works well 
> if you need to have a big query limit set or you have lots of features in a 
> layer.
> 
>     /*
>      * CHECK IF THERE ARE RESULTLAYERS TO ADD
>      ********************************************************/
>     function pmap_checkResultLayers()
>     {
>       if (isset($_GET["resultlayer"]))
>       {
>         $resultlayerStr = $_GET["resultlayer"];
> 
>         if ($resultlayerStr == "remove")
>         {
>           session_unregister("resultlayers");
>         }
>         else
>         {
>           $resultlayer = explode(" ", $resultlayerStr);
>           $reslayname = $resultlayer[0];
>           $shpindexes = explode("|", $resultlayer[1]);
>           $resultlayers[$reslayname] = $shpindexes;
>           $_SESSION["hilayer"] = $reslayname;
>           $_SESSION["resultlayers"] = $resultlayers;
>           $this->pmap_addhiLayer($reslayname, $shpindexes);
>         }
>       }
>       elseif (isset($_SESSION["resultlayers"]))
>       {
>         $resultlayers = $_SESSION["resultlayers"];
> 
>         foreach ($resultlayers as $reslayer => $shpindexes)
>         {
>           $this->pmap_addhiLayer($reslayer, $shpindexes);
>         }
>       }
>     }
>     /*
>      * FOR ZOOM TO SELECTED.
>      * Adds a new layer to the map for highlighting feature
>      *****************************************************************/
>     function pmap_addhiLayer($layerIn, $shpindexes)
>     {
> 
>       if(!$layerIn)
>         $layerIn = $_SESSION['activegroup'];
> 
>       $reslayers = $_SESSION['resultlayers'];
> 
>       if(!$reslayers)
>       {
>         $objects = $shpindexes;
>       }
>       else
>       {
>         $objects = $reslayers[$layerIn];
>       }
> 
>       $clone = $this->map->getLayerByName($layerIn);
> 
>       $newResLayer = ms_newLayerObj($this->map);
>       $newResLayer->set('type',$clone->type);
>       $newResLayer->set('name','target');
>       $newResLayer->set('data',$clone->data);
>       $newResLayer->set('connection',$clone->connection);
>       $newResLayer->set('connectiontype',$clone->connectiontype);
> 
>       $newResLayer->set('classitem','oid');
>       $newResLayer->set('status',MS_ON);
> 
>       $limit = sizeof($objects);
> 
>       for($ii = 0;$ii < $limit;$ii++)
>       {
>         if($objects[$ii] != '')
>         {
>         if($ii == $limit - 1)
>             $filterstring .= $objects[$ii];
>         else
>             $filterstring .= $objects[$ii].'|';
>         }
>       }
> 
>       if($limit > 0 || $_SESSION['queryresults'] || $filterstring != '')
>       {
>         $hiClass = ms_newClassObj($newResLayer);
>         $hiClass->set('status',MS_ON);
>         $hiClass->setExpression('/'.$filterstring.'/');
> 
>         // SELECTION COLOR
>         $iniClrStr = trim($_SESSION["highlightColor"]);
>         $iniClrList = preg_split('/[\s,]+/', $iniClrStr);
>         $iniClr0 = $iniClrList[0];
>         $iniClr1 = $iniClrList[1];
>         $iniClr2 = $iniClrList[2];
> 
>         $hiStyle = ms_newStyleObj($hiClass);
>         $hiStyle->set('symbolname','circle');
>         $hiStyle->outlinecolor->setRGB($iniClr0,$iniClr1,$iniClr2);
>         if($_SESSION["marker"] != 'outline')
>         $hiStyle->color->setRGB($iniClr0,$iniClr1,$iniClr2);
> 
>         //increase the width of the line as we move out
>         if($_SESSION['geo_scale'] > 80000)
>            $symSize = 12;
>         else
>         {
>            $symSize = ($qlayType < 1 ? 5 : 3);
>         }
> 
>         $hiStyle->set('size',5);
> 
>         $this->hiliteLayer = $newResLayer;
>       }
>     }
> 
> 
> 
> --
> Things are only difficult while you don't understand them.
> 
> 
> 
> _______________________________________________
> Pmapper-users mailing list
> Pmapper-users at faunalia.it
> http://faunalia.it/cgi-bin/mailman/listinfo/pmapper-users
> 
> 

Reply via email to