Michal

I hope I understood your question correctly...:

the following code returns all class indexes for the provided layer and full map extent that appear in the data.

$me = $map->extent;
$layer->open();
$status = $layer->whichShapes($me);
$classWithData = array();
while ($shape = $layer->nextShape()) {
    $shpIdx = $shape->index;
    $clsIdx = $layer->getClassIndex($shape);
    if (!in_array($clsIdx, $classWithData) && $clsIdx >= 0) {
        $classWithData[] = $clsIdx;
    }
}
$layer->close();

You could use this to get first all classes *with* data and then calculate the difference of this array with the array of total classes. The resulting array should contain the classes that are *not represented in the data* , like

$allClasses = range(0, $layer->numclasses-1);
$noDataList = array_diff($allClasses, $classWithData);
print_r($noDataList);


Note however that this works like listed above only for layers that have the same projection as the map. If both projections are different then the call of "$layer->nextShape()" causes a segmentation fault (in both MS 5.6 and 6). In this case you need to re-project the layer beforehand to the projection of the map, then it should work.

Armin


On 17/12/2011 22:35, Michal Seidl wrote:
I would like to get in PHP/Python environment the list of CLASSes which do
not target any data. The situation is like this.

1) I am interested only in vector data
2) I have mapfile and running mapserver
3) There is LAYER with many CLASSes which are defined by EXPRESSION in
mapfile

Any suggestion how get classes with no data?

Thanks Michal

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Get-MAP-file-CLASSes-with-no-data-empty-tp7104765p7104765.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to