mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
[Advanced Logbook] Added CQ and ITU zone to the bottom
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
var lang_gen_hamradio_cq_zones = '<?= _pgettext("Map Options", "CQ Zones"); ?>';
|
||||
var lang_gen_hamradio_itu_zones = '<?= _pgettext("Map Options", "ITU Zones"); ?>';
|
||||
var lang_gen_hamradio_nightshadow = '<?= _pgettext("Map Options", "Night Shadow"); ?>';
|
||||
var lang_gen_hamradio_ituzone = '<?= __("ITU Zone"); ?>';
|
||||
var lang_gen_hamradio_cqzone = '<?= __("CQ Zone"); ?>';
|
||||
<?php
|
||||
echo "var homegrid ='" . strtoupper($homegrid[0]) . "';";
|
||||
if (!isset($options)) {
|
||||
|
||||
@@ -942,7 +942,7 @@ label {
|
||||
#latDeg, #lngDeg {
|
||||
width: 170px;
|
||||
}
|
||||
#locator, #distance, #bearing {
|
||||
#locator, #distance, #bearing, #ituzonedisplay, #cqzonedisplay{
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,71 @@ function onMapMove(event) {
|
||||
|
||||
$('#bearing').html(distance.deg + '°');
|
||||
$('#distance').html(Math.round(distance.distance * 10) / 10 + ' ' +unit);
|
||||
|
||||
if (typeof zonestuff !== 'undefined' && zonestuff) {
|
||||
const cqZone = findCQZone(event.latlng);
|
||||
$('#cqzonedisplay').html(cqZone);
|
||||
}
|
||||
|
||||
if (typeof ituzonestuff !== 'undefined' && ituzonestuff) {
|
||||
const ituZone = findITUZone(event.latlng);
|
||||
$('#ituzonedisplay').html(ituZone);
|
||||
}
|
||||
};
|
||||
|
||||
function findCQZone(latlng) {
|
||||
let cqZone = null;
|
||||
zonestuff.features.forEach(feature => {
|
||||
try {
|
||||
if (isMarkerInsidePolygon(latlng, feature)) {
|
||||
cqZone = feature.properties.cq_zone_number;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
return cqZone;
|
||||
}
|
||||
|
||||
function findITUZone(latlng) {
|
||||
if (85 < parseFloat(latlng.lat).toFixed(6))
|
||||
return "75";
|
||||
if (-85 > parseFloat(latlng.lat).toFixed(6))
|
||||
return "74";
|
||||
let ituZone = null;
|
||||
ituzonestuff.features.forEach(feature => {
|
||||
try {
|
||||
if (isMarkerInsidePolygon(latlng, feature)) {
|
||||
ituZone = feature.properties.itu_zone_number;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
return ituZone;
|
||||
}
|
||||
|
||||
function isMarkerInsidePolygon(marker, poly) {
|
||||
const x = marker.lng; // Longitude
|
||||
const y = marker.lat; // Latitude
|
||||
|
||||
const polyPoints = poly.geometry.coordinates[0];
|
||||
let inside = false;
|
||||
|
||||
for (let i = 0, j = polyPoints.length - 1; i < polyPoints.length; j = i++) {
|
||||
const xi = polyPoints[i][0], yi = polyPoints[i][1];
|
||||
const xj = polyPoints[j][0], yj = polyPoints[j][1];
|
||||
|
||||
const intersect = ((yi > y) !== (yj > y)) &&
|
||||
(x < (xj - xi) * (y - yi) / (yj - yi) + xi);
|
||||
if (intersect) inside = !inside;
|
||||
}
|
||||
|
||||
return inside;
|
||||
}
|
||||
|
||||
function onMapClick(event) {
|
||||
var LatLng = event.latlng;
|
||||
var lat = LatLng.lat;
|
||||
|
||||
@@ -242,6 +242,10 @@ function loadMap(data, iconsList) {
|
||||
'<div class="cohidden col-auto text-success fw-bold" id="distance"></div>' +
|
||||
'<div class="cohidden">' + lang_gen_hamradio_bearing + ' </div>' +
|
||||
'<div class="cohidden col-auto text-success fw-bold" id="bearing"></div>' +
|
||||
'<div class="cohidden">' + lang_gen_hamradio_cqzone + ' </div>' +
|
||||
'<div class="cohidden col-auto text-success fw-bold" id="cqzonedisplay"></div>' +
|
||||
'<div class="cohidden">' + lang_gen_hamradio_ituzone + ' </div>' +
|
||||
'<div class="cohidden col-auto text-success fw-bold" id="ituzonedisplay"></div>' +
|
||||
'</div>');
|
||||
$('.cohidden').show();
|
||||
set_advancedmap_height();
|
||||
|
||||
Reference in New Issue
Block a user