[OpenLayers-Users] KaMap Broken Image and Image Cache Fix

dgaarsoemail-gis at yahoo.com dgaarsoemail-gis at yahoo.com
Wed Jan 10 20:50:31 EST 2007


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.

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:

Modify lines 55 and 56 of the latest SVN KaMap.js to round off to the nearest tile boundary.  Please replace

var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w);
var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h);

with
var pX = Math.round(((bounds.left) / cellSize.w)) * this.tileSize.w;

var pY = -Math.round(((bounds.top) / cellSize.h)) * this.tileSize.h;


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).

      http://www.php.net/manual/en/function.file-exists.php#56121

Hope this helps,
David


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070110/a78cf334/attachment.html


More information about the Users mailing list