don't redefine L, don't undefine DEG_TO_RAD

Moved the consts to below function definition.
This commit is contained in:
AJ ONeal 2016-07-25 22:50:45 -04:00 committed by GitHub
parent eb224e01aa
commit 61b3ea3f37
1 changed files with 12 additions and 8 deletions

View File

@ -28,7 +28,7 @@
window.S2 = {};
var LatLngToXYZ = function(latLng) {
var d2r = L.LatLng.DEG_TO_RAD;
var d2r = S2.L.LatLng.DEG_TO_RAD;
var phi = latLng.lat*d2r;
var theta = latLng.lng*d2r;
@ -39,12 +39,12 @@ var LatLngToXYZ = function(latLng) {
};
var XYZToLatLng = function(xyz) {
var r2d = L.LatLng.RAD_TO_DEG;
var r2d = S2.L.LatLng.RAD_TO_DEG;
var lat = Math.atan2(xyz[2], Math.sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]));
var lng = Math.atan2(xyz[1], xyz[0]);
return L.LatLng(lat*r2d, lng*r2d);
return S2.L.LatLng(lat*r2d, lng*r2d);
};
var largestAbsComponent = function(xyz) {
@ -311,11 +311,7 @@ S2.S2Cell.prototype.getNeighbors = function() {
// Adapted from Leafletjs https://searchcode.com/codesearch/view/42525008/
var L = { LatLng: {} };
window.L = L;
L.LatLng.DEG_TO_RAD = Math.PI / 180;
L.LatLng.RAD_TO_DEG = 180 / Math.PI;
var L = {};
L.LatLng = function (/*Number*/ rawLat, /*Number*/ rawLng, /*Boolean*/ noWrap) {
var lat = parseFloat(rawLat);
@ -332,4 +328,12 @@ S2.S2Cell.prototype.getNeighbors = function() {
return { lat: lat, lng: lng };
};
L.LatLng.DEG_TO_RAD = Math.PI / 180;
L.LatLng.RAD_TO_DEG = 180 / Math.PI;
if (!window.L) {
window.L = L;
}
S2.L = L;
})();