[OpenLayers-Dev] WorldWind cache proposal

Tim Schaub tschaub at openplans.org
Fri Nov 2 14:06:11 EDT 2007


Hey-

I'll reply above here instead of buried below.

There are really two ways to request tiles (or three if you like a 
combination of the two), right?  A request can put the information about 
the tile in the URL path or in the URL query string.  The TMS and 
TileCache layers are about requesting tiles based on URL path.  Most 
other layers are about requesting layers based on URL query string.

The HTTPRequest layer is really about requesting stuff based on query 
string (it doesn't do any path modification, only query string 
modification).

The Grid layer is a HTTPRequest layer that adds knowledge about tiles.

The TMS and TileCache layers are Grid layers that pretend they don't 
really inherit from HTTPRequest (they ignore their params related 
origins, but still have methods like mergeNewParams).

(This is getting a bit sloppy isn't it?)

Now, the HTTPRequest layer isn't *really* about http.  This layer can 
legitimately be used to request data with the file URL schema, for 
example.  If your url is file based ("file://host/path"), the 
HTTPRequest layer will work perfectly well.  (Maybe this layer is really 
a QueryString layer!)

So, anyway, the way things are, you want a Grid layer that looks a lot 
like the TMS and TileCache layers (they are largely about overriding the 
getURL method).

Since you are really just specifying the URL path generation behavior 
(generate a path with this algorithm that is based on these options) for 
an instance of the Grid class, it would be nice if things were 
generalized more to make this easier - instead of adding a bunch of 
custom code to the WorldWind layer.

Basically I'm saying I don't think you should modify the WorldWind layer 
  so that it switches between URL path generation and URL query string 
generation for tile requests.

In a perfect world (3.0), we'd probably have a URL layer.  You could 
modify this layer with custom path and query string behaviors.  The way 
things are, you could create a WorldWindCache layer.

If you want your map to switch between remote and local data at some 
resolution, then use two layers.

I know this doesn't treat the case where you want to switch behavior 
(from path based to query string based) given the availability of an 
individual tile with the first behavior (I'd just use img.onerror here). 
  This is getting pretty custom - and I'm not the one to say how 
appropriate it is here (since I don't really have experience with the 
WorldWind layer).

Tim

Andrew Larcombe wrote:
> Hi List,
> 
> I have the following proposals for additions to the WorldWind classes  
> within OpenLayers that I'd like your feed back on.
> 
> Regards,
> 
> Andrew
> 
> 
> 
> Proposal to add local caching options to WorldWind classes in OpenLayers
> 
> Scope
> This document covers the proposal of additional functionality to  
> OpenLayers to be able to use locally stored WorldWind cache files  
> when the URI of the page containing the OpenLayers map is of a file:  
> scheme.
> 
> Motivation
> Although Worldwind data is most commonly used in an client-server  
> based online environment, it is possible to download WorldWind cache  
> files for offline use[1]. OpenLayers contains a class to access  
> server-based WorldWind caches using a well defined URL naming scheme,  
> but there is no functionality to retrieve some or all tiles for a  
> request from a local WorldWind cache.
> 
> Proposals
> The existing WorldWind class, OpenLayers.Layer.WorldWind, contains  
> the logic to determine which tile to display given a bounding box.  
> This can be found in the method OpenLayers.Layer.WorldWind.getURL.  
> The three key values it calculates, zoom, x and y can be used, with  
> correct formatting rules applied, to retrieve an image tile from a  
> local WorldWind cache directory instead of a remote server.
> 
> Proposal 1
> Function OpenLayers.Layer.WorldWind.getURL to be modified to return a  
> file scheme URI of a tile in a local WorldWind cache - the directory  
> of which has been specified by the url parameter in the constructor  
> of the layer.
> 
> eg
> 
> ww = new OpenLayers.Layer.WorldWind( "WorldWind", "file:///Volumes/ 
> homes/mapdata/NASA/World Wind 1.3/Cache/BMNG/BMNG (Shaded +  
> Bathymetry) Tiled - 1.2004/", 36, 4);
> 
> would create a new layer which would retrieve images from the  
> WorldWind cache located in the local directory /Volumes/homes/mapdata/ 
> NASA/World Wind 1.3/Cache/BMNG/BMNG (Shaded + Bathymetry) Tiled -  
> 1.2004/.
> 
> Proposal 2
> Rather than choose between whether to retrieve files from a local  
> cache or a remote server at development time it may be advantageous  
> to retrieve some tiles (eg those at a high zoom level) from a local  
> cache, with others being retrieved from a remote server. To enable  
> this an entry in the options array of the OpenLayers.Layer.WorldWind  
> constructer could be used to indicate the location of a local cache  
> directory. The function OpenLayers.Layer.WorldWind.getURL could then  
> detect whether the local cache contains data for the particular zoom  
> level that has been requested using the  
> Components.interfaces.nsILocalFile (Mozilla-based browsers) or  
> Scripting.FileSystemObject (Internet Explorer) components[2]. If data  
> is available in the local WorldWind cache then getURL will return the  
> URI to that tile, else it will return the URI to the tile on the  
> remote server.
> 
> eg
> 
> ww = new OpenLayers.Layer.WorldWind( "WorldWind", "http:// 
> worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4,{T:"bmng.topo.bathy. 
> 200406"},{cache:"/Volumes/homes/mapdata/NASA/World Wind 1.3/Cache/ 
> BMNG/BMNG (Shaded + Bathymetry) Tiled - 1.2004/"});
> 
> would create a new layer which would retrieve images from the  
> WorldWind cache located in the local directory /Volumes/homes/mapdata/ 
> NASA/World Wind 1.3/Cache/BMNG/BMNG (Shaded + Bathymetry) Tiled -  
> 1.2004/ , if that directory contains data for the requested zoom  
> level, else it would attempt to retrieve it from the server at http:// 
> worldwind25.arc.nasa.gov/tile/tile.aspx?
> 
> [1] - eg http://www.worldwinddata.com/
> [2] - Using a Javascript-only approach this functionality would be  
> limited to these two browser types.
> 




More information about the Dev mailing list