Opened 15 years ago
Last modified 15 years ago
#2975 new enhancement
PHP Mapscript should only update the parameters specified
| Reported by: | youknowho | Owned by: | mapserverbugs |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | MapScript-PHP | Version: | 5.2 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Extra undefined/unwanted parameters are being appended to a map file when using PHP MapScript. The additional information that is added is:
STYLE
ANGLE 360
OPACITY 100
SYMBOL 0
END
As an example, a CLASS that originally looks like:
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
after using the following MapScript code to change ONLY the DATA parameter:
<?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);
?>
The expected behavior is that PHP MapScript will only update the specified DATA parameter and nothing else.
Note:
See TracTickets
for help on using tickets.

Using the same PHP MapScript code originally posted, PHP MapScript is changing more than first noted. The following changes occur:
MAP configuration before script:
OUTPUTFORMAT NAME PNG24 DRIVER "GD/PNG" MIMETYPE "image/png" IMAGEMODE RGB EXTENSION "png" FORMATOPTION "INTERLACE=OFF" ENDMAP configuration after script:
The layer that I am dynamically changing starts as:
LAYER NAME "arrow" TYPE POLYGON PROJECTION "init=epsg:4326" END METADATA "wms_title" "arrow" END DATA shapefiles/arrow STATUS ON TRANSPARENCY ALPHA CLASS STYLE ANTIALIAS TRUE COLOR 255 0 0 OUTLINECOLOR 0 0 0 END ## Style END ## Class END ## Layerand after PHP MapScript runs looks like:
LAYER DATA "shapefiles/arrow" METADATA "wms_title" "arrow" END NAME "arrow" PROJECTION "init=epsg:4326" END STATUS ON OPACITY ALPHA TYPE POLYGON UNITS METERS CLASS STYLE ANGLE 360 ANTIALIAS TRUE COLOR 255 0 0 OPACITY 100 OUTLINECOLOR 0 0 0 SYMBOL 0 END END ENDThrough a flag, configuration, directive, etc for PHP MapScript, please enable it to ONLY change the parameters supplied in the script, and not alter/add/remove additional map parameters.