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
 
   8 OpenLayers.Layer.KaMap = Class.create();
 
   9 OpenLayers.Layer.KaMap.prototype = 
 
  10   Object.extend( new OpenLayers.Layer.Grid(), {
 
  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(
 
  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(
 
  48         return new OpenLayers.Tile.Image(this, position, bounds, 
 
  51     /** @final @type String */
 
  52     CLASS_NAME: "OpenLayers.Layer.KaMap"