<commit_before>/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
 * text of the license. */
// @require: OpenLayers/Layer/Grid.js
/**
* @class
*/
OpenLayers.Layer.KaMap = Class.create();


OpenLayers.Layer.KaMap.prototype = 
  Object.extend( new OpenLayers.Layer.Grid(), {
    
    units: 'degrees',
    scales: {inches: 1, feet: 12, miles: 63360.0, meters: 39.3701, kilometers: 39370.1, degrees: 4374754},


    resolution: 72,
    
    DEFAULT_PARAMS: {
        i: 'jpeg',
        map: ''
    },
        
    // this.cellSize = newScale/(oMap.resolution * inchesPerUnit[oMap.units]);
    // kaMap.prototype.geoToPix = function( gX, gY ) { var pX = gX / this.cellSize; var pY = -1 * gY / this.cellSize; }
    initialize: function(name, url, params, units, resolution) {
        var newArguments = new Array();
        if (units) this.units = units;
        if (resolution) this.resolution = resolution;
        newArguments.push(name, url, params);
        OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
        this.params = (params ? params : {});
        if (arguments.length > 0 && params) {
            OpenLayers.Util.applyDefaults(
                           this.params, 
                           this.DEFAULT_PARAMS
                           );
        }
    },
    addTile:function(bounds,position) {
        var zoom = this.map.getZoom();
        var maxRes = this.map.maxResolution;
        var mapRes = this.map.getResolution();
        var scale = Math.round((((this.tileSize.w * this.map.maxResolution * this.resolution) * (this.scales[this.units])) / this.tileSize.w) / Math.pow(2, zoom));
        
        var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h);
        var pX = Math.floor(((bounds.left) / cellSize.w) * this.tileSize.w);
        var pY = -Math.floor(((bounds.top) / cellSize.h) * this.tileSize.h);
        var url = this.getFullRequestString(
                      { t: pY, 
                        l: pX,
                        s: scale
                      });
        return new OpenLayers.Tile.Image(this, position, bounds, 
                                             url, this.tileSize);
    },
    _initTiles:function() {

        //first of all, clear out the main div
        this.div.innerHTML = "";

        //now clear out the old grid and start a new one
        this.clearGrid();
        this.grid = new Array();

        var viewSize = this.map.getSize();
        var bounds = this.map.getExtent();
        var extent = this.map.getFullExtent();
        var resolution = this.map.getResolution();
        var tilelon = resolution*this.tileSize.w;
        var tilelat = resolution*this.tileSize.h;
        
        var offsetlon = bounds.left;
        var tilecol = Math.floor(offsetlon/tilelon);<commit_msg>KaMap can't round. It works fine for degrees, but when you're working in inches, feet, meters, the rounding errors become quite significant. <commit_after>/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
 * text of the license. */
// @require: OpenLayers/Layer/Grid.js
/**
* @class
*/
OpenLayers.Layer.KaMap = Class.create();


OpenLayers.Layer.KaMap.prototype = 
  Object.extend( new OpenLayers.Layer.Grid(), {
    
    units: 'degrees',
    scales: {inches: 1, feet: 12, miles: 63360.0, meters: 39.3701, kilometers: 39370.1, degrees: 4374754},


    resolution: 72,
    
    DEFAULT_PARAMS: {
        i: 'jpeg',
        map: ''
    },
        
    // this.cellSize = newScale/(oMap.resolution * inchesPerUnit[oMap.units]);
    // kaMap.prototype.geoToPix = function( gX, gY ) { var pX = gX / this.cellSize; var pY = -1 * gY / this.cellSize; }
    initialize: function(name, url, params, units, resolution) {
        var newArguments = new Array();
        if (units) this.units = units;
        if (resolution) this.resolution = resolution;
        newArguments.push(name, url, params);
        OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
        this.params = (params ? params : {});
        if (arguments.length > 0 && params) {
            OpenLayers.Util.applyDefaults(
                           this.params, 
                           this.DEFAULT_PARAMS
                           );
        }
    },
    addTile:function(bounds,position) {
        var zoom = this.map.getZoom();
        var maxRes = this.map.maxResolution;
        var mapRes = this.map.getResolution();
        var scale = (((this.tileSize.w * this.map.maxResolution * this.resolution) * (this.scales[this.units])) / this.tileSize.w) / Math.pow(2, zoom);
        
        var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h);
        var pX = Math.floor(((bounds.left) / cellSize.w) * this.tileSize.w);
        var pY = -Math.floor(((bounds.top) / cellSize.h) * this.tileSize.h);
        var url = this.getFullRequestString(
                      { t: pY, 
                        l: pX,
                        s: scale
                      });
        return new OpenLayers.Tile.Image(this, position, bounds, 
                                             url, this.tileSize);
    },
    _initTiles:function() {

        //first of all, clear out the main div
        this.div.innerHTML = "";

        //now clear out the old grid and start a new one
        this.clearGrid();
        this.grid = new Array();

        var viewSize = this.map.getSize();
        var bounds = this.map.getExtent();
        var extent = this.map.getFullExtent();
        var resolution = this.map.getResolution();
        var tilelon = resolution*this.tileSize.w;
        var tilelat = resolution*this.tileSize.h;
        
        var offsetlon = bounds.left;
        var tilecol = Math.floor(offsetlon/tilelon);
{'fraction_non_alphanumeric': 0.12811447811447813, 'fraction_numerical': 0.012457912457912458, 'mean_word_length': 1.9914400805639476, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2108706', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1756, 'n_words': 417}