Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a very known problem, but I can't solve it.

I have set the same maxExtents in the config as in the Openlayers init JS. I have done the same thing with the projection (EPSG:900913) and done all the transformation on OpenLayers FW. But there is still an error, that the tiles can't be shown because they don't start at the right point.

It seems that they are not constraint. Why? Any idea? Where is the keypoint in the solution!

Thanks. Martin

Edit:


I don't see any pics as tiles. I just see red-loadfail boxes. If I click with the right mouse button on the tile and let me show the picture I get this message: "An error occurred: Current x value 967644.673573 is too far from tile corner x 939258.202600"


My tilecache.cfg config is:


[osm]

type=MapnikLayer

mapfile= /var/www/tilecache/osm.xml

#layers=osm

spherical_mercator=true

#tms_type=google

srs=EPSG:900913

bbox=654558.60577333,5745163.8837113,1173307.4327978,6075303.6111284

#bbox=5.88,45.78,47.81,10.54

#maxReolution=19567.879237500

maxResolution=156543.03390000001

resolutions=156543.03390000001, 78271.516950000005, 39135.758475000002, 19567.879237500001, 9783.9396187500006, 4891.9698093750003, 2445.9849046875001, 1222.9924523437501, 611.49622617187504, 305.74811308593752, 152.87405654296876, 76.43702827148438, 38.21851413574219, 19.109257067871095, 9.5546285339355475, 4.7773142669677737, 2.3886571334838869, 1.1943285667419434, 0.59716428337097172, 0.29858214168548586

maxResolution=78271.51695

extent_type=loose

levels=20


OSM CODE


  function init() {
    var tilecacheBbox = new OpenLayers.Bounds(5.88, 45.78, 10.54, 47.81).transform(
        new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
        new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
      );
    alert(tilecacheBbox);

    var map_options = {
        maxExtent: tilecacheBbox,
        restrictedExtent: tilecacheBbox,
        maxResolution: 156543.03390000001,
        resolutions: [156543.03390000001, 78271.516950000005, 39135.758475000002, 19567.879237500001, 9783.9396187500006, 4891.9698093750003, 2445.9849046875001, 1222.9924523437501, 611.49622617187504, 305.74811308593752, 152.87405654296876, 76.43702827148438, 38.21851413574219, 19.109257067871095, 9.5546285339355475, 4.7773142669677737, 2.3886571334838869, 1.1943285667419434, 0.59716428337097172, 0.29858214168548586],
        //maxResolution: 78271.51695,
        projection: new OpenLayers.Projection("EPSG:900913"),
        //units: "meters",
        numZoomLevels: 20
    };

    map = new OpenLayers.Map("basicMap", map_options);
    map.addControl(new OpenLayers.Control.PanZoomBar());
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    var mapnik = new OpenLayers.Layer.OSM();
    // var tilescache = new OpenLayers.Layer.TileCache();
    tiles = new OpenLayers.Layer.WMS("OSM@Mapnik", "tilecache/tilecache.cgi?",{
        layers: 'osm', format: 'image/png', srs: 'EPSG:900913'
    });

    map.addLayer(mapnik);
    map.addLayer(tiles);
    map.setCenter(new OpenLayers.LonLat(8, 46.5)  // Center of the map
      .transform(
        new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
        new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
      ), 8 // Zoom level
    );
  }
share|improve this question
    
Martin, you should provide more information about your setup: which server is fronted by tilecache, post the exact error message and the relevant OL sections. –  unicoletti Dec 2 '11 at 7:48
    
I posted an answer with more details. Couldn't do this yesterday had a busy day... –  Styp Dec 2 '11 at 8:04
    
You should have included the details in the original question. I recommend you read the FAQ. –  unicoletti Dec 2 '11 at 8:14
    
thanks. did it. –  Styp Dec 2 '11 at 8:37
1  
+1: really want to know the answer too –  k102 Feb 21 '12 at 11:20
add comment

2 Answers

up vote 2 down vote accepted

In the OpenLayers code try to initialize the variable tilecacheBbox with the exact coordinates you set bbox in the TileCache config file.

var tilecacheBbox = new OpenLayers.Bounds();
tilecacheBbox.extend(654558.60577333, 5745163.8837113);
tilecacheBbox.extend(1173307.4327978, 6075303.6111284);

Perhaps the problem is that the coordinate transformation you are doing in the OpenLayers code generates values that differ in some decimals from the value bbox - TileCache configuration file - was set to. This difference can be big enough to mislead TileCache.

share|improve this answer
add comment

I had a similar issue, adding

OpenLayers.DOTS_PER_INCH = 90.71428571428572;

did the trick for me.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.