Re: [mapserver-users] Filtering NULL values from Postgis Layer in Mapserver 7

2016-08-17 Thread Lime, Steve D (MNIT)
The filter option is still there - it's just implemented as a processing option 
instead. So what was:

  FILTER 'myitem != NULL'

Becomes:

  PROCESSING 'NATIVE_FILTER=myitem != NULL'
  
This bypasses any translation idiosyncrasies as pointed out in this thread.

Steve  

-Original Message-
From: mapserver-users [mailto:mapserver-users-boun...@lists.osgeo.org] On 
Behalf Of deduikertjes
Sent: Wednesday, August 17, 2016 4:09 AM
To: mapserver-users@lists.osgeo.org
Subject: Re: [mapserver-users] Filtering NULL values from Postgis Layer in 
Mapserver 7

Andreas, 

Thank you. 

hmm, that's very interesting. Lets see if I understand correctly:

I observe that in the CLASS EXPRESSIONs in a Postgis layer NULL is treated
as zero for numeric fields. So NULL gets visualized in the class where zero
is visualized. In my opinion that is not very desirable. I actually would
expect a default behaviour where NULL values will not match any CLASS
EXPRESSION.

In Mapserver 6 we luckily had the FILTER option to filter out the NULL
values to remedy this behaviour. Not very elegant but very doable.

Now in Mapserver 7 we lost the FILTER option and have to write a subselect
in the DATA statement to get rid of NULL values. That seems to be a rather
complicated solution for something which seems to be a very common task.

Or am I missing something and is there a way to avoid that NULL values end
up as being treated as 0?

MArco



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Filtering-NULL-values-from-Postgis-Layer-in-Mapserver-7-tp5280893p5281035.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Re: [mapserver-users] Filtering NULL values from Postgis Layer in Mapserver 7

2016-08-17 Thread Eichner, Andreas - SID
Hello Marco,

IMHO the best solution would be to implement a "IS NULL" operator or function 
for the mapserver expressions. I guess this was not implemented because MS was 
originally developed for rendering ESRI-Shapefiles which do not support NULL 
values.

According to http://mapserver.org/cgi/runsub.html#table-of-contents 
LAYER/PROCESSING should support runtime substitution since 7.0 so you could try 
to use the 'NATIVE_FILTER' processing option with something like '%MY_VAR1% is 
not null and %MY_VAR2% is not null' (very much like your FILTER in MS 6.4):

PROCESSING "NATIVE_FILTER=%MY_VAR1% is not null and %MY_VAR2% is not null"

If that does not work (check the debug log if the statement build has 
substitutions applied) your only solution would be to use the DATA statement 
with a sub-select. Something like:

DATA "the_geom from (select gid, the_geom, %MY_VAR1% as attr1, %MY_VAR2% as 
attr2 from
  geotable where %MY_VAR1% is not null and %MY_VAR2% is not null) as 
subquery
  using unique gid using srid=4326"

Hopefully one of that works for you...

> -Ursprüngliche Nachricht-
> Von: mapserver-users [mailto:mapserver-users-boun...@lists.osgeo.org] Im
> Auftrag von deduikertjes
> Gesendet: Mittwoch, 17. August 2016 11:09
> An: mapserver-users@lists.osgeo.org
> Betreff: Re: [mapserver-users] Filtering NULL values from Postgis Layer in
> Mapserver 7
> 
> Andreas,
> 
> Thank you.
> 
> hmm, that's very interesting. Lets see if I understand correctly:
> 
> I observe that in the CLASS EXPRESSIONs in a Postgis layer NULL is treated
> as zero for numeric fields. So NULL gets visualized in the class where
> zero
> is visualized. In my opinion that is not very desirable. I actually would
> expect a default behaviour where NULL values will not match any CLASS
> EXPRESSION.
> 
> In Mapserver 6 we luckily had the FILTER option to filter out the NULL
> values to remedy this behaviour. Not very elegant but very doable.
> 
> Now in Mapserver 7 we lost the FILTER option and have to write a subselect
> in the DATA statement to get rid of NULL values. That seems to be a rather
> complicated solution for something which seems to be a very common task.
> 
> Or am I missing something and is there a way to avoid that NULL values end
> up as being treated as 0?
> 
> MArco
> 
> 
> 
> --
> View this message in context: http://osgeo-
> org.1560.x6.nabble.com/Filtering-NULL-values-from-Postgis-Layer-in-
> Mapserver-7-tp5280893p5281035.html
> Sent from the Mapserver - User mailing list archive at Nabble.com.
> ___
> mapserver-users mailing list
> mapserver-users@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Re: [mapserver-users] Filtering NULL values from Postgis Layer in Mapserver 7

