you're reading...
gvsig mobile, spherical mercator, tiling, wonthurt

On-the-fly reprojection of tiles using your favorite conventional WMS servers

If we accept Spherical Mercator tiles and the ZXY storage scheme as standard and still wish to use all the nice WMS servers we know, we can easily set up a middle tile server like this:

For example, this request gets a OSM-like tile from a conventional Bavarian WMS server:

http://lucasdom.homelinux.org:8077/services/smtile?baseurl=http://www.geodaten.bayern.de/ogc/getogc.cgi%3fREQUEST=GetMap%26SERVICE=WMS%26VERSION=1.1.1%26LAYERS=UK500,TK50&x=8711&y=5643&z=14

The advantage of this over cascading WMS is that the middle server does not need to know the targeted server URL in advance, and the client (possibly a handheld) only has to provide the URL and the tile indices (x, y, z). In this example, I’m assuming that the targeted WMS server supports EPSG:4326, which is true in almost all cases.

A middle server of this type is currently up and running in my home computer. The images you see here are static ones. The URL to get them from the middle server is provided in the code boxes:

http://lucasdom.homelinux.org:8077/services/smtile?baseurl=http://shagrat.icc.es:80/lizardtech/iserv/ows%3fREQUEST=GetMap%26SERVICE=WMS%26VERSION=1.1.1%26LAYERS=mtc250m,mtc50m,mtc25m,mtc10m,mtc5m&x=132657&y=97914&z=18

Medieval quarter in Barcelona (Spain). Source: Institut Cartogràfic de Catalunya.
Corresponding OSM tile with the same indices:

x = 132657
y = 97914
z = 18

http://lucasdom.homelinux.org:8077/services/smtile?baseurl=http://www.geosignal.org/cgi-bin/wmsmap%3fREQUEST=GetMap%26SERVICE=WMS%26VERSION=1.1.1%26LAYERS=RASTER4000k,RASTER1000k,RASTER500k,RASTER250k,RASTER100k,RASTER50k,RASTER25k,RASTER5k&x=1027&y=717&z=11

A French town called Tours. Source: Geosignal.
Corresponding OSM tile with the same indices:

x = 1027
y = 717
z = 11

http://lucasdom.homelinux.org:8077/services/smtile?baseurl=http://www.geodaten.bayern.de/ogc/getogc.cgi%3fREQUEST=GetMap%26SERVICE=WMS%26VERSION=1.1.1%26LAYERS=UK500,TK50&x=8711&y=5643&z=14

A German town called Ingolstadt. Source: Bayerische Vermessungsverwaltung.
Corresponding OSM tile with the same indices:

x = 8711
y = 5643
z = 14

Advertisements

Discussion

3 thoughts on “On-the-fly reprojection of tiles using your favorite conventional WMS servers

  1. HI Juan,
    very interesting indeed.
    What kind of server and set-up are you using as the middle server in teh example above ? Would you have any more details how the reprojection is done and handed?
    Thanks
    Karsten

    Posted by Karsten vennemann | 03/05/2010, 6:26 PM
    • Hello, Karsten.

      The service ‘http://lucasdom.homelinux.org:8077/services/smtile’ is associated to a servlet in a small Java application that runs on the server. The server is very bad: Windows XP Home Edition (5 year old computer, 500 MB RAM) connected to my router via wifi. It’s not multi-thread-safe or anything, just a little example to prove that it works :)

      The relevant method looks like this:

      public void run(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
      ...
      }

      The body of that method is like this:

      1. If parameters of request are not OK, return an image saying “Bad parameters”. End.
      2. Compute file name (with full path) of the requested tile in the cache folder.
      3. If that file exists (previously requested) then return it. End.
      4. Compute WGS84 coordinates and request the image from the target server (width and height should be at least 256 pixels, so when we reproject it, the quality will be OK). Store the image in a temporary location and create also its WLD file.
      5. Write a short script (.sh or .bat) to reproject the temporary image to Spherical Mercator with size = 256 x 256 and clipping the image to the correct bounding box of the requested tile. Run that script, which will use the GDAL utilities, installed in the server.
      6. Copy the resulting tile to the right place in the cache folder and return it. End.

      Posted by gvsigmobileonopenmoko | 03/05/2010, 9:45 PM
  2. Thanks for sharing great post dear. Your post enhanced my knowledge and made me aware about re-projection. Keep posting great post…

    Posted by Geomarketing | 09/11/2010, 10:42 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: