Class Names not saved?
Ben Loh
benpub at INQUIRIUM.NET
Thu Sep 1 22:43:45 PDT 2005
Hi,
I'm putting together a historical map application for high
school/college level students and am running into some problems with
setting class names.
Perhaps I'm missing something obvious, but here's what's happening:
I want to dynamically create classes for a given map (In the full
app, I create classes, for the test app, I'm just changing an
existing class). So, I read in the map, get the layer, and set the
class name to a new name. Everything looks fine until I try to get
the class name from the layer again: the class name reverts to the
default name defined in the .map file! Is this some kind of
referencing problem that I'm overlooking? Any help would be much
appreciated.
Thanks!
Ben
Here's a snippet of my map file:
============================================================
LAYER
NAME "PersonSqK"
DATA states1790
STATUS ON
TYPE POLYGON
CLASS
NAME "Orig Class Name"
EXPRESSION ([PERSONSSQK] <= 305)
STYLE
COLOR 255 255 255
OUTLINECOLOR 153 153 153
END #STYLE
END #CLASS
END #LAYER
And here's some test code to generate the error:
============================================================
<?php
dl('php_mapscript.so');
function dbgout( $text ) { echo $text.'<br>'; }
$map = ms_newMapObj( 'classtest.map' );
$allLayers = $map->getAllLayerNames();
foreach($allLayers as $a) {
$theLayer = $map->getLayerByName($a);
$baseClass = $theLayer->getClass( 0 );
dbgout( 'baseClass default name = '.$baseClass->name);
// This displays: "Orig Class Name"
// Try setting the name to something new
$baseClass->name = 'Replaced Name';
dbgout( 'baseClass changed name = '.$baseClass->name);
// This displays: "Replaced Name", so far everything is fine.
}
foreach($allLayers as $a) {
$theLayer = $map->getLayerByName($a);
$baseClass = $theLayer->getClass( 0 );
dbgout( 'baseClass reread name = '.$baseClass->name);
// This displays: "Orig Class Name"!!!! Where did the replaced name go?
}
?>
You can test this on my server:
http://benloh.com/hmapstaging/projects/1790/classtest.php
--
b e n l o h . . . i n q u i r i u m
. design for learning . mobile 773-220-8889 (primary line)
. www.inquirium.net . voice 773-947-0450
. ben at inquirium.net . fax 773-947-6764
More information about the MapServer-users
mailing list