My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* 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. */

/**
* @class
*
* @requires OpenLayers/Layer/Grid1D.js
*/

OpenLayers.Layer.Grid.prototype.initGriddedTiles = function(bounds) {
if(this.grid.length == 0){ this.grid.push([]); }

var viewSize = this.map.getSize();
var minCols = Math.ceil(viewSize.w/this.tileSize.w) +
Math.max(1, 2 * this.buffer);

var extent = this.map.getMaxExtent();
var resolution = this.map.getResolution();

var tileLayout = this.calculateGridLayout(bounds, extent, resolution);

var tileoffsetx = Math.round(tileLayout.tileoffsetx);
var tileoffsetlon = tileLayout.tileoffsetlon;
var tilelon = tileLayout.tilelon;

this.origin = new OpenLayers.Pixel(tileoffsetx, 0);

var startX = tileoffsetx;
var startLon = tileoffsetlon;

var colidx = 0;


var layerContainerDivLeft = parseInt(this.map.layerContainerDiv.style.left);
var layerContainerDivTop = parseInt(this.map.layerContainerDiv.style.top);

// follow the inner loop in the original OpenLayers version.
do {
var tileBounds = new OpenLayers.Bounds(tileoffsetlon,
0,
tileoffsetlon + tilelon,
1);

//var x = tileoffsetx;
//x -= layerContainerDivLeft;
//var y = 0;

var px = new OpenLayers.Pixel(tileoffsetx - layerContainerDivLeft, 0);

var tile = this.grid[0][colidx++];
if (!tile) {
tile = this.addTile(tileBounds, px);
this.addTileMonitoringHooks(tile);
this.grid[0].push(tile);
} else {
tile.moveTo(tileBounds, px, false);
}

tileoffsetlon += tilelon;
tileoffsetx += this.tileSize.w;
} while ((tileoffsetlon <= bounds.right + tilelon * this.buffer)
|| colidx < minCols)

this.removeExcessTiles(2, colidx);
//now actually draw the tiles
//this.linearTileLoad();
this.spiralTileLoad();
};
OpenLayers.Layer.Grid.prototype.buffer = 1;


OpenLayers.Layer.Genomic = OpenLayers.Class.create();
OpenLayers.Layer.Genomic.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {

/** Hashtable of default parameter key/value pairs
* @final @type Object */
DEFAULT_PARAMS: {

},

/**
* @constructor
*
* @param {String} name
* @param {String} url
* @param {Object} params
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, params, options) {
var newArguments = [];
//uppercase params
newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
OpenLayers.Util.applyDefaults(
this.params,
this.DEFAULT_PARAMS
);

// unless explicitly set in options, if the layer is transparent,
// it will be an overlay
if (options == null || options.isBaseLayer == null) {
this.isBaseLayer = ((this.params.TRANSPARENT != "true") &&
(this.params.TRANSPARENT != true));
}
},

/**
*
*/
destroy: function() {
// for now, nothing special to do here.
OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
},


/**
* @param {Object} obj
*
* @returns An exact clone of this OpenLayers.Layer.Genomic
* @type OpenLayers.Layer.Genomic
*/
clone: function (obj) {

if (obj == null) {
obj = new OpenLayers.Layer.Genomic(this.name,
this.url,
this.params,
this.options);
}

//get all additions from superclasses
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);

// copy/set any non-init, non-simple values here

return obj;
},

/**
* @param {OpenLayers.Bounds} bounds
*
* @returns A string with the layer's url and parameters and also the
* passed-in bounds and appropriate tile size specified as
* parameters
* @type String
*/
getZoom: function(){
return this.map.resolutions.length - this.map.getZoom() -1;
},
getURL: function (bounds) {
var zoom = this.getZoom();
var res = this.getResolution();
var xmin = Math.floor(Math.floor(bounds.left/res) * res);
var xmax = Math.floor(Math.floor(bounds.right/res) * res);
return this.getFullRequestString(
{
xmin : xmin,
xmax : xmax,
width: this.map.tileSize.w
});
},

getResolution: function(){
return this.map.resolutions[this.map.getZoom()];
},

/**
* addTile creates a tile, initializes it, and
* adds it to the layer div.
*
* @param {OpenLayers.Bounds} bounds
*
* @returns The added OpenLayers.Tile.Image
* @type OpenLayers.Tile.Image
*/
addTile:function(bounds,position) {
url = this.getURL(bounds);
return new OpenLayers.Tile.Image(this, position, bounds,
url, this.tileSize);
},


getExtent: function(resolution) {
var extent = null;
var center = this.map.getCenter();
if (center != null) {

if (resolution == null) {
resolution = this.getResolution();
}
var size = this.map.getSize();
var w_deg = size.w * resolution;

extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
0,
center.lon + w_deg / 2,
1);

}

return extent;
},

/**
* Catch changeParams and uppercase the new params to be merged in
* before calling changeParams on the super class.
*
* Once params have been changed, we will need to re-init our tiles
*
* @param {Object} newParams Hashtable of new params to use
*/
mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
var newArguments = [upperParams];
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,
newArguments);

if (this.map != null) {
this._initTiles();
}
},

/** combine the layer's url with its params and these newParams.
*
* Add the SRS parameter from projection -- this is probably
* more eloquently done via a setProjection() method, but this
* works for now and always.
*
* @param {Object} newParams
*
* @type String
*/
getFullRequestString:function(newParams) {

return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
this, arguments);
},

/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Genomic"
});
Show details Hide details

Change log

r18 by bpederse on Apr 24, 2008   Diff
update to OL 2.6, clean out Grid1D.js and
move the only remaning function into
Genomic.js. now incompatible with < OL 2.6
Go to: 
Project members, sign in to write a code review

Older revisions

r17 by bpederse on Apr 07, 2008   Diff
fix bug reported in  issue 2 :
http://code.google.com/p/genome-
browser/issues/detail?id=2 thanks
peter underdog
r10 by bpederse on Dec 19, 2007   Diff
fix zooms
r8 by bpederse on Jun 18, 2007   Diff
fix grid to not depend on 0 to 1 for y
extent, it is whatever is
sent in to the constructor.
All revisions of this file

File info

Size: 7531 bytes, 243 lines

File properties

svn:mime-type
text/javascript
Hosted by Google Code