2016-08-17 Thread deduikertjes
Andreas, 

Thank you. 

hmm, that's very interesting. Lets see if I understand correctly:

I observe that in the CLASS EXPRESSIONs in a Postgis layer NULL is treated
as zero for numeric fields. So NULL gets visualized in the class where zero
is visualized. In my opinion that is not very desirable. I actually would
expect a default behaviour where NULL values will not match any CLASS
EXPRESSION.

In Mapserver 6 we luckily had the FILTER option to filter out the NULL
values to remedy this behaviour. Not very elegant but very doable.

Now in Mapserver 7 we lost the FILTER option and have to write a subselect
in the DATA statement to get rid of NULL values. That seems to be a rather
complicated solution for something which seems to be a very common task.

Or am I missing something and is there a way to avoid that NULL values end
up as being treated as 0?

MArco



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Filtering-NULL-values-from-Postgis-Layer-in-Mapserver-7-tp5280893p5281035.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Re: [mapserver-users] Filtering NULL values from Postgis Layer in Mapserver 7

2016-08-16 Thread Eichner, Andreas - SID
Hello Marco,

in MapServer expressions you cannot test for NULL values and the NATIVE_FITLER 
processing key does not support runtime substitutions. You could try to use a 
sub-select directly in the DATA as described in 
http://mapserver.org/input/vector/postgis.html#table-of-contents 

HTH

> -Ursprüngliche Nachricht-
> Von: mapserver-users [mailto:mapserver-users-boun...@lists.osgeo.org] Im
> Auftrag von deduikertjes
> Gesendet: Dienstag, 16. August 2016 12:54
> An: mapserver-users@lists.osgeo.org
> Betreff: [mapserver-users] Filtering NULL values from Postgis Layer in
> Mapserver 7
> 
> Hi,
> 
> In mapserver 6 I use the following to filter out records containing NULL
> values in a Postgis layer (I am using runtime substitution for MY_VAR1 and
> MY_VAR2):
> 
> FILTER (NOT (%MY_VAR1% IS NULL OR %MY_VAR2% IS NULL))
> 
> This is working fine, but doesn't work in mapserver 7 anymore as
> documented
> in  http://mapserver.org/MIGRATION_GUIDE.html#mapserver-6-4-to-7-0-
> migration
> <http://mapserver.org/MIGRATION_GUIDE.html#mapserver-6-4-to-7-0-migration>
> According to that page I have to write the FILTER statement in the
> MapServer
> expression syntax.
> 
> So now I'm trying to do so but I am not winning. I cannot find a way to
> properly detect NULL values using MapServer expression syntax. Is there
> any
> way writing such a filter without using a PROCESSING 'NATIVE_FILTER='
> construct?
> 
> Any help greatly appreciated, MArco
> 
> 
> 
> 
> --
> View this message in context: http://osgeo-
> org.1560.x6.nabble.com/Filtering-NULL-values-from-Postgis-Layer-in-
> Mapserver-7-tp5280893.html
> Sent from the Mapserver - User mailing list archive at Nabble.com.
> ___
> mapserver-users mailing list
> mapserver-users@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

[mapserver-users] Filtering NULL values from Postgis Layer in Mapserver 7

2016-08-16 Thread deduikertjes
Hi,

In mapserver 6 I use the following to filter out records containing NULL
values in a Postgis layer (I am using runtime substitution for MY_VAR1 and
MY_VAR2):

FILTER (NOT (%MY_VAR1% IS NULL OR %MY_VAR2% IS NULL)) 

This is working fine, but doesn't work in mapserver 7 anymore as documented
in  http://mapserver.org/MIGRATION_GUIDE.html#mapserver-6-4-to-7-0-migration
  
According to that page I have to write the FILTER statement in the MapServer
expression syntax.

So now I'm trying to do so but I am not winning. I cannot find a way to
properly detect NULL values using MapServer expression syntax. Is there any
way writing such a filter without using a PROCESSING 'NATIVE_FILTER='
construct?

Any help greatly appreciated, MArco




--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Filtering-NULL-values-from-Postgis-Layer-in-Mapserver-7-tp5280893.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users