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

Josh Hevenor jhevenor at rogers.com
Thu Mar 25 10:19:36 EDT 2010


I think I came across the same thing, or something related, when I was
trying to generate KML using mapserver templates.   I know I ended up
recreating the class expression in my output instead of using the
[shpclass] variable.  Let me know if a bug is filed and I'll work up an
example to submit.  (mapserver 5.2)

Josh

Alan Boudreault wrote:
> 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
>>
>>     
>
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.437 / Virus Database: 271.1.1/2769 - Release Date: 03/25/10 07:33:00
>
>   


More information about the mapserver-users mailing list