# The annotated map file (sort of)
# Created by Pericles S. Nacionales for the MapServer tutorial
# 2005-06-23
# Maintained & enhanced since by Jeff McKenna, GatewayGeo
# 2021-11-19 last updated
#
# Map files begin with map keyword to signify the start of the map object.
# Well, the entire map file is THE map object.  Enclosed between MAP and END 
# at the very bottom of this map file, are keyword/value pairs and other 
# objects.
MAP
  NAME           EX3_
  IMAGETYPE      png24
  EXTENT         166221 -371954 1505849 632767 # LAEA
  #EXTENT         -97.5 41.619778 -82.122902 49.38562 # Geographic
  SIZE           400 300
  SHAPEPATH      "../data"
  SYMBOLSET      "../symbols/symbols.txt"
  FONTSET        "../fonts/fonts.txt"
  
  #URLCONFIG     'example3*'

  # When changing any of the mapfile parameters via the web interface, you
  # need to define a TEMPLATEPATTERN.  This is required for security reasons.
  # Since the example filenames in section 2 begin with "example2" (as in
  # example2-1.html or example2-2.html), you can use it as the pattern.
  # The template pattern is a regular expression used by MapServer to match the 
  # value of map_web_template variable against.
  TEMPLATEPATTERN 'example3*'


  # The web object is defined at the level below the map object.  All
  # web-related parameters (I interchange "parameters" and "keyword/value
  # pairs" quite frequently, sorry about that) are defined in this object.
  WEB
    HEADER    '../templates/example3_header.html'
    #FOOTER    '../templates/example3_footer.html'
    FOOTER    '../templates/example3_footer_querymap.html'
    TEMPLATE  'to be replaced by map_web_template variable in section3.html'
    IMAGEPATH '/ms4w/tmp/ms_tmp/'
    IMAGEURL  '/ms_tmp/'
    VALIDATION
     'queryfile' '.*'
    END #validation
  END # Every object in MapServer must have an END.;)


  # The projection object is typically used within the map and the layer
  # objects. You only define it once within the map object and this definition
  # becomes your output projection--MapServer will render your maps in this
  # projection.  You also use the projection object within the layer object to
  # define your input projection.  Your layers can be in different
  # projections--MapServer will reproject them into your output projection.
  # If no projection is defined within the layer object, MapServer assumes
  # your input projection is the same as your output projection.  This is not
  # a required object unless you're creating a map file that supports one of
  # the OGC interoperability web services specifications (WMS/WFS/WCS).
  PROJECTION
    # Projection parameters can be defined in two ways...
    # This is the traditional PROJ definition of Lambert Azimuthal Equal-Area
    # projection for the Continental U.S.
    #  "proj=laea"
    #  "ellps=clrk66"
    #  "lat_0=45"
    #  "lon_0=-100"
    #
    # Alternatively, you can specify an EPSG code.
    # This is the EPSG code for Lambert Azimuthal Equal-Area
    # projection for the U.S.
    "init=epsg:2163"
  END # This is the ending of the output projection

  #
  # Start of legend
  #
  LEGEND
    KEYSIZE 12 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
    STATUS ON
  END

  # The reference object is used to define a reference map for your mapping
  # application.  This typically involves defining a small image that covers
  # the entire area of the map and defining a box that represents the current
  # view on in relation to the entire area.
  REFERENCE
    IMAGE '../images/ugl_ref1.png' # The reference image
    SIZE 155 105 # The size of the reference image in pixels
    EXTENT 201621.496941 -294488.285333 1425518.020722 498254.511514 # The extent of the reference image in map units
    STATUS ON
    MINBOXSIZE 10 # How small can the reference box be before it gets drawn as a point, in pixels
    MAXBOXSIZE 150 # The maximum size of the reference box, in pixels
    COLOR -1 -1 -1 # The reference box fill color, negative numbers mean transparent
    OUTLINECOLOR 128 0 0 # The reference box outline color
    MARKERSIZE 8 # The size of the point marker
    MARKER 'star' # The marker symbol
  END

  # A scalebar object is defined one level below the map object.  This object
  # controls how a scalebar is drawn by MapServer.  Scalebars can be embedded
  # in the map itself or can be created as a separate image.  It has an
  # associated MapServer CGI variable called "scalebar" (or [scalebar] when
  # used in the HTML template).
  SCALEBAR
    IMAGECOLOR 255 255 255
    LABEL
      COLOR 0 0 0
      SIZE TINY
    END
    STYLE 1
    SIZE 100 2
    COLOR 0 0 0
    UNITS MILES
    INTERVALS 2
    TRANSPARENT FALSE
    STATUS ON
  END # Scalebar object ends


  #
  # A querymap object is used to highlight, or make prominent, the features on a 
  # map selected via a query or nquery request.   This means you can display 
  # your query results and a map showing the features selected for the query.
  QUERYMAP
    SIZE 200 150
    STATUS ON
    STYLE HILITE  # SELECTED | NORMAL
    COLOR 255 0 0
  END

  # Layer objects, too, are defined beneath the map object.  Be mindful of the
  # order of your layer objects.  MapServer "stacks them" in reverse
  # order--that is, the last layer you define (at the bottom of the map file)
  # will be drawn on top and the first layer you define (right after this
  # comment), will be drawn at the bottom.  Here's my rule: rasters and
  # polygons are defined first, followed by the line layers, and the point layers 
  # are defined last.  You can play around with the ordering
  # of your layers until you're satisfied.

  # Start of LAYER DEFINITIONS ---------------------------------------------
  LAYER # States polygon layer begins here
    NAME         "states"
    DATA         "states_ugl.shp"
    STATUS       DEFAULT
    TYPE         POLYGON
    REQUIRES     "![modis] OR ![modis_nasa]"

    # Here's an example of the input projection definition.
    # EPSG:4326 is code for geographic (latlong) projection
    # using the WGS84 datum
    PROJECTION
      "init=epsg:4326"
    END

	LABELITEM    "STATE"
    CLASSITEM    "CLASS"

    # The class object is defined within the layer object.  You can define as
    # many classes as you need.
    CLASS
      EXPRESSION 'land'
      
      # There are styles in a class, just like there are classes in a layer, 
      # just like there are layers in a map. 
      STYLE
        SYMBOL     0
        COLOR      232 232 232
      END # And they all must come to an end.
      LABEL
        COLOR 132 31 31
        OUTLINECOLOR 128 128 128
        SHADOWCOLOR 218 218 218
        SHADOWSIZE 1 1
        TYPE TRUETYPE
        FONT arial-bold
        SIZE 12
        ANTIALIAS TRUE
        POSITION CL
        PARTIALS FALSE
        MINDISTANCE 200
        BUFFER 4
      END # end of label		  
    END # End of this class.
  END # States polygon layer ends here

  LAYER # MODIS raster layer begins here
    NAME         "relief"
    DATA         "raster/shdrlfi020g_ugl.tif"
    STATUS       OFF
    TYPE         RASTER
    OFFSITE      169 209 254

    METADATA
      WMS_TITLE "UGL Shaded Relief"
      WMS_ABSTRACT "Shaded Relief of Michigan, Minnesota, and Wisconsin.  Clipped from National Atlas data (http://www.nationalatlas.gov)."
      WMS_SRS "EPSG:2163 EPSG:4326 EPSG:26915"
    END

    PROJECTION
      "init=epsg:4326"
    END

    CLASS
      NAME 'Shaded Relief'
      KEYIMAGE 'graphics/relief_keyimage.png'
    END
  END # MODIS raster layer ends here

  LAYER # MODIS raster layer begins here
    NAME         "modis"
    DATA         "raster/mod09a12003161_ugl_ll_idxa.tif"
    STATUS       OFF
    TYPE         RASTER
    OFFSITE      70 74 66 #167 151 152

    PROJECTION
      "init=epsg:4326"
    END

    CLASS
      NAME 'MODIS Image'
      KEYIMAGE 'graphics/modis_keyimage.png'
    END
  END # MODIS raster layer ends here

  LAYER # MODIS WMS map from NASA
    NAME         "modis_nasa"
    TYPE         RASTER
    OFFSITE      0 0 0
    STATUS       OFF
    CONNECTIONTYPE WMS
    CONNECTION "https://neo.sci.gsfc.nasa.gov/wms/wms?"
    
    METADATA
      "wms_srs" "EPSG:4326"
      "wms_name" "MOD_143D_RR"
      "wms_server_version" "1.1.1"
      "wms_format" "image/jpeg"
    END

    PROJECTION
      "init=epsg:4326"
    END
	
    CLASS
      NAME 'MODIS NASA WMS'
      KEYIMAGE 'graphics/landsat_keyimage.png'
    END	
	
  END # Modis WMS image ends here

  LAYER # Urban areas polygon layer begins here
    NAME "cities_poly"
    GROUP "cities"
    TYPE Polygon
    STATUS on
    DATA "urban_ugl.shp"

    # The HEADER and FOOTER keywords within a layer object is used to define the
    # header and footer templates for the TEMPLATE keyword used in the CLASS
    # object.  Uncomment the two lines below and look at the template files
    # themselves to see how they work.
    HEADER '../templates/cities_header.html'
    FOOTER '../templates/cities_footer.html'

    # The keyword TOLERANCE provides a measure of sensitivity for point-based
    # queries.  In this example, a mouse-click will have a radius of 3 pixels.
    # TOLERANCE has an associated keyword, TOLERANCEUNITS.  When TOLERANCEUNITS
    # isn't defined, MapServer assumes the units to be pixels.
    TOLERANCE 3
    CLASS
        NAME 'Urban Areas'

        # The TEMPLATE keyword within a CLASS object is used to define the
        # HTML query template to use in displaying database records when the
        # query or nquery mode in MapServer is invoked.
        TEMPLATE '../templates/cities_query.html'

      STYLE
        COLOR 255 240 115
      END
     END  # CLASS

    PROJECTION
      "init=epsg:4326"
    END
  END  # Urban areas polygon layer ends here

  LAYER # Federal land polygon layer begins here
    NAME "fedlands"
    TYPE Polygon
    STATUS on
    DATA "fedlan_ugl.shp"

    CLASSITEM 'FEATURE1'
    CLASS
      NAME 'Federal Land'
      EXPRESSION ('[FEATURE1]' ne 'Null') 
      STYLE
        COLOR 164 96 89
        OUTLINECOLOR 144 72 64
      END
    END  # CLASS

    PROJECTION
      "init=epsg:4326"
    END
  END  # Federal land polygon layer begins here

  LAYER # Hydrography layer begins here
    NAME "hydro"
    TYPE POLYGON
    STATUS OFF
    DATA "hydrop_ugl.shp"

    PROJECTION
      "init=epsg:4326"
    END

    CLASSITEM 'FEATURE'
    CLASS
      NAME 'Lakes'
      EXPRESSION /(^B|^C|^L|^R)./
      STYLE
        COLOR 72 64 254
      END
    END  # CLASS
    CLASS
      NAME 'Rivers'
      EXPRESSION 'Stream'
      STYLE
        COLOR 136 128 255
      END
    END  # CLASS
    CLASS
      NAME 'Wetlands'
      EXPRESSION 'Swamp or Marsh'
      STYLE
        COLOR 195 252 255
        #OUTLINECOLOR 195 252 255
        #SYMBOL 'circle'
        #SIZE 1
      END
    END  # CLASS
  END  # LAYER

  LAYER # Counties line layer begins here
    NAME         "counties"
    DATA         "co2000_ugl.shp"
    STATUS       OFF
    TYPE         LINE

    PROJECTION
      "init=epsg:4326"
    END

    CLASSITEM    'county'
    CLASS
      NAME       'County Boundary'
      EXPRESSION /./
      STYLE
        SYMBOL     'line5'
        COLOR      92 92 92
        SIZE       1
      END
    END
  END # Counties line layer ends here

  LAYER # ROADS LAYER
    NAME "cty_roads"
    GROUP "roads"
    TYPE LINE
    STATUS OFF
    DATA "roads_ugl.shp"
    MAXSCALE 750000

    PROJECTION
      "init=epsg:4326"
    END

    LABELITEM 'SIGN'
    CLASSITEM 'CLASS1'
    CLASS
      NAME 'Minor Arterial Road'
      EXPRESSION '3'
      STYLE
        COLOR 165 165 165
      END
      LABEL
        STYLE #shield
          SYMBOL '../symbols/sthwy.png'
          SIZE 20
        END # end of style
        COLOR 0 0 0
        TYPE TRUETYPE
        FONT vera_sans
        SIZE tiny
        ANTIALIAS TRUE
        POSITION CC
        PARTIALS FALSE
        MINDISTANCE 150
        MINFEATURESIZE 50
        BUFFER 4
      END # end of label	  
    END  # CLASS
    CLASS
      EXPRESSION '4'
      STYLE
        COLOR 210 210 210
      END
    END  # CLASS
  END  # ROADS LAYER

  LAYER # state highways begin here
    NAME "state_hwy"
    GROUP "roads"
    MAXSCALE 1500000
    STATUS OFF
    DATA "roads_ugl.shp"
    TYPE LINE
    FILTERITEM 'CLASS1'
    FILTER '2'
    LABELITEM 'SIGN'	

    CLASS
      NAME 'Principal Arterial Road'
      STYLE
        COLOR 255 0 0
        SIZE 1
        SYMBOL 'circle'
      END
      LABEL
        STYLE #shield
          SYMBOL '../symbols/ushwy.png'
          SIZE 20
		END # end of style
        COLOR 0 0 0
        TYPE TRUETYPE
        FONT vera_sans
        SIZE tiny
        ANTIALIAS TRUE
        POSITION CC
        PARTIALS FALSE
        MINDISTANCE 150
        MINFEATURESIZE 50
        BUFFER 4
      END # end of label	  
    END

    PROJECTION
      "init=epsg:4326"
    END
  END # highways

  LAYER # interstate highways begin here
    NAME "interstate"
    GROUP "roads"
