Hi,<br> I just got tilecache working on xp and win 2003, and with my wms (using manifold gis) the open layers example works great. However, I configured tilecache in the hopes of using it in conjunction with google maps. However, it appears that tilecache is not honoring the wms requests that are being generated from the script in google maps (see below). The requests are valid, if I point the script directly at the wms, the tiles come back just fine. But when i put tilecache in between, I get <br>
<br><pre>An error occurred: Current y value 37.718590 is too far from tile corner y 37.968750<br><br></pre>You can see the working google map with tiles coming back directly from the wms here:<br><br><br><a href="http://warbler2.cit.cornell.edu/pfw-maps/wms-without-cache.html">http://warbler2.cit.cornell.edu/pfw-maps/wms-without-cache.html</a><br>
<br><br>the entry in tilecache.cfg looks like this<br>
<br>[google-tiles]<br>type=WMS<br>url=<a href="http://mycomputer.com/local-wms/wms.asp" target="_blank">http://mycomputer.com/local-wms/wms.asp</a><br>layers=Active_Year_2005<br>tms_type=google<br><br><br>I use the following script to convert the mercator coords to lat lng, which i modified from here (<a href="http://johndeck.blogspot.com/#114071052432996324" target="_blank">http://johndeck.blogspot.com/#114071052432996324</a>)<br>
<br>/**<br> * GoogleMapsWmsOverlays<br> * @param {Object} opts<br> * @param {String} myLayers The layers requested from wms<br> * @param {String} myFormat The image format<br> * @param {String} myBaseURL The url of the wms server<br>
* @param {Number} myOpacity opacity<br> * @param {String} myStyles wms styles<br> * @param {Number} myMercLevel The level at which switch to lat/lng is made??<br> */<br>function GoogleMapsWmsOverlay(opts){<br> var me = this;<br>
me.MAGIC_NUMBER=6356752.3142;<br> me.WGS84_SEMI_MAJOR_AXIS = 6378137.0;<br> me.WGS84_ECCENTRICITY = 0.0818191913108718138;<br> me.DEG2RAD=0.0174532922519943;<br> me.PI=3.14159267;<br> me.FORMAT_DEFAULT="image/png"; //Default image format, used if none is specified<br>
me.MERC_ZOOM_DEFAULT = 15; //Google Maps Zoom level at which we switch from Mercator to Lat/Long.<br> <br> me.Options = {<br> myLayers: opts.myLayers || "error",<br> myFormat: opts.myFormat || me.FORMAT_DEFAULT,<br>
myBaseURL: opts.myBaseURL || "error",<br> myStyles: opts.myStyles || ""<br> }<br>}<br><br>GoogleMapsWmsOverlay.prototype.dd2MercMetersLng = function(p_lng) {<br> var me = this;<br>
return me.WGS84_SEMI_MAJOR_AXIS * (p_lng * me.DEG2RAD);<br>}<br><br>GoogleMapsWmsOverlay.prototype.dd2MercMetersLat = function(p_lat) {<br> var me = this;<br> var lat_rad = p_lat * me.DEG2RAD;<br> return me.WGS84_SEMI_MAJOR_AXIS * <br>
Math.log(Math.tan((lat_rad + me.PI / 2) / 2) *<br> Math.pow( ((1 - me.WGS84_ECCENTRICITY * Math.sin(lat_rad)) /<br> (1 + me.WGS84_ECCENTRICITY * Math.sin(lat_rad))), (me.WGS84_ECCENTRICITY/2)));<br>
}<br><br>/**<br> * use?<br> */<br>GoogleMapsWmsOverlay.prototype.customOpacity = function() {<br> <br> return this.myOpacity; <br>}<br><br>GoogleMapsWmsOverlay.prototype.customGetTileUrl = function(a,b,c) {<br> var opts = this.Options;<br>
/*if (opts.myMercZoomLevel == undefined) {<br> opts.myMercZoomLevel = MERC_ZOOM_DEFAULT;<br> }*/<br> <br> var lULP = new GPoint(a.x*256,(a.y+1)*256);<br> var lLRP = new GPoint((a.x+1)*256,a.y*256);<br>
var lUL = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP,b,c);<br> var lLR = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP,b,c);<br><br> // switch between Mercator and DD if merczoomlevel is set<br> // NOTE -it is now safe to use Mercator exclusively for all zoom levels (if your WMS supports it)<br>
// so you can just use the two lines of code below the IF (& delete the ELSE)<br> // drg & doq are topozone layers--- they don't work with epsg:54004<br> /*if (opt.myLayers!="drg" && opt.myLayers!="doq") {<br>
var lBbox=dd2MercMetersLng(lUL.x)+","+dd2MercMetersLat(lUL.y)+","+dd2MercMetersLng(lLR.x)+","+dd2MercMetersLat(lLR.y);<br> //Change for GeoServer - 41001 is mercator and installed by default.<br>
var lSRS="EPSG:54004";<br> } else {*/<br> //var lBbox=lUL.x.toFixed(6)+","+lUL.y.toFixed(6)+","+lLR.x.toFixed(6)+","+lLR.y.toFixed(6);<br> var lBbox=lUL.x+","+lUL.y+","+lLR.x+","+lLR.y;<br>
var lSRS="EPSG:4326";<br> //} <br> var lURL=opts.myBaseURL;<br> lURL+="?REQUEST=GetMap";<br> lURL+="&SERVICE=WMS";<br> lURL+="&VERSION=1.1.1";<br> lURL+="&EXCEPTIONS=application/vnd.ogc.se_inimage";<br>
lURL+="&LAYERS="+opts.myLayers;<br> lURL+="&STYLES="+opts.myStyles;<br> lURL+="&FORMAT="+opts.myFormat;<br> lURL+="&BGCOLOR=0xFFFFFF";<br> lURL+="&TRANSPARENT=TRUE";<br>
lURL+="&SRS="+lSRS; //use CRS for v1.3.0<br> lURL+="&BBOX="+lBbox;<br> lURL+="&WIDTH=256";<br> lURL+="&HEIGHT=256";<br> //lURL+="&reaspect=false";<br>
//document.write(lURL + "<br/>")<br> //alert(" url is " + lURL);<br> return lURL;<br>}<br><br>GoogleMapsWmsOverlay.prototype.getTileLayer = function(){<br> var me = this;<br> var tileLayer = new GTileLayer(new GCopyrightCollection(""), 0, 17);<br>
tileLayer.Options = me.Options;<br> tileLayer.getTileUrl = me.customGetTileUrl;<br> return tileLayer;<br>}<br><br><br>My maps in manifold are in mercator, but it has no problem accpeting the lat/lng requests, and spitting back the correct mercator tiles. Any help would be greatly appreciated!<br>
chris-<br><br>-- <br><br>Chris Marx<br>Programmer/Analyst<br>Cornell Lab of Ornithology<br>159 Sapsucker Woods Rd.<br>Ithaca, NY 14850<br>t. 1.607.254.1142<br><a href="http://www.birds.cornell.edu/" target="_blank">http://www.birds.cornell.edu/</a><br>