[Chameleon] legendtemplate problem: numlayers

Yewondwossen Assefa assefa at dmsolutions.ca
Thu Aug 12 11:56:05 EDT 2004


Here is a simple script with gmap data and the results :

<?php

dl("php_mapscript_43.dll");

$oMap = ms_newMapobj("c:/msapps/gmap-ms40/htdocs/gmap75.map");

echo "before add layer : " . $oMap->numlayers . "<br>";
$oLayer = ms_newlayerobj($oMap);
echo "after add layer : " . $oMap->numlayers . "<br>";


$oLayer = $oMap->getlayerbyname("popplace");
echo "before add class : " . $oLayer->numclasses . "<br>";
$oClass = ms_newclassObj($oLayer);
echo "after add class : " . $oLayer->numclasses . "<br>";

$oClass = $oLayer->getclass(0);
echo "before add style : " . $oClass->numstyles . "<br>";
$oStyle = ms_newstyleobj($oClass);
echo "after add style : " . $oClass->numstyles . "<br>";


?>


Results are :

  before add layer : 11
after add layer : 12
before add class : 2
after add class : 3
before add style : 1
after add style : 2



  I do not think that this is a mapscript problem. Maybe It is just a 
caching problem.

Later,

Paul Spencer wrote:

> Um, this was broken when we used it last fall for building Studio and 
> working with both classes and styles through mapscript.  We now make it 
> standard practice to refetch objects when anything has changed because 
> synchronization just doesn't happen.
> 
> In fact, Zak was having problems with this for the aggregator until he 
> rewrote the code to basically save and open the map file again because 
> layer objects get very messed up (esp metadata I think) when you use 
> them over again.
> 
> I just assumed that this was "the way it worked" with PHP and was a 
> limitation of the way PHP works with extensions and C 
> structures/objects, not necessarily a problem with MapScript.  If you 
> think it should work, however, then perhaps there is some other problem?
> 
> I'm not sure if this is a chameleon problem, I would have to dig into 
> it.  I know in the case of Studio the problem was easily reproducible 
> outside of Chameleon.  I guess we would need to do the same thing here.
> 
> Bart, if possible, can you produce a short php/mapscript test case 
> outside of chameleon that replicates the problem?  If you cannot 
> replicate it then it is likely a chameleon issue.
> 
> Cheers,
> 
> Paul
> 
> Daniel Morissette wrote:
> 
>> Paul Spencer wrote:
>>
>>> Bart,
>>>
>>> I think there is some problem with PHP and extensions, for instance 
>>> if you add a class then layer->numclasses is not updated unless you 
>>> refetch the layer ($oLayer = $oMap->getLayer( 0 ) for instance) ... 
>>> this synchronization (or lack thereof) seems to cause all kinds of 
>>> problems.
>>>
>>
>> Are you sure that it's not Chameleon or the widget that's caching the 
>> numlayers value?  (Bart's problem seems to be with numlayers, not 
>> numclasses BTW)
>>
>> I seem to remember a problem related to that in PHP MapScript but it 
>> would have been fixed a long time ago (back in 2002 according to CVS 
>> logs). I just checked in the 4.2 source and the $layer->numclasses is 
>> synchronized after creating a new class. Same with the $map->numlayers 
>> when adding a new layer.
>>
>> Daniel
> 
> 


-- 
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst

Email: assefa at dmsolutions.ca
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------




More information about the Chameleon mailing list