Re: [mapserver-users] php Mapscript queryByAttributes

2017-10-13 Thread Lime, Steve D (MNIT)
Ticket is https://github.com/mapserver/mapserver/issues/5490... --Steve

From: Carlos Ruiz [mailto:boolean10...@yahoo.com]
Sent: Thursday, October 12, 2017 12:55 PM
To: Lime, Steve D (MNIT) ; 
mapserver-users@lists.osgeo.org; Sven Schroeter 
Subject: Re: AW: RE: [mapserver-users] php Mapscript queryByAttributes

Sven,

This is a good workarround. It's weird why the IN operator is not working for 
Postgres but as Steve wrote, a ticket will be opened.

On Thursday, October 12, 2017, 8:04:46 AM CDT, Sven Schroeter 
> wrote:


Hi Steve and Carlos,

thanks for your support.

When I understand it correctly, I can not use the IN operator in conjunction 
with queryByAttributes in Mapserver 7 (mapscript) ?
I use this function so far for the transfer of different IDs (whether integer 
or string) to read out a subset of POSTGIS tables.
I have now tried the following and it works:

$qstring = "([gid] = '1' || [gid] = '2' || [gid] = '4' || [gid] = '11')";
$query_layer->queryByAttributes("gid",$qstring,MS_MULTIPLE);

Maybe it is possible to get the IN operator back in the future?

Sven

Von: Lime, Steve D (MNIT) 
[mailto:steve.l...@state.mn.us]
Gesendet: Mittwoch, 11. Oktober 2017 23:33
An: Carlos Ruiz; 
mapserver-users@lists.osgeo.org; Sven 
Schroeter
Betreff: RE: RE: [mapserver-users] php Mapscript queryByAttributes

Ugh, my bad. At least with the LIKE operator it’s because MapServer doesn’t 
support it. Using a regex should work depending on your back-end. Which reminds 
me, which backend are you using? I need to investigate the IN operator. It 
maybe that I can come up with a work around for Sven using the native SQL that 
worked previously since that can still be set as a processing option. Will 
report back…

Steve

From: Carlos Ruiz [mailto:boolean10...@yahoo.com]
Sent: Wednesday, October 11, 2017 4:03 PM
To: mapserver-users@lists.osgeo.org; 
Sven Schroeter >; Lime, Steve D 
(MNIT) >
Subject: Re: RE: [mapserver-users] php Mapscript queryByAttributes

Hey Steve,

> the IN operator works off a delimited list, try queryByAttributes("gid", 
> "([gid] IN ‘100,101’)", MS_MULTIPLE);. Any whitespace > is considered part of 
> the tokens in a list.

I have tried this and it doesn't work. There's a query error because Mapserver 
try to add the following: and ("gid"'100,101')

> This is close, it’s a logical expression but you’re comparing a number 
> against a string. It should be
> queryByAttributes("municipio", "(‘[municipio]’ LIKE 'G%')", MS_MULTIPLE);

I have tried this and it doesn't work. There's a query error because Mapserver 
try to add the following: and ("municipio"::text'G%')

Maybe this happens because the MS4W version (3.1.3) with Mapserver CGI 7.0.1


On Wednesday, October 11, 2017, 2:31:41 PM CDT, Lime, Steve D (MNIT) 
> wrote:


The query syntax is given in MapServer expression syntax. I think there’s a 
logical expression for why you’re seeing these results:

  queryByAttributes("gid", "gid > 100", MS_MULTIPLE) // does not found anything

is evaluated as gid = “gid > 100”. Valid but not what you’re looking for. Your 
last example is the right way to do it - queryByAttributes("gid", "([gid] > 
100)", MS_MULTIPLE);. If MapServer sees the qstring is a logical expression 
then it ignores the qitem.
  queryByAttributes("gid", "100", MS_MULTIPLE) // found one result

is evaluated as gid = 100 which makes sense.

  queryByAttributes("municipio", "'GUADALAJARA'", MS_MULTIPLE) // found one 
result

is evaluated as municipio = GUADALAJARA which makes sense. I don’t think you 
need the interior quotes around GUADALAJARA though.

  queryByAttributes("municipio", "municipio LIKE 'G%'", MS_MULTIPLE) // does 
not found anything

like the first example this evaluates as municipio = "municipio LIKE 'G%'", not 
what you want. See below…

  queryByAttributes("gid", "([gid] IN (100, 101))", MS_MULTIPLE); // query error

the IN operator works off a delimited list, try queryByAttributes("gid", 
"([gid] IN ‘100,101’)", MS_MULTIPLE);. Any whitespace is considered part of the 
tokens in a list.

  queryByAttributes("municipio", "([municipio] LIKE 'G%')", MS_MULTIPLE); // 
query error

This is close, it’s a logical expression but you’re comparing a number against 
a string. It should be queryByAttributes("municipio", "(‘[municipio]’ LIKE 
'G%')", MS_MULTIPLE);

