I am using OpenLayers WMS to load a layer from the PostGIS Raster Table, the JavaScript on OpenLayers are as following:
function init(){
var map = new OpenLayers.Map('map');
var imagery = new OpenLayers.Layer.WMS(
"Global Imagery",
"http://maps.opengeo.org/geowebcache/service/wms",
{
layers: "bluemarble",
}
);
map.addLayer(imagery);
localWMS = new OpenLayers.Layer.WMS(
"Local WMS layers",
"http://127.0.0.1/cgi-bin/mapserv.exe?MAP=C:/Users/gyu1/Desktop/Newfolder/mapserver.map",
{
layers: 'polygon',
transparent: true
}, {
isBaseLayer: false
}
);
map.addLayer(localWMS);
map.setCenter(
new OpenLayers.LonLat(1.147, 52.472).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 5
);
map.addControl( new OpenLayers.Control.LayerSwitcher());
}
The map file linking the Data and styling are as following:
MAP
NAME "polygon"
WEB
METADATA
"wms_title" "MapServer"
"wms_onlineresource" "http://127.0.0.1/cgi-bin/mapserv.exe?MAP=C:/Users/gyu1/Desktop/Newfolder/mapserver.map"
"wms_srs" "EPSG:4326 EPSG:3857"
END
END
PROJECTION
"init=epsg:3857"
END
LAYER
NAME "postgis"
TYPE raster
STATUS ON
DATA "PG:host=localhost port=5432 dbname='fusiongeo' user='postgres' password='**' schema='public' table='london' mode='2'"
PROCESSING "NODATA=-9999"
PROCESSING "SCALE=AUTO"
CLASS
NAME "boring"
EXPRESSION ([pixel] < 50)
COLOR 250 100 0
END
CLASS
NAME "mildly interesting"
EXPRESSION ([pixel] > 50 AND [pixel] < 100)
COLOR 100 0 0
END
CLASS
NAME "very interesting"
EXPRESSION ([pixel] >= 100)
COLOR 0 50 0
END
END
END # end map
It works for the Google Base Map not the OpenStreetMap. I am quite new with the MapServer, OpenLayers and I don't know how to change the SRS to make it work.
The data in PostGIS are in EPSG:3857.