Home > openlayers > TileCache and Openlayers Problem - Projections?

TileCache and Openlayers Problem - Projections?

December 1Hits:1
Advertisement

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("[email protected]", "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     );   } 

Answers

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.

I had a similar issue, adding

OpenLayers.DOTS_PER_INCH = 90.71428571428572;

did the trick for me.

Related Articles

  • TileCache and Openlayers Problem - Projections?December 1

    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

  • Tile script (Mapnik) with OpenLayers - Problem with projection (900913)

    Tile script (Mapnik) with OpenLayers - Problem with projection (900913)May 9

    I use Mapnik python bindings in a geodjango application to render tiles in openlayers with datasource stored in postGIS in 900913 projection. The feature seems to be rendered correctly in the spherical mercator projection, but at a very high zoomLeve

  • OpenLayers and GeoJSON - problem projecting EPSG:4326February 19

    I'm trying to project some GeoJSON data but it ends up at 0,0. I've looked at other posts and tried those solutions to no avail. Can anyone help? Here is the code: <html> <head> <title>OpenLayers Example</title> <script src=&quo

  • Tilecache and Mapnik problem

    Tilecache and Mapnik problemFebruary 21

    My configs: # Rendering OpenStreetMap data with Mapnik; should use metaTiling to # avoid labels across tile boundaries [osm-map] type=MapnikLayer mapfile=/usr/home/sergeev/osm_mapnik/osm.xml spherical_mercator=true tms_type=google metatile=yes extent

  • User Input in Openlayers ProblemAugust 13

    I thought you could give me some advice regarding my problem. I have a working WFS Layer and I want to be able to type in some text which then should be used as the filter value. Afterwards the map should be refreshed, however only with the features

  • OpenLayers: Problems adding WMS layer to OSMJune 11

    I need to create a map with 2 layers. The first layer (basemap) is the OSM layer, and the second layer is my custom geoserver WMS layer. This layer is in EPSG:4326 projection. Is this possible? I have read many posts but I didn't solve my problem. I

  • Openlayers Plugin, Project CRS and Grids in ComposerJuly 25

    Apologies in advance for the potential for this to be a duplicate question, I've had a good look, and I can't see a solution thatI understand well enough to help me. I have my project CRS set to a local UTM projection, however when I add a map from O

  • Openlayers map projection not working while saving the features into PostGis

    Openlayers map projection not working while saving the features into PostGisNovember 1

    In my web map application, I have added the wfs vector layer for feature editing. There is no issue When I save the feature in postgis after editing. But when I refresh the wfs layer, its showing the edited portion in somewhere. See the below image H

  • OpenLayers Problem | Unable to zoom Layer

    OpenLayers Problem | Unable to zoom LayerMay 1

    I am trying basic examples of OpenLayers with my own Geoserver. When I tried to replace WMS with own local WMS path, I am unable to zoom layer after a specific scale. var map; function init(){ map = new OpenLayers.Map('map_element', {}); var wms = ne

  • openlayers display projectionSeptember 15

    I'm displaying coordinates in EPSG:900913 using ol.control.MousePosition() with OSM. I'd like to convert these on the fly in another EPSG:2154. I call in the header : <script src="./proj4js-1-1-0/lib/proj4js-compressed.js" type="text/jav

  • Ext and Openlayers problem color layerOctober 13

    I had symbolized different layers as you can see here: if (vector_layer.name == "Buffer"){ vector_layer.style = {fillColor: "blue", pointRadius: 7, fillOpacity: 0.3, strokeColor:"#F2F2F2"}; vector_layer.addFeatures(geojson_fo

  • OpenLayers - Problems With WPSClientNovember 17

    I am trying to incorporate a WPS running in GeoServer into an OpenLayers client. I am using this simple example as my reference. Using either a local install of OpenLayers.js (v 2.12), or the http://openlayers.org/api/OpenLayers.js, I get an error wh

  • Openlayers - Problem with selecting features from overlapping vector layersMarch 11

    I face the following problem. I have two vector layers. One has linestring and the other point geometry. When I add this line to my point geometry vector layer: pointLayer.setZIndex( 1001 ); I get the point layer on top and then I am unable to select

  • Openlayers multiple zoom problemAugust 4

    I have a simple WebGIS with Mapserver, Tilecache and Openlayers. This project has something like 12 zoom levels. The problem is when I zoom for several layers (say 8 lavels), it becomes very slow, since it tries to load images for all the previous 8

  • How to measure correct distances in a project with OpenLayers background?August 25

    I have 3 lat/long points as follows: A = {35.257246,139.721256} B = {35.256541,139.721491} C = {35.256326,139.7203271} 1) Measurement result by Movable Type Scripts: By using the distance calculation method at Movable Type Scripts, the distance resul

  • OpenLayers wrapDateLine Problems with ArcGIS93Rest

    OpenLayers wrapDateLine Problems with ArcGIS93RestMarch 21

    I'm having issues viewing a ArcGIS93Rest layer on both sides of the dateline -- the data doesn't cross the dateline. The problem is that i only see data for one side of the dateline until i pan west and vice versa (see attached pics at bottom). I'm t

  • QGIS: On the fly projection from WGS84, 19 N, to Web Mercator. Do I need to define a new CRS with transformation parameters?

    QGIS: On the fly projection from WGS84, 19 N, to Web Mercator. Do I need to define a new CRS with transformation parameters?December 3

    Workin in QGIS, I have a shapefile called "protected areas" of Dominican Republic, that was digitized from topomaps 50k. Shapefile is projected to WGS84, 19N zone. My problem is that when I load openlayers, the limits of almost all protected are

  • OpenLayers.Map is not a constructorJune 6

    I am trying to enter in my maps application (Geoserver, postgis, openlayer) but it is empty and I get an error with Firebug: TypeError: OpenLayers.Map is not a constructor in my map.js script in line var map = new OpenLayers.Map({projection: "EPSG:90

  • OpenLayers and external CSSJune 21

    I am using geoExt and OpenLayers to plot some map. Everything worked well until I had to add some styling. To display it on the webpage, I need to use the CSS of my university and once I do that, I have some horizontal white lines between each tile (

  • What's a good way to display a custom raster basefile in OpenlayersSeptember 22

    I have a land cover raster that I'd like to display as part of an Openlayers based application. I'm able to load the raster directly as a PNG but my Openlayers application becomes VERY slow. I think I want something that can tile the raster and send

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.723 s.