mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
Cleaning
This commit is contained in:
@@ -2,32 +2,16 @@
|
||||
|
||||
export default function useMultipleCircleDraw(circles, addCircle, removeCircle, radius) {
|
||||
|
||||
function getDistanceFromLatLon({ lat: lat1, lng: lon1 }, { lat: lat2, lng: lon2 }) {
|
||||
const degToRad = (deg) => deg * (Math.PI / 180);
|
||||
var R = 6371; // Radius of the earth in km
|
||||
var dLat = degToRad(lat2 - lat1);
|
||||
var dLon = degToRad(lon2 - lon1);
|
||||
var a =
|
||||
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
||||
Math.cos(degToRad(lat1)) * Math.cos(degToRad(lat2)) *
|
||||
Math.sin(dLon / 2) * Math.sin(dLon / 2)
|
||||
;
|
||||
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
var d = R * c; // Distance in km
|
||||
return d * 1000;
|
||||
}
|
||||
|
||||
function isBaddlyPlaced(latlng) {
|
||||
return circles.some(circle => getDistanceFromLatLon(latlng, circle.center) < 2 * circle.radius);
|
||||
return circles.some(circle => latlng.distanceTo(circle.center) < 2 * circle.radius);
|
||||
}
|
||||
|
||||
function getCircleFromLatlng(latlng) {
|
||||
return circles.find(circle => getDistanceFromLatLon(latlng, circle.center) < circle.radius);
|
||||
return circles.find(circle => latlng.distanceTo(circle.center) < circle.radius);
|
||||
}
|
||||
|
||||
function handleLeftClick(e) {
|
||||
if (isBaddlyPlaced(e.latlng)) return;
|
||||
addCircle(e.latlng, radius);
|
||||
if (!isBaddlyPlaced(e.latlng)) addCircle(e.latlng, radius);
|
||||
}
|
||||
|
||||
function handleRightClick(e) {
|
||||
|
||||
Reference in New Issue
Block a user