[mapserver-users] PHP MapScript: shape->classindex is always 0

Alan Boudreault aboudreault at mapgears.com
Thu Mar 25 07:07:35 PDT 2010


Hi Peter,

If you are sure that the shape use the different classes you specified in the 
mapfile (you probably see it in your map image), so I guess it could be a bug. 
Please fill a ticket with a test case. Assign it to "aboudreault". 

regards,
Alan

On March 24, 2010 06:38:49 am Peter Hopfgartner wrote:
> Hello
> 
> As I interpreted this, classindex should point to the right class of the
> instantiated shape. Unfortunatly, classindex is always 0.
> 
> As a test I have a LAYER with 2 classes,
>     CLASS
>        NAME 'class1'
>        EXPRESSION (([class] eq 1))
>        STYLE
>          SYMBOL "circle"
>          SIZE 7.0
>          OUTLINECOLOR 0 0 0
>          COLOR 0 128 0
>        END
>     END
>     CLASS
>        NAME 'class2'
>        EXPRESSION (([class] eq 2))
>        STYLE
>          SYMBOL "circle"
>          SIZE 7.0
>          OUTLINECOLOR 0 0 0
>          COLOR 0 0 128
>        END
>     END
> 
> In the PostGIS database are 4 point, 2 with class=1 and 2 with class=2,
> the generated map image shows the expected colors.
> 
> The following script:
> 
> <?php
> $mapfile = 'test.map';
> $map = ms_newmapobj($mapfile);
> $layer = $map->getLayerByName('test');
> $status = $layer->open();
> $status = $layer->whichShapes($map->extent);
> while ($shape = $layer->nextShape())
> {
>    echo "index: {$shape->index}\tclassindex: {$shape->classindex}\n";
> }
> $layer->close();
> ?>
> 
> the following output:
> 
> index: 0    classindex: 0
> index: 1    classindex: 0
> index: 2    classindex: 0
> index: 3    classindex: 0
> 
> which is not what I expected.
> 
> Am I missing something obvious or is this a MapServer bug?
> 
> Regards,
> 
> Peter
> 

-- 
Alan Boudreault
Mapgears
http://www.mapgears.com



More information about the MapServer-users mailing list