#    MAXSCALE 22500000
    STATUS OFF
    DATA "roads_ugl.shp"
    TYPE LINE
    FILTERITEM 'CLASS1'
    FILTER '1'
    LABELITEM 'SIGN'	

    CLASS
      NAME "Interstate Highway"
      STYLE
        COLOR 128 0 0
      END
      LABEL
        STYLE #shield
          SYMBOL '../symbols/interstate.png'
          SIZE 20
        END # end of style
        COLOR 255 255 255
        TYPE TRUETYPE
        FONT vera_sans
        SIZE tiny
        ANTIALIAS TRUE
        POSITION CC
        PARTIALS FALSE
        MINDISTANCE 150
        MINFEATURESIZE 20
        BUFFER 4
      END # end of label	  
    END

    PROJECTION
      "init=epsg:4326"
    END
  END # highways

  LAYER # States line layer begins here
    NAME         "states"
    DATA         "states_ugl.shp"
    STATUS       OFF
    TYPE         LINE

    PROJECTION
      "init=epsg:4326"
    END

    CLASSITEM    "CLASS"
    CLASS
      NAME       'State Boundary'
      EXPRESSION 'land'
      STYLE
        SYMBOL     'line5'
        COLOR      32 32 32
        SIZE       1
      END
    END
  END # States line layer ends here
  
  # End of LAYER DEFINITIONS -------------------------------

END # end of map file
