[mapserver-dev] Boolean class expression Mapserver 7.2

Karin Kuipers Karin.Kuipers at kartverket.no
Fri Jan 4 06:43:40 PST 2019


Hi Steve,

Good new year and my apologies for the late reaction.
Thank you for looking into it!

The data is stored in a postgres database.
Type: boolean in a materialized view.
When opening the table it shows TRUE and FALSE. When calling it using SQL the output shows t and f
SELECT DISTINCT something FROM table
I don't think this is relevant though.

Your examples look good so I guess you are right and this is wms specific

CLASS
      NAME "Eiendomsgrense"
      #EXPRESSION (("[fromtable]" == "eiendomsgrense") && ("[something]" == 'f'))
      EXPRESSION (("[fromtable]" == "eiendomsgrense") && ("[something]" != 't'))
            STYLE
        MAXWIDTH 1.8
        MINWIDTH 0.7
        COLOR 255 0 0
      END
    END

Again thank you for your time.

With kind regards,
Karin
Fra: Lime, Steve D (MNIT) [mailto:steve.lime at state.mn.us]
Sendt: 21. desember 2018 22:35
Til: Lime, Steve D (MNIT) <steve.lime at state.mn.us>; Karin Kuipers <Karin.Kuipers at kartverket.no>; mapserver-dev at lists.osgeo.org
Emne: RE: Boolean class expression Mapserver 7.2

I've been unable to replicate the bug using straight MapServer expressions and Postgres. Both 7.0.7 and 7.2.1 work as expected, which makes me think we're not talking about the same thing. I setup a layer like so:

LAYER
  NAME 'test'
  STATUS DEFAULT
  TYPE POLYGON
  CONNECTIONTYPE postgis
  CONNECTION 'host=localhost port=5432 dbname=foo password=**** user=****'
  DATA "shape FROM (SELECT objectid, shape, 'f' as something  FROM mytable) as foo USING UNIQUE objectid USING SRID=26915"
  CLASS
    EXPRESSION ("[something]" == 'f')
    STYLE
      COLOR 255 0 0
    END
  END
END

The expression handling in MapServer behaves as expected. All features are drawing with "[something]" == 'f' or "[something]" != 'k' and none are drawn with "[something]" == 'k' or "[something]" != 'f'. In the expression case MapServer is doing the expression evaluation. I also tried using a filter where Postgres is doing the evaluation and the filter is translated, so:

LAYER
  NAME 'test'
  STATUS DEFAULT
  TYPE POLYGON
  CONNECTIONTYPE postgis
  CONNECTION 'host=localhost port=5432 dbname=foo password=**** user=****'
  DATA "shape FROM (SELECT objectid, shape, 'f' as something  FROM mytable) as foo USING UNIQUE objectid USING SRID=26915"
  FILTER ("[something]" == 'f')
  CLASS
    STYLE
      COLOR 255 0 0
    END
  END
END

Again, both versions behave as expected. I guess I'll need more info to be of any assistance... Perhaps this is specific to WMS?

--Steve

From: mapserver-dev [mailto:mapserver-dev-bounces at lists.osgeo.org] On Behalf Of Lime, Steve D (MNIT)
Sent: Thursday, December 20, 2018 9:55 AM
To: Karin Kuipers <Karin.Kuipers at kartverket.no<mailto:Karin.Kuipers at kartverket.no>>; mapserver-dev at lists.osgeo.org<mailto:mapserver-dev at lists.osgeo.org>
Subject: Re: [mapserver-dev] Boolean class expression Mapserver 7.2

What data type is the "something" column in your case? I'll whip up a quick test and see what the translated SQL looks like. --Steve

From: Karin Kuipers [mailto:Karin.Kuipers at kartverket.no]
Sent: Thursday, December 20, 2018 1:11 AM
To: Lime, Steve D (MNIT) <steve.lime at state.mn.us<mailto:steve.lime at state.mn.us>>; mapserver-dev at lists.osgeo.org<mailto:mapserver-dev at lists.osgeo.org>
Subject: SV: Boolean class expression Mapserver 7.2

Hi Steve,

"you're saying you have data where something = 'f' and it works in 7.0 but not in 7.2"
That is indeed what I am trying to say.

The portgis data is 'true' or 'false' (data type boolean) in Mapserver we query this with 't' and 'f'

I have a WMS build in 7.0 with the == 'f' expression
We want to upgrade to 7.2 and during testing the layer with =='f' expression fails.

When changing the expression to != 't' the layer works again.

With kind regards,
Karin

Fra: Lime, Steve D (MNIT) [mailto:steve.lime at state.mn.us]
Sendt: 19. desember 2018 16:55
Til: Karin Kuipers <Karin.Kuipers at kartverket.no<mailto:Karin.Kuipers at kartverket.no>>; mapserver-dev at lists.osgeo.org<mailto:mapserver-dev at lists.osgeo.org>
Emne: RE: Boolean class expression Mapserver 7.2

Hi Karin: All of the example expressions below represent straight string comparisons so for ("[something]" == 'f') to evaluate to true the value for something would need to be 'f', same goes for all the others. 'f', 't' and 'false' are just strings and are not equivalent to true/false - you'd use something like ([something] == true) if you really wanted that type of comparison.

Anyway, just so I understand, you're saying you have data where something = 'f' and it works in 7.0 but not in 7.2?

--Steve

From: mapserver-dev [mailto:mapserver-dev-bounces at lists.osgeo.org] On Behalf Of Karin Kuipers
Sent: Wednesday, December 19, 2018 3:03 AM
To: mapserver-dev at lists.osgeo.org<mailto:mapserver-dev at lists.osgeo.org>
Subject: [mapserver-dev] Boolean class expression Mapserver 7.2

Dear sir/madame,

I think I found an issue with the boolean class expression in Mapserver 7.2

On 7.0 ("[something]" == 'f') works

On 7.2 ("[something]" == 'f') does not work but ("[something]" != 't') works fine and ("[something]" == 'false') is fine as well.

Connection is to a postgis database.

With kind regards,

Karin Kuipers

[logo_sign]

Karin Kuipers
Overingeniør GIS-Specialist
IT-avdelingen, Geodatatjenester -I5
Tlf.: +47 321 13036 mob.:+47 46 213 198
E-post: karin.kuipers at kartverket.no<mailto:karin.kuipers at kartverket.no>

Tlf. sentralbord: 32 11 81 00
Kundesenter: 08700
www.kartverket.no<http://www.kartverket.no/>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20190104/ab8942af/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4450 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20190104/ab8942af/attachment-0001.png>


More information about the mapserver-dev mailing list