I was advised in a previous post to ask this question again using a small data sample
My base layer is a postgis vector dataset in WGS84
When I click on the map I get the following an error in the nodelist could somebody help part of the error is here
X and Y incorrectly specified Details:
org.geoserver.platform.ServiceException: X and Y incorrectly specified at org.geoserver.wms.featureinfo.GetFeatureInfoKvpReader.read(GetFeatureInf
oKvpReader.java:162) at
org.geoserver.ows.Dispatcher.parseRequestKVP(Dispatcher.java:1230) at
org.geoserver.ows.Dispatcher.dispatch(Dispatcher.java:488) at
org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:231)
at
org.springframework.web.servlet.mvc.AbstractController.handleRequest(Abs
tractController.java:153) ava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)
My openlayers code is generated from a perl script the code below is the result of right click View Page Source.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css"href="http://localhost:8080/geoserver/openlayers/theme/default/style.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/geoserver/www/scale/scalebar-fat.css"/>
<!-- Basic CSS definitions -->
<style type="text/css">
/* General settings */
body {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: small;
}
/* Toolbar styles */
#toolbar {
position: relative;
padding-bottom: 0.5em;
display: none;
}
#toolbar ul {
list-style: none;
padding: 0;
margin: 0;
}
#toolbar ul li {
float: left;
padding-right: 1em;
padding-bottom: 0.5em;
}
#toolbar ul li a {
font-weight: bold;
font-size: smaller;
vertical-align: middle;
color: black;
text-decoration: none;
}
#toolbar ul li a:hover {
text-decoration: underline;
}
#toolbar ul li * {
vertical-align: middle;
}
/* The map and the location bar */
#map {
clear: both;
position: relative;
width: 600px;
height: 600px;
border: 1px solid black;
}
#wrapper {
width: 512px;
}
#location {
float: right;
}
#options {
position: absolute;
left: 13px;
top: 7px;
z-index: 3000;
}
/* Styles used by the default GetFeatureInfo output, added to make IE happy */
table.featureInfo, table.featureInfo td, table.featureInfo th {
border: 1px solid #ddd;
border-collapse: collapse;
margin: 0;
padding: 0;
font-size: 90%;
padding: .2em .1em;
}
table.featureInfo th {
padding: .2em .2em;
text-transform: uppercase;
font-weight: bold;
background: #eee;
}
table.featureInfo td {
background: #fff;
}
table.featureInfo tr.odd td {
background: #eee;
}
table.featureInfo caption {
text-align: left;
font-size: 100%;
font-weight: bold;
text-transform: uppercase;
padding: .2em .2em;
}
</style>
</style>
<script src="http://localhost:8080/geoserver/www/OpenLayers-2.11/OpenLayers.js"> </script>
<script src="http://localhost:8080/geoserver/www/scale/ScaleBar.js"></script>
<script type="text/javascript">
var pureCoverage = false;
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
// make OL compute scale according to WMS spec
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
var map, scalebar;
function createGeodesicPolygon(origin, radius, sides, rotation, projection) {
if (projection.getCode() !== "EPSG:4326") {
origin.transform(projection, new OpenLayers.Projection("EPSG:4326"));
}
var latlon = new OpenLayers.LonLat(origin.x, origin.y);
var angle;
var new_lonlat, geom_point;
var points = [];
for (var i = 0; i < sides; i++) {
angle = (i * 360 / sides) + rotation;
new_lonlat = OpenLayers.Util.destinationVincenty(latlon, angle, radius);
new_lonlat.transform(newOpenLayers.Projection("EPSG:4326"), projection);
geom_point = new OpenLayers.Geometry.Point(new_lonlat.lon,new_lonlat.lat);
points.push(geom_point);
}
var ring = new OpenLayers.Geometry.LinearRing(points);
return new OpenLayers.Geometry.Polygon([ring]);
}
var map = new OpenLayers.Map({
div: "map",
center: new OpenLayers.LonLat(0, 0),
minResolution: "auto",
maxResolution: "auto"
});
function init(){
format = 'image/png';
if(pureCoverage) {
document.getElementById('filterType').disabled = true;
document.getElementById('filter').disabled = true;
document.getElementById('antialiasSelector').disabled = true;
document.getElementById('updateFilterButton').disabled = true;
document.getElementById('resetFilterButton').disabled = true;
document.getElementById('jpeg').selected = true;
format = "image/jpeg";
}
var bounds = new OpenLayers.Bounds(
1, 53, 3, 54
);
var options = {
controls: [],
//'PanZoomBar', 'Navigation', 'Scale', 'MousePosition'
maxExtent: bounds,
maxResolution: 0.00365234375,
projection: "EPSG:4326",
units: 'degrees'
};
map = new OpenLayers.Map('map', options);
//
var Base = new OpenLayers.Layer.WMS(
"Land",
"http://localhost:8080/geoserver/cite/wms",
{LAYERS: 'cite:land',
format: 'image/png',
isBaseLayer: true,
srsName: 'EPSG:4326',
}
);
map.addLayers([Base]);
var L1234 = new OpenLayers.Layer.WMS(
"1234",
"http://localhost:8080/geoserver/cite/wms",
{
VIEWPARAMS: 'kathy:10654',
LAYERS: 'cite:Q_Results',
transparent: 'true',
isBaseLayer: false
}
);
var vectorLayer = new OpenLayers.Layer.Vector("myPolygonLayer",{
styleMap: new OpenLayers.StyleMap({
fillColor: "#33CC00",
strokeColor: "#000000",
strokeWidth: 1
})
}
);
var format = new OpenLayers.Format.WKT({
'internalProjection': map.baseLayer.projection,
'externalProjection': new OpenLayers.Projection("EPSG:4326"),
});
var polygonFeature= format.read("POLYGON((1.9 53.17,2.4 53.17,2.4 53.49, 1.9 53.49,1.9 53.17))");
vectorLayer.addFeatures([polygonFeature]);
map.addLayers([L1234,vectorLayer]);
// build up all controls
// build up all controls
map.addControl(new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));
map.addControl(new openLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher')}));
var scalebar = new OpenLayers.Control.ScaleBar({
div: document.getElementById("scalebar"),
displaySystem: "metric",
minWidth: 175,
maxWidth: 575,
divisions: 4,
subdivisions: 1,
showMinorMeasures: true,
abbreviateLabel: true,
singleLine: true
});
map.addControl(scalebar);
map.zoomToExtent(
new OpenLayers.Bounds(1, 53, 3, 54)
);
// support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodelist').innerHTML = "Loading... please wait...";
var params = {
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
SERVICE: "WMS",
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
Viewparams: 'kathy:10654',
Layers: 'cite:land,cite:Q_Results',
WIDTH: map.size.w,
HEIGHT: map.size.h,
format: format,
styles: map.layers[0].params.STYLES,
srs: map.layers[0].params.SRS};
// handle the wms 1.3 vs wms 1.1 madness
if(map.layers[0].params.VERSION == "1.3.0") {
params.version = "1.3.0";
params.j = e.xy.x;
params.i = e.xy.y;
} else {
params.version = "1.1.1";
params.x = e.xy.x;
params.y = e.xy.y;
}
// merge filters
if(map.layers[0].params.CQL_FILTER != null) {
params.cql_filter = map.layers[0].params.CQL_FILTER;
}
if(map.layers[0].params.FILTER != null) {
params.filter = map.layers[0].params.FILTER;
}
if(map.layers[0].params.FEATUREID) {
params.featureid = map.layers[0].params.FEATUREID;
}
OpenLayers.loadURL("http://localhost:8080/geoserver/cite/wms", params, this, setHTML, setHTML);
OpenLayers.Event.stop(e);
});
}
// end init
// sets the HTML provided into the nodelist element
function setHTML(response){
document.getElementById('nodelist').innerHTML = response.responseText;
};
</script>
</head>
<body onload="init()">
<h3>OpenLayers PostGis Layers</h3>
<DIV id=layerswitcher class=olControlLayerSwitcher></DIV>
<div id="map"></div>
<div id="wrapper">
<div id="location">location</div>
<div id="scale"> </div>
<div id=scalebar></div>
</div>
<div id="nodelist">
</div>
</body>
</html>
Update New Error
The above works if suggestions by iant are used however if an additional layer is added and the veiwparams in the GetFeatureInfo are altered to incorporate this new layer an error similar to 3 layers selected but 2 veiwparams occurs when you click on the map.
Please advise
var L5678= new OpenLayers.Layer.WMS(
"5678",
"http://localhost:8080/geoserver/cite/wms",
{
VIEWPARAMS: 'kathy:5678',
LAYERS: 'cite:Q_Results',
transparent: 'true',
isBaseLayer: false
}
);
Viewparams: 'kathy:10654,5678',