Changeset 3832
- Timestamp:
- 08/01/07 08:33:01 (1 year ago)
- Files:
-
- sandbox/jachym/openlayers/lib/OpenLayers/Layer.js (modified) (3 diffs)
- sandbox/jachym/openlayers/lib/OpenLayers/Layer/Grid.js (modified) (2 diffs)
- sandbox/jachym/openlayers/lib/OpenLayers/Map.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/jachym/openlayers/lib/OpenLayers/Layer.js
r3819 r3832 758 758 var center = this.map.getCenter(); 759 759 if (center) { 760 var res = this.map.getResolution(); 760 var resx; 761 var resy; 762 resx = resy = this.map.getResolution(); 761 763 762 764 var delta_x = viewPortPx.x - (size.w / 2); 763 765 var delta_y = viewPortPx.y - (size.h / 2); 766 767 // strech the map according to lat 768 if (this.map.stretch && (this.map.units == "dd" || this.map.units == "degrees")) { 769 resy *= this.map.stretchConts; 770 } 764 771 765 lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,766 center.lat - delta_y * res );772 lonlat = new OpenLayers.LonLat(center.lon + delta_x * resx , 773 center.lat - delta_y * resy); 767 774 768 775 if (this.wrapDateLine) { … … 788 795 var px = null; 789 796 if (lonlat != null) { 790 var resolution = this.map.getResolution(); 797 var xres; 798 var yres; 799 xres = yres = this.map.getResolution(); 791 800 var extent = this.map.getExtent(); 801 802 // strech the map according to lat 803 if (this.map.stretch && (this.map.units == "dd" || this.map.units == "degrees")) { 804 yres*= this.map.stretchConts; 805 } 792 806 px = new OpenLayers.Pixel( 793 Math.round(1/ resolution* (lonlat.lon - extent.left)),794 Math.round(1/ resolution* (extent.top - lonlat.lat))807 Math.round(1/xres * (lonlat.lon - extent.left)), 808 Math.round(1/yres * (extent.top - lonlat.lat)) 795 809 ); 796 810 } … … 842 856 // Adjust the extent of a bounds in map units by the 843 857 // layer's gutter in pixels. 844 var mapGutter = this.gutter * this.map.getResolution(); 845 bounds = new OpenLayers.Bounds(bounds.left - mapGutter, 846 bounds.bottom - mapGutter, 847 bounds.right + mapGutter, 848 bounds.top + mapGutter); 858 var mapGutterX; 859 var mapGutterY; 860 mapGutterX = mapGutterY = this.gutter * this.map.getResolution(); 861 862 // strech the map according to lat 863 if (this.map.stretch && (this.map.units == "dd" || this.map.units == "degrees")) { 864 mapGutterY *= this.map.stretchConts; 865 } 866 bounds = new OpenLayers.Bounds(bounds.left - mapGutterX, 867 bounds.bottom - mapGutterY, 868 bounds.right + mapGutterX, 869 bounds.top + mapGutterY); 849 870 } 850 871 sandbox/jachym/openlayers/lib/OpenLayers/Layer/Grid.js
r3829 r3832 307 307 var tilelon = resolution * this.tileSize.w; 308 308 var tilelat = resolution * this.tileSize.h; 309 310 // strech the map according to lat 311 if (this.map.stretch && (this.map.units == "dd" || this.map.units == "degrees")) { 312 tilelat *= this.map.stretchConts; 313 } 309 314 310 315 var offsetlon = bounds.left - extent.left; … … 567 572 var deltaLat = resolution * -deltaY; 568 573 574 // strech the map according to lat 575 if (this.map.stretch && (this.map.units == "dd" || this.map.units == "degrees")) { 576 deltaLat *= this.map.stretchConts; 577 } 578 569 579 var row = (prepend) ? this.grid.pop() : this.grid.shift(); 570 580 sandbox/jachym/openlayers/lib/OpenLayers/Map.js
r3829 r3832 230 230 */ 231 231 fallThrough: false, 232 233 /** Should the map be "streched" if units are degrees (assuming EPSG: 234 * 4326 projection) ? 235 * Default is no. 236 * 237 * @type boolean 238 */ 239 stretch: false, 240 241 /** This constant should be initialized at the beginning 242 * 243 * @type Integer 244 */ 245 stretchConts: null, 246 232 247 233 248 /** … … 956 971 var w_deg = size.w * resolution; 957 972 var h_deg = size.h * resolution; 973 974 // strech the map according to lat 975 if (this.stretch && (this.units == "dd" || this.units == "degrees")) { 976 if (!this.stretchConts) { 977 this.stretchConts = Math.cos(center.lat/180*Math.PI); 978 } 979 h_deg *= this.stretchConts; 980 } 958 981 959 982 extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
