Opened 10 years ago

Last modified 10 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


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:

NAME 'test' 
SIZE 400 400 
EXTENT 0 0 100 100 

NAME 'Airports' 
TYPE point 
FEATURE POINTS 10 10 50 50 1 50 70 10 END END 
SYMBOL 'airport.gif' 

$oMap = ms_newMapObjFromString($mapDef); 
//First problem: returns -1 
//echo $oLayer->type; 

//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); 
$img = $oMap->draw(); 

Attachments (1)

airport.gif (67 bytes) - added by joefranklin 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by joefranklin

Attachment: airport.gif added


comment:1 Changed 10 years ago by dmorissette

Cc: sdlime added
Owner: changed from mapserverbugs to aboudreault

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 Changed 10 years ago by aboudreault

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 Changed 10 years ago by aboudreault

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 Changed 10 years ago by aboudreault

Cc: hobu added
Note: See TracTickets for help on using tickets.