[MapProxy] mapproxy-seed - Create OSM like tile

Mayeul Kauffmann mayeul.kauffmann at free.fr
Sun Feb 26 15:08:56 EST 2012


Hi,
Thanks Oliver! I had tried this already as I saw it in the forum, but I
tried in the wrong place:
caches:
  osm_cache:
    grids: [GLOBAL_MERCATOR] #, global_geodetic_sqrt2]
        origin: nw
(The above makes mapproxy exit)
I then tried flipping in openlayers, but my trials failed.

The one below works. I was confused by the fact that the "grids:" item
can be found in different places, but with different meaning and
options.

Here are 4 hints that may help other users:
-----------------------------
- if your project is local, try and add a simple world map, in order to
have something  to check visually at any zoom level and almost every
where (without this, I add only blank tiles in several of my trials)
-----------------------------
- I was seeding by simply browsing the WMS example at:
http://localhost:8080/demo/?wms_layer=osm&format=image%2Fpng
The first zoom level I could see was not 0, but 2 (for z=0 or 1, my WMS
gave error 500, so no tile). Start for a level and place where you are
100% sure you have tiles; checking overview levels is easier (less
tiles)
-----------------------------
- Connecting with OpenLayers worked with this: 

     function init() {
        map = new OpenLayers.Map("basicMap");
//         var mapnik = new OpenLayers.Layer.OSM();
        var newLayer = new OpenLayers.Layer.OSM("New Layer",
"file:///hometb/mk/sig/raster/mes_cartes/OSM/tiles_va_v1/mapproxy_tiles_va_v1/cache_data/osm_cache_EPSG900913/${z}/${x}/${y}.png", {numZoomLevels: 19});
        map.addLayer(newLayer);
//         map.addLayer(mapnik);
        map.setCenter(new OpenLayers.LonLat(13.41,52.52) // Center of
the map
          .transform(
            new OpenLayers.Projection("EPSG:4326"), // transform from
WGS 1984
            new OpenLayers.Projection("EPSG:900913") // to Spherical
Mercator Projection
          ), 2 // Zoom level
        );
      }

Rest of code is here:
http://wiki.openstreetmap.org/w/index.php?title=OpenLayers_Simple_Example&oldid=720377#A_little_more_extensive_example
------------------------------------
The above gives a full screen map, while the cache created by browsing
http://localhost:8080/demo/?wms_layer=osm&format=image%2Fpng is made on
a small moving div. With above js code, if some tiles are missing
(typically when you zoom in), things goes wrong!

Vielen Dank!

Hopes this helps someone else.

Mayeul Kauffmann

---- mapproxy.yaml -----
services:
  demo:
  kml:
  tms:
  wms:
    # srs: ['EPSG:4326', 'EPSG:900913']
    # image_formats: ['image/jpeg', 'image/png']
    md:
      # metadata used in capabilities documents
      title: MapProxy WMS Proxy
      abstract: This is the fantastic MapProxy.
      online_resource: http://mapproxy.org/
      contact:
        person: Your Name Here
      fees: 'None'

layers:
  - name: osm
    title: My OSM WMS
    sources: [osm_cache]
    
caches:
  osm_cache:
#     grids: [GLOBAL_MERCATOR] #, global_geodetic_sqrt2]
    grids: [global_mercator_flipped]
    sources: [osm_wms]
    cache:
      type: file
      directory_layout: tms

sources:
  osm_wms:
    type: wms
    req:
      url:
http://localhost/cgi-bin/qgis_mapserv.fcgi?map=/home/mk/sig/projects/via_alpina_climat_qgis19_v1_extrait.qgs&
      layers: countries,srtm_italy_x4,cities,towns
   
grids:
  global_geodetic_sqrt2:
    base: GLOBAL_GEODETIC
    res_factor: 'sqrt2'
  global_mercator_flipped:
    base: GLOBAL_MERCATOR
    origin: nw

globals:
  cache:
    base_dir: './cache_data'
    lock_dir: './cache_data/locks'

  # image/transformation options
  image:
      resampling_method: nearest





Le dimanche 26 février 2012 à 19:31 +0100, Oliver Tonnhofer a écrit :
> Hi,
> 
> On 26.02.2012, at 03:01, Mayeul Kauffmann wrote:
> > Vertical tile order is incorrect.
> > Following your suggestions, I tried playing around with y
> > For instance var y = 2^z - 1 - Math.round ((this.maxExtent.top -
> > bounds.top) / (res * this.tileSize.h));
> > but it did not work.
> 
> You mean that the Y-axis is flipped? See http://mapproxy.org/docs/nightly/configuration.html#origin
> 
> Regards,
> Oliver
> 




More information about the MapProxy mailing list