Interactive interface for browsing global, full-resolution satellite imagery
Revert "Dual colormap schema hack"
Taylor Gunnoeec9fd6d0de79
diff --git a/bin/wv-options-colormap b/bin/wv-options-colormapindex ef0e3197a..e5ef87033 100755--- a/bin/wv-options-colormap+++ b/bin/wv-options-colormap@@ -110,79 +110,6 @@ def process_file(file):newSchema = document["ColorMaps"]except:print "Layer uses old colormap schema, processing differently..."- sys.stderr.write("---- this is the old schema ---")- scaleColors = []- scaleLabels = []- scaleValues = []- classColors = []- classLabels = []- specialColors = []- specialLabels = []- units = None- minValue = float("inf")- maxValue = float("-inf")-- entries = document["ColorMap"]["ColorMapEntry"]- if not isinstance(entries, list):- entries = [entries]-- for entry in entries:- r,g,b = entry["@rgb"].split(",")- a = 255- if "@transparent" in entry and entry["@transparent"] == "true":- a = 0- color = "{0:02x}{1:02x}{2:02x}{3:02x}".format(int(r), int(g), int(b), a)- label = entry["@label"]- if a == 0:- specialColors += [color]- specialLabels += [label]- elif "@value" in entry:- items = re.sub(r"[\(\)\[\]]", "", entry["@value"]).split(",")- try:- for scaleValue in items:- v = float(scaleValue)- if v == float("inf"):- v = sys.float_info.max- if v == float("-inf"):- v = sys.float_info.min- scaleValues += [v]- except ValueError as e:- raise ValueError("Invalid value: %s" % entry["@value"])- scaleColors += [color]- scaleLabels += [label]- else:- classColors += [color]- classLabels += [label]-- id = os.path.splitext(os.path.basename(input_file))[0]- data = {}- if len(scaleColors) > 0:- data["scale"] = {- "colors": scaleColors,- "values": scaleValues,- "labels": scaleLabels,- }- if len(specialColors) > 0:- data["special"] = {- "colors": specialColors,- "labels": specialLabels- }- if len(classColors) > 0:- data["classes"] = {- "colors": classColors,- "labels": classLabels,- }-- data["id"] = id-- json_options = {}- json_options["indent"] = 4- json_options["separators"] = (',', ': ')-- output_file = os.path.join(output_dir, id + ".json")- with open(output_file, "w") as fp:- json.dump(data, fp, **json_options)-else:if newSchema is not None:colormaps = to_list(document["ColorMaps"]["ColorMap"])diff --git a/web/js/edsc/arc.js b/web/js/edsc/arc.jsindex d4422fb0f..f437eef5d 100644--- a/web/js/edsc/arc.js+++ b/web/js/edsc/arc.js@@ -1,66 +1,66 @@-(function() {- var ns;+(function () {+ var ns;- ns = window.edsc.map;+ ns = window.edsc.map;- ns.Arc = (function(L, Coordinate) {- var Arc, EPSILON, exports;- EPSILON = 0.00000001;- Arc = (function() {- function Arc(coordA, coordB) {- var ref;- if (coordB.theta < coordA.theta) {- ref = [coordA, coordB], coordB = ref[0], coordA = ref[1];- }- if (coordB.theta - coordA.theta > Math.PI) {- this.coordB = coordA;- this.coordA = coordB;- } else {- this.coordA = coordA;- this.coordB = coordB;- }- this.normal = this.coordA.cross(this.coordB);- }+ ns.Arc = (function (L, Coordinate) {+ var Arc, EPSILON, exports;+ EPSILON = 0.00000001;+ Arc = (function () {+ function Arc(coordA, coordB) {+ var ref;+ if (coordB.theta < coordA.theta) {+ ref = [coordA, coordB]; coordB = ref[0]; coordA = ref[1];+ }+ if (coordB.theta - coordA.theta > Math.PI) {+ this.coordB = coordA;+ this.coordA = coordB;+ } else {+ this.coordA = coordA;+ this.coordB = coordB;+ }+ this.normal = this.coordA.cross(this.coordB);+ }- Arc.prototype.antimeridianCrossing = function() {- var abs, x, xN, y, yA, yN, z, zN;- abs = Math.abs;- if (this.coordA.theta < this.coordB.theta) {- return null;- }- if (abs(Math.PI - abs(this.coordA.theta)) < EPSILON || abs(Math.PI - abs(this.coordB.theta)) < EPSILON) {- return null;- }- if (abs(this.coordA.theta - this.coordB.theta) % Math.PI < EPSILON) {- return null;- }- xN = this.normal.x;- yN = this.normal.y;- zN = this.normal.z;- yA = this.coordA.y;- if (abs(yA) < EPSILON) {- yA = this.coordB.y;- }- if (abs(yA) < EPSILON) {- return null;- }- if (abs(zN) < EPSILON && abs(xN) < EPSILON) {- return null;- }- x = -zN / yA;- y = 0;- z = xN / yA;- if (x > 0) {- x = -x;- z = -z;- }- return Coordinate.fromXYZ(x, y, z);- };+ Arc.prototype.antimeridianCrossing = function () {+ var abs, x, xN, y, yA, yN, z, zN;+ abs = Math.abs;+ if (this.coordA.theta < this.coordB.theta) {+ return null;+ }+ if (abs(Math.PI - abs(this.coordA.theta)) < EPSILON || abs(Math.PI - abs(this.coordB.theta)) < EPSILON) {+ return null;+ }+ if (abs(this.coordA.theta - this.coordB.theta) % Math.PI < EPSILON) {+ return null;+ }+ xN = this.normal.x;+ yN = this.normal.y;+ zN = this.normal.z;+ yA = this.coordA.y;+ if (abs(yA) < EPSILON) {+ yA = this.coordB.y;+ }+ if (abs(yA) < EPSILON) {+ return null;+ }+ if (abs(zN) < EPSILON && abs(xN) < EPSILON) {+ return null;+ }+ x = -zN / yA;+ y = 0;+ z = xN / yA;+ if (x > 0) {+ x = -x;+ z = -z;+ }+ return Coordinate.fromXYZ(x, y, z);+ };- return Arc;+ return Arc;- })();- return exports = Arc;- })(L, ns.Coordinate);+ })();+ return exports = Arc;+ })(L, ns.Coordinate);}).call(this);diff --git a/web/js/edsc/coordinate.js b/web/js/edsc/coordinate.jsindex a8eafac16..12b760290 100644--- a/web/js/edsc/coordinate.js+++ b/web/js/edsc/coordinate.js@@ -1,113 +1,113 @@-(function() {- var ns,- slice = [].slice;+(function () {+ var ns,+ slice = [].slice;- ns = window.edsc.map;+ ns = window.edsc.map;- ns.Coordinate = (function(L) {- var Coordinate, DEG_TO_RAD, RAD_TO_DEG, exports;- DEG_TO_RAD = Math.PI / 180;- RAD_TO_DEG = 180 / Math.PI;- Coordinate = (function() {- Coordinate.fromLatLng = function() {- var args, lat, lng, ref;- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];- if (args.length === 1) {- ref = args[0], lat = ref.lat, lng = ref.lng;- } else {- lat = args[0], lng = args[1];- }- return Coordinate.fromPhiTheta(lat * DEG_TO_RAD, lng * DEG_TO_RAD);- };+ ns.Coordinate = (function (L) {+ var Coordinate, DEG_TO_RAD, RAD_TO_DEG, exports;+ DEG_TO_RAD = Math.PI / 180;+ RAD_TO_DEG = 180 / Math.PI;+ Coordinate = (function () {+ Coordinate.fromLatLng = function () {+ var args, lat, lng, ref;+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];+ if (args.length === 1) {+ ref = args[0]; lat = ref.lat; lng = ref.lng;+ } else {+ lat = args[0]; lng = args[1];+ }+ return Coordinate.fromPhiTheta(lat * DEG_TO_RAD, lng * DEG_TO_RAD);+ };- Coordinate.fromPhiTheta = function(phi, theta) {- var PI, cos, sin, x, y, z;- PI = Math.PI;- cos = Math.cos;- sin = Math.sin;- while (phi >= PI) {- phi -= 2 * PI;- }- while (phi < PI) {- phi += 2 * PI;- }- if (phi > PI / 2) {- phi = PI - phi;- theta += PI;- }- if (phi < -PI / 2) {- phi = -PI - phi;- theta += PI;- }- while (theta >= PI) {- theta -= 2 * PI;- }- while (theta < -PI) {- theta += 2 * PI;- }- x = cos(phi) * cos(theta);- y = cos(phi) * sin(theta);- z = sin(phi);- return new Coordinate(phi, theta, x, y, z);- };+ Coordinate.fromPhiTheta = function (phi, theta) {+ var PI, cos, sin, x, y, z;+ PI = Math.PI;+ cos = Math.cos;+ sin = Math.sin;+ while (phi >= PI) {+ phi -= 2 * PI;+ }+ while (phi < PI) {+ phi += 2 * PI;+ }+ if (phi > PI / 2) {+ phi = PI - phi;+ theta += PI;+ }+ if (phi < -PI / 2) {+ phi = -PI - phi;+ theta += PI;+ }+ while (theta >= PI) {+ theta -= 2 * PI;+ }+ while (theta < -PI) {+ theta += 2 * PI;+ }+ x = cos(phi) * cos(theta);+ y = cos(phi) * sin(theta);+ z = sin(phi);+ return new Coordinate(phi, theta, x, y, z);+ };- Coordinate.fromXYZ = function(x, y, z) {- var d, phi, scale, theta;- d = x * x + y * y + z * z;- if (d === 0) {- d = x = 1;- }- scale = 1 / Math.sqrt(d);- x *= scale;- y *= scale;- z *= scale;- theta = Math.atan2(y, x);- phi = Math.asin(z);- return new Coordinate(phi, theta, x, y, z);- };+ Coordinate.fromXYZ = function (x, y, z) {+ var d, phi, scale, theta;+ d = x * x + y * y + z * z;+ if (d === 0) {+ d = x = 1;+ }+ scale = 1 / Math.sqrt(d);+ x *= scale;+ y *= scale;+ z *= scale;+ theta = Math.atan2(y, x);+ phi = Math.asin(z);+ return new Coordinate(phi, theta, x, y, z);+ };- function Coordinate(phi1, theta1, x1, y1, z1) {- this.phi = phi1;- this.theta = theta1;- this.x = x1;- this.y = y1;- this.z = z1;- }+ function Coordinate(phi1, theta1, x1, y1, z1) {+ this.phi = phi1;+ this.theta = theta1;+ this.x = x1;+ this.y = y1;+ this.z = z1;+ }- Coordinate.prototype.dot = function(other) {- return this.x * other.x + this.y * other.y + this.z * other.z;- };+ Coordinate.prototype.dot = function (other) {+ return this.x * other.x + this.y * other.y + this.z * other.z;+ };- Coordinate.prototype.cross = function(other) {- var x, y, z;- x = this.y * other.z - this.z * other.y;- y = this.z * other.x - this.x * other.z;- z = this.x * other.y - this.y * other.x;- return Coordinate.fromXYZ(x, y, z);- };+ Coordinate.prototype.cross = function (other) {+ var x, y, z;+ x = this.y * other.z - this.z * other.y;+ y = this.z * other.x - this.x * other.z;+ z = this.x * other.y - this.y * other.x;+ return Coordinate.fromXYZ(x, y, z);+ };- Coordinate.prototype.distanceTo = function(other) {- return Math.acos(this.dot(other));- };+ Coordinate.prototype.distanceTo = function (other) {+ return Math.acos(this.dot(other));+ };- Coordinate.prototype.toLatLng = function() {- return new L.LatLng(RAD_TO_DEG * this.phi, RAD_TO_DEG * this.theta);- };+ Coordinate.prototype.toLatLng = function () {+ return new L.LatLng(RAD_TO_DEG * this.phi, RAD_TO_DEG * this.theta);+ };- Coordinate.prototype.toString = function() {- var latlng;- latlng = this.toLatLng();- return "(" + (latlng.lat.toFixed(3)) + ", " + (latlng.lng.toFixed(3)) + ")";- };+ Coordinate.prototype.toString = function () {+ var latlng;+ latlng = this.toLatLng();+ return "(" + (latlng.lat.toFixed(3)) + ", " + (latlng.lng.toFixed(3)) + ")";+ };- Coordinate.prototype.toXYZString = function() {- return "<" + (this.x.toFixed(3)) + ", " + (this.y.toFixed(3)) + ", " + (this.z.toFixed(3)) + ">";- };+ Coordinate.prototype.toXYZString = function () {+ return "<" + (this.x.toFixed(3)) + ", " + (this.y.toFixed(3)) + ", " + (this.z.toFixed(3)) + ">";+ };- return Coordinate;+ return Coordinate;- })();- return exports = Coordinate;- })(L);+ })();+ return exports = Coordinate;+ })(L);}).call(this);diff --git a/web/js/edsc/geoutil.js b/web/js/edsc/geoutil.jsindex 959fe3b19..8df65dc45 100644--- a/web/js/edsc/geoutil.js+++ b/web/js/edsc/geoutil.js@@ -1,232 +1,232 @@-(function() {- var ns;+(function () {+ var ns;- ns = window.edsc.map;+ ns = window.edsc.map;- ns.geoutil = (function(L, Coordinate, Arc, config) {- var DEG_TO_RAD, EPSILON, NORTH_POLE, RAD_TO_DEG, SOUTH_POLE, _angleDelta, _course, _rotationDirection, area, containsPole, exports, gcInterpolate;- EPSILON = 0.00000001;- NORTH_POLE = 1;- SOUTH_POLE = 2;- DEG_TO_RAD = Math.PI / 180;- RAD_TO_DEG = 180 / Math.PI;- gcInterpolate = function(p1, p2) {- return (function(abs, asin, sqrt, pow, sin, cos, atan2) {- var AB, d, lat, lat1, lat2, lon, lon1, lon2, ref, ref1, x, y, z;- if ((abs(p1.lat) === (ref = abs(p2.lat)) && ref === 90)) {- return p1;- }- if (p2.lng < p1.lng) {- ref1 = [p2, p1], p1 = ref1[0], p2 = ref1[1];- }- lat1 = p1.lat * DEG_TO_RAD;- lon1 = p1.lng * DEG_TO_RAD;- lat2 = p2.lat * DEG_TO_RAD;- lon2 = p2.lng * DEG_TO_RAD;- d = 2 * asin(sqrt(pow(sin((lat1 - lat2) / 2), 2) + cos(lat1) * cos(lat2) * pow(sin((lon1 - lon2) / 2), 2)));- AB = sin(d / 2) / sin(d);- x = AB * (cos(lat1) * cos(lon1) + cos(lat2) * cos(lon2));- y = AB * (cos(lat1) * sin(lon1) + cos(lat2) * sin(lon2));- z = AB * (sin(lat1) + sin(lat2));- lat = RAD_TO_DEG * atan2(z, sqrt(x * x + y * y));- lon = RAD_TO_DEG * atan2(y, x);- if (isNaN(lat) || isNaN(lon)) {- return p1;- }- while (lon < p1.lng - EPSILON) {- lon += 360;- }- while (lon > p2.lng + EPSILON) {- lon -= 360;- }- return new L.LatLng(lat, lon);- })(Math.abs, Math.asin, Math.sqrt, Math.pow, Math.sin, Math.cos, Math.atan2);- };- _course = function(latlng1, latlng2) {- var PI, atan2, c1, c2, cos, denom, lat1, lat2, lng1, lng2, numer, result, sin;- sin = Math.sin, cos = Math.cos, atan2 = Math.atan2, PI = Math.PI;- c1 = Coordinate.fromLatLng(latlng1);- c2 = Coordinate.fromLatLng(latlng1);- lat1 = latlng1.lat * DEG_TO_RAD;- lng1 = latlng1.lng * DEG_TO_RAD;- lat2 = latlng2.lat * DEG_TO_RAD;- lng2 = latlng2.lng * DEG_TO_RAD;- if (lat1 > PI / 2 - EPSILON) {- return PI;- }- if (lat1 < -PI / 2 + EPSILON) {- return 2 * PI;- }- numer = sin(lng1 - lng2) * cos(lat2);- denom = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lng1 - lng2);- result = atan2(numer, denom) % (2 * PI);- if (result < 0) {- result += 2 * PI;- }- return result;- };- _angleDelta = function(a1, a2) {- var left_turn_amount;- if (a2 < a1) {- a2 += 360;- }- left_turn_amount = a2 - a1;- if (left_turn_amount === 180) {- return 0;- } else if (left_turn_amount > 180) {- return left_turn_amount - 360;- } else {- return left_turn_amount;- }- };- _rotationDirection = function(angles) {- var a1, a2, delta, i, j, len, ref;- delta = 0;- len = angles.length;- for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {- a1 = angles[i];- a2 = angles[(i + 1) % len];- delta += _angleDelta(a1, a2);- }- if (Math.abs(delta) < EPSILON) {- delta = 0;- }- return delta;- };- containsPole = function(latlngs) {- var angles, delta, delta0, delta1, dir, final, i, initial, j, latlng, latlng0, latlng1, latlng2, len, prev, ref;- if (latlngs.length < 3) {- return false;- }- latlngs = (function() {- var j, len1, results;- results = [];- for (j = 0, len1 = latlngs.length; j < len1; j++) {- latlng = latlngs[j];- results.push(L.latLng(latlng));- }- return results;- })();- delta = 0;- len = latlngs.length;- for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {- latlng0 = latlngs[(i - 1 + len) % len];- latlng1 = latlngs[i];- latlng2 = latlngs[(i + 1) % len];- prev = (_course(latlng1, latlng0) + Math.PI) % (2 * Math.PI);- initial = _course(latlng1, latlng2);- final = (_course(latlng2, latlng1) + Math.PI) % (2 * Math.PI);- delta0 = initial - prev;- if (delta0 > Math.PI) {- delta0 -= 2 * Math.PI;- }- if (delta0 < -Math.PI) {- delta0 += 2 * Math.PI;- }- if (Math.abs(Math.PI - Math.abs(delta0)) < EPSILON) {- delta0 = 0;- }- delta1 = final - initial;- if (delta1 > Math.PI) {- delta1 -= 2 * Math.PI;- }- if (delta1 < -Math.PI) {- delta1 += 2 * Math.PI;- }- if (Math.abs(Math.PI - Math.abs(delta1)) < EPSILON) {- delta1 = 0;- }- delta += delta0 + delta1;- }- delta = delta * RAD_TO_DEG;- if (delta < -360 + EPSILON) {- return NORTH_POLE | SOUTH_POLE;- } else if (delta < EPSILON) {- angles = (function() {- var k, len1, results;- results = [];- for (k = 0, len1 = latlngs.length; k < len1; k++) {- latlng = latlngs[k];- results.push(latlng.lng);- }- return results;- })();- dir = _rotationDirection(angles);- if (dir > 0) {- return NORTH_POLE;- } else if (dir < 0) {- return SOUTH_POLE;- } else {- if (config.debug) {- console.warn("Rotation direction is NONE despite containing a pole");- }- return 0;- }- } else {- return 0;- }- };- area = function(origLatlngs) {- var PI, crossesMeridian, i, j, k, latlngA, latlngB, latlngC, latlngs, len, phiB, ref, ref1, sum, thetaA, thetaB, thetaC;- if (origLatlngs.length < 3) {- return 0;- }- latlngs = [];- len = origLatlngs.length;- for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {- latlngA = origLatlngs[i];- latlngB = origLatlngs[(i + 1) % len];- latlngs.push(latlngA);- if (Math.abs(latlngA.lat - latlngB.lat) > 20 || Math.abs(latlngA.lng - latlngB.lng) > 20) {- latlngs.push(gcInterpolate(latlngA, latlngB));- }- }- PI = Math.PI;- crossesMeridian = false;- sum = 0;- len = latlngs.length;- for (i = k = 0, ref1 = len; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {- latlngA = latlngs[i];- latlngB = latlngs[(i + 1) % len];- latlngC = latlngs[(i + 2) % len];- thetaA = latlngA.lng * DEG_TO_RAD;- thetaB = latlngB.lng * DEG_TO_RAD;- thetaC = latlngC.lng * DEG_TO_RAD;- phiB = latlngB.lat * DEG_TO_RAD;- if (Math.abs(thetaB - thetaA) > PI) {- crossesMeridian = !crossesMeridian;- if (thetaB > thetaA) {- thetaB -= 2 * Math.PI;- } else {- thetaB += 2 * Math.PI;- }- }- if (Math.abs(thetaC - thetaB) > PI) {- crossesMeridian = !crossesMeridian;- if (thetaC > thetaB) {- thetaC -= 2 * Math.PI;- } else {- thetaC += 2 * Math.PI;- }- }- sum += (thetaC - thetaA) * Math.sin(phiB);- }- if (crossesMeridian) {- sum = 4 * Math.PI + sum;- }- area = -sum / 2;- if (area < 0) {- area = 4 * Math.PI + area;- }- return area;- };- return exports = {- gcInterpolate: gcInterpolate,- area: area,- containsPole: containsPole,- NORTH_POLE: NORTH_POLE,- SOUTH_POLE: SOUTH_POLE- };- })(L, ns.Coordinate, ns.Arc, this.edsc.config);+ ns.geoutil = (function (L, Coordinate, Arc, config) {+ var DEG_TO_RAD, EPSILON, NORTH_POLE, RAD_TO_DEG, SOUTH_POLE, _angleDelta, _course, _rotationDirection, area, containsPole, exports, gcInterpolate;+ EPSILON = 0.00000001;+ NORTH_POLE = 1;+ SOUTH_POLE = 2;+ DEG_TO_RAD = Math.PI / 180;+ RAD_TO_DEG = 180 / Math.PI;+ gcInterpolate = function (p1, p2) {+ return (function (abs, asin, sqrt, pow, sin, cos, atan2) {+ var AB, d, lat, lat1, lat2, lon, lon1, lon2, ref, ref1, x, y, z;+ if ((abs(p1.lat) === (ref = abs(p2.lat)) && ref === 90)) {+ return p1;+ }+ if (p2.lng < p1.lng) {+ ref1 = [p2, p1]; p1 = ref1[0]; p2 = ref1[1];+ }+ lat1 = p1.lat * DEG_TO_RAD;+ lon1 = p1.lng * DEG_TO_RAD;+ lat2 = p2.lat * DEG_TO_RAD;+ lon2 = p2.lng * DEG_TO_RAD;+ d = 2 * asin(sqrt(pow(sin((lat1 - lat2) / 2), 2) + cos(lat1) * cos(lat2) * pow(sin((lon1 - lon2) / 2), 2)));+ AB = sin(d / 2) / sin(d);+ x = AB * (cos(lat1) * cos(lon1) + cos(lat2) * cos(lon2));+ y = AB * (cos(lat1) * sin(lon1) + cos(lat2) * sin(lon2));+ z = AB * (sin(lat1) + sin(lat2));+ lat = RAD_TO_DEG * atan2(z, sqrt(x * x + y * y));+ lon = RAD_TO_DEG * atan2(y, x);+ if (isNaN(lat) || isNaN(lon)) {+ return p1;+ }+ while (lon < p1.lng - EPSILON) {+ lon += 360;+ }+ while (lon > p2.lng + EPSILON) {+ lon -= 360;+ }+ return new L.LatLng(lat, lon);+ })(Math.abs, Math.asin, Math.sqrt, Math.pow, Math.sin, Math.cos, Math.atan2);+ };+ _course = function (latlng1, latlng2) {+ var PI, atan2, c1, c2, cos, denom, lat1, lat2, lng1, lng2, numer, result, sin;+ sin = Math.sin; cos = Math.cos; atan2 = Math.atan2; PI = Math.PI;+ c1 = Coordinate.fromLatLng(latlng1);+ c2 = Coordinate.fromLatLng(latlng1);+ lat1 = latlng1.lat * DEG_TO_RAD;+ lng1 = latlng1.lng * DEG_TO_RAD;+ lat2 = latlng2.lat * DEG_TO_RAD;+ lng2 = latlng2.lng * DEG_TO_RAD;+ if (lat1 > PI / 2 - EPSILON) {+ return PI;+ }+ if (lat1 < -PI / 2 + EPSILON) {+ return 2 * PI;+ }+ numer = sin(lng1 - lng2) * cos(lat2);+ denom = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lng1 - lng2);+ result = atan2(numer, denom) % (2 * PI);+ if (result < 0) {+ result += 2 * PI;+ }+ return result;+ };+ _angleDelta = function (a1, a2) {+ var left_turn_amount;+ if (a2 < a1) {+ a2 += 360;+ }+ left_turn_amount = a2 - a1;+ if (left_turn_amount === 180) {+ return 0;+ } else if (left_turn_amount > 180) {+ return left_turn_amount - 360;+ } else {+ return left_turn_amount;+ }+ };+ _rotationDirection = function (angles) {+ var a1, a2, delta, i, j, len, ref;+ delta = 0;+ len = angles.length;+ for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {+ a1 = angles[i];+ a2 = angles[(i + 1) % len];+ delta += _angleDelta(a1, a2);+ }+ if (Math.abs(delta) < EPSILON) {+ delta = 0;+ }+ return delta;+ };+ containsPole = function (latlngs) {+ var angles, delta, delta0, delta1, dir, final, i, initial, j, latlng, latlng0, latlng1, latlng2, len, prev, ref;+ if (latlngs.length < 3) {+ return false;+ }+ latlngs = (function () {+ var j, len1, results;+ results = [];+ for (j = 0, len1 = latlngs.length; j < len1; j++) {+ latlng = latlngs[j];+ results.push(L.latLng(latlng));+ }+ return results;+ })();+ delta = 0;+ len = latlngs.length;+ for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {+ latlng0 = latlngs[(i - 1 + len) % len];+ latlng1 = latlngs[i];+ latlng2 = latlngs[(i + 1) % len];+ prev = (_course(latlng1, latlng0) + Math.PI) % (2 * Math.PI);+ initial = _course(latlng1, latlng2);+ final = (_course(latlng2, latlng1) + Math.PI) % (2 * Math.PI);+ delta0 = initial - prev;+ if (delta0 > Math.PI) {+ delta0 -= 2 * Math.PI;+ }+ if (delta0 < -Math.PI) {+ delta0 += 2 * Math.PI;+ }+ if (Math.abs(Math.PI - Math.abs(delta0)) < EPSILON) {+ delta0 = 0;+ }+ delta1 = final - initial;+ if (delta1 > Math.PI) {+ delta1 -= 2 * Math.PI;+ }+ if (delta1 < -Math.PI) {+ delta1 += 2 * Math.PI;+ }+ if (Math.abs(Math.PI - Math.abs(delta1)) < EPSILON) {+ delta1 = 0;+ }+ delta += delta0 + delta1;+ }+ delta = delta * RAD_TO_DEG;+ if (delta < -360 + EPSILON) {+ return NORTH_POLE | SOUTH_POLE;+ } else if (delta < EPSILON) {+ angles = (function () {+ var k, len1, results;+ results = [];+ for (k = 0, len1 = latlngs.length; k < len1; k++) {+ latlng = latlngs[k];+ results.push(latlng.lng);+ }+ return results;+ })();+ dir = _rotationDirection(angles);+ if (dir > 0) {+ return NORTH_POLE;+ } else if (dir < 0) {+ return SOUTH_POLE;+ } else {+ if (options.debug) {+ console.warn("Rotation direction is NONE despite containing a pole");+ }+ return 0;+ }+ } else {+ return 0;+ }+ };+ area = function (origLatlngs) {+ var PI, crossesMeridian, i, j, k, latlngA, latlngB, latlngC, latlngs, len, phiB, ref, ref1, sum, thetaA, thetaB, thetaC;+ if (origLatlngs.length < 3) {+ return 0;+ }+ latlngs = [];+ len = origLatlngs.length;+ for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {+ latlngA = origLatlngs[i];+ latlngB = origLatlngs[(i + 1) % len];+ latlngs.push(latlngA);+ if (Math.abs(latlngA.lat - latlngB.lat) > 20 || Math.abs(latlngA.lng - latlngB.lng) > 20) {+ latlngs.push(gcInterpolate(latlngA, latlngB));+ }+ }+ PI = Math.PI;+ crossesMeridian = false;+ sum = 0;+ len = latlngs.length;+ for (i = k = 0, ref1 = len; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {+ latlngA = latlngs[i];+ latlngB = latlngs[(i + 1) % len];+ latlngC = latlngs[(i + 2) % len];+ thetaA = latlngA.lng * DEG_TO_RAD;+ thetaB = latlngB.lng * DEG_TO_RAD;+ thetaC = latlngC.lng * DEG_TO_RAD;+ phiB = latlngB.lat * DEG_TO_RAD;+ if (Math.abs(thetaB - thetaA) > PI) {+ crossesMeridian = !crossesMeridian;+ if (thetaB > thetaA) {+ thetaB -= 2 * Math.PI;+ } else {+ thetaB += 2 * Math.PI;+ }+ }+ if (Math.abs(thetaC - thetaB) > PI) {+ crossesMeridian = !crossesMeridian;+ if (thetaC > thetaB) {+ thetaC -= 2 * Math.PI;+ } else {+ thetaC += 2 * Math.PI;+ }+ }+ sum += (thetaC - thetaA) * Math.sin(phiB);+ }+ if (crossesMeridian) {+ sum = 4 * Math.PI + sum;+ }+ area = -sum / 2;+ if (area < 0) {+ area = 4 * Math.PI + area;+ }+ return area;+ };+ return exports = {+ gcInterpolate: gcInterpolate,+ area: area,+ containsPole: containsPole,+ NORTH_POLE: NORTH_POLE,+ SOUTH_POLE: SOUTH_POLE+ };+ })(L, ns.Coordinate, ns.Arc, this.edsc.config);}).call(this);diff --git a/web/js/edsc/interpolation.js b/web/js/edsc/interpolation.jsindex 8752948a3..f351df15e 100644--- a/web/js/edsc/interpolation.js+++ b/web/js/edsc/interpolation.js@@ -1,132 +1,132 @@-(function() {- var ns;+(function () {+ var ns;- ns = this.edsc.map.L;+ ns = this.edsc.map.L;- ns.interpolation = (function(L, gcInterpolate) {- var exports, interpolateCartesian, interpolateGeodetic, projectLatLngPath, projectLatlngs, projectPath;- interpolateCartesian = function(ll0, ll1) {- return L.latLng((ll0.lat + ll1.lat) / 2, (ll0.lng + ll1.lng) / 2);- };- interpolateGeodetic = function(ll0, ll1) {- return gcInterpolate(ll0, ll1);- };- projectLatLngPath = function(latLngs, proj, interpolateFn, tolerance, maxDepth) {- var d, depth, depth0, depth1, interpolatedLatLngs, interpolatedPoints, ll, ll0, ll1, maxDepthReached, p, p0, p1, points, ref;- if (tolerance == null) {- tolerance = 1;- }- if (maxDepth == null) {- maxDepth = 10;- }- if (latLngs.length === 0) {- return [];- }- if ((Math.abs(latLngs[0].lng) === (ref = Math.abs(latLngs[latLngs.length - 1].lng)) && ref === 180)) {- latLngs = latLngs.concat(latLngs[latLngs.length - 1]);- } else {- latLngs = latLngs.concat(latLngs[0]);- }- points = (function() {- var i, len, results;- results = [];- for (i = 0, len = latLngs.length; i < len; i++) {- ll = latLngs[i];- results.push(proj(ll));- }- return results;- })();- interpolatedLatLngs = [latLngs.shift()];- interpolatedPoints = [points.shift()];- depth0 = 0;- depth1 = 0;- maxDepthReached = false;- while (latLngs.length > 0) {- ll0 = interpolatedLatLngs[interpolatedLatLngs.length - 1];- p0 = interpolatedPoints[interpolatedPoints.length - 1];- ll1 = latLngs[0];- p1 = points[0];- ll = interpolateFn(ll0, ll1);- p = proj(ll);- depth = Math.max(depth0, depth1) + 1;- d = L.LineUtil.pointToSegmentDistance(p, p0, p1);- if (d < tolerance || depth >= maxDepth) {- if (depth >= maxDepth) {- maxDepthReached = true;- }- interpolatedLatLngs.push(ll, latLngs.shift());- interpolatedPoints.push(p, points.shift());- depth0 = depth1;- depth1 = Math.max(0, depth1 - 2);- } else {- latLngs.unshift(ll);- points.unshift(p);- depth1 += 1;- }- }- if (maxDepthReached && config.debug) {- console.log("Max interpolation depth reached.");- }- return interpolatedPoints;- };- projectPath = function(map, latlngs, holes, fn, tolerance, maxDepth) {- var hole, proj, result;- if (holes == null) {- holes = [];- }- if (fn == null) {- fn = 'geodetic';- }- if (tolerance == null) {- tolerance = 1;- }- if (maxDepth == null) {- maxDepth = 10;- }- if (fn === 'geodetic') {- fn = interpolateGeodetic;- }- if (fn === 'cartesian') {- fn = interpolateCartesian;- }- proj = function(ll) {- var MAX_RES, result;- MAX_RES = 10000000;- if (ll.lat === 90) {- ll = L.latLng(89.999, ll.lng);- }- result = map.latLngToLayerPoint.call(map, ll);- result.x = Math.max(Math.min(result.x, MAX_RES), -MAX_RES);- result.y = Math.max(Math.min(result.y, MAX_RES), -MAX_RES);- return result;- };- return result = {- boundary: projectLatLngPath(latlngs, proj, fn, tolerance, maxDepth),- holes: (function() {- var i, len, ref, results;- ref = holes != null ? holes : [];- results = [];- for (i = 0, len = ref.length; i < len; i++) {- hole = ref[i];- results.push(projectLatLngPath(hole, proj, fn, tolerance, maxDepth));- }- return results;- })()- };- };- projectLatlngs = function() {- var interpolated;- interpolated = projectPath(this._map, this._latlngs, this._holes, this._interpolationFn);- this._originalPoints = interpolated.boundary;- return this._holePoints = interpolated.holes;- };- L.Polyline.prototype.projectLatlngs = projectLatlngs;- L.Polygon.prototype.projectLatlngs = projectLatlngs;- L.Polyline.prototype._interpolationFn = interpolateGeodetic;- L.Rectangle.prototype._interpolationFn = interpolateCartesian;- return exports = {- projectPath: projectPath- };- })(L, window.edsc.map.geoutil.gcInterpolate);+ ns.interpolation = (function (L, gcInterpolate) {+ var exports, interpolateCartesian, interpolateGeodetic, projectLatLngPath, projectLatlngs, projectPath;+ interpolateCartesian = function (ll0, ll1) {+ return L.latLng((ll0.lat + ll1.lat) / 2, (ll0.lng + ll1.lng) / 2);+ };+ interpolateGeodetic = function (ll0, ll1) {+ return gcInterpolate(ll0, ll1);+ };+ projectLatLngPath = function (latLngs, proj, interpolateFn, tolerance, maxDepth) {+ var d, depth, depth0, depth1, interpolatedLatLngs, interpolatedPoints, ll, ll0, ll1, maxDepthReached, p, p0, p1, points, ref;+ if (tolerance == null) {+ tolerance = 1;+ }+ if (maxDepth == null) {+ maxDepth = 10;+ }+ if (latLngs.length === 0) {+ return [];+ }+ if ((Math.abs(latLngs[0].lng) === (ref = Math.abs(latLngs[latLngs.length - 1].lng)) && ref === 180)) {+ latLngs = latLngs.concat(latLngs[latLngs.length - 1]);+ } else {+ latLngs = latLngs.concat(latLngs[0]);+ }+ points = (function () {+ var i, len, results;+ results = [];+ for (i = 0, len = latLngs.length; i < len; i++) {+ ll = latLngs[i];+ results.push(proj(ll));+ }+ return results;+ })();+ interpolatedLatLngs = [latLngs.shift()];+ interpolatedPoints = [points.shift()];+ depth0 = 0;+ depth1 = 0;+ maxDepthReached = false;+ while (latLngs.length > 0) {+ ll0 = interpolatedLatLngs[interpolatedLatLngs.length - 1];+ p0 = interpolatedPoints[interpolatedPoints.length - 1];+ ll1 = latLngs[0];+ p1 = points[0];+ ll = interpolateFn(ll0, ll1);+ p = proj(ll);+ depth = Math.max(depth0, depth1) + 1;+ d = L.LineUtil.pointToSegmentDistance(p, p0, p1);+ if (d < tolerance || depth >= maxDepth) {+ if (depth >= maxDepth) {+ maxDepthReached = true;+ }+ interpolatedLatLngs.push(ll, latLngs.shift());+ interpolatedPoints.push(p, points.shift());+ depth0 = depth1;+ depth1 = Math.max(0, depth1 - 2);+ } else {+ latLngs.unshift(ll);+ points.unshift(p);+ depth1 += 1;+ }+ }+ if (maxDepthReached && config.debug) {+ console.log("Max interpolation depth reached.");+ }+ return interpolatedPoints;+ };+ projectPath = function (map, latlngs, holes, fn, tolerance, maxDepth) {+ var hole, proj, result;+ if (holes == null) {+ holes = [];+ }+ if (fn == null) {+ fn = 'geodetic';+ }+ if (tolerance == null) {+ tolerance = 1;+ }+ if (maxDepth == null) {+ maxDepth = 10;+ }+ if (fn === 'geodetic') {+ fn = interpolateGeodetic;+ }+ if (fn === 'cartesian') {+ fn = interpolateCartesian;+ }+ proj = function (ll) {+ var MAX_RES, result;+ MAX_RES = 10000000;+ if (ll.lat === 90) {+ ll = L.latLng(89.999, ll.lng);+ }+ result = map.latLngToLayerPoint.call(map, ll);+ result.x = Math.max(Math.min(result.x, MAX_RES), -MAX_RES);+ result.y = Math.max(Math.min(result.y, MAX_RES), -MAX_RES);+ return result;+ };+ return result = {+ boundary: projectLatLngPath(latlngs, proj, fn, tolerance, maxDepth),+ holes: (function () {+ var i, len, ref, results;+ ref = holes != null ? holes : [];+ results = [];+ for (i = 0, len = ref.length; i < len; i++) {+ hole = ref[i];+ results.push(projectLatLngPath(hole, proj, fn, tolerance, maxDepth));+ }+ return results;+ })()+ };+ };+ projectLatlngs = function () {+ var interpolated;+ interpolated = projectPath(this._map, this._latlngs, this._holes, this._interpolationFn);+ this._originalPoints = interpolated.boundary;+ return this._holePoints = interpolated.holes;+ };+ L.Polyline.prototype.projectLatlngs = projectLatlngs;+ L.Polygon.prototype.projectLatlngs = projectLatlngs;+ L.Polyline.prototype._interpolationFn = interpolateGeodetic;+ L.Rectangle.prototype._interpolationFn = interpolateCartesian;+ return exports = {+ projectPath: projectPath+ };+ })(L, window.edsc.map.geoutil.gcInterpolate);}).call(this);diff --git a/web/js/edsc/spherical_polygon.js b/web/js/edsc/spherical_polygon.jsindex a6f590085..ab20a82be 100644--- a/web/js/edsc/spherical_polygon.js+++ b/web/js/edsc/spherical_polygon.js@@ -1,284 +1,284 @@-(function() {- var ns;+(function () {+ var ns;- ns = edsc.map;+ ns = edsc.map;- ns.L.sphericalPolygon = (function(L, geoutil, Arc, Coordinate) {- var antimeridianCrossing, convertLatLngs, dividePolygon, exports, ll2j, ll2s, makeCounterclockwise, originalRemove;- convertLatLngs = function(latlngs) {- var j, latlng, len1, original, result;- result = [];- for (j = 0, len1 = latlngs.length; j < len1; j++) {- original = latlngs[j];- latlng = L.latLng(original);- while (latlng.lng > 180) {- latlng.lng -= 360;- }- while (latlng.lng < -180) {- latlng.lng += 360;- }- result.push(latlng);- }- return result;- };- antimeridianCrossing = function(latlng0, latlng1) {- var arc, ref;- arc = new Arc(Coordinate.fromLatLng(L.latLng(latlng0)), Coordinate.fromLatLng(L.latLng(latlng1)));- return (ref = arc.antimeridianCrossing()) != null ? ref.toLatLng() : void 0;- };- makeCounterclockwise = function(latlngs) {- var area;- area = geoutil.area(latlngs);- if (area > 2 * Math.PI) {- latlngs.reverse();- }- return latlngs;- };- ll2s = function(latlngs) {- var ll;- return ((function() {- var j, len1, results;- results = [];- for (j = 0, len1 = latlngs.length; j < len1; j++) {- ll = latlngs[j];- results.push("(" + ll.lat + ", " + ll.lng + ")");- }- return results;- })()).join(', ');- };- ll2j = function(latlngs) {- var ll;- return ((function() {- var j, len1, ref, results;- ref = latlngs.concat(latlngs[0]);- results = [];- for (j = 0, len1 = ref.length; j < len1; j++) {- ll = ref[j];- results.push(ll.lng + "," + ll.lat);- }- return results;- })()).join(', ');- };- dividePolygon = function(latlngs) {- var boundaries, boundary, containedPoles, containsNorthPole, containsSouthPole, crossing, extra, extras, hasInsertions, hasPole, hole, holes, i, inc, interior, interiors, j, k, l, lat, latlng, latlng1, latlng2, len, len1, len2, len3, lng, m, maxCrossingLat, minCrossingLat, n, next, o, p, q, ref, ref1, split;- interiors = [];- boundaries = [];- holes = [];- if (latlngs && L.Util.isArray(latlngs[0]) && typeof latlngs[0][0] !== 'number') {- ref = latlngs.slice(1);- for (j = 0, len1 = ref.length; j < len1; j++) {- hole = ref[j];- hole = convertLatLngs(hole);- denormalizePath(hole);- holes.push(hole);- }- latlngs = latlngs[0];- }- latlngs = convertLatLngs(latlngs);- latlngs = makeCounterclockwise(latlngs);- containedPoles = geoutil.containsPole(latlngs);- containsNorthPole = (containedPoles & geoutil.NORTH_POLE) !== 0;- containsSouthPole = (containedPoles & geoutil.SOUTH_POLE) !== 0;- maxCrossingLat = -95;- minCrossingLat = 95;- split = [];- len = latlngs.length;- for (i = k = 0, ref1 = len; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {- latlng1 = latlngs[i];- latlng2 = latlngs[(i + 1) % len];- crossing = antimeridianCrossing(latlng1, latlng2);- split.push(latlng1);- extras = [];- if (crossing != null) {- lat = crossing.lat;- if (latlng1.lng < latlng2.lng) {- extras = [[lat, -180], [lat, 180]];- } else {- extras = [[lat, 180], [lat, -180]];- }- } else if (latlng1.lng === 180 && latlng2.lng < 0) {- extras = [[latlng1.lat, -180]];- } else if (latlng1.lng === -180 && latlng2.lng > 0) {- extras = [[latlng1.lat, 180]];- } else if (latlng2.lng === 180 && latlng1.lng < 0) {- extras = [[latlng2.lat, -180]];- } else if (latlng2.lng === -180 && latlng1.lng > 0) {- extras = [[latlng2.lat, 180]];- }- for (l = 0, len2 = extras.length; l < len2; l++) {- extra = extras[l];- lat = extra[0], lng = extra[1];- split.push(L.latLng(lat, lng));- maxCrossingLat = Math.max(lat, maxCrossingLat);- minCrossingLat = Math.min(lat, minCrossingLat);- }- }- hasInsertions = latlngs.length < split.length;- interior = [];- boundary = [];- if (hasInsertions) {- if (Math.abs(split[0].lng) !== 180 || Math.abs(split[split.length - 1].lng) !== 180) {- while (Math.abs(split[0].lng) !== 180) {- split.push(split.shift());- }- split.push(split.shift());- }- }- for (i = m = 0, len3 = split.length; m < len3; i = ++m) {- latlng = split[i];- interior.push(latlng);- boundary.push(latlng);- next = split[(i + 1) % split.length];- if (interior.length > 2 && Math.abs(latlng.lng) === 180 && Math.abs(next.lng) === 180) {- boundaries.push(boundary);- boundary = [];- hasPole = false;- if (containsNorthPole && latlng.lat === maxCrossingLat) {- hasPole = true;- lng = latlng.lng;- inc = lng < 0 ? 90 : -90;- for (i = n = 0; n <= 4; i = ++n) {- interior.push(L.latLng(90, lng + i * inc));+ ns.L.sphericalPolygon = (function (L, geoutil, Arc, Coordinate) {+ var antimeridianCrossing, convertLatLngs, dividePolygon, exports, ll2j, ll2s, makeCounterclockwise, originalRemove;+ convertLatLngs = function (latlngs) {+ var j, latlng, len1, original, result;+ result = [];+ for (j = 0, len1 = latlngs.length; j < len1; j++) {+ original = latlngs[j];+ latlng = L.latLng(original);+ while (latlng.lng > 180) {+ latlng.lng -= 360;+ }+ while (latlng.lng < -180) {+ latlng.lng += 360;+ }+ result.push(latlng);}- }- if (containsSouthPole && latlng.lat === minCrossingLat) {- hasPole = true;- lng = latlng.lng;- inc = lng < 0 ? 90 : -90;- for (i = o = 0; o <= 4; i = ++o) {- interior.push(L.latLng(-90, lng + i * inc));+ return result;+ };+ antimeridianCrossing = function (latlng0, latlng1) {+ var arc, ref;+ arc = new Arc(Coordinate.fromLatLng(L.latLng(latlng0)), Coordinate.fromLatLng(L.latLng(latlng1)));+ return (ref = arc.antimeridianCrossing()) != null ? ref.toLatLng() : void 0;+ };+ makeCounterclockwise = function (latlngs) {+ var area;+ area = geoutil.area(latlngs);+ if (area > 2 * Math.PI) {+ latlngs.reverse();}- }- if (!hasPole) {- interiors.push(interior);+ return latlngs;+ };+ ll2s = function (latlngs) {+ var ll;+ return ((function () {+ var j, len1, results;+ results = [];+ for (j = 0, len1 = latlngs.length; j < len1; j++) {+ ll = latlngs[j];+ results.push("(" + ll.lat + ", " + ll.lng + ")");+ }+ return results;+ })()).join(', ');+ };+ ll2j = function (latlngs) {+ var ll;+ return ((function () {+ var j, len1, ref, results;+ ref = latlngs.concat(latlngs[0]);+ results = [];+ for (j = 0, len1 = ref.length; j < len1; j++) {+ ll = ref[j];+ results.push(ll.lng + "," + ll.lat);+ }+ return results;+ })()).join(', ');+ };+ dividePolygon = function (latlngs) {+ var boundaries, boundary, containedPoles, containsNorthPole, containsSouthPole, crossing, extra, extras, hasInsertions, hasPole, hole, holes, i, inc, interior, interiors, j, k, l, lat, latlng, latlng1, latlng2, len, len1, len2, len3, lng, m, maxCrossingLat, minCrossingLat, n, next, o, p, q, ref, ref1, split;+ interiors = [];+ boundaries = [];+ holes = [];+ if (latlngs && L.Util.isArray(latlngs[0]) && typeof latlngs[0][0] !== 'number') {+ ref = latlngs.slice(1);+ for (j = 0, len1 = ref.length; j < len1; j++) {+ hole = ref[j];+ hole = convertLatLngs(hole);+ denormalizePath(hole);+ holes.push(hole);+ }+ latlngs = latlngs[0];+ }+ latlngs = convertLatLngs(latlngs);+ latlngs = makeCounterclockwise(latlngs);+ containedPoles = geoutil.containsPole(latlngs);+ containsNorthPole = (containedPoles & geoutil.NORTH_POLE) !== 0;+ containsSouthPole = (containedPoles & geoutil.SOUTH_POLE) !== 0;+ maxCrossingLat = -95;+ minCrossingLat = 95;+ split = [];+ len = latlngs.length;+ for (i = k = 0, ref1 = len; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {+ latlng1 = latlngs[i];+ latlng2 = latlngs[(i + 1) % len];+ crossing = antimeridianCrossing(latlng1, latlng2);+ split.push(latlng1);+ extras = [];+ if (crossing != null) {+ lat = crossing.lat;+ if (latlng1.lng < latlng2.lng) {+ extras = [[lat, -180], [lat, 180]];+ } else {+ extras = [[lat, 180], [lat, -180]];+ }+ } else if (latlng1.lng === 180 && latlng2.lng < 0) {+ extras = [[latlng1.lat, -180]];+ } else if (latlng1.lng === -180 && latlng2.lng > 0) {+ extras = [[latlng1.lat, 180]];+ } else if (latlng2.lng === 180 && latlng1.lng < 0) {+ extras = [[latlng2.lat, -180]];+ } else if (latlng2.lng === -180 && latlng1.lng > 0) {+ extras = [[latlng2.lat, 180]];+ }+ for (l = 0, len2 = extras.length; l < len2; l++) {+ extra = extras[l];+ lat = extra[0]; lng = extra[1];+ split.push(L.latLng(lat, lng));+ maxCrossingLat = Math.max(lat, maxCrossingLat);+ minCrossingLat = Math.min(lat, minCrossingLat);+ }+ }+ hasInsertions = latlngs.length < split.length;interior = [];- }- }- }- if (boundary.length > 0) {- boundaries.push(boundary);- }- if (interior.length > 0) {- interiors.push(interior);- }- if (containsNorthPole && containsSouthPole && !hasInsertions) {- interior = [];- for (i = p = 0; p <= 4; i = ++p) {- interior.push(L.latLng(90, -180 + i * 90));- }- for (i = q = 0; q <= 4; i = ++q) {- interior.push(L.latLng(-90, 180 - i * 90));- }- interiors.unshift(interior);- }- return {- interiors: interiors,- boundaries: boundaries- };- };- L.SphericalPolygon = L.Polygon.extend({- includes: [L.LayerGroup.prototype, L.FeatureGroup.prototype],- options: {- fill: true- },- initialize: function(latlngs, options) {- this._layers = {};- this._options = L.extend({}, this.options, options);- return this.setLatLngs(latlngs);- },- setLatLngs: function(latlngs) {- var divided, latlng;- if (latlngs[0] && Array.isArray(latlngs[0]) && latlngs[0].length > 2) {- if (console.warn) {- console.warn("Polygon with hole detected. Ignoring.");- }- latlngs = latlngs[0];- }- latlngs = (function() {- var j, len1, results;- results = [];- for (j = 0, len1 = latlngs.length; j < len1; j++) {- latlng = latlngs[j];- results.push(L.latLng(latlng));- }- return results;- })();- this._latlngs = latlngs;- divided = dividePolygon(latlngs);- if (this._boundaries) {- this._interiors.setLatLngs(divided.interiors);- return this._boundaries.setLatLngs(divided.boundaries);- } else {- this._interiors = L.polygon(divided.interiors, L.extend({}, this._options, {- stroke: false- }));- this._boundaries = L.multiPolyline(divided.boundaries, L.extend({}, this._options, {- fill: false- }));- this.addLayer(this._interiors);- return this.addLayer(this._boundaries);- }- },- getLatLngs: function() {- return makeCounterclockwise(this._latlngs.concat());- },- newLatLngIntersects: function(latlng, skipFirst) {- return false;- },- setOptions: function(options) {- this._options = this.options = L.extend({}, this._options, options);- L.setOptions(this._interiors, L.extend({}, this._options, {- stroke: false- }));- L.setOptions(this._boundaries, L.extend({}, this._options, {- fill: false- }));- return this.redraw();- },- setStyle: function(style) {- if (this.options.previousOptions) {- this.options.previousOptions = this._options;- }- this._interiors.setStyle(L.extend({}, style, {- stroke: false- }));- return this._boundaries.setStyle(L.extend({}, style, {- fill: false- }));- },- redraw: function() {- return this.setLatLngs(this._latlngs);- }- });- L.sphericalPolygon = function(latlngs, options) {- return new L.SphericalPolygon(latlngs, options);- };- originalRemove = L.EditToolbar.Delete.prototype._removeLayer;- L.EditToolbar.Delete.prototype._removeLayer = function(e) {- var ref;- if ((ref = e.target) != null ? ref._boundaries : void 0) {- e.layer = e.target;- }- return originalRemove.call(this, e);- };- L.Draw.Polygon = L.Draw.Polygon.extend({- Poly: L.SphericalPolygon,- addHooks: function() {- L.Draw.Polyline.prototype.addHooks.call(this);- if (this._map) {- return this._poly = new L.SphericalPolygon([], this.options.shapeOptions);- }- }- });- L.Edit.Poly = L.Edit.Poly.extend({- _getMiddleLatLng: function(marker1, marker2) {- var latlng;- return latlng = geoutil.gcInterpolate(marker1.getLatLng(), marker2.getLatLng());- }- });- return exports = {- dividePolygon: dividePolygon- };- })(L, ns.geoutil, ns.Arc, ns.Coordinate);+ boundary = [];+ if (hasInsertions) {+ if (Math.abs(split[0].lng) !== 180 || Math.abs(split[split.length - 1].lng) !== 180) {+ while (Math.abs(split[0].lng) !== 180) {+ split.push(split.shift());+ }+ split.push(split.shift());+ }+ }+ for (i = m = 0, len3 = split.length; m < len3; i = ++m) {+ latlng = split[i];+ interior.push(latlng);+ boundary.push(latlng);+ next = split[(i + 1) % split.length];+ if (interior.length > 2 && Math.abs(latlng.lng) === 180 && Math.abs(next.lng) === 180) {+ boundaries.push(boundary);+ boundary = [];+ hasPole = false;+ if (containsNorthPole && latlng.lat === maxCrossingLat) {+ hasPole = true;+ lng = latlng.lng;+ inc = lng < 0 ? 90 : -90;+ for (i = n = 0; n <= 4; i = ++n) {+ interior.push(L.latLng(90, lng + i * inc));+ }+ }+ if (containsSouthPole && latlng.lat === minCrossingLat) {+ hasPole = true;+ lng = latlng.lng;+ inc = lng < 0 ? 90 : -90;+ for (i = o = 0; o <= 4; i = ++o) {+ interior.push(L.latLng(-90, lng + i * inc));+ }+ }+ if (!hasPole) {+ interiors.push(interior);+ interior = [];+ }+ }+ }+ if (boundary.length > 0) {+ boundaries.push(boundary);+ }+ if (interior.length > 0) {+ interiors.push(interior);+ }+ if (containsNorthPole && containsSouthPole && !hasInsertions) {+ interior = [];+ for (i = p = 0; p <= 4; i = ++p) {+ interior.push(L.latLng(90, -180 + i * 90));+ }+ for (i = q = 0; q <= 4; i = ++q) {+ interior.push(L.latLng(-90, 180 - i * 90));+ }+ interiors.unshift(interior);+ }+ return {+ interiors: interiors,+ boundaries: boundaries+ };+ };+ L.SphericalPolygon = L.Polygon.extend({+ includes: [L.LayerGroup.prototype, L.FeatureGroup.prototype],+ options: {+ fill: true+ },+ initialize: function (latlngs, options) {+ this._layers = {};+ this._options = L.extend({}, this.options, options);+ return this.setLatLngs(latlngs);+ },+ setLatLngs: function (latlngs) {+ var divided, latlng;+ if (latlngs[0] && Array.isArray(latlngs[0]) && latlngs[0].length > 2) {+ if (console.warn) {+ console.warn("Polygon with hole detected. Ignoring.");+ }+ latlngs = latlngs[0];+ }+ latlngs = (function () {+ var j, len1, results;+ results = [];+ for (j = 0, len1 = latlngs.length; j < len1; j++) {+ latlng = latlngs[j];+ results.push(L.latLng(latlng));+ }+ return results;+ })();+ this._latlngs = latlngs;+ divided = dividePolygon(latlngs);+ if (this._boundaries) {+ this._interiors.setLatLngs(divided.interiors);+ return this._boundaries.setLatLngs(divided.boundaries);+ } else {+ this._interiors = L.polygon(divided.interiors, L.extend({}, this._options, {+ stroke: false+ }));+ this._boundaries = L.multiPolyline(divided.boundaries, L.extend({}, this._options, {+ fill: false+ }));+ this.addLayer(this._interiors);+ return this.addLayer(this._boundaries);+ }+ },+ getLatLngs: function () {+ return makeCounterclockwise(this._latlngs.concat());+ },+ newLatLngIntersects: function () {+ return false;+ },+ setOptions: function (options) {+ this._options = this.options = L.extend({}, this._options, options);+ L.setOptions(this._interiors, L.extend({}, this._options, {+ stroke: false+ }));+ L.setOptions(this._boundaries, L.extend({}, this._options, {+ fill: false+ }));+ return this.redraw();+ },+ setStyle: function (style) {+ if (this.options.previousOptions) {+ this.options.previousOptions = this._options;+ }+ this._interiors.setStyle(L.extend({}, style, {+ stroke: false+ }));+ return this._boundaries.setStyle(L.extend({}, style, {+ fill: false+ }));+ },+ redraw: function () {+ return this.setLatLngs(this._latlngs);+ }+ });+ L.sphericalPolygon = function (latlngs, options) {+ return new L.SphericalPolygon(latlngs, options);+ };+ originalRemove = L.EditToolbar.Delete.prototype._removeLayer;+ L.EditToolbar.Delete.prototype._removeLayer = function (e) {+ var ref;+ if ((ref = e.target) != null ? ref._boundaries : void 0) {+ e.layer = e.target;+ }+ return originalRemove.call(this, e);+ };+ L.Draw.Polygon = L.Draw.Polygon.extend({+ Poly: L.SphericalPolygon,+ addHooks: function () {+ L.Draw.Polyline.prototype.addHooks.call(this);+ if (this._map) {+ return this._poly = new L.SphericalPolygon([], this.options.shapeOptions);+ }+ }+ });+ L.Edit.Poly = L.Edit.Poly.extend({+ _getMiddleLatLng: function (marker1, marker2) {+ var latlng;+ return latlng = geoutil.gcInterpolate(marker1.getLatLng(), marker2.getLatLng());+ }+ });+ return exports = {+ dividePolygon: dividePolygon+ };+ })(L, ns.geoutil, ns.Arc, ns.Coordinate);}).call(this);