Changeset 5452
- Timestamp:
- 12/16/07 22:12:57 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/BaseTypes/Bounds.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/BaseTypes/LonLat.js (modified) (1 diff)
- trunk/openlayers/tests/BaseTypes/test_Bounds.html (modified) (1 diff)
- trunk/openlayers/tests/BaseTypes/test_LonLat.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/BaseTypes/Bounds.js
r4985 r5452 426 426 return quadrant; 427 427 }, 428 429 /** 430 * APIMethod: transform 431 * Transform the Bounds object from source to dest. 432 * 433 * Parameters: 434 * source - {<OpenLayers.Projection>} Source projection. 435 * dest - {<OpenLayers.Projection>} Destination projection. 436 * 437 * Returns: 438 * {<OpenLayers.Bounds>} Itself, for use in chaining operations. 439 */ 440 transform: function(source, dest) { 441 var ll = OpenLayers.Projection.transform( 442 {'x': this.left, 'y': this.bottom}, source, dest); 443 var ur = OpenLayers.Projection.transform( 444 {'x': this.right, 'y': this.top}, source, dest); 445 this.left = ll.x; 446 this.bottom = ll.y; 447 this.right = ur.x; 448 this.top = ur.y; 449 return this; 450 }, 428 451 429 452 /** trunk/openlayers/lib/OpenLayers/BaseTypes/LonLat.js
r4985 r5452 113 113 return equals; 114 114 }, 115 116 /** 117 * APIMethod: transform 118 * Transform the LonLat object from source to dest. 119 * 120 * Parameters: 121 * source - {<OpenLayers.Projection>} Source projection. 122 * dest - {<OpenLayers.Projection>} Destination projection. 123 * 124 * Returns: 125 * {<OpenLayers.LonLat>} Itself, for use in chaining operations. 126 */ 127 transform: function(source, dest) { 128 var point = OpenLayers.Projection.transform( 129 {'x': this.lon, 'y': this.lat}, source, dest); 130 this.lon = point.x; 131 this.lat = point.y; 132 return this; 133 }, 115 134 116 135 /** trunk/openlayers/tests/BaseTypes/test_Bounds.html
r4059 r5452 495 495 496 496 } 497 function test_Bounds_transform(t) { 498 t.plan( 3 ); 499 bounds = new OpenLayers.Bounds(10, -10, 20, 10); 500 bounds.transform(new OpenLayers.Projection("foo"), new OpenLayers.Projection("Bar")); 501 t.eq(bounds.toBBOX(), "10,-10,20,10", "null transform okay"); 502 bounds.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); 503 t.eq(bounds.toBBOX(), "1113194.907778,-1118889.974702,2226389.815556,1118889.974702", "bounds for spherical mercator transform are correct"); 504 bounds.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); 505 t.eq(bounds.toBBOX(), "10,-10,20,10", "bounds for inverse spherical mercator transform are correct"); 506 } 497 507 498 508 function test_17_Bounds_add(t) { trunk/openlayers/tests/BaseTypes/test_LonLat.html
r4059 r5452 103 103 } 104 104 105 function test_LonLat_transform(t) { 106 t.plan( 6 ); 107 lonlat = new OpenLayers.LonLat(10, -10); 108 lonlat.transform(new OpenLayers.Projection("foo"), new OpenLayers.Projection("Bar")); 109 t.eq(lonlat.lon, 10, "lon for null transform is the same") 110 t.eq(lonlat.lat, -10, "lat for null transform is the same") 111 lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); 112 t.eq(Math.round(lonlat.lon), 1113195, "lon for spherical mercator transform is correct"); 113 t.eq(Math.round(lonlat.lat), -1118890, "lat for spherical mercator correct") 114 lonlat.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); 115 t.eq(lonlat.lon, 10, "lon for inverse spherical mercator transform is correct"); 116 t.eq(Math.round(lonlat.lat), -10, "lat for inverse spherical mercator correct") 117 } 118 105 119 function test_08_LonLat_wrapDateLine(t) { 106 120 t.plan( 6 );
