]> git.openstreetmap.org Git - rails.git/blob - public/lib/OpenLayers/Layer/KaMap.js
Added tests for changeset close method.
[rails.git] / public / lib / OpenLayers / Layer / KaMap.js
1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2  * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3  * text of the license. */
4 // @require: OpenLayers/Layer/Grid.js
5 /**
6 * @class
7 */
8 OpenLayers.Layer.KaMap = Class.create();
9 OpenLayers.Layer.KaMap.prototype = 
10   Object.extend( new OpenLayers.Layer.Grid(), {
11     metaTileHeight: 6,
12     metaTileWidth: 6,
13     
14     DEFAULT_PARAMS: {
15         i: 'jpeg',
16         map: ''
17     },
18         
19     // this.cellSize = newScale/(oMap.resolution * inchesPerUnit[oMap.units]);
20     // kaMap.prototype.geoToPix = function( gX, gY ) { var pX = gX / this.cellSize; var pY = -1 * gY / this.cellSize; }
21     initialize: function(name, url, params, origin) {
22         this.kaOrigin = origin;
23         var newArguments = new Array();
24         newArguments.push(name, url, params);
25         OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
26         this.params = (params ? params : {});
27         if (arguments.length > 0 && params) {
28             OpenLayers.Util.applyDefaults(
29                            this.params, 
30                            this.DEFAULT_PARAMS
31                            );
32         }
33     },
34     addTile:function(bounds,position) {
35         var zoom = this.map.getZoom();
36         var resolution = this.map.getResolution();
37         var scale = 128000000 / Math.pow(2, zoom);
38         // 1280000 is an empirical value for a specific tile server, not yet figured out the right way to do this in general.
39         // This will probably be based on map.maxResolution.
40         var cellSize = new OpenLayers.Size(resolution*this.tileSize.w, resolution*this.tileSize.h);
41         var pX = Math.floor(((bounds.left + this.kaOrigin.lon) / cellSize.w) * this.tileSize.w);
42         var pY = -Math.floor(((bounds.top+this.kaOrigin.lat) / cellSize.h) * this.tileSize.h);
43         var url = this.getFullRequestString(
44                       { t: pY, 
45                         l: pX,
46                         s: scale
47                       });
48         return new OpenLayers.Tile.Image(this, position, bounds, 
49                                              url, this.tileSize);
50     },
51     /** @final @type String */
52     CLASS_NAME: "OpenLayers.Layer.KaMap"
53 });