[mapserver-users] PHP mapscript createLegendIcon doesn't follow style maxscaledenom

Moen, Paul T. pmoen at nd.gov
Thu Mar 30 08:45:13 PDT 2017


I am finding that createLegendIcon returns a different legend item than what is used in the map output when using scaledenom in the style.

Below is a test script that produces what I am talking about.

The script will create 4 images.

map_scale_873.png -> map->draw output with a 873 scaledenom
map_scale_2618.png -> map->draw with a 873 scaledenom
legimg_scale_873.png -> createLegendIcon output with a 873 scaledenom
legimg_scale_2618.png -> createLegendIcon output with a 873 scaledenom


I was expecting that the legend image at the 873 scale, legimg_scale_873.png would match the map output, map_scale_873.png.  Can anyone see a problem, is this a bug, or is this expected behavior?

<?php

$mapstr = <<<EOT
MAP
                NAME AERIAL
                EXTENT 100 100 400 400
                SIZE 100 100
                UNITS FEET
                LAYER
                                NAME 'TEST'
                                STATUS ON
                                TYPE LINE
                                FEATURE
                                                WKT 'LINESTRING(250 250, 250 500, 500 500, 500 250,250 250)'
                                END
                                CLASS
                                                NAME "Boundary"
                                                STYLE
                                                                WIDTH 4.0
                                                                MAXWIDTH 6.0
                                                                COLOR 150 255 150
                                                                MAXSCALEDENOM 1000
                                                END
                                                STYLE
                                                                WIDTH 2.0
                                                                MAXWIDTH 2.0
                                                                COLOR 0 0 0
                                                                PATTERN 20.0 10.0 5.0 10.0 END
                                                                MAXSCALEDENOM 1000
                                                END
                                                STYLE
                                                                WIDTH 4.0
                                                                MAXWIDTH 4.0
                                                                COLOR 150 255 150
                                                                MINSCALEDENOM 1001
                                                END
                                                END
                                END
                END
END
EOT;

                $map = ms_newMapObjFromString($mapstr);
                $map->selectOutputFormat('png');
                $img=$map->draw();
                $name=round($map->scaledenom);
                $img->saveImage("map_scale_$name.png");
                $tmpLay =$map->getLayer(0);
                $tmpclass = $tmpLay->getClass(0);
                $tmpImg = $tmpclass->createLegendIcon(50,50);
                $tmpImg->saveImage("legimg_scale_$name.png");
                $map->setextent(200,200,300,300);
                $img2=$map->draw();
                $name=round($map->scaledenom);
                $img2->saveImage("map_scale_$name.png");
                $tmpImg->saveImage("legimg_scale_$name.png");

?>

Thanks,

Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20170330/ae653a3c/attachment-0001.html>


More information about the mapserver-users mailing list