0

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,

Gery
  • 8,390
  • 3
  • 22
  • 39

3 Answers3

2

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.

Tim Autin
  • 6,043
  • 5
  • 46
  • 76
1

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
Hal Mueller
  • 7,019
  • 2
  • 24
  • 42
  • Thanks for the reply but it didn't work, it very likely works only for points and not for rasters – Gery May 20 '15 at 18:47
  • Ah, missed that point. The Mapfile you posted has just 3 static images. How about using GDAL to merge them into one, and serve that? Or if that isn't your real Mapfile, post the real one? – Hal Mueller May 20 '15 at 18:59
  • yeah I think that's the way to go with GDAL, thanks again for the support! – Gery May 20 '15 at 19:20
1

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

Damian Dixon
  • 889
  • 8
  • 21