<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt">After struggling with broken image tiles using the KaMap/MapServer layer support, there are some findings and a fix I'd like to share. Hopefully the fix will get into the next version of OpenLayers. If this is the wrong forum for this post, please let me know where I should post it.<br><br>Sometimes, for some reason, the tiles requested do not fall on the expected tile boundary. I do not know why this would be (any ideas?). Whenever this happens, new images are generated (slow), and no image that matches the bad tile boundaries is created (and you get a broken image). A quick fix that patches/hides this problem is as follows:<br><br>Modify lines 55 and 56 of the latest SVN KaMap.js to round off to the nearest tile boundary. Please replace<br><br><div
style="margin-left: 40px;">var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w);<br>var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h);<br></div>with<br><div style="margin-left: 40px;">var pX = Math.round(((bounds.left) / cellSize.w)) * this.tileSize.w;<br>
var pY = -Math.round(((bounds.top) / cellSize.h)) * this.tileSize.h;<br></div><br>There is also a second problem with tile generation using a MS Windows (ms4w?) MapServer back end. If you have a complete tile cache this bug ceases to surface, so I have not come up with a fix for it as of yet. The problem is that on MS Windows, PHP file_exists() claims a file does not exist for the first few hundred milliseconds after a tile is generated. This results in contention between the OpenLayers tile requests. None of the concurrent tile requests think their tile has been generated so they all generate the entire meta tile, so tile generation takes many times longer than it should. Also a broken image is often delivered even though the tiles are generated. The fopen() call on line 493 of examples/kamap.txt can fail immediately after tile generation (unless a sleep is introduced). The URL below shows the only reference I
could find on Google to the MS Windows problem (in case someone wants to put a bug report in with the PHP folks).<br><br><span> <a target="_blank" href="http://www.php.net/manual/en/function.file-exists.php#56121">http://www.php.net/manual/en/function.file-exists.php#56121</a></span><br><br>Hope this helps,<br>David<br><br><br></div></body></html>