Changeset 140
- Timestamp:
- 05/18/06 08:48:52 (3 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/Grid.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Marker.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Util.js (modified) (6 diffs)
- trunk/openlayers/tests/test_Bounds.html (modified) (5 diffs)
- trunk/openlayers/tests/test_Tile.html (modified) (1 diff)
- trunk/openlayers/tests/test_Tile_Image.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/Grid.js
r104 r140 44 44 } else { 45 45 var i = 0; 46 while (this.getGridBounds(). minlat > bounds.minlat) {46 while (this.getGridBounds().bottom > bounds.bottom) { 47 47 this.insertRow(false); 48 48 } 49 while (this.getGridBounds(). minlon > bounds.minlon) {49 while (this.getGridBounds().left > bounds.left) { 50 50 this.insertColumn(true); 51 51 } 52 while (this.getGridBounds(). maxlat < bounds.maxlat) {52 while (this.getGridBounds().top < bounds.top) { 53 53 this.insertRow(true); 54 54 } 55 while (this.getGridBounds(). maxlon < bounds.maxlon) {55 while (this.getGridBounds().right < bounds.right) { 56 56 this.insertColumn(false); 57 57 } … … 61 61 var topLeftTile = this.grid[0][0]; 62 62 var bottomRightTile = this.grid[this.grid.length-1][this.grid[0].length-1]; 63 return new OpenLayers.Bounds(topLeftTile.bounds. minlon,64 bottomRightTile.bounds. minlat,65 bottomRightTile.bounds. maxlon,66 topLeftTile.bounds. maxlat);63 return new OpenLayers.Bounds(topLeftTile.bounds.left, 64 bottomRightTile.bounds.bottom, 65 bottomRightTile.bounds.right, 66 topLeftTile.bounds.top); 67 67 }, 68 68 _initTiles:function() { … … 74 74 var tilelat = resolution*this.tileSize.h; 75 75 76 var offsetlon = bounds. minlon - extent.minlon;76 var offsetlon = bounds.left - extent.left; 77 77 var tilecol = Math.floor(offsetlon/tilelon); 78 78 var tilecolremain = offsetlon/tilelon - tilecol; 79 79 var tileoffsetx = -tilecolremain * this.tileSize.w; 80 var tileoffsetlon = extent. minlon+ tilecol * tilelon;81 82 var offsetlat = bounds. maxlat - (extent.minlat+ tilelat);80 var tileoffsetlon = extent.left + tilecol * tilelon; 81 82 var offsetlat = bounds.top - (extent.bottom + tilelat); 83 83 var tilerow = Math.ceil(offsetlat/tilelat); 84 84 var tilerowremain = tilerow - offsetlat/tilelat; 85 85 var tileoffsety = -tilerowremain * this.tileSize.h; 86 var tileoffsetlat = extent. minlat+ tilerow * tilelat;86 var tileoffsetlat = extent.bottom + tilerow * tilelat; 87 87 88 88 tileoffsetx = Math.round(tileoffsetx); // heaven help us … … 114 114 tileoffsetlon += tilelon; 115 115 tileoffsetx += this.tileSize.w; 116 } while (tileoffsetlon < bounds. maxlon)116 } while (tileoffsetlon < bounds.right) 117 117 118 118 tileoffsetlat -= tilelat; 119 119 tileoffsety += this.tileSize.h; 120 } while(tileoffsetlat > bounds. minlat- tilelat)120 } while(tileoffsetlat > bounds.bottom - tilelat) 121 121 122 122 }, … … 140 140 var bounds = modelTile.bounds.copyOf(); 141 141 var position = modelTile.position.copyOf(); 142 bounds. minlat = bounds.minlat+ deltaLat;143 bounds. maxlat = bounds.maxlat+ deltaLat;142 bounds.bottom = bounds.bottom + deltaLat; 143 bounds.top = bounds.top + deltaLat; 144 144 position.y = position.y + deltaY; 145 145 var newTile = this.addTile(bounds, position); … … 173 173 var bounds = modelTile.bounds.copyOf(); 174 174 var position = modelTile.position.copyOf(); 175 bounds. minlon = bounds.minlon+ deltaLon;176 bounds. maxlon = bounds.maxlon+ deltaLon;175 bounds.left = bounds.left + deltaLon; 176 bounds.right = bounds.right + deltaLon; 177 177 position.x = position.x + deltaX; 178 178 var newTile = this.addTile(bounds, position); trunk/openlayers/lib/OpenLayers/Layer/Marker.js
r135 r140 51 51 var extent = this.map.getExtent(); 52 52 var pixel = new OpenLayers.Pixel( 53 1/resolution * (marker.lonlat.lon - extent. minlon),54 1/resolution * (extent. maxlat- marker.lonlat.lat)53 1/resolution * (marker.lonlat.lon - extent.left), 54 1/resolution * (extent.top - marker.lonlat.lat) 55 55 ); 56 56 var m = marker.generateMarker(pixel); trunk/openlayers/lib/OpenLayers/Map.js
r118 r140 223 223 getZoomForExtent: function (bounds) { 224 224 var size = this.getSize(); 225 var deg_per_pixel = bounds. width/ size.w;225 var deg_per_pixel = bounds.getWidth() / size.w; 226 226 var zoom = Math.log(deg_per_pixel / this.maxResolution) / Math.log(2); 227 227 return Math.floor(Math.max(zoom, 0)); … … 319 319 this.zoom = this.getZoomForExtent( fullExtent ); 320 320 this.setCenter( 321 new OpenLayers.LonLat((fullExtent. minlon+fullExtent.maxlon)/2,322 (fullExtent. minlat+fullExtent.maxlat)/2)321 new OpenLayers.LonLat((fullExtent.left+fullExtent.right)/2, 322 (fullExtent.bottom+fullExtent.top)/2) 323 323 ); 324 324 }, trunk/openlayers/lib/OpenLayers/Util.js
r139 r140 1 /* 1 /** 2 2 * @class 3 3 */ … … 224 224 /** 225 225 * @class This class represents a bounding box. 226 * Data stored as Min and Max Longitudes and Latitudes226 * Data stored as left, bottom, right, top floats 227 227 */ 228 228 OpenLayers.Bounds = Class.create(); … … 230 230 231 231 /** @type float */ 232 minlon: 0.0, 233 234 /** @type float */ 235 minlat: 0.0, 236 237 /** @type float */ 238 maxlon: 0.0, 239 240 /** @type float */ 241 maxlat: 0.0, 242 243 /** @type float */ 244 width: 0.0, 245 246 /** @type float */ 247 height: 0.0, 248 249 250 /** 232 left: 0.0, 233 234 /** @type float */ 235 bottom: 0.0, 236 237 /** @type float */ 238 right: 0.0, 239 240 /** @type float */ 241 top: 0.0, 242 243 /** 251 244 * @constructor 252 245 * 253 * @param {float} minlon 254 * @param {float} minlat 255 * @param {float} maxlon 256 * @param {float} maxlat 257 */ 258 initialize: function(minlon, minlat, maxlon, maxlat) { 259 this.minlon = minlon; 260 this.minlat = minlat; 261 this.maxlon = maxlon; 262 this.maxlat = maxlat; 263 this.width = Math.abs(this.maxlon - this.minlon); 264 this.height = Math.abs(this.maxlat - this.minlat); 265 }, 266 246 * @param {float} left 247 * @param {float} bottom 248 * @param {float} right 249 * @param {float} top 250 * 251 */ 252 initialize: function(left, bottom, right, top) { 253 this.left = left; 254 this.bottom = bottom; 255 this.right = right; 256 this.top = top; 257 }, 258 259 /** 260 * @returns A fresh copy of the bounds 261 * @type OpenLayers.Bounds 262 */ 263 copyOf:function() { 264 return new OpenLayers.Bounds(this.left, this.bottom, 265 this.right, this.top); 266 }, 267 267 268 /** 268 269 * @return String representation of OpenLayers.Bounds object. 269 * (ex.<i>" Min lon/lat=5/42 Max lon/lat=10/45 width=5 height=3"</i>)270 * (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>) 270 271 * @type String 271 272 */ 272 273 toString:function(){ 273 return ("Min lon/lat=" + this.minlon +"/"+ this.minlat 274 + " Max lon/lat=" + this.maxlon +"/"+ this.maxlat 275 + " width=" + this.width + " height=" + this.height); 276 }, 277 278 /** 279 * @return New OpenLayers.Bounds object with the same min/max lon/lat values 280 * @type OpenLayers.Bounds 281 */ 282 copyOf:function() { 283 return new OpenLayers.Bounds(this.minlon, this.minlat, 284 this.maxlon, this.maxlat); 274 return ( "left-bottom=(" + this.left + "," + this.bottom + ")" 275 + " right-top=(" + this.right + "," + this.top + ")" ); 285 276 }, 286 277 … … 291 282 */ 292 283 toBBOX:function() { 293 return (this.minlon + "," + this.minlat + "," + 294 this.maxlon + "," + this.maxlat); 295 }, 296 297 298 /** 299 * @return Whether or not the passed-in coordinate is within the area 300 * delineated by this OpenLayers.Bounds 284 return (this.left + "," + this.bottom + "," 285 + this.right + "," + this.top); 286 }, 287 288 /** 289 * @returns The width of the bounds 290 * @type float 291 */ 292 getWidth:function() { 293 return (this.right - this.left); 294 }, 295 296 /** 297 * @returns The height of the bounds 298 * @type float 299 */ 300 getHeight:function() { 301 return (this.top - this.bottom); 302 }, 303 304 /** 305 * @returns An OpenLayers.Size which represents the size of the box 306 * @type OpenLayers.Size 307 */ 308 getSize:function() { 309 return new OpenLayers.Size(this.getWidth(), this.getHeight()); 310 }, 311 312 /** 313 * @returns An OpenLayers.Pixel which represents the center of the bounds 314 * @type OpenLayers.Pixel 315 */ 316 getCenterPixel:function() { 317 return new OpenLayers.Pixel(this.left + (this.getWidth() / 2), 318 this.bottom + (this.getHeight() / 2)); 319 }, 320 321 /** 322 * @returns An OpenLayers.LonLat which represents the center of the bounds 323 * @type OpenLayers.LonLat 324 */ 325 getCenterLonLat:function() { 326 return new OpenLayers.LonLat(this.left + (this.getWidth() / 2), 327 this.bottom + (this.getHeight() / 2)); 328 }, 329 330 /** 331 * @param {float} x 332 * @param {float} y 333 * 334 * @returns A new OpenLayers.Bounds whose coordinates are the same as this, 335 * but shifted by the passed-in x and y values 336 * @type OpenLayers.Bounds 337 */ 338 add:function(x, y){ 339 return new OpenLayers.Box(this.left + x, this.bottom + y, 340 this.right + x, this.top + y); 341 }, 342 343 /** 344 * @param {float} x 345 * @param {float} y 346 * @param {Boolean} inclusive Whether or not to include the border. 347 * Default is true 348 * 349 * @return Whether or not the passed-in coordinates are within this bounds 301 350 * @type Boolean 302 351 */ 303 contains:function(ll) { 304 return ((ll.lon >= this.minlon) && (ll.lon <= this.maxlon) 305 && (ll.lat >= this.minlat) && (ll.lat <= this.maxlat)); 306 }, 307 352 contains:function(x, y, inclusive) { 353 354 //set default 355 if (inclusive == null) { 356 inclusive = true; 357 } 358 359 var contains = false; 360 if (inclusive) { 361 contains = ((x >= this.left) && (x <= this.right) && 362 (y >= this.bottom) && (y <= this.top)); 363 } else { 364 contains = ((x > this.left) && (x < this.right) && 365 (y > this.bottom) && (y < this.top)); 366 } 367 return contains; 368 }, 369 370 /** 371 * @param {OpenLayers.Bounds} bounds 372 * @param {Boolean} partial If true, only part of passed-in 373 * OpenLayers.Bounds needs be within this bounds. 374 * If false, the entire passed-in bounds must be 375 * within. Default is false 376 * @param {Boolean} inclusive Whether or not to include the border. 377 * Default is true 378 * 379 * @return Whether or not the passed-in OpenLayers.Bounds object is 380 * contained within this bounds. 381 * @type Boolean 382 */ 383 containsBounds:function(bounds, partial, inclusive) { 384 385 //set defaults 386 if (partial == null) { 387 partial = false; 388 } 389 if (inclusive == null) { 390 inclusive = true; 391 } 392 393 var inLeft; 394 var inTop; 395 var inRight; 396 var inBottom; 397 398 if (inclusive) { 399 inLeft = (bounds.left >= this.left) && (bounds.left <= this.right); 400 inTop = (bounds.top >= this.bottom) && (bounds.top <= this.top); 401 inRight= (bounds.right >= this.left) && (bounds.right <= this.right); 402 inBottom = (bounds.bottom >= this.bottom) && (bounds.bottom <= this.top); 403 } else { 404 inLeft = (bounds.left > this.left) && (bounds.left < this.right); 405 inTop = (bounds.top > this.bottom) && (bounds.top < this.top); 406 inRight= (bounds.right > this.left) && (bounds.right < this.right); 407 inBottom = (bounds.bottom > this.bottom) && (bounds.bottom < this.top); 408 } 409 410 return (partial) ? (inTop || inBottom) && (inLeft || inRight ) 411 : (inTop && inLeft && inBottom && inRight); 412 }, 413 308 414 /** @final @type String */ 309 415 CLASS_NAME: "OpenLayers.Bounds" … … 328 434 }; 329 435 330 OpenLayers.Box = Class.create();331 OpenLayers.Box.prototype = {332 initialize: function(x,y,w,h){333 this.xy=new OpenLayers.Pixel(x,y);334 this.sz=new OpenLayers.Size(w,h);335 this.c = new OpenLayers.Pixel(x+(w/2), y+(h/2));336 this.br = new OpenLayers.Pixel(x+w-1,y+h-1);337 },338 339 /* offset box by df340 * @df(OpenLayers.Size)341 */342 offset:function(df){343 this.xy=new OpenLayers.Pixel(this.xy.x+df.w,this.xy.y+df.h);344 this.c = new OpenLayers.Pixel(this.xy.x+(this.sz.w/2), this.xy.y+(this.sz.h/2));345 var x=this.xy.x;346 var y=this.xy.y;347 var w=this.sz.w;348 var h=this.sz.h;349 this.br = new OpenLayers.Pixel(x+w-1,y+h-1);350 },351 352 getOrigin:function(){return this.xy;},353 getSize:function(){return this.sz;},354 getCenter:function(){return this.c;},355 getBotRight:function(){return this.br;},356 getWidth:function(){return this.sz.w;},357 getHeight:function(){return this.sz.h;},358 getSize:function(){return this.sz;},359 360 toString:function(){361 return (this.xy.toString() + " " + this.sz.toString());362 },363 copyOf:function(){364 return new OpenLayers.Box(this.xy.x, this.xy.y, this.sz.w, this.sz.h);365 },366 toCoordsString:function(){367 var x1 = this.xy.x;368 var x2 = this.xy.x+this.sz.w-1;369 var y1 = this.xy.y;370 var y2 = this.xy.y+this.sz.h-1;371 return (x1+","+y1+","+x2+","+y2);372 },373 contains:function(pt){374 var returnVal = false;375 376 var lx=this.xy.x;377 var ly=this.xy.y;378 var rx=lx+this.sz.w-1;379 var ry=ly+this.sz.h-1;380 381 if (pt != null) {382 //upper left in383 returnVal = (pt.x >=lx && pt.x <=rx && pt.y >=ly && pt.y <= ry);384 }385 return returnVal;386 },387 388 /**389 * @param {ol.Box} box390 * @param {bool} partial - if true, returns whether any part of the passed391 * in box is within the calling box. otherwise box392 * must contain entire box to return true.393 *394 * @return {bool}395 */396 containsBox:function(box, partial) {397 var contains = false;398 399 var mainTop = this.xy.y;400 var mainLeft = this.xy.x;401 var mainBottom = this.xy.y + this.sz.h;402 var mainRight = this.xy.x + this.sz.w;403 404 var top = box.xy.y;405 var left = box.xy.x;406 var bottom = box.xy.y + box.sz.h;407 var right = box.xy.x + box.sz.w;408 409 var inTop = (top >= mainTop) && (top <= mainBottom);410 var inLeft = (left >= mainLeft) && (left <= mainRight);411 var inBottom = (bottom >= mainTop) && (bottom <= mainBottom);412 var inRight= (right >= mainLeft) && (right <= mainRight);413 414 if (partial) {415 contains = (inTop || inBottom) && (inLeft || inRight );416 } else {417 contains = (inTop && inLeft && inBottom && inRight);418 }419 420 return contains;421 },422 423 // is this point the center of the box, +-2 pixels (@todo fix that number!)424 isCenter:function(pt){425 var size = this.c.absDiff(pt);426 return (size.w <= 2 && size.h <= 2);427 }428 };429 436 430 437 431 438 // Some other helpful things 439 440 /** 441 * @param {String} sStart 442 * 443 * @returns Whether or not this string starts with the string passed in. 444 * @type Boolean 445 */ 432 446 String.prototype.startsWith = function(sStart){ 433 return (this.substr(0,sStart.length) ==sStart);447 return (this.substr(0,sStart.length) == sStart); 434 448 }; 435 449 String.prototype.trim = function() { … … 464 478 Array.prototype.clear=function() {this.length=0;}; 465 479 480 481 466 482 /** Create a child element (a div currently) that 467 483 * is a proper child of the supplied parent, is invisible, trunk/openlayers/tests/test_Bounds.html
r122 r140 5 5 var bounds; 6 6 function test_01_Bounds_constructor (t) { 7 t.plan( 8);7 t.plan( 14 ); 8 8 bounds = new OpenLayers.Bounds(0,2,10,4); 9 9 t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" ); 10 10 t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" ); 11 t.eq( bounds.minlon, 0, "bounds.minlon is set correctly" ); 12 t.eq( bounds.minlat, 2, "bounds.minlat is set correctly" ); 13 t.eq( bounds.maxlon, 10, "bounds.maxlon is set correctly" ); 14 t.eq( bounds.maxlat, 4, "bounds.maxlat is set correctly" ); 15 t.eq( bounds.width, 10, "bounds.width is set correctly" ); 16 t.eq( bounds.height, 2, "bounds.height is set correctly" ); 11 t.eq( bounds.left, 0, "bounds.left is set correctly" ); 12 t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" ); 13 t.eq( bounds.right, 10, "bounds.right is set correctly" ); 14 t.eq( bounds.top, 4, "bounds.top is set correctly" ); 15 t.eq( bounds.getWidth(), 10, "bounds.getWidth() returns correct value" ); 16 t.eq( bounds.getHeight(), 2, "bounds.getHeight() returns correct value" ); 17 18 var sz = bounds.getSize(); 19 t.eq( sz.w, 10, "bounds.getSize() has correct width value" ); 20 t.eq( sz.h, 2, "bounds.getSize() has correct height value" ); 21 22 var center = bounds.getCenterPixel(); 23 t.eq( center.x, 5, "bounds.getCenterPixel() has correct x value" ); 24 t.eq( center.y, 3, "bounds.getCenterPixel() has correct y value" ); 25 26 var center = bounds.getCenterLonLat(); 27 t.eq( center.lon, 5, "bounds.getCenterLonLat() has correct lon value" ); 28 t.eq( center.lat, 3, "bounds.getCenterLonLat() has correct lat value" ); 29 17 30 } 18 31 … … 26 39 t.plan( 1 ); 27 40 bounds = new OpenLayers.Bounds(1,2,3,4); 28 t.eq( bounds.toString(), " Min lon/lat=1/2 Max lon/lat=3/4 width=2 height=2", "toString() returns correct value." );41 t.eq( bounds.toString(), "left-bottom=(1,2) right-top=(3,4)", "toString() returns correct value." ); 29 42 } 30 43 31 44 function test_04_Bounds_contains(t) { 32 t.plan( 3);45 t.plan( 4 ); 33 46 bounds = new OpenLayers.Bounds(10,10,40,40); 34 ll = new OpenLayers.LonLat(20,20); 35 t.eq( bounds.contains(ll), true, "bounds(10,10,40,40) correctly contains LonLat(20,20)" ); 36 ll = new OpenLayers.LonLat(0,0); 37 t.eq( bounds.contains(ll), false, "bounds(10,10,40,40) correctly does not contain LonLat(0,0)" ); 38 ll = new OpenLayers.LonLat(40,40); 39 t.eq( bounds.contains(ll), true, "bounds(10,10,40,40) correctly contains LonLat(40,40)" ); 47 t.eq( bounds.contains(20,20), true, "bounds(10,10,40,40) correctly contains LonLat(20,20)" ); 48 t.eq( bounds.contains(0,0), false, "bounds(10,10,40,40) correctly does not contain LonLat(0,0)" ); 49 t.eq( bounds.contains(40,40), true, "bounds(10,10,40,40) correctly contains LonLat(40,40) with inclusive set to true" ); 50 t.eq( bounds.contains(40,40, false), false, "bounds(10,10,40,40) correctly does not contain LonLat(40,40) with inclusive set to false" ); 40 51 } 41 52 … … 44 55 bounds = OpenLayers.Bounds.fromString("1,2,3,4"); 45 56 t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" ); 46 t.eq( bounds. minlon, 1, "bounds.minlonis set correctly" );47 t.eq( bounds. minlat, 2, "bounds.minlatis set correctly" );48 t.eq( bounds. maxlon, 3, "bounds.maxlonis set correctly" );49 t.eq( bounds. maxlat, 4, "bounds.maxlatis set correctly" );57 t.eq( bounds.left, 1, "bounds.left is set correctly" ); 58 t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" ); 59 t.eq( bounds.right, 3, "bounds.right is set correctly" ); 60 t.eq( bounds.top, 4, "bounds.top is set correctly" ); 50 61 } 51 62 … … 54 65 bounds = OpenLayers.Bounds.fromString("1.1,2.2,3.3,4.4"); 55 66 t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" ); 56 t.eq( bounds. minlon, 1.1, "bounds.minlonis set correctly" );57 t.eq( bounds. minlat, 2.2, "bounds.minlatis set correctly" );58 t.eq( bounds. maxlon, 3.3, "bounds.maxlonis set correctly" );59 t.eq( bounds. maxlat, 4.4, "bounds.maxlatis set correctly" );67 t.eq( bounds.left, 1.1, "bounds.left is set correctly" ); 68 t.eq( bounds.bottom, 2.2, "bounds.bottom is set correctly" ); 69 t.eq( bounds.right, 3.3, "bounds.right is set correctly" ); 70 t.eq( bounds.top, 4.4, "bounds.top is set correctly" ); 60 71 } 61 72 … … 65 76 var bounds = oldBounds.copyOf(); 66 77 t.ok( bounds instanceof OpenLayers.Bounds, "copyOf returns new OpenLayers.Bounds object" ); 67 t.eq( bounds. minlon, 1, "bounds.minlonis set correctly" );68 t.eq( bounds. minlat, 2, "bounds.minlatis set correctly" );69 t.eq( bounds. maxlon, 3, "bounds.maxlonis set correctly" );70 t.eq( bounds. maxlat, 4, "bounds.maxlatis set correctly" );78 t.eq( bounds.left, 1, "bounds.left is set correctly" ); 79 t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" ); 80 t.eq( bounds.right, 3, "bounds.right is set correctly" ); 81 t.eq( bounds.top, 4, "bounds.top is set correctly" ); 71 82 72 //change minlon of oldBounds - if bounds is a 73 // real copyOf, bounds.minlon should not change 74 oldBounds.minlon = 100; 75 t.eq( bounds.minlon, 1, "changing olBounds.minlon does not change bounds.minlon" ); 83 oldBounds.left = 100; 84 t.eq( bounds.left, 1, "changing olBounds.left does not change bounds.left" ); 76 85 } 77 86 87 function test_08_Bounds_containsBounds(t) { 88 t.plan( 35 ); 89 containerBounds = new OpenLayers.Bounds(10,10,40,40); 78 90 91 //totally outside 92 bounds = new OpenLayers.Bounds(0,0,5,5); 93 t.eq( containerBounds.containsBounds(bounds) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ")"); 94 t.eq( containerBounds.containsBounds(bounds, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false" ); 95 t.eq( containerBounds.containsBounds(bounds, false, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is true" ); 96 t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" ); 97 t.eq( containerBounds.containsBounds(bounds, true) , false , "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true" ); 98 t.eq( containerBounds.containsBounds(bounds, true, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true, inclusive is true" ); 99 t.eq( containerBounds.containsBounds(bounds, true, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true, inclusive is false" ); 100 101 //totally outside on border 102 bounds = new OpenLayers.Bounds(15,0,30,10); 103 t.eq( containerBounds.containsBounds(bounds) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ")"); 104 t.eq( containerBounds.containsBounds(bounds, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false" ); 105 t.eq( containerBounds.containsBounds(bounds, false, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is true" ); 106 t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" ); 107 t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" ); 108 t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" ); 109 t.eq( containerBounds.containsBounds(bounds, true, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true, inclusive is false" ); 110 111 //partially inside 112 bounds = new OpenLayers.Bounds(20,20,50,30); 113 t.eq( containerBounds.containsBounds(bounds) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ")"); 114 t.eq( containerBounds.containsBounds(bounds, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false" ); 115 t.eq( containerBounds.containsBounds(bounds, false, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is true" ); 116 t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" ); 117 t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" ); 118 t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" ); 119 t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" ); 120 121 //totally inside on border 122 bounds = new OpenLayers.Bounds(10,20,30,30); 123 t.eq( containerBounds.containsBounds(bounds) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ")"); 124 t.eq( containerBounds.containsBounds(bounds, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false" ); 125 t.eq( containerBounds.containsBounds(bounds, false, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false, inclusive is true" ); 126 t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" ); 127 t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" ); 128 t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" ); 129 t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" ); 130 131 //totally inside 132 bounds = new OpenLayers.Bounds(20,20,30,30); 133 t.eq( containerBounds.containsBounds(bounds) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ")"); 134 t.eq( containerBounds.containsBounds(bounds, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false" ); 135 t.eq( containerBounds.containsBounds(bounds, false, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false, inclusive is true" ); 136 t.eq( containerBounds.containsBounds(bounds, false, false), true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false, inclusive is false" ); 137 t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" ); 138 t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" ); 139 t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" ); 140 } 141 142 79 143 // --> 80 144 </script> trunk/openlayers/tests/test_Tile.html
r104 r140 12 12 t.ok( tile instanceof OpenLayers.Tile, "new OpenLayers.Tile returns Tile object" ); 13 13 t.ok( tile.bounds instanceof OpenLayers.Bounds, "tile.bounds is a Bounds object" ); 14 t.eq( tile.bounds. minlon, 1, "tile.bounds.minlonis set correctly");15 t.eq( tile.bounds. minlat, 2, "tile.bounds.minlatis set correctly");16 t.eq( tile.bounds. maxlon, 3, "tile.bounds.maxlonis set correctly");17 t.eq( tile.bounds. maxlat, 4, "tile.bounds.maxlatis set correctly");14 t.eq( tile.bounds.left, 1, "tile.bounds.left is set correctly"); 15 t.eq( tile.bounds.bottom, 2, "tile.bounds.bottom is set correctly"); 16 t.eq( tile.bounds.right, 3, "tile.bounds.right is set correctly"); 17 t.eq( tile.bounds.top, 4, "tile.bounds.top is set correctly"); 18 18 t.ok( tile.size instanceof OpenLayers.Size, "tile.size is a Size object" ); 19 19 t.eq( tile.size.w, 5, "tile.size.w is set correctly"); trunk/openlayers/tests/test_Tile_Image.html
r104 r140 12 12 t.ok( tile instanceof OpenLayers.Tile.Image, "new OpenLayers.Tile returns Tile object" ); 13 13 t.ok( tile.bounds instanceof OpenLayers.Bounds, "tile.bounds is a Bounds object" ); 14 t.eq( tile.bounds. minlon, 1, "tile.bounds.minlonis set correctly");15 t.eq( tile.bounds. minlat, 2, "tile.bounds.minlatis set correctly");16 t.eq( tile.bounds. maxlon, 3, "tile.bounds.maxlonis set correctly");17 t.eq( tile.bounds. maxlat, 4, "tile.bounds.maxlatis set correctly");14 t.eq( tile.bounds.left, 1, "tile.bounds.left is set correctly"); 15 t.eq( tile.bounds.bottom, 2, "tile.bounds.bottom is set correctly"); 16 t.eq( tile.bounds.right, 3, "tile.bounds.right is set correctly"); 17 t.eq( tile.bounds.top, 4, "tile.bounds.top is set correctly"); 18 18 t.ok( tile.size instanceof OpenLayers.Size, "tile.size is a Size object" ); 19 19 t.eq( tile.size.w, 5, "tile.size.w is set correctly");
