[Mapserver-users] Logical expressions in CLASS EXPRESSION

Gerry Creager N5JXS gerry.creager at tamu.edu
Mon Jul 26 08:27:51 EDT 2004


This is a multi-part message in MIME format.
--------------010604040006050405040002
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

See if this snippet helps.  It's a piece from a known, working mapfile.

gerry

Stefanie Weykam wrote:
> Hi folks,
> I have some problems specifying the class by a logical expression in my map
> file.
> 
> I am running MapsServer4.2 on Windows and the layer is a shape file. Data
> type of the field IS numeric (int) and field name IS correct. 
> 
> 
>  CLASSITEM   "Riq50" 
>  CLASS
>     EXPRESSION   ([Riq50]>1) 
>     COLOR         255 0 0
>     OUTLINECOLOR  0 0 0 
>  END  
> 
> This expression works:  EXPRESSION   '1' 
> This one doesn't:           EXPRESSION   ([Riq50]>1) 
> ..which makes me think that the expression is (always? by default?) a string
> comparison expression and the field is read as string. At least as long as
> the data type of the field is string or int - no results with real numbers
> though.
> 
> I have tried all combinations of brackets and quotes and still don't get
> anywhere. Can anybody give me a clue on that???
> 
> My aim is actually to render quantitative data (lets say 4 o 5 classes)
> according to (whatever) data ranges found in the selected data field. I will
> have to intercept the min and max values of the selected field, divide the
> values into 4 or 5 classes (or perhaps quantiles) and assign colors and data
> ranges by logical expressions to the classes.
> 
> Is there any example out there or could somebody give me one?
> 
> Stefanie
> 
> 
> 
> 

-- 
Gerry Creager -- gerry.creager at tamu.edu
Texas Mesonet -- AATLT, Texas A&M University	
Cell: 979.229.5301 Office: 979.458.4020 FAX: 979.847.8578
Page: 979.228.0173
Office: 903A Eller Bldg, TAMU, College Station, TX 77843

--------------010604040006050405040002
Content-Type: text/plain;
 name="pwv.map"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pwv.map"

### This is an extract of a working mapserver mapfile.  
### The class statements allow a different color to be used.
### This is NOT a complete mapfile.

SYMBOL
  NAME 'pwvcircle'
  TYPE ELLIPSE
  FILLED TRUE
  POINTS 10 10 END
END

#
# PWV values
#
LAYER
#SIZEUNITS pixels
PROJECTION
	"init=epsg:4269"
END
  CLASSITEM "pwv"
  NAME weather-pwv
  TYPE POINT
  DATA currentWeather  
#DATA currentPWV
  STATUS ON
#  LABELCACHE on
  LABELITEM "pwv"
  SIZEUNITS kilometers 
 CLASS
    EXPRESSION ([pwv] >= 0.0 AND [pwv] <= 0.05)
    NAME 'PWV 0.00-0.05 in'
    COLOR 224 224 224
    SYMBOL 'pwvcircle'		
    SIZE 15
    LABEL
	FORCE TRUE
      COLOR 140 0 160 
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
#      BUFFER -10  #-15
      BUFFER 1		### Changed 2003-07-13
      PARTIALS TRUE
    END
  END
  CLASS
    NAME '0.05-0.20 in'
    EXPRESSION ([pwv] > 0.05 and [pwv] <= 0.20)
    COLOR 117 117 0
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE
      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
#      BUFFER -10 
      BUFFER 1
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '0.20-0.40 in'
    EXPRESSION ([pwv] > 0.20 and [pwv] <= 0.40)
    COLOR 255 0 0
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE
      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '0.40-0.60 in'
    EXPRESSION ([pwv] > 0.40 and [pwv] <= 0.60)
    COLOR 255 145 46
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '0.60-0.80 in'
    EXPRESSION ([pwv] > 0.600 and [pwv] <= 0.80)
    COLOR 255 237 26
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '0.80-1.00 in'
    EXPRESSION ([pwv] > 0.80 and [pwv] <= 1.00)
    COLOR 166 255 18
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '1.00-1.20 in'
    EXPRESSION ([pwv] > 1.00 and [pwv] <= 1.20)
    COLOR 102 255 0
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '1.20-1.40 in'
    EXPRESSION ([pwv] > 1.20 and [pwv] <= 1.400)
    COLOR 15 255 128
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE
      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '1.40-1.60 in'
    EXPRESSION ([pwv] > 1.400 and [pwv] <= 1.600)
    COLOR 18 224 255
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '1.80-1.60 in'
    EXPRESSION ([pwv] > 1.60 and [pwv] <= 1.800)
    COLOR 18 191 255
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '1.80-2.00 in'
    EXPRESSION ([pwv] > 1.800 and [pwv] <= 2.00)
    COLOR 8 89 255
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
  CLASS
	
    NAME '>2.00 in'
    EXPRESSION ([pwv] > 2.00)
    COLOR 0 0 255
    SYMBOL 'pwvcircle'
    SIZE 15
    LABEL
        FORCE TRUE

      COLOR 140 0 160
      TYPE BITMAP
      SIZE MEDIUM
      POSITION UC
      OFFSET 2 2
      BUFFER 1 
      PARTIALS TRUE
    END
  END
END


END # Map File

--------------010604040006050405040002--




More information about the mapserver-users mailing list