[OpenLayers-Users] wms query frustration
Justin Palk
jmpalk at gmail.com
Thu Jun 5 10:13:16 EDT 2008
Hi all -- I'm just starting out with openlayers, and I'm a little frustrated.
I've been trying for a few days now to set up a simple map that will
let me query some hypothetical election results, but I keep running
into two snags:
1) When I first go to my test.html page, I'll get:
"An error occurred: can't find resolution index for 0.002231.
Available resolutions are: [0.0011154260000000001,
0.00055771300000000005, 0.00027885650000000002, 0.00013942825000000001
(etc.)"
I can't figure out why I'm starting at a resolution of 0.002231 when I
set a maxResolution of 0.001115426.
2) If I zoom in one step (to resolution 0.001115426) I get the following error:
"An error occurred: Current x value -77.535047 is too far from tile
corner x -77.677821"
The "Current x value" never seems to change regardless of where I
click on the map.
I can only assume this is some sort of projection error, but I've been
beating my head against the wall checking and double-checking my srs's
and resolutions, but I can't seem to find a solution. Any suggestions
would be greatly appreciated.
I'm working with a map in EPSG:4326
ogrinfo -so returns:
INFO: Open of `election_4326.shp'
using driver `ESRI Shapefile' successful.
Layer name: election_4326
Geometry: Polygon
Feature Count: 61
Extent: (-77.677821, 39.219771) - (-77.106723, 39.719845)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_1984",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]]
ED_NUM: Integer (10.0)
ED_NAME: String (16.0)
PRECINCT: String (6.0)
LEGIS_DIST: String (3.0)
POLL_NAME: String (50.0)
POLL_TYPE: String (40.0)
POLL_ADDRE: String (40.0)
CITY: String (25.0)
ZIP_CODE: String (15.0)
SHAPE_area: Real (19.11)
SHAPE_len: Real (19.11)
Here's the relevant bit from my tilecache.cfg:
[election_results]
type=MapnikLayer
mapfile=/tmp/ed.xml
extent_type=loose
bbox=-77.677821,39.219771,-77.106723,39.719845
maxResolution = 0.001115426
The map line from ed.xml:
<Map bgcolor="steelblue" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
and my script:
<script type="text/javascript">
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
var map = new OpenLayers.Map("map",
{maxExtent: new OpenLayers.Bounds(-77.677821,39.219771,-77.106723,39.719845),
maxResolution:0.001115426}
);
var er = new OpenLayers.Layer.WMS("election_results",
"http://127.0.0.1/cgi-bin/tilecache-2.03/tilecache.cgi?",
{layers: 'election_results', format: 'image/png', projection:
"EPSG:4326"});
map.addLayer(er);
map.addControl(new OpenLayers.Control.Permalink());
map.zoomToMaxExtent();
map.events.register('click', map, function (e){
OpenLayers.Util.getElement('nodeList').innerHTML = "Loading...";
var url = er.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: er.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
OUERY_LAYERS: er.params.LAYERS,
WIDTH: er.map.size.w,
HEIGHT: er.map.size.h});
OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
}
);
function setHTML(response){
OpenLayers.Util.getElement('nodeList').innerHTML = response.responseText;
}
</script>
--
"News is what people want to keep hidden, and everything else is publicity"
--Bill Moyers
More information about the Users
mailing list