[mapserver-users] PHP MapScript inserting extra parameters into .map file
Ian
iansgis at gmail.com
Wed Apr 8 13:02:28 PDT 2009
I'm using PHP MapScript to change layers' DATA parameters as the user
selects options in an OpenLayers 2.7/MapServer 5.2 WMS setting. This
is working fine however I just noticed that extra undefined/unwanted
information is being appended to the map file when my script runs.
Specifically:
STYLE
ANGLE 360
OPACITY 100
SYMBOL 0
END
is appended to each CLASS so what was originally:
CLASS
EXPRESSION ([pixel] >= 155 AND [pixel] < 164)
COLOR 28 28 28
END
becomes:
CLASS
EXPRESSION ([pixel] >= 155 AND [pixel] < 164)
STYLE
ANGLE 360
COLOR 28 28 28
OPACITY 100
SYMBOL 0
END
END
Is there a way to prevent MapScript from doing this? My script is:
<?php
// Grab POST parameters
$mapFile = $_POST['mapFile'];
$layerString = $_POST['layers'];
// Separate layers on comma
$layers = explode(",", $layerString);
// Load MapServer .map file
$map = ms_newMapObj($mapFile);
// Update map file with each layer
for ($i = 0; $i < sizeof($layers); ++$i) {
$layerPrefix = explode("_", $layers[$i]);
$layer = $map->getLayerByName($layerPrefix[0]);
// Change DATA parameter for layer
$layer->set("data", 'path/to/data/' . $layers[$i]);
}
// Finished editing, save .map file
$map->save($mapFile);
?>
Thank you,
Ian
More information about the MapServer-users
mailing list