4

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
    );
  }
3
  • 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, 2011 at 7:48
  • I posted an answer with more details. Couldn't do this yesterday had a busy day...
    – Styp
    Dec 2, 2011 at 8:04
  • You should have included the details in the original question. I recommend you read the FAQ.
    – unicoletti
    Dec 2, 2011 at 8:14

2 Answers 2

2

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.

1

I had a similar issue, adding

OpenLayers.DOTS_PER_INCH = 90.71428571428572;

did the trick for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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