[MapServer-users] creating a layer with PHP MapScript - shapes do not use classindex

Worth Lutz wal3 at mindspring.com
Mon Oct 16 09:49:18 PDT 2023


Hi,

I've come to the same conclusion this morning about using a different 
layer for each style.  It should work with the way my data is arriving 
from the client. It just seems like a more complicated method.

I cannot change to the SWIG MapScript at the moment. Too much to change. 
That will happen when we build the next server with an OS version jump.

Thanks for your suggestions.

*Worth Lutz*


On 10/16/23 10:29, Seth G wrote:
> Hi,
>
> You could probably achieve this with the new SWIG MapScript.
>
> Alternatively how about creating an individual LAYER for each set of 
> features with a single CLASS (I'm not sure how the CLASS is determined 
> if the features have no attributes in the first place), and adding 
> features to the relevant layer.
>
> If you then want to combine these into a single layer you could try a 
> UNION LAYER [1], and use the STYLEITEM AUTO to pick up the styles from 
> the layers.
>
> Seth
>
> [1] https://mapserver.org/mapfile/union.html
> [2] https://mapserver.org/mapfile/union.html#classes-and-styles
>
>
> --
> web:https://geographika.net & https://mapserverstudio.net
> twitter: @geographika
>
> On Mon, Oct 16, 2023, at 2:57 PM, Worth Lutz wrote:
>> Hi,
>>
>> I had thought of trying that but the attributes in the values are 
>> read-only. Since i created the shapeObj from WTK there are no values.
>>
>> I'm using v7 of MapServer and the old PHP mapscript. There does not 
>> appear to be a way for me to set attributes on these shapes which are 
>> being passed down from an OpenLayers client app.
>>
>> I had thought of setting a single class and putting the different 
>> colors, etc, in as attribute values in the shapeObj but cannot find a 
>> way to write them to the object.
>>
>> I'll try any suggestions given.
>>
>> Thanks,
>>
>> *Worth Lutz*
>>
>> On 10/16/23 03:59, Seth G wrote:
>>> Hi,
>>>
>>> The rendering code could be reassigning the classindex for the 
>>> shapes based on their attributes. You will probably need to make 
>>> sure the CLASS is assigned based on an attribute of the feature - 
>>> e.g. add a CLASSITEM to the layer and add a value to the feature 
>>> that will match the correct CLASS.
>>>
>>> Seth
>>>
>>> --
>>> web:https://geographika.net <https://geographika.net> & 
>>> https://mapserverstudio.net <https://mapserverstudio.net>
>>> twitter: @geographika
>>>
>>> On Sun, Oct 15, 2023, at 3:12 PM, Worth Lutz via MapServer-users wrote:
>>>> HI,
>>>>
>>>> I'm trying to create a layer to insert into a map. I have shapes in 
>>>> WKT and am trying to insert them into a layer and draw it to a pdf.
>>>>
>>>> It works fine if I only have one class for the shapes. I am trying 
>>>> to add several classes to the layer to draw in different colors. I 
>>>> cannot get the shapes to use the proper class.
>>>>
>>>> Here is what I'm doing.
>>>>
>>>> After creating a layer and adding all the classes, I add the shapes.
>>>>
>>>>     for (i = 0, ii = count($features); $i < $ii; i++) {
>>>>     $shape = ms_shhapeObjFrom Wkt($features[$i]->geometry);
>>>>     $shape->set('classindex', $features[$i]->classindex);
>>>>     $success = $layer->addFeature($shape);
>>>>     }
>>>>
>>>> The shapes draw but all use $class[0].
>>>>
>>>> If I add this line in before the draw,
>>>>
>>>>     $layer-moveclassup(1);
>>>>
>>>> all the shapes are drawn with that class.
>>>>
>>>> I have been able to verify that the classes exist in the layerObj 
>>>> and that the classindex in the shapeObj points to the proper class.
>>>>
>>>> Does anyone have any ideas why the drawing code is not using the 
>>>> classindex to draw these shapes in different colors?
>>>>
>>>> What am I doing wrong?
>>>> --
>>>> *Worth Lutz*
>>>>
>>>> _______________________________________________
>>>> MapServer-users mailing list
>>>> MapServer-users at lists.osgeo.org 
>>>> <mailto:MapServer-users at lists.osgeo.org>
>>>> https://lists.osgeo.org/mailman/listinfo/mapserver-users 
>>>> <https://lists.osgeo.org/mailman/listinfo/mapserver-users>
>>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20231016/f27cbafe/attachment-0001.htm>


More information about the MapServer-users mailing list