Steve

From: mapserver-users 
[mailto:mapserver-users-boun...@lists.osgeo.org]
 On Behalf Of Carlos Ruiz
Sent: Wednesday, October 11, 2017 1:36 PM
To: mapserver-users@lists.osgeo.org; 
Sven Schroeter 

Re: [mapserver-users] passing variables to includes

2017-10-13 Thread lars . schylberg

Hi Jörg,

I also had this same thought and it would be a good mechanism. 
But I solved it with my own preprocessing. 

I have been doing Nautical charts with Mapserver for a 
couple of years and realized that I was reusing 
the same layers up to 18 times.  

So I did templates where I had LAYER->NAME, LAYER->GROUP, 
LAYER->DATA and STYLE->COLOR as variables in Mapserver templates.  
Color for instance has fixed names like “DEPVS”, 
that means depth very shallow.  
But depending on if it is day mode, dawn dusk mode or night mode 
the colors have different rgb or hex values.  
All variables are stored in csv files.  The variables are read into 
associative arrays in a bash script.  Then  I use my Mapserver 
mapfile templates that are processed with a very long sed statement 
that substitutes the variables depending on color mode and scale level.   

Layer names and groups have one csv file that tells how to 
assemble all the layers.  To make it even more flexible, I can 
also use offical IHO colors, Swedish or French color tables 
to get different look and feel.

An example is for instance the layer template for rivers:

 Rivers Lines 

LAYER
    NAME  "Rivers_line_{CL}"
    GROUP "{GROUP}"
    METADATA
    "ows_title"   "Rivers"
    "ows_enable_request"   "*"
    "gml_include_items" "all"
    "wms_feature_mime_type" "text/html"
    END
    TEMPLATE blank.html
    TYPE LINE
    STATUS ON
    MAXSCALEDENOM {MAXSCALE}
    DATA "{PATH}"
    CLASS
    NAME "Rivers (lines)"
    STYLE
   # DEPVS
   # RGB # COLOR {DEPVS_rgb}
   COLOR "{DEPVS}"
   WIDTH 1.5
   # RGB # COLOR {OUTLL_rgb}
   OUTLINECOLOR "{OUTLL}"
   OUTLINEWIDTH 0.3
    END
    END
END


All this can be seen in the git hub:  https://github.com/LarsSchy/SMAC-M 
I finally got permission from my company to release it this summer, so that we 
can discuss this.
I would like to do a demo site with open data, but haven't had time to do this 
yet.

The script: process_layer_color.sh shows the real processing part and the sed 
script. 

https://github.com/LarsSchy/SMAC-M/blob/master/chart-installation/generate_map_files/scripts/process_layer_colors.sh

Have fun 

Lars Schylberg
Saab AB


-Originalmeddelande- 
> Från: "Jörg Thomsen (WhereGroup)"  
> Till: mapserver-users@lists.osgeo.org 
> Datum: 2017-10-13 09:43 
> Ämne: [mapserver-users] passing variables to includes 
> 
> Hi,
> 
> I had a MapServer Training this week and one of the participations asks
> a nice question:
> 
> Is it possible to pass variables to includes? I think this is a very
> good idea, it could save a lot of includefiles. In know it's very close
> to mapscript, but has anyone done this without?
> 


___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users

[mapserver-users] passing variables to includes

2017-10-13 Thread WhereGroup
Hi,

I had a MapServer Training this week and one of the participations asks
a nice question:

Is it possible to pass variables to includes? I think this is a very
good idea, it could save a lot of includefiles. In know it's very close
to mapscript, but has anyone done this without?

sth like

 include layer.inc.map(soil, blah.shp, clay, 255 0 0)

and in layer.inc.map

Layer
  NAME '%0%'
  data '%1%'
  METADATA
wms_title '%0%'
...
  END
  CLASS
NAME '%2%'
STYLE
   SYMBOL 'hatch'
   COLOR %3%'
   OUTLINECOLOR  0 0 0
   SIZE 5
   WIDTH 15
   ANGLE 45
END
...




Viele Grüße,
Jörg

-- 

-
Aufwind durch Wissen!
Qualifizierte Open-Source-GIS-Schulungen
bei der www.foss-academy.com
-

Jörg Thomsen
WhereGroup GmbH & Co. KG
Gillweg 3
14193 Berlin
Germany

Fon: +49 (0)30 / 5130 278 74
Fax: +49 (0)30 / 89 09 53 21

joerg.thom...@wheregroup.com
www.wheregroup.com
Amtsgericht Bonn, HRA 6788
---
Komplementärin:
WhereGroup Verwaltungs GmbH
vertreten durch:
Olaf Knopp, Peter Stamm
---
Folgen Sie der WhereGroup auf twitter: http://twitter.com/WhereGroup_com
___
mapserver-users mailing list
mapserver-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users