[mapserver-users] Fwd: MapServer 7 arithmetic expressions do not work on STYLE attributes?

Seth G sethg at geographika.co.uk
Thu Jun 16 05:47:22 PDT 2022


Hi,

Couldn't you just add a new field to the DATA clause and use that?

`DATA "geom from (select pk, geom, size, (size * 2) as mycolor from sizes_of_thing) USING srid 3788 version 11g" `
`CLASS `
`MAXSCALEDENOM 5001 `
`STYLE `
`    COLOR [`mycolor`]`

Or maybe this is a cut-down example.

`Seth`
``
--
web:https://geographika.net
twitter: @geographika


On Thu, Jun 16, 2022, at 11:04 AM, Andi p3 Domi wrote:
> I am trying to port my code from MapServer 5 (Oracle) to MapServer 7 (PostgreSQL), but I am encountering an issue when trying to apply arithmetic expressions in the style class. So previously in MapServer 5 I would have something like:
> 
> `DATA "geom from (select pk, geom, size from sizes_of_thing) USING srid 3788 version 11g"
> CLASS
>     MAXSCALEDENOM 5001
>     STYLE
>         COLOR [size*2]
`
> Which worked perfectly fine: But if I convert it to MapServer 7 and PostgreSQL like:
> 
> `DATA "geom from (select pk, geom, size from sizes_of_thing sot) USING unique pk USING srid=3788"
> CLASS
>     STYLE
>         COLOR [size*2]
`
> Throws an error such as:
> 
> `msPostGISLayerWhichShapes(): Error (ERROR:  column "size*2" does not exist
`
> By any chance are these expressions not supported anymore in MapServer 7/PostGIS or am I doing something wrong?
> 
> What I have tried so far is to write something like
> 
> `SIZE [size]*2
> SIZE ([size]*2)
`
> create an expression like:
> 
> `EXPRESSION ("size2" "[size]*2")
`
> And use it in something like:
> 
> `SIZE [size2]
`
> create a validation variable such as:
> 
> `VALIDATION
> "size2" '[size]*2'
`
> and then
> 
> `SIZE [size2]
`
> But it seems like none of them work.
> 
> _______________________________________________
> MapServer-users mailing list
> MapServer-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20220616/d07644da/attachment.htm>


More information about the MapServer-users mailing list