|
发表于 2022-5-19 22:10:18
|
显示全部楼层
安徽省滁州市
var GPS = {
PI : 3.14159265358979324,
x_pi : 3.14159265358979324 * 3000.0 / 180.0,
delta : function (lat, lon) {
// Krasovsky 1940
//
// a = 6378245.0, 1/f = 298.3
// b = a * (1 - f)
// ee = (a^2 - b^2) / a^2;
var a = 6378245.0; // a: 卫星椭球坐标投影到平面地图坐标系的投影因子。
var ee = 0.00669342162296594323; // ee: 椭球的偏心率。
var dLat = this.transformLat(lon - 105.0, lat - 35.0);
var dLon = this.transformLon(lon - 105.0, lat - 35.0);
var radLat = lat / 180.0 * this.PI;
var magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
var sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * this.PI);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * this.PI);
return {'lat': dLat, 'lon': dLon};
},
//GPS---高德
gcj_encrypt : function ( wgsLat , wgsLon ) {
if (this.outOfChina(wgsLat, wgsLon))
return {'lat': wgsLat, 'lon': wgsLon};
var d = this.delta(wgsLat, wgsLon);
return JSON.stringify({'lat' : wgsLat + d.lat,'lon' : wgsLon + d.lon});
},
outOfChina : function (lat, lon) {
if (lon < 72.004 || lon > 137.8347)
return true;
if (lat < 0.8293 || lat > 55.8271)
return true;
return false;
},
transformLat : function (x, y) {
var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin(y / 3.0 * this.PI)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(y / 12.0 * this.PI) + 320 * Math.sin(y * this.PI / 30.0)) * 2.0 / 3.0;
return ret;
},
transformLon : function (x, y) {
var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin(x / 3.0 * this.PI)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(x / 12.0 * this.PI) + 300.0 * Math.sin(x / 30.0 * this.PI)) * 2.0 / 3.0;
return ret;
}
};
(function() {
var o = !0,
w = null;
(function(B) {
function v(a) {
if ("bug-string-char-index" == a) return "a" != "a" [0];
var f, c = "json" == a;
if (c || "json-stringify" == a || "json-parse" == a) {
if ("json-stringify" == a || c) {
var d = k.stringify,
b = "function" == typeof d && l;
if (b) {
(f = function() {
return 1
}).toJSON = f;
try {
b = "0" === d(0) && "0" === d(new Number) && '""' == d(new String) && d(m) === r && d(r) === r && d() === r && "1" === d(f) && "[1]" == d([f]) && "[null]" == d([r]) && "null" == d(w) && "[null,null,null]" == d([r, m, w]) && '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}' == d({
a: [f, o, !1, w, "\0\b\n\f\r\t"]
}) && "1" === d(w, f) && "[\n 1,\n 2\n]" == d([1, 2], w, 1) && '"-271821-04-20T00:00:00.000Z"' == d(new Date(-864e13)) && '"+275760-09-13T00:00:00.000Z"' == d(new Date(864e13)) && '"-000001-01-01T00:00:00.000Z"' == d(new Date(-621987552e5)) && '"1969-12-31T23:59:59.999Z"' == d(new Date(-1))
} catch (n) {
b = !1
}
}
if (!c) return b
}
if ("json-parse" == a || c) {
a = k.parse;
if ("function" == typeof a) try {
if (0 === a("0") && !a(!1)) {
f = a('{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}');
var e = 5 == f.a.length && 1 === f.a[0];
if (e) {
try {
e = !a('"\t"')
} catch (g) {}
if (e) try {
e = 1 !== a("01")
} catch (i) {}
}
}
} catch (O) {
e = !1
}
if (!c) return e
}
return b && e
}
}
var m = {}.toString,
p, C, r, D = typeof define === "function" && define.amd,
k = "object" == typeof exports && exports;
k || D ? "object" == typeof JSON && JSON ? k ? (k.stringify = JSON.stringify, k.parse = JSON.parse) : k = JSON : D && (k = B.JSON = {}) : k = B.JSON || (B.JSON = {});
var l = new Date(-0xc782b5b800cec);
try {
l = -109252 == l.getUTCFullYear() && 0 === l.getUTCMonth() && 1 === l.getUTCDate() && 10 == l.getUTCHours() && 37 == l.getUTCMinutes() && 6 == l.getUTCSeconds() && 708 == l.getUTCMilliseconds()
} catch (P) {}
if (!v("json")) {
var s = v("bug-string-char-index");
if (!l) var t = Math.floor,
J = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
z = function(a, f) {
return J[f] + 365 * (a - 1970) + t((a - 1969 + (f = +(f > 1))) / 4) - t((a - 1901 + f) / 100) + t((a - 1601 + f) / 400)
};
if (!(p = {}.hasOwnProperty)) p = function(a) {
var f = {}, c;
if ((f.__proto__ = w, f.__proto__ = {
toString: 1
}, f).toString != m) p = function(a) {
var f = this.__proto__,
a = a in (this.__proto__ = w, this);
this.__proto__ = f;
return a
};
else {
c = f.constructor;
p = function(a) {
var f = (this.constructor || c).prototype;
return a in this && !(a in f && this[a] === f[a])
}
}
f = w;
return p.call(this, a)
};
var K = {
"boolean": 1,
number: 1,
string: 1,
"undefined": 1
};
C = function(a, f) {
var c = 0,
b, h, n;
(b = function() {
this.valueOf = 0
}).prototype.valueOf = 0;
h = new b;
for (n in h)
p.call(h, n) && c++;
b = h = w;
if (c) c = c == 2 ? function(a, f) {
var c = {}, b = m.call(a) == "[object Function]",
d;
for (d in a)!(b && d == "prototype") && !p.call(c, d) && (c[d] = 1) && p.call(a, d) && f(d)
} : function(a, f) {
var c = m.call(a) == "[object Function]",
b, d;
for (b in a)!(c && b == "prototype") && p.call(a, b) && !(d = b === "constructor") && f(b);
(d || p.call(a, b = "constructor")) && f(b)
};
else {
h = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
c = function(a, f) {
var c = m.call(a) == "[object Function]",
b, d;
if (d = !c) if (d = typeof a.constructor != "function") {
d = typeof a.hasOwnProperty;
d = d == "object" ? !! a.hasOwnProperty : !K[d]
}
d = d ? a.hasOwnProperty : p;
for (b in a)!(c && b == "prototype") && d.call(a, b) && f(b);
for (c = h.length; b = h[--c]; d.call(a, b) && f(b));
}
}
c(a, f)
};
if (!v("json-stringify")) {
var L = {
92: "\\\\",
34: '\\"',
8: "\\b",
12: "\\f",
10: "\\n",
13: "\\r",
9: "\\t"
}, u = function(a, f) {
return ("000000" + (f || 0)).slice(-a)
}, G = function(a) {
var f = '"',
b = 0,
d = a.length,
h = d > 10 && s,
n;
for (h && (n = a.split("")); b < d; b++) {
var e = a.charCodeAt(b);
switch (e) {
case 8:
case 9:
case 10:
case 12:
case 13:
case 34:
case 92:
f = f + L[e];
break;
default:
if (e < 32) {
f = f + ("\\u00" + u(2, e.toString(16)));
break
}
f = f + (h ? n[b] : s ? a.charAt(b) : a[b])
}
}
return f + '"'
}, E = function(a, b, c, d, h, n, e) {
var g = b[a],
i, j, k, l, q, s, v, x, y;
try {
g = b[a]
} catch (A) {}
if (typeof g == "object" && g) {
i = m.call(g);
if (i == "[object Date]" && !p.call(g, "toJSON")) if (g > -1 / 0 && g < 1 / 0) {
if (z) {
k = t(g / 864e5);
for (i = t(k / 365.2425) + 1970 - 1; z(i + 1, 0) <= k; i++);
for (j = t((k - z(i, 0)) / 30.42); z(i, j + 1) <= k; j++);
k = 1 + k - z(i, j);
l = (g % 864e5 + 864e5) % 864e5;
q = t(l / 36e5) % 24;
s = t(l / 6e4) % 60;
v = t(l / 1e3) % 60;
l = l % 1e3
} else {
i = g.getUTCFullYear();
j = g.getUTCMonth();
k = g.getUTCDate();
q = g.getUTCHours();
s = g.getUTCMinutes();
v = g.getUTCSeconds();
l = g.getUTCMilliseconds()
}
g = (i <= 0 || i >= 1e4 ? (i < 0 ? "-" : "+") + u(6, i < 0 ? -i : i) : u(4, i)) + "-" + u(2, j + 1) + "-" + u(2, k) + "T" + u(2, q) + ":" + u(2, s) + ":" + u(2, v) + "." + u(3, l) + "Z"
} else g = w;
else if (typeof g.toJSON == "function" && (i != "[object Number]" && i != "[object String]" && i != "[object Array]" || p.call(g, "toJSON"))) g = g.toJSON(a)
}
c && (g = c.call(b, a, g));
if (g === w) return "null";
i = m.call(g);
if (i == "[object Boolean]") return "" + g;
if (i == "[object Number]") return g > -1 / 0 && g < 1 / 0 ? "" + g : "null";
if (i == "[object String]") return G("" + g);
if (typeof g == "object") {
for (a = e.length; a--;)
if (e[a] === g) throw TypeError();
e.push(g);
x = [];
b = n;
n = n + h;
if (i == "[object Array]") {
j = 0;
for (a = g.length; j < a; y || (y = o), j++) {
i = E(j, g, c, d, h, n, e);
x.push(i === r ? "null" : i)
}
a = y ? h ? "[\n" + n + x.join(",\n" + n) + "\n" + b + "]" : "[" + x.join(",") + "]" : "[]"
} else {
C(d || g, function(a) {
var b = E(a, g, c, d, h, n, e);
b !== r && x.push(G(a) + ":" + (h ? " " : "") + b);
y || (y = o)
});
a = y ? h ? "{\n" + n + x.join(",\n" + n) + "\n" + b + "}" : "{" + x.join(",") + "}" : "{}"
}
e.pop();
return a
}
};
k.stringify = function(a, b, c) {
var d, h, j;
if (typeof b == "function" || typeof b == "object" && b) if (m.call(b) == "[object Function]") h = b;
else if (m.call(b) == "[object Array]") {
j = {};
for (var e = 0, g = b.length, i; e < g; i = b[e++], (m.call(i) == "[object String]" || m.call(i) == "[object Number]") && (j[i] = 1));
}
if (c) if (m.call(c) == "[object Number]") {
if ((c = c - c % 1) > 0) {
d = "";
for (c > 10 && (c = 10); d.length < c; d = d + " ");
}
} else m.call(c) == "[object String]" && (d = c.length <= 10 ? c : c.slice(0, 10));
return E("", (i = {}, i[""] = a, i), h, j, d, "", [])
}
}
if (!v("json-parse")) {
var M = String.fromCharCode,
N = {
92: "\\",
34: '"',
47: "/",
98: "\b",
116: "\t",
110: "\n",
102: "\f",
114: "\r"
}, b, A, j = function() {
b = A = w;
throw SyntaxError()
}, q = function() {
for (var a = A, f = a.length, c, d, h, k, e; b < f;) {
e = a.charCodeAt(b);
switch (e) {
case 9:
case 10:
case 13:
case 32:
b++;
break;
case 123:
case 125:
case 91:
case 93:
case 58:
case 44:
c = s ? a.charAt(b) : a[b];
b++;
return c;
case 34:
c = "@";
for (b++; b < f;) {
e = a.charCodeAt(b);
if (e < 32) j();
else if (e == 92) {
e = a.charCodeAt(++b);
switch (e) {
case 92:
case 34:
case 47:
case 98:
case 116:
case 110:
case 102:
case 114:
c = c + N[e];
b++;
break;
case 117:
d = ++b;
for (h = b + 4; b < h; b++) {
e = a.charCodeAt(b);
e >= 48 && e <= 57 || e >= 97 && e <= 102 || e >= 65 && e <= 70 || j()
}
c = c + M("0x" + a.slice(d, b));
break;
default:
j()
}
} else {
if (e == 34) break;
e = a.charCodeAt(b);
for (d = b; e >= 32 && e != 92 && e != 34;)
e = a.charCodeAt(++b);
c = c + a.slice(d, b)
}
}
if (a.charCodeAt(b) == 34) {
b++;
return c
}
j();
default:
d = b;
if (e == 45) {
k = o;
e = a.charCodeAt(++b)
}
if (e >= 48 && e <= 57) {
for (e == 48 && (e = a.charCodeAt(b + 1), e >= 48 && e <= 57) && j(); b < f && (e = a.charCodeAt(b), e >= 48 && e <= 57); b++);
if (a.charCodeAt(b) == 46) {
for (h = ++b; h < f && (e = a.charCodeAt(h), e >= 48 && e <= 57); h++);
h == b && j();
b = h
}
e = a.charCodeAt(b);
if (e == 101 || e == 69) {
e = a.charCodeAt(++b);
(e == 43 || e == 45) && b++;
for (h = b; h < f && (e = a.charCodeAt(h), e >= 48 && e <= 57); h++);
h == b && j();
b = h
}
return +a.slice(d, b)
}
k && j();
if (a.slice(b, b + 4) == "true") {
b = b + 4;
return o
}
if (a.slice(b, b + 5) == "false") {
b = b + 5;
return false
}
if (a.slice(b, b + 4) == "null") {
b = b + 4;
return w
}
j()
}
}
return "$"
}, F = function(a) {
var b, c;
a == "$" && j();
if (typeof a == "string") {
if ((s ? a.charAt(0) : a[0]) == "@") return a.slice(1);
if (a == "[") {
for (b = [];; c || (c = o)) {
a = q();
if (a == "]") break;
if (c) if (a == ",") {
a = q();
a == "]" && j()
} else j();
a == "," && j();
b.push(F(a))
}
return b
}
if (a == "{") {
for (b = {};; c || (c = o)) {
a = q();
if (a == "}") break;
if (c) if (a == ",") {
a = q();
a == "}" && j()
} else j();
(a == "," || typeof a != "string" || (s ? a.charAt(0) : a[0]) != "@" || q() != ":") && j();
b[a.slice(1)] = F(q())
}
return b
}
j()
}
return a
}, I = function(a, b, c) {
c = H(a, b, c);
c === r ? delete a[b] : a[b] = c
}, H = function(a, b, c) {
var d = a[b],
h;
if (typeof d == "object" && d) if (m.call(d) == "[object Array]") for (h = d.length; h--;)
I(d, h, c);
else C(d, function(a) {
I(d, a, c)
});
return c.call(a, b, d)
};
k.parse = function(a, f) {
var c, d;
b = 0;
A = "" + a;
c = F(q());
q() != "$" && j();
b = A = w;
return f && m.call(f) == "[object Function]" ? H((d = {}, d[""] = c, d), "", f) : c
}
}
}
D && define(function() {
return k
})
})(this)
})();
|
|