<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.&nbsp;&nbsp; Hopefully the fix will get into the next version of OpenLayers.&nbsp;&nbsp; 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.&nbsp;&nbsp; I do not know why this would be (any ideas?).&nbsp;&nbsp; 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).&nbsp;&nbsp; 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.&nbsp; 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.&nbsp; 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. &nbsp; 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.&nbsp;&nbsp; This results in contention between the OpenLayers tile requests.&nbsp; 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.&nbsp; Also a broken image is often delivered even though the tiles are generated.&nbsp;&nbsp; The fopen() call on line 493 of examples/kamap.txt can fail immediately after tile generation (unless a sleep is introduced).&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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>