Update index.html
Browse files- index.html +114 -1
index.html
CHANGED
@@ -440,4 +440,117 @@
|
|
440 |
position: {
|
441 |
lat: station.location[0] + (Math.random() - 0.5) * range,
|
442 |
lon: station.location[1] + (Math.random() - 0.5) * range
|
443 |
-
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
position: {
|
441 |
lat: station.location[0] + (Math.random() - 0.5) * range,
|
442 |
lon: station.location[1] + (Math.random() - 0.5) * range
|
443 |
+
},
|
444 |
+
|
445 |
+
speed: Math.random() * 100 + 50,
|
446 |
+
heading: Math.random() * 360,
|
447 |
+
station: station
|
448 |
+
};
|
449 |
+
}
|
450 |
+
|
451 |
+
updateTargets() {
|
452 |
+
if (Math.random() < 0.1 && this.targets.size < 10) {
|
453 |
+
this.targets.add(this.generateTarget());
|
454 |
+
}
|
455 |
+
|
456 |
+
this.targets.forEach(target => {
|
457 |
+
// Update target position based on heading and speed
|
458 |
+
const rad = target.heading * Math.PI / 180;
|
459 |
+
target.position.lat += Math.cos(rad) * target.speed * 0.00001;
|
460 |
+
target.position.lon += Math.sin(rad) * target.speed * 0.00001;
|
461 |
+
|
462 |
+
// Remove targets that are too far from their station
|
463 |
+
const distance = this.calculateDistance(
|
464 |
+
target.position.lat,
|
465 |
+
target.position.lon,
|
466 |
+
target.station.location[0],
|
467 |
+
target.station.location[1]
|
468 |
+
);
|
469 |
+
|
470 |
+
if (distance > target.station.range) {
|
471 |
+
this.targets.delete(target);
|
472 |
+
}
|
473 |
+
});
|
474 |
+
}
|
475 |
+
|
476 |
+
calculateDistance(lat1, lon1, lat2, lon2) {
|
477 |
+
const R = 6371; // Earth's radius in km
|
478 |
+
const dLat = (lat2 - lat1) * Math.PI / 180;
|
479 |
+
const dLon = (lon2 - lon1) * Math.PI / 180;
|
480 |
+
const a =
|
481 |
+
Math.sin(dLat/2) * Math.sin(dLat/2) +
|
482 |
+
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
|
483 |
+
Math.sin(dLon/2) * Math.sin(dLon/2);
|
484 |
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
485 |
+
return R * c;
|
486 |
+
}
|
487 |
+
|
488 |
+
addDetection(target) {
|
489 |
+
const container = document.getElementById('detections');
|
490 |
+
const detection = document.createElement('div');
|
491 |
+
detection.className = 'detection';
|
492 |
+
detection.innerHTML = `
|
493 |
+
${target.type === 'aircraft' ? '✈️' : '🚗'} Signal detected at
|
494 |
+
${target.position.lat.toFixed(4)}, ${target.position.lon.toFixed(4)}
|
495 |
+
<br>Speed: ${target.speed.toFixed(1)} km/h
|
496 |
+
<br>Heading: ${target.heading.toFixed(1)}°
|
497 |
+
<br>Station: ${target.station.name}
|
498 |
+
`;
|
499 |
+
container.insertBefore(detection, container.firstChild);
|
500 |
+
|
501 |
+
if (container.children.length > 5) {
|
502 |
+
container.removeChild(container.lastChild);
|
503 |
+
}
|
504 |
+
|
505 |
+
// Update signal strength bar
|
506 |
+
const receiver = document.getElementById(`rx-${target.station.url.split(':')[0]}`);
|
507 |
+
const signalBar = receiver.querySelector('.signal-bar');
|
508 |
+
signalBar.style.width = `${Math.random() * 40 + 60}%`;
|
509 |
+
|
510 |
+
// Add signal line
|
511 |
+
this.addSignalLine(target);
|
512 |
+
}
|
513 |
+
|
514 |
+
addSignalLine(target) {
|
515 |
+
const stationPos = this.latLongToXY(target.station.location[0], target.station.location[1]);
|
516 |
+
const targetPos = this.latLongToXY(target.position.lat, target.position.lon);
|
517 |
+
|
518 |
+
const line = document.createElement('div');
|
519 |
+
line.className = 'signal-line';
|
520 |
+
line.style.position = 'absolute';
|
521 |
+
line.style.left = `${stationPos.x}px`;
|
522 |
+
line.style.top = `${stationPos.y}px`;
|
523 |
+
|
524 |
+
const length = Math.sqrt(
|
525 |
+
Math.pow(targetPos.x - stationPos.x, 2) +
|
526 |
+
Math.pow(targetPos.y - stationPos.y, 2)
|
527 |
+
);
|
528 |
+
const angle = Math.atan2(targetPos.y - stationPos.y, targetPos.x - stationPos.x);
|
529 |
+
|
530 |
+
line.style.width = `${length}px`;
|
531 |
+
line.style.transform = `rotate(${angle}rad)`;
|
532 |
+
|
533 |
+
document.getElementById('map-container').appendChild(line);
|
534 |
+
|
535 |
+
setTimeout(() => line.remove(), 2000);
|
536 |
+
}
|
537 |
+
|
538 |
+
startTracking() {
|
539 |
+
setInterval(() => {
|
540 |
+
this.updateTargets();
|
541 |
+
this.targets.forEach(target => {
|
542 |
+
if (Math.random() < 0.3) {
|
543 |
+
this.addDetection(target);
|
544 |
+
}
|
545 |
+
});
|
546 |
+
}, 2000);
|
547 |
+
}
|
548 |
+
}
|
549 |
+
|
550 |
+
// Initialize the radar system when the page loads
|
551 |
+
window.addEventListener('load', () => {
|
552 |
+
new RadarSystem();
|
553 |
+
});
|
554 |
+
</script>
|
555 |
+
</body>
|
556 |
+
</html>
|