Internalise third-party dependencies

(cherry picked from commit 725eb619b4)
This commit is contained in:
Ian Renton
2026-06-18 20:07:42 +01:00
parent 4408203d55
commit 88f055384d
47 changed files with 4771 additions and 49 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

163
webassets/vendor/js/leaflet-cqzones.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

263
webassets/vendor/js/leaflet-ituzones.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
/*
* L.Maidenhead displays a Maidenhead Locator of lines on the map.
*/
L.Maidenhead = L.LayerGroup.extend({
options: {
// Line and label color
color: 'rgba(255, 0, 0, 0.4)',
// Redraw on move or moveend
redraw: 'move'
},
initialize: function (options) {
L.LayerGroup.prototype.initialize.call(this);
L.Util.setOptions(this, options);
},
onAdd: function (map) {
this._map = map;
var grid = this.redraw();
this._map.on('viewreset '+ this.options.redraw, function () {
grid.redraw();
});
this.eachLayer(map.addLayer, map);
},
onRemove: function (map) {
// remove layer listeners and elements
map.off('viewreset '+ this.options.redraw, this.map);
this.eachLayer(this.removeLayer, this);
},
redraw: function () {
var d3 = new Array(20,10,10,10,10,10,1 ,1 ,1 ,1 ,1/24,1/24,1/24,1/24,1/24,1/240,1/240,1/240,1/240/24,1/240/24,1/240/24 );
var lat_cor = new Array(0 ,8 ,8 ,8 ,10,14,6 ,8 ,8 ,8 ,1.4 ,2.5 ,3 ,3.5 ,4 ,4 ,3.5 ,3.5 ,1.47 ,1.8 ,1.6 );
var bounds = map.getBounds();
var zoom = map.getZoom();
var unit = d3[Math.round(zoom)];
var lcor = lat_cor[Math.round(zoom)];
var w = bounds.getWest();
var e = bounds.getEast();
var n = bounds.getNorth();
var s = bounds.getSouth();
if (zoom==1) {var c = 2;} else {var c = 0.1;}
if (n > 85) n = 85;
if (s < -85) s = -85;
var left = Math.floor(w/(unit*2))*(unit*2);
var right = Math.ceil(e/(unit*2))*(unit*2);
var top = Math.ceil(n/unit)*unit;
var bottom = Math.floor(s/unit)*unit;
this.eachLayer(this.removeLayer, this);
for (var lon = left; lon < right; lon += (unit*2)) {
for (var lat = bottom; lat < top; lat += unit) {
var bounds = [[lat,lon],[lat+unit,lon+(unit*2)]];
this.addLayer(L.rectangle(bounds, {color: this.options.color, weight: 1, fill:false, interactive: false}));
//var pont = map.latLngToLayerPoint([lat,lon]);
//console.log(pont.x);
this.addLayer(this._getLabel(lon+unit-(unit/lcor),lat+(unit/2)+(unit/lcor*c)));
}
}
return this;
},
_getLabel: function(lon,lat) {
var title_size = new Array(0 ,10,12,16,20,26,12,16,24,36,12 ,14 ,20 ,36 ,60 ,12 ,20 ,36 ,8 ,12 ,24 );
var zoom = map.getZoom();
var size = title_size[Math.round(zoom)]+'px';
var title = '<span style="cursor: default;"><font style="color:'+this.options.color+'; font-size:'+size+'; font-weight: 900; ">' + this._getLocator(lon,lat) + '</font></span>';
var myIcon = L.divIcon({className: 'my-div-icon', html: title});
var marker = L.marker([lat,lon], {icon: myIcon}, clickable=false);
return marker;
},
_getLocator: function(lon,lat) {
var ydiv_arr=new Array(10, 1, 1/24, 1/240, 1/240/24);
var d1 = "ABCDEFGHIJKLMNOPQR".split("");
var d2 = "ABCDEFGHIJKLMNOPQRSTUVWX".split("");
var d4 = new Array(0 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,3 ,3 ,3 ,3 ,3 ,4 ,4 ,4 ,5 ,5 ,5 );
var locator = "";
var x = lon;
var y = lat;
var precision = d4[Math.round(map.getZoom())];
while (x < -180) {x += 360;}
while (x > 180) {x -=360;}
x = x + 180;
y = y + 90;
locator = locator + d1[Math.floor(x/20)] + d1[Math.floor(y/10)];
for (var i=0; i<4; i=i+1) {
if (precision > i+1) {
rlon = x%(ydiv_arr[i]*2);
rlat = y%(ydiv_arr[i]);
if ((i%2)==0) {
locator += Math.floor(rlon/(ydiv_arr[i+1]*2)) +""+ Math.floor(rlat/(ydiv_arr[i+1]));
} else {
locator += d2[Math.floor(rlon/(ydiv_arr[i+1]*2))] +""+ d2[Math.floor(rlat/(ydiv_arr[i+1]))];
}
}
}
return locator;
},
});
L.maidenhead = function (options) {
return new L.Maidenhead(options);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
/**
* Minified by jsDelivr using Terser v5.37.0.
* Original file: /npm/@joergdietrich/leaflet.terminator@1.1.0/L.Terminator.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],i):(t.L=t.L||{},t.L.terminator=i(t.L))}(this,(function(t){"use strict";var i=(t=t&&t.hasOwnProperty("default")?t.default:t).Polygon.extend({options:{color:"#00",opacity:.5,fillColor:"#00",fillOpacity:.5,resolution:2},initialize:function(i){this.version="0.1.0",this._R2D=180/Math.PI,this._D2R=Math.PI/180,t.Util.setOptions(this,i);var n=this._compute(this.options.time);this.setLatLngs(n)},setTime:function(t){this.options.time=t;var i=this._compute(t);this.setLatLngs(i)},_sunEclipticPosition:function(t){var i=t-2451545,n=280.46+.9856474*i,e=357.528+.9856003*i;return e%=360,{lambda:(n%=360)+1.915*Math.sin(e*this._D2R)+.02*Math.sin(2*e*this._D2R),R:1.00014-.01671*Math.cos(e*this._D2R)-.0014*Math.cos(2*e*this._D2R)}},_eclipticObliquity:function(t){var i=(t-2451545)/36525;return 23.43929111-i*(46.836769/3600-i*(1831e-7/3600+i*(5.565e-7-i*(1.6e-10-4.34e-8*i/3600))))},_sunEquatorialPosition:function(t,i){var n=Math.atan(Math.cos(i*this._D2R)*Math.tan(t*this._D2R))*this._R2D,e=Math.asin(Math.sin(i*this._D2R)*Math.sin(t*this._D2R))*this._R2D;return{alpha:n+=90*Math.floor(t/90)-90*Math.floor(n/90),delta:e}},_hourAngle:function(t,i,n){return 15*(n+t/15)-i.alpha},_latitude:function(t,i){return Math.atan(-Math.cos(t*this._D2R)/Math.tan(i.delta*this._D2R))*this._R2D},_compute:function(t){for(var i=t?new Date(t):new Date,n=i/864e5+2440587.5,e=function(t){return(18.697374558+24.06570982441908*(t-2451545))%24}(n),o=[],s=this._sunEclipticPosition(n),a=this._eclipticObliquity(n),h=this._sunEquatorialPosition(s.lambda,a),r=0;r<=720*this.options.resolution;r++){var u=r/this.options.resolution-360,l=this._hourAngle(u,h,e);o[r+1]=[this._latitude(l,h),u]}return h.delta<0?(o[0]=[90,-360],o[o.length]=[90,360]):(o[0]=[-90,-360],o[o.length]=[-90,360]),o}});return function(t){return new i(t)}}));
//# sourceMappingURL=/sm/0ad6cc527a0e7748dc9ea3acda4c2088f86401baae9f9dddc41fc73f9afa2de2.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,259 @@
L.WorkedAllBritainIreland = L.LayerGroup.extend({
options: {
// Line and label color
color: 'rgba(80, 80, 80, 1)',
// Grid squares to draw
gbSquares: ["HP", "HT", "HU", "HW", "HX", "HY", "HZ", "NA", "NB", "NC", "ND", "NF", "NG", "NH", "NJ", "NK", "NL", "NM", "NN", "NO", "NR", "NS", "NT", "NU", "NW", "NX", "NY", "NZ", "OV", "SC", "SD", "SE", "SH", "SJ", "SK", "SM", "SN", "SO", "SP", "SR", "SS", "ST", "SU", "SV", "SW", "SX", "SY", "SZ", "TA", "TF", "TG", "TL", "TM", "TR", "TQ", "TV"],
ieSquares: ["B", "C", "D", "F", "G", "H", "J", "L", "M", "N", "O", "Q", "R", "S", "T", "V", "W", "X"],
ciSquares: ["WA", "WV"]
},
initialize: function (options) {
// Initialise the LayerGroup superclass and set the options for this class.
L.LayerGroup.prototype.initialize.call(this);
L.Util.setOptions(this, options);
// Workaround to load the geodesy modules in non-modular code. Once we have loaded all three modules, trigger a
// first draw.
import("https://misc.ianrenton.com/Leaflet.WorkedAllBritainIreland/modules/geodesy/osgridref.js")
.then(module => {
this._osGridLibrary = module;
if (this._ieGridLibrary && this._utmLibrary) {
this.redraw();
}
})
.catch(error => {
console.log("Error loading OS Grid Ref library, GB WAB squares may not be available.");
console.log(error);
});
import("https://misc.ianrenton.com/Leaflet.WorkedAllBritainIreland/modules/geodesy/iegridref.js")
.then(module => {
this._ieGridLibrary = module;
if (this._osGridLibrary && this._utmLibrary) {
this.redraw();
}
})
.catch(error => {
console.log("Error loading IE Grid Ref library, NI WAB squares may not be available.");
console.log(error);
});
import("https://misc.ianrenton.com/Leaflet.WorkedAllBritainIreland/modules/geodesy/utm_ci.js")
.then(module => {
this._utmLibrary = module;
if (this._osGridLibrary && this._ieGridLibrary) {
this.redraw();
}
})
.catch(error => {
console.log("Error loading UTM library, Channel Islands WAB squares may not be available.");
console.log(error);
});
},
onAdd: function (map) {
this._map = map;
var grid = this.redraw();
map.on('moveend', function () { grid.redraw(); });
map.on('zoomend', function () { grid.redraw(); });
this.eachLayer(map.addLayer, map);
},
onRemove: function (map) {
map.off('moveend', this.map);
map.off('zoomend', this.map);
this.eachLayer(this.removeLayer, this);
},
redraw: function () {
// Don't proceed unless we have a map object and our libraries are loaded
if (this._map && this._osGridLibrary && this._ieGridLibrary && this._utmLibrary) {
// Remove existing content
this.eachLayer(this.removeLayer, this);
// Determine detail level based on current map zoom.
const detailLevel = (map.getZoom() > 4) ? (map.getZoom() > 8) ? 2 : 1 : 0;
// Generate new content for the three grid systems.
this.options.gbSquares.forEach(squareRef => {
this._addWABGraphicsForSquare(squareRef, "GB", detailLevel);
});
this.options.ieSquares.forEach(squareRef => {
this._addWABGraphicsForSquare(squareRef, "IE", detailLevel);
});
this.options.ciSquares.forEach(squareRef => {
this._addWABGraphicsForSquare(squareRef, "CI", detailLevel);
});
}
return this;
},
// Add WAB graphics to the layer for the given square, using the given grid system ("GB", "IE" or "CI") and the
// required level of detail.
_addWABGraphicsForSquare: function (squareRef, gridSystem, detailLevel) {
if (detailLevel === 0 || detailLevel === 1) {
// If detail level is 0 or 1, we want a single large square.
const swCorner = this._gridRefToLatLon(squareRef + " 00000 00000", gridSystem);
const nwCorner = this._gridRefToLatLon(squareRef + " 99999 00000", gridSystem);
const neCorner = this._gridRefToLatLon(squareRef + " 99999 99999", gridSystem);
const seCorner = this._gridRefToLatLon(squareRef + " 00000 99999", gridSystem);
const centre = this._gridRefToLatLon(squareRef + " 50000 50000", gridSystem);
let square = L.polygon([swCorner, nwCorner, neCorner, seCorner], {color: this.options.color, interactive: false});
this.addLayer(square);
// Additionally if detail level is 1, we want to label it.
if (detailLevel === 1) {
let label = new L.marker(centre, {
icon: new L.DivIcon({
html: '<span style="position: relative; top: -40%; left: -40%; text-align: center; cursor: hand; color:'+this.options.color+'; font-weight: bold; font-size:120%;">' + squareRef + '</font></span>',
className: 'wabSquareLabel' // Prevent default background & border and provide ability to customise
})
}, clickable=false);
this.addLayer(label);
}
} else if (detailLevel === 2) {
// If detail level is 2, we want to generate all the inner squares (with labels)
// instead of just one square. But, doing this for every square will cause CPU issues,
// so we only want to generate graphics if they would actually end up on screen.
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
// Bail out if we have a grid reference that doesn't apply. This is where GB grid overlaps with NI etc.
// are deconflicted.
if (this._validSmallSquare(squareRef, i, j)) {
// If we get this far, now calculate the coordinates of the box.
const swCorner = this._gridRefToLatLon(squareRef + " " + i + "0000 " + j + "0000", gridSystem);
const nwCorner = this._gridRefToLatLon(squareRef + " " + i + "9999 " + j + "0000", gridSystem);
const neCorner = this._gridRefToLatLon(squareRef + " " + i + "9999 " + j + "9999", gridSystem);
const seCorner = this._gridRefToLatLon(squareRef + " " + i + "0000 " + j + "9999", gridSystem);
const centre = this._gridRefToLatLon(squareRef + " " + i + "5000 " + j + "5000", gridSystem);
// Find out if this box is going to be on our screen. If not, don't draw anything.
if (map.getBounds().contains(swCorner) || map.getBounds().contains(nwCorner)
|| map.getBounds().contains(neCorner) || map.getBounds().contains(seCorner)) {
let square = L.polygon([swCorner, nwCorner, neCorner, seCorner], {color: this.options.color, interactive: false});
this.addLayer(square);
let label = new L.marker(centre, {
icon: new L.DivIcon({
html: '<span style="position: relative; top: -20%; left: -100%; text-align: center; cursor: hand; color:'+this.options.color+'; font-weight: bold; font-size:120%;">' + squareRef + i + j + '</font></span>',
className: 'wabSquareLabelLong' // Prevent default background & border and provide ability to customise
})
}, clickable=false);
this.addLayer(label);
}
}
}
}
}
},
// Determine if a given small square is OK to draw. This is where e.g. overlapping GB and IE squares are
// deconflicted in the Irish Sea.
_validSmallSquare: function (squareRef, i, j) {
let valid = true;
if (squareRef === "WA" && j > 1) {
valid = false;
} else if (squareRef === "TR" && i > 4 && j < 5) {
valid = false;
} else if (squareRef === "SM" && i < 4) {
valid = false;
} else if (squareRef === "SM" && i < 7 && j > 4) {
valid = false;
} else if (squareRef === "TV" && i === 9 && j === 0) {
valid = false;
} else if (squareRef === "NW" && i < 9) {
valid = false;
} else if (squareRef === "NR" && i < 5 && j < 3) {
valid = false;
} else if (squareRef === "C" && j > 6) {
valid = false;
} else if (squareRef === "D" && (i > 5 || j > 5 || (i > 2 && j > 3))) {
valid = false;
} else if (squareRef === "J" && i > 6) {
valid = false;
} else if (squareRef === "O" && i > 8) {
valid = false;
} else if (squareRef === "T" && i > 6 && j < 5) {
valid = false;
}
return valid;
},
// Convert the given grid reference to lat/lon, using the given grid system ("GB", "IE" or "CI")
_gridRefToLatLon: function (grid, gridSystem) {
if (gridSystem === "GB") {
return this._osgbGridRefToLatLon(grid);
} else if (gridSystem === "IE") {
return this._osieGridRefToLatLon(grid);
} else if (gridSystem === "CI") {
return this._ciGridRefToLatLon(grid);
} else {
return null;
}
},
// OSGB grid reference to lat/lon
_osgbGridRefToLatLon: function (grid) {
if (this._osGridLibrary) {
return this._osGridLibrary.default.parse(grid).toLatLon();
} else {
return null;
}
},
// Lat/lon to OSGB grid reference
_latLonToOSGBGridRef: function (lat, lon) {
if (this._osGridLibrary) {
return new this._osGridLibrary.LatLon(lat, lon).toOsGrid();
} else {
return null;
}
},
// OSIE grid reference to lat/lon
_osieGridRefToLatLon: function (grid) {
if (this._ieGridLibrary) {
return this._ieGridLibrary.default.parse(grid).toLatLon();
} else {
return null;
}
},
// Lat/lon to OSIE grid reference
_latLonToOSIEGridRef: function (lat, lon) {
if (this._ieGridLibrary) {
return new this._ieGridLibrary.LatLon(lat, lon).toOsGrid();
} else {
return null;
}
},
// CI grid reference to lat/lon
_ciGridRefToLatLon: function (grid) {
if (this._utmLibrary) {
return this._utmLibrary.default.parseChannelIslandGrid(grid).toLatLon();
} else {
return null;
}
},
// Lat/lon to CI grid reference
_latLonToCIGridRef: function (lat, lon) {
if (this._utmLibrary) {
let utm = (new this._utmLibrary.LatLon(lat, lon)).toUtm();
// todo convert UTM coordinate system back to CI grid ref cells
return null;
} else {
return null;
}
}
});
L.workedAllBritainIreland = function (options) {
return new L.WorkedAllBritainIreland(options);
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(){var t,n=document.createElement("pre"),h=document.createElement("canvas"),r=h.getContext("2d"),i={font:"Sans-serif",align:"left",color:"#000000",size:16,background:"rgba(0, 0, 0, 0)",stroke:0,strokeColor:"#FFFFFF",lineHeight:"1.2em",bold:!1,italic:!1};function s(t){t=String(t),n.innerText=t,n.setAttribute("style",this._style),document.body.append(n);var e=t.split("\n"),i=this.style.stroke,s=n.offsetHeight/e.length,l=.25*s;h.width=n.offsetWidth+2*i,h.height=n.offsetHeight,r.clearRect(0,0,h.width,h.height),r.fillStyle=this.style.background,r.beginPath(),r.fillRect(0,0,h.width,h.height),r.fill();var o="";switch(this.style.italic&&(o+="italic "),this.style.bold&&(o+="bold "),o+=this.style.size+"pt "+this.style.font,r.font=o,r.textAlign=this.style.align,r.lineWidth=this.style.stroke,r.strokeStyle=this.style.strokeColor,r.fillStyle=this.style.color,r.textAlign){case"center":i=h.width/2;break;case"right":i=h.width-i}e.forEach(function(t,e){this.style.stroke&&r.strokeText(t,i,s*(e+1)-l),r.fillText(t,i,s*(e+1)-l)}.bind(this)),document.body.removeChild(n)}window.TextImage=function(t){return this instanceof TextImage?(this.setStyle(t),this):new TextImage(t)},(t=window.TextImage.prototype).setStyle=function(t){for(var e in this.style=t||{},i)this.style[e]||(this.style[e]=i[e]);return this._style="font: ",this.style.italic&&(this._style+="italic "),this.style.bold&&(this._style+="bold "),this._style+=this.style.size+"pt "+this.style.font+";",this._style+="line-height:"+this.style.lineHeight+";",this._style+="text-align: "+this.style.align+";",this._style+="color: "+this.style.color+";",this._style+="background-color: "+this.style.background+";",this._style+=";padding: 0; display: block; position: fixed; top: 100%; overflow: hidden;",this},t.toDataURL=function(t){return t&&s.call(this,t),h.toDataURL()},t.toImage=function(t,e){s.call(this,t);var i=new Image;return e&&(i.onload=e),i.src=h.toDataURL(),i}}();

File diff suppressed because one or more lines are too long