Skip to main content
added 1 characters in body
Source Link
DavidF
  • 4.9k
  • 1
  • 27
  • 32

Here is another way that you can do it. This way involves using one layer with expressions in each class. It is a little more 'expensive' to do it this way because it involves logical expressions, but you may never notice the difference unless you hit really high-load situations.

Each class has a two-part expression. Both parts of the expression need to be true for the features to be drawn. The first part of the expression selects the features that should fall into that class based on an attribute in your shapefile. The second part of the expression evaluates the value of a variable passed in through the url. It doesn't matter what you name the variable in your url (don't use any reserved words like 'layer'), it just has to match the variable name in your expression.

Here are some sample layers:

LAYER
  NAME "watersheds"
  STATUS DEFAULT
  DATA 'majclip'
  TYPE POLYGON
    CLASS
       NAME "water"
       EXPRESSION ([MAJOR] < 42 AND '%wanted%' = 'water')
       STYLE
          COLOR 0 0 255
       END
    END
    CLASS
       NAME "wood"
       EXPRESSION ([MAJOR] >= 42AND42 AND '%wanted%' = 'wood')
       STYLE
          COLOR 0 255 0
       END
    END
END

To draw just the water features, you would use a URL request like this: http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/mymapfile.map&mode=map&wanted=wood

Since this is the third valid way of accomplishing your goal, you really want to think about what your objectives are. If your data changes frequently, you may want to go with this option. If your data doesn't change as often, I would personally go with two layers. I might even split the shapefile into multiple shapefiles by land use type if that improved performance. (It might not, layer filters are pretty efficient). With Web mapping, the more you pre-optimize your data, the better.

Here is another way that you can do it. This way involves using one layer with expressions in each class. It is a little more 'expensive' to do it this way because it involves logical expressions, but you may never notice the difference unless you hit really high-load situations.

Each class has a two-part expression. Both parts of the expression need to be true for the features to be drawn. The first part of the expression selects the features that should fall into that class based on an attribute in your shapefile. The second part of the expression evaluates the value of a variable passed in through the url. It doesn't matter what you name the variable in your url (don't use any reserved words like 'layer'), it just has to match the variable name in your expression.

Here are some sample layers:

LAYER
  NAME "watersheds"
  STATUS DEFAULT
  DATA 'majclip'
  TYPE POLYGON
    CLASS
       NAME "water"
       EXPRESSION ([MAJOR] < 42 AND '%wanted%' = 'water')
       STYLE
          COLOR 0 0 255
       END
    END
    CLASS
       NAME "wood"
       EXPRESSION ([MAJOR] >= 42AND '%wanted%' = 'wood')
       STYLE
          COLOR 0 255 0
       END
    END
END

To draw just the water features, you would use a URL request like this: http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/mymapfile.map&mode=map&wanted=wood

Since this is the third valid way of accomplishing your goal, you really want to think about what your objectives are. If your data changes frequently, you may want to go with this option. If your data doesn't change as often, I would personally go with two layers. I might even split the shapefile into multiple shapefiles by land use type if that improved performance. (It might not, layer filters are pretty efficient). With Web mapping, the more you pre-optimize your data, the better.

Here is another way that you can do it. This way involves using one layer with expressions in each class. It is a little more 'expensive' to do it this way because it involves logical expressions, but you may never notice the difference unless you hit really high-load situations.

Each class has a two-part expression. Both parts of the expression need to be true for the features to be drawn. The first part of the expression selects the features that should fall into that class based on an attribute in your shapefile. The second part of the expression evaluates the value of a variable passed in through the url. It doesn't matter what you name the variable in your url (don't use any reserved words like 'layer'), it just has to match the variable name in your expression.

Here are some sample layers:

LAYER
  NAME "watersheds"
  STATUS DEFAULT
  DATA 'majclip'
  TYPE POLYGON
    CLASS
       NAME "water"
       EXPRESSION ([MAJOR] < 42 AND '%wanted%' = 'water')
       STYLE
          COLOR 0 0 255
       END
    END
    CLASS
       NAME "wood"
       EXPRESSION ([MAJOR] >= 42 AND '%wanted%' = 'wood')
       STYLE
          COLOR 0 255 0
       END
    END
END

To draw just the water features, you would use a URL request like this: http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/mymapfile.map&mode=map&wanted=wood

Since this is the third valid way of accomplishing your goal, you really want to think about what your objectives are. If your data changes frequently, you may want to go with this option. If your data doesn't change as often, I would personally go with two layers. I might even split the shapefile into multiple shapefiles by land use type if that improved performance. (It might not, layer filters are pretty efficient). With Web mapping, the more you pre-optimize your data, the better.

Source Link
DavidF
  • 4.9k
  • 1
  • 27
  • 32

Here is another way that you can do it. This way involves using one layer with expressions in each class. It is a little more 'expensive' to do it this way because it involves logical expressions, but you may never notice the difference unless you hit really high-load situations.

Each class has a two-part expression. Both parts of the expression need to be true for the features to be drawn. The first part of the expression selects the features that should fall into that class based on an attribute in your shapefile. The second part of the expression evaluates the value of a variable passed in through the url. It doesn't matter what you name the variable in your url (don't use any reserved words like 'layer'), it just has to match the variable name in your expression.

Here are some sample layers:

LAYER
  NAME "watersheds"
  STATUS DEFAULT
  DATA 'majclip'
  TYPE POLYGON
    CLASS
       NAME "water"
       EXPRESSION ([MAJOR] < 42 AND '%wanted%' = 'water')
       STYLE
          COLOR 0 0 255
       END
    END
    CLASS
       NAME "wood"
       EXPRESSION ([MAJOR] >= 42AND '%wanted%' = 'wood')
       STYLE
          COLOR 0 255 0
       END
    END
END

To draw just the water features, you would use a URL request like this: http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/mymapfile.map&mode=map&wanted=wood

Since this is the third valid way of accomplishing your goal, you really want to think about what your objectives are. If your data changes frequently, you may want to go with this option. If your data doesn't change as often, I would personally go with two layers. I might even split the shapefile into multiple shapefiles by land use type if that improved performance. (It might not, layer filters are pretty efficient). With Web mapping, the more you pre-optimize your data, the better.