[Chameleon] Locate layers

Paul Spencer pspencer at dmsolutions.ca
Thu Feb 24 06:29:22 EST 2005


The number of kbs in a map image depend on several things.  You can 
estimate it from $oMap->width*$oMap->height*8 OR *24 depending on image 
format you are using (note this doesn't account for compression).

Or ... you can use bandwidth monitoring software with your web server

Or ... in drawmap (if you are prepared for it to be a little bit slower) 
you can look for the line:

         $url = $oImage->saveImage("");

around 974 and change it as follows:

$tmpPath = '/some/valid/path/on/your/system/'.uniqid();
$oImage->saveImage( $tmpPath ); //this saves it on your file system
$size = filesize($tmpPath);
unlink($tmpPath);

$url = $oImage->saveImage(""); //this sends it to the browser

Cheers

Paul

Vicente Espinosa Garcia wrote:
> 
> Thank you for your code is perfect for my project, but with this code I 
> only get the layers used in a request and my main problem is to know How 
> many Kbs a wms server send to wms client in a request. I only want to 
> know the Kbs of map sent ( The map that a user see in the secreen). Is 
> posible to get this information in Chameleon source code?. I wait that 
> you understand my question. Thank you very much.
> 
>>
>> You will need to add some custom code in the main application file 
>> (like sample_basic.phtml).
>>
>> The subclass of the Chameleon class that is your application can be 
>> extended to extract the information you need.  On each page load, you 
>> can scan the layers in the map file for those that are on with some 
>> mapscript code like:
>>
>>
>>
>> class SampleApp extends Chameleon
>> {
>>   function SampleApp()
>>   {
>>     parent::Chameleon();
>>     $this->moMapSession = new MapSession_RW;
>>     $this->moMapSession->setTempDir( getSessionSavePath());
>>   }
>>   function CWCDrawPublish()
>>   {
>>     for($i=0;$i<$this->moMapObject->oMap->numlayers;$i++)
>>     {
>>       $oLayer = $this->moMapObject->oMap->getLayer($i);
>>       if ($oLayer->status == MS_ON || $oLayer->status == MS_DEFAULT)
>>       {
>>         //layer is being requested, do some accounting here ...
>>         echo "accessing ".$oLayer->name." from ".$oLayer->data;
>>       }
>>     }
>>     echo $this->moUI->DrawPublish();
>>   }
>> }
>>
>>
>> You could also add this loop to drawmap.php instead.
>>
>> Cheers,
>>
>> Paul
>>
>> Vicente Espinosa Garcia wrote:
>>
>>>
>>>
>>> Hi
>>>
>>> First thanks for your answer and sorry but my english is terrible.I 
>>> want to remake my question, I want to make a log of the requested 
>>> layers for any user. My problem is to get filenames and Kbs of layers 
>>> used in a request. Is  possible to get this data in chameleon source 
>>> code?. thanks.
>>>
>>>
>>>>
>>>> Hi,
>>>>
>>>> I'm not exactly sure what you are asking.  Chameleon uses MapServer 
>>>> to draw the map image.  The layers that are part of the map image 
>>>> are defined in a MAP file that is loaded by MapServer.  In the 
>>>> sample applications, most use the MAP file 
>>>> chameleon/samples/map/chameleon.map.  This file directs MapServer to 
>>>> use the data files from chameleon/samples/data/ and they are mostly 
>>>> shape files.
>>>>
>>>> HTH
>>>>
>>>> Paul
>>>>
>>>> Vicente Espinosa Garcia wrote:
>>>>
>>>>>
>>>>> Hi I'm a newbie in chameleon software. I'm studying the chameleon 
>>>>> source code.I want to get the name and the filename of the layers 
>>>>> that the chameleon load in a request. I have studying the 
>>>>> drawmap.php but I don't have succes in my search. Please help me. 
>>>>> thanks.
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Chameleon mailing list
>>>>> Chameleon at lists.maptools.org
>>>>> http://lists.maptools.org/mailman/listinfo/chameleon
>>>>>
>>>>
>>>> -- 
>>>> +-----------------------------------------------------------------+
>>>> |Paul Spencer                           pspencer at dmsolutions.ca   |
>>>> +-----------------------------------------------------------------+
>>>> |Applications & Software Development                              |
>>>> |DM Solutions Group Inc                 http://www.dmsolutions.ca/|
>>>> +-----------------------------------------------------------------+
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Chameleon mailing list
>>> Chameleon at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/chameleon
>>>
>>
>> -- 
>> +-----------------------------------------------------------------+
>> |Paul Spencer                           pspencer at dmsolutions.ca   |
>> +-----------------------------------------------------------------+
>> |Applications & Software Development                              |
>> |DM Solutions Group Inc                 http://www.dmsolutions.ca/|
>> +-----------------------------------------------------------------+
> 
> 
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 

-- 
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+


More information about the Chameleon mailing list