[Cartoweb-users] passing variables to MapServer (for filtering)

Gustavo Concheiro concheirog at si.edu
Wed Jun 29 16:49:40 EDT 2005


>>> Alexandre Saunier <alexandre.saunier at camptocamp.com> 29/06/05 13:09 >>>

>> How can I do what I used to do with plain MapServer CGI: to pass, as a variable, a user selection, that can then be replaced by MapServer (or PostGIS) as a filter expression.

>I'm not quite sure to understand what you mean!?
>Do you have an example?


Dear Alex:


Ok, here it goes:

LAYER # show birds of a genus labeled by species
  NAME "birds_by_genus"
  GROUP "Panamá birds"
  DATA "birds/pajarracos1-sorted"  
  TYPE POINT
  STATUS OFF
  PROJECTION
    "proj=latlong"
    "ellps=WGS84"
  END # projection
  UNITS DD  
  MAXSCALE 10000000 
  LABELMAXSCALE 1000000
  FILTERITEM "T_AOU_GENU"
  FILTER  "%genus%"
  LABELITEM  "T_AOU_SCI_"
  CLASS
    NAME "birds"
    COLOR 255 51 0 
    OUTLINECOLOR 0 0 0
    SYMBOL 'triangle'
    SIZE 5
    LABEL
      COLOR 255 255 255
      SHADOWCOLOR 51 51 51
      SHADOWSIZE 1 1
      TYPE TRUETYPE
      FONT sans
      SIZE 8
      ANTIALIAS TRUE
      POSITION AUTO
      PARTIALS FALSE
      MINDISTANCE 0
      BUFFER 0
    END # label
  END # class
  TOLERANCEUNITS kilometers	# pixels|feet|inches|kilometers|meters|miles|dd
  TOLERANCE 10	
  HEADER "birds_by_genus_header.html"
  TEMPLATE "birds_all.html"
  FOOTER "birds_all_footer.html"
  DUMP TRUE # allow GML export
END # layer


So, I passed genus as URL variable to the MapServer CGI; the user chose it from a <select> element, say, <option> is «Ara» (a genus of macaws), so MapServer will filter column «T_AOU_GENU» so only those species will be displayed for the layer.

Same goes for other columns, like species, family, database from where the records were pulled, and many others.  REAL useful thing. (Those birdies are a 50000-strong legion, so imagine.)

Oh, the same idea I implemented for PostGIS layers, but in the SQL statement instead of the FILTER element.


About grouping layes, thanks, Marc Monnerat answered before with the same solution, and works just just fine, thanks a million!  As Marc says, it IS in the docs but it is not clear.  

[
I keep having this problem---maybe because I come from biology?---that the documentation for all this MapServer & Friends are hard to understand.  Sure, it tells you HOW to do things, but not WHAT to do.  I spend 95% of the time figuring out the *concepts*---they are just not spelled out.  I'd love to see, not «CartoWeb for dummies», but «CartoWeb for the smart ignorant».  CartoWeb, in fact, is a very minor offender; Chameleon is like crawling through concertina wire... :-P 
]


Best from Panamá,
-gus


Oh, PS, since you are connected (work for?) Camptocamp: who can I contact about contracting tech support, training, and development for our web mapping needs here at STRI?   In GTP (Global Trade Pidgin, also known as «English» ;-), not French.  I did see the «Combien coûte une application basée sur CartoWeb?» but it is not detailed and I see no contact info, and anyway my French is good enough for the souris but not for technical issues, and as for the gringos'... well... :-P  TIA.

-gus




More information about the Cartoweb-users mailing list