Gery
Gery

Reputation: 9046

Single WMS from single mapfile with several rasters in MapServer

I have several rasters in a single mapfile, I put them as layers like here:

LAYER
    NAME            "Layer 1"
    GROUP           "All Layers"
    TYPE            RASTER
    STATUS          ON
    DATA            "layer1.png"

    PROJECTION
        "init=epsg:4326"
    END

    METADATA
        "wms_title"         "Layer 1"
        "wms_srs"           "EPSG:4326"
        "wms_group_title"   "All layers"
        "wms_abstract"          "No abstract"
        "wms_server_version"        "1.1.1"
        "wms_format"            "image/png"
        "wms_include_items"     "all"
        "gml_include_items"     "all"
        "gml_geom_type"         "raster"
    END
END

LAYER
    NAME            "Layer 2"
    GROUP           "All Layers"
    TYPE            RASTER
    STATUS          ON
    DATA            "layer2.png"

    PROJECTION
        "init=epsg:4326"
    END

    METADATA
        "wms_title"         "Layer 2"
        "wms_srs"           "EPSG:4326"
        "wms_group_title"   "All layers"
        "wms_abstract"          "No abstract"
        "wms_server_version"        "1.1.1"
        "wms_format"            "image/png"
        "wms_include_items"     "all"
        "gml_include_items"     "all"
        "gml_geom_type"         "raster"
    END
END

LAYER
    NAME            "Layer 3"
    GROUP           "All Layers"
    TYPE            RASTER
    STATUS          ON
    DATA            "layer3.png"

    PROJECTION
        "init=epsg:4326"
    END

    METADATA
        "wms_title"         "Layer 3"
        "wms_srs"           "EPSG:4326"
        "wms_group_title"   "All layers"
        "wms_abstract"          "No abstract"
        "wms_server_version"        "1.1.1"
        "wms_format"            "image/png"
        "wms_include_items"     "all"
        "gml_include_items"     "all"
        "gml_geom_type"         "raster"
    END
END

The problem is that I want to have a single WMS layer (named as in GroupTitle) as output from this mapfile (because it is only one mapfile), instead I have four WMS layers (three coming from each LAYER and one from the GROUP LAYER).

How can I achieve what I want? I use Mapserver 6.4.1 in OL 2.11.

Any ideas are welcomed, thanks in advance,

Upvotes: 0

Views: 2114

Answers (3)

Damian Dixon
Damian Dixon

Reputation: 979

I believe that what you are looking for is the TILEINDEX approach that was introduced in 6.4.

To quote the reference:

When handling very large raster layers it is often convenient, and higher performance to split the raster image into a number of smaller images. Each file is a tile of the larger raster mosaic available for display. The list of files forming a layer can be stored in a shapefile with polygons representing the footprint of each file, and the name of the files.

See Rasters and Tile Indexing

Upvotes: 1

Tim Autin
Tim Autin

Reputation: 6165

You can just use the GROUP element:

LAYER
    NAME           "layer1"
    GROUP           "both_layers"
    STATUS         OFF
    TYPE           RASTER
    DATA           "layer1.tif"
END

LAYER
    NAME           "layer2"
    GROUP           "both_layers"
    STATUS         OFF
    TYPE           RASTER
    DATA           "layer2.tif"
END

Then you reference "both_layers" in your WMS requests.

Upvotes: 2

Hal Mueller
Hal Mueller

Reputation: 7655

It appears that a Union Layer would do what you're asking. I haven't tried it myself. From the documentation linked above:

LAYER
  NAME "union-layer"
  TYPE POINT
  STATUS DEFAULT
  CONNECTIONTYPE UNION
  CONNECTION "layer1,layer2,layer3" # reference to the source layers
  PROCESSING "ITEMS=itemname1,itemname2,itemname3"
  ...
END
LAYER
  NAME "layer1"
  TYPE POINT
  STATUS OFF
  CONNECTIONTYPE OGR
  CONNECTION ...
  ...
END

Upvotes: 1

Related Questions