Opened 14 years ago
Last modified 14 years ago
#3273 new defect
layer->updateFromString problem setting type and symbol name
Reported by: | joefranklin | Owned by: | aboudreault |
---|---|---|---|
Priority: | normal | Milestone: | 5.6.1 release |
Component: | MapScript-PHP | Version: | 5.6 |
Severity: | major | Keywords: | updateFromString |
Cc: | sdlime, hobu |
Description
I really like the updateFromString functions in Mapserver Mapscript. I've eliminated my .map files, instead storing the layer definitions in a database and drawing them on-demand using PHP. However, I've found a few values ($layer->type and $style->symbolname) that aren't correctly set using Mapserver 5.6.1 (also tried 5.4.2). Here's an example:
<?php $mapDef="MAP NAME 'test' SIZE 400 400 EXTENT 0 0 100 100 END "; $layerDef="LAYER NAME 'Airports' STATUS ON TYPE point FEATURE POINTS 10 10 50 50 1 50 70 10 END END CLASS STYLE SYMBOL 'airport.gif' END END END"; $oMap = ms_newMapObjFromString($mapDef); $oLayer=ms_newLayerObj($oMap); $oLayer->updateFromString($layerDef); //First problem: returns -1 //echo $oLayer->type; //$oLayer->set("type",MS_LAYER_POINT); //Second problem is that the symbol gif isn't used //unless it is explicitly set again below //$cls = $oLayer->getClass(0); //$style = $cls->getStyle(0); //if($style->symbolname!='')$style->set("symbolname",$style->symbolname); $oMap->selectOutputFormat('gif'); $img = $oMap->draw(); $img->saveImage("output.gif"); ?>
Attachments (1)
Change History (5)
by , 14 years ago
Attachment: | airport.gif added |
---|
comment:1 by , 14 years ago
Cc: | added |
---|---|
Owner: | changed from | to
There are at least two classes of issues here:
1- symbolname support: after loading a map, loadMapInternal() (mapfile.c) loops through layers and classes to resolve symbol names. We need to do something similar in updateFromString(). This should affect all versions of MapScript, not just PHP, unless something was done for this already in the SWIG bingings.
2- Class members such as layer->type are not properly updated in PHP MapScript after the call to updateFromString(). This is due to the way the PHP wrappers are implemented and would be trickier to fix. There may be some new callback magic that we could use in PHP5 to improve the way we handle class member variables and their mapping to the C structs... something to investigate.
comment:2 by , 14 years ago
1- I've added appropriate loop in the updateLayerFromString and updateClassFromString functions. I cannot do the same thing for updateStyleFromString function since I can't access the layer/map object. I have done something to verify the symbolname inside PHP mapscript... but still wondering how to do it in swig bindings...
2- This is fixed with the php refactoring.
comment:3 by , 14 years ago
Fixed and committed in r10261. I don't think it's possible to do something similar of what I've done for php style updateFromString function in swig... so in all swig bindings, the updateFromString method of the style object will not resolve symbol names.
comment:4 by , 14 years ago
Cc: | added |
---|
airport.gif