[mapserver-users] layer classification with MapScript

Mr. Puneet Kishor punk.kish at gmail.com
Sun Aug 28 14:27:41 EDT 2011


On Aug 28, 2011, at 8:11 AM, Cristiano Sumariva wrote:

> You can do database stuff using your programming language to access the
> database.
> 
> To create classes there is the msNewClassObj function to append a class to
> an layer reference.
> You can get function details in documentation page at
> http://mapserver.org/mapscript/php/index.html#classes.
> 
> If you want walk over records from the data statement declared on the data
> field, maybe using the getShape(  ), getNumResults() method on your layer
> reference may do what you want. But I do not have practice using it.
> 
> for ( loop = 0; loop < layer->getNumResults(); loop + 1 )
> dbRowFromDataField = layer->getResult( loop );
> class = msnewclass( layer );
> class->set( name, dbRowFromDataField.field );
> ...


The above seems logical, but I think it might have to do with the results from a "click" query rather than the data retrieved by MS from the data source in the first place. In any case, the following doesn't do anything at all (empty, white image) --

    for ( 0 .. $layerObj->getNumResults() - 1) {
        my $row = $layerObj->getResult( $_ );
        my $classObj = new mapscript::classObj( $layerObj );
        $classObj->{name} = $row->{interval_name};
        my $styleObj = new map script::styleObj( $classObj );
	set style color based on $row->{class_color};
    }

> 
> 
> 2011/8/27 Mr. Puneet Kishor <punk.kish at gmail.com>
> 
>> I have a layer classification issue. I want to do something along the lines
>> of (semi-pseudocode ahead) --
>> 
>>   $layerObj->{data} = 'the_geom FROM (SELECT gid, the_geom, class_name,
>> class_color FROM table) t USING UNIQUE gid';
>>   $layerObj->{classitem} = 'class_name';
>> 
>>   while (my $row in $layerObj->{data}) {
>>       create class with 'name = class_name', 'expression = class_name',
>> 'color = class_color'
>>   }
>> 
>> How do I iterate over the rows retrieved from the table in order to create
>> classes? I don't see any obvious reference to a db result
>> set._______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> 



More information about the mapserver-users mailing list