I'm trying to use Openlayers and Mapserver to display a shapefile. My HTML file is as follows:
<html>
<head>
<title>OpenLayers Example</title>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script type="text/javascript">
var map = new OpenLayers.Map('map');
var googleLayer = new OpenLayers.Layer.Google('Google', {type: google.maps.MapTypeId.SATELLITE});
// Create WFS layer
var wfsLayer= new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
url: "http://mysite.com/mapserv.cgi/wfs?&map=wfs_1.map&",
featureType: "MLSOA",
featureNS: "http://mapserver.gis.umn.edu/mapserver",
srsName: "EPSG:27700",
version: "1.1.0",
PropertyName: "NAME" //also tried "FID"
})
});
//add layers
map.addLayers([googleLayer,wfsLayer]);
// Set initial center location
map.setCenter(new OpenLayers.LonLat(-0.13, 51.55).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()),5);
</script>
</body>
</html>
This loads a google-map base map, and should overlay a shapefile over all of England. When the page loads the coordinates of the bounding box of the map are sent to MapServer. I can see that it is sending just the lon/lat values. In my mapfile, I have the projection of the data defined as follows, in both the intro part, and also in the layer:
PROJECTION
"init=epsg:27700"
END
However, the response from the server gives me an error WFS server error. Invalid or Unsupported FILTER in
, and I don't know whether it is due to an incorrect bounding box, or whether I have a mistake with my query using
GetFeaturePropertyName
. From searching online this appears to have been a bug, but I don't know whether it is still a problem or not.
<?xml version="1.0" encoding="ISO-8859-1"?>
<ows:ExceptionReport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ows="http://www.opengis.net/ows" version="1.1.0" language="en-US"
xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="InvalidParameterValue" locator="filter">
<ows:ExceptionText>msWFSGetFeature(): WFS server error. Invalid or Unsupported FILTER in
GetFeature : <
Filter ogc="http://www.opengis.net/ogc">
<BBOX>
<Envelope gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<lowerCorner>-55.50109375 43.134977942511</lowerCorner>
<upperCorner>55.24109375 59.593781185019</upperCorner>
</Envelope>
</BBOX>
</Filter>
</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
What do I need to do to fix this? Should I make sure that I am passing a bounding box in epsg:27700
coordinates? Or can Mapserver accept lon/lat and project them into the required coordinate system?
I have asked another question on the same topic recently, but I had a different problem then!
Best Answer
Those & in the url look suspicious, try without:
if it still does not work try to remove only the first one (the one before map=..)