Ticket #1019: spherical.3.patch
| File spherical.3.patch, 9.7 kB (added by euzuro, 1 year ago) |
|---|
-
lib/OpenLayers/Layer/SphericalMercator.js
old new 30 30 */ 31 31 OpenLayers.Layer.SphericalMercator = { 32 32 33 /**34 * Method: getExtent35 * Get the map's extent.36 *37 * Returns:38 * {<OpenLayers.Bounds>} The map extent.39 */40 getExtent: function() {41 var extent = null;42 if (this.sphericalMercator) {43 extent = this.map.calculateBounds();44 } else {45 extent = OpenLayers.Layer.FixedZoomLevels.prototype.getExtent.apply(this);46 }47 return extent;48 },49 50 33 /** 51 34 * Method: initMercatorParameters 52 35 * Set up the mercator parameters on the layer: resolutions, … … 61 44 } 62 45 this.units = "m"; 63 46 this.projection = "EPSG:900913"; 64 },65 47 48 49 50 //translation functions 51 52 53 //instead of using FixedZoomLevels to calculate bounds, use map 54 this.getExtent = function() { 55 return this.map.calculateBounds(); 56 }; 57 58 //lon from maplonlat 59 var oldGetLon = this.getLongitudeFromMapObjectLonLat; 60 this.getLongitudeFromMapObjectLonLat = function(moLonLat) { 61 var lon = oldGetLon(moLonLat); 62 return this.forwardMercator(lon, 1).lon; 63 }; 64 65 //lat from maplonlat 66 var oldGetLat = this.getLatitudeFromMapObjectLonLat; 67 this.getLatitudeFromMapObjectLonLat = function(moLonLat) { 68 var lat = oldGetLat(moLonLat); 69 return this.forwardMercator(1, lat).lat; 70 }; 71 72 //maplonlat from lonlat 73 var oldGetLonLat = this.getMapObjectLonLatFromLonLat; 74 this.getMapObjectLonLatFromLonLat = function(lon, lat) { 75 var newLonLat = this.inverseMercator(lon, lat); 76 return oldGetLonLat(newLonLat.lon, newLonLat.lat); 77 }; 78 79 }, 80 81 66 82 /** 67 83 * Method: forwardMercator 68 84 * Given a lon,lat in EPSG:4326, return a point in Spherical Mercator. -
lib/OpenLayers/Layer/VirtualEarth.js
old new 228 228 * {Float} Longitude of the given MapObject LonLat 229 229 */ 230 230 getLongitudeFromMapObjectLonLat: function(moLonLat) { 231 return this.sphericalMercator ? 232 this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lon : 233 moLonLat.Longitude; 231 return moLonLat.Longitude; 234 232 }, 235 233 236 234 /** … … 243 241 * {Float} Latitude of the given MapObject LonLat 244 242 */ 245 243 getLatitudeFromMapObjectLonLat: function(moLonLat) { 246 return this.sphericalMercator ? 247 this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lat : 248 moLonLat.Latitude; 244 return moLonLat.Latitude; 249 245 }, 250 246 251 247 /** … … 259 255 * {Object} MapObject LonLat built from lon and lat params 260 256 */ 261 257 getMapObjectLonLatFromLonLat: function(lon, lat) { 262 var veLatLong; 263 if(this.sphericalMercator) { 264 var lonlat = this.inverseMercator(lon, lat); 265 veLatLong = new VELatLong(lonlat.lat, lonlat.lon); 266 } else { 267 veLatLong = new VELatLong(lat, lon); 268 } 258 var veLatLong = new VELatLong(lat, lon); 269 259 return veLatLong; 270 260 }, 271 261 -
lib/OpenLayers/Layer/Google.js
old new 211 211 getOLBoundsFromMapObjectBounds: function(moBounds) { 212 212 var olBounds = null; 213 213 if (moBounds != null) { 214 214 215 var sw = moBounds.getSouthWest(); 216 left = this.getLongitudeFromMapObjectLonLat(sw); 217 bottom = this.getLatitudeFromMapObjectLonLat(sw); 218 215 219 var ne = moBounds.getNorthEast(); 216 if (this.sphericalMercator) { 217 sw = this.forwardMercator(sw.lng(), sw.lat()); 218 ne = this.forwardMercator(ne.lng(), ne.lat()); 219 } else { 220 sw = new OpenLayers.LonLat(sw.lng(), sw.lat()); 221 ne = new OpenLayers.LonLat(ne.lng(), ne.lat()); 222 } 223 olBounds = new OpenLayers.Bounds(sw.lon, 224 sw.lat, 225 ne.lon, 226 ne.lat ); 220 right = this.getLongitudeFromMapObjectLonLat(ne); 221 top = this.getLatitudeFromMapObjectLonLat(ne); 222 223 olBounds = new OpenLayers.Bounds(left, bottom, right, top); 227 224 } 228 225 return olBounds; 229 226 }, … … 241 238 getMapObjectBoundsFromOLBounds: function(olBounds) { 242 239 var moBounds = null; 243 240 if (olBounds != null) { 244 var sw = this.sphericalMercator ? 245 this.inverseMercator(olBounds.bottom, olBounds.left) : 246 new OpenLayers.LonLat(olBounds.bottom, olBounds.left); 247 var ne = this.sphericalMercator ? 248 this.inverseMercator(olBounds.top, olBounds.right) : 249 new OpenLayers.LonLat(olBounds.top, olBounds.right); 250 moBounds = new GLatLngBounds(new GLatLng(sw.lat, sw.lon), 251 new GLatLng(ne.lat, ne.lon)); 241 var sw = new OpenLayers.LonLat(olBounds.bottom, olBounds.left); 242 var gSw = this.getMapObjectLonLatFromLonLat(sw); 243 244 var ne = new OpenLayers.LonLat(olBounds.top, olBounds.right); 245 var gNe = this.getMapObjectLonLatFromLonLat(ne); 246 247 moBounds = new GLatLngBounds(sw, ne); 252 248 } 253 249 return moBounds; 254 250 }, … … 418 414 * {Float} Longitude of the given MapObject LonLat 419 415 */ 420 416 getLongitudeFromMapObjectLonLat: function(moLonLat) { 421 return this.sphericalMercator ? 422 this.forwardMercator(moLonLat.lng(), moLonLat.lat()).lon : 423 moLonLat.lng(); 417 return moLonLat.lng(); 424 418 }, 425 419 426 420 /** … … 433 427 * {Float} Latitude of the given MapObject LonLat 434 428 */ 435 429 getLatitudeFromMapObjectLonLat: function(moLonLat) { 436 var lat = this.sphericalMercator ? 437 this.forwardMercator(moLonLat.lng(), moLonLat.lat()).lat : 438 moLonLat.lat(); 439 return lat; 430 return moLonLat.lat(); 440 431 }, 441 432 442 433 /** … … 450 441 * {Object} MapObject LonLat built from lon and lat params 451 442 */ 452 443 getMapObjectLonLatFromLonLat: function(lon, lat) { 453 var gLatLng; 454 if(this.sphericalMercator) { 455 var lonlat = this.inverseMercator(lon, lat); 456 gLatLng = new GLatLng(lonlat.lat, lonlat.lon); 457 } else { 458 gLatLng = new GLatLng(lat, lon); 459 } 444 var gLatLng = new GLatLng(lat, lon); 460 445 return gLatLng; 461 446 }, 462 447 -
lib/OpenLayers/Layer/Yahoo.js
old new 306 306 * {Float} Longitude of the given MapObject LonLat 307 307 */ 308 308 getLongitudeFromMapObjectLonLat: function(moLonLat) { 309 return this.sphericalMercator ? 310 this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lon : 311 moLonLat.Lon; 309 return moLonLat.Lon; 312 310 }, 313 311 314 312 /** … … 321 319 * {Float} Latitude of the given MapObject LonLat 322 320 */ 323 321 getLatitudeFromMapObjectLonLat: function(moLonLat) { 324 return this.sphericalMercator ? 325 this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lat : 326 moLonLat.Lat; 322 return moLonLat.Lat; 327 323 }, 328 324 329 325 /** … … 337 333 * {Object} MapObject LonLat built from lon and lat params 338 334 */ 339 335 getMapObjectLonLatFromLonLat: function(lon, lat) { 340 var yLatLong; 341 if(this.sphericalMercator) { 342 var lonlat = this.inverseMercator(lon, lat); 343 yLatLong = new YGeoPoint(lonlat.lat, lonlat.lon); 344 } else { 345 yLatLong = new YGeoPoint(lat, lon); 346 } 336 var yLatLong = new YGeoPoint(lat, lon); 347 337 return yLatLong; 348 338 }, 349 339 -
lib/OpenLayers/Layer/MultiMap.js
old new 208 208 * {Float} Longitude of the given MapObject LonLat 209 209 */ 210 210 getLongitudeFromMapObjectLonLat: function(moLonLat) { 211 return this.sphericalMercator ? 212 this.forwardMercator(moLonLat.lon, moLonLat.lat).lon : 213 moLonLat.lon; 211 return moLonLat.lon; 214 212 }, 215 213 216 214 /** … … 223 221 * {Float} Latitude of the given MapObject LonLat 224 222 */ 225 223 getLatitudeFromMapObjectLonLat: function(moLonLat) { 226 return this.sphericalMercator ? 227 this.forwardMercator(moLonLat.lon, moLonLat.lat).lat : 228 moLonLat.lat; 224 return moLonLat.lat; 229 225 }, 230 226 231 227 /** … … 239 235 * {Object} MapObject LonLat built from lon and lat params 240 236 */ 241 237 getMapObjectLonLatFromLonLat: function(lon, lat) { 242 var mmLatLon; 243 if(this.sphericalMercator) { 244 var lonlat = this.inverseMercator(lon, lat); 245 mmLatLon = new MMLatLon(lonlat.lat, lonlat.lon); 246 } else { 247 mmLatLon = new MMLatLon(lat, lon); 248 } 238 var mmLatLon = new MMLatLon(lat, lon); 249 239 return mmLatLon; 250 240 }, 251 241
