Grid on windy map?
-
Hello, I'm developing a tool to display a csv routing in a windy map. I'm getting points, places with precise geographical positions but it's on a grid, the links of these points too. How can I solve this problem? I speak french. I put my code and a screen.
I should have 1 point every 10 minutes, i.e. 1975 points with csv, but I only have about hundred.
Discord : joko___
document.getElementById('csvFile').addEventListener('change', handleFileSelect, false); let map; let result = []; function handleFileSelect(event) { const file = event.target.files[0]; if (!file) { return; } const reader = new FileReader(); reader.onload = function (e) { const contents = e.target.result; parseCSV(contents); }; reader.readAsText(file); } function parseCSV(data) { const lines = data.split("\n"); const headers = lines[0].split(";"); console.log("Entêtes : ", headers); for (let i = 1; i < lines.length; i++) { const cells = lines[i].split(";"); if (cells.length < headers.length) { console.log("Ligne ignorée (incomplète) : ", lines[i]); continue; } const entry = { DateHeureUTC: cells[0], Latitude: parseFloat(cells[3]), Longitude: parseFloat(cells[4]) }; if (isNaN(entry.Latitude) || isNaN(entry.Longitude)) { console.log(`Coordonnées invalides pour le point: ${cells}`); continue; } console.log(`Point valide : ${entry.DateHeureUTC} - Latitude: ${entry.Latitude} - Longitude: ${entry.Longitude}`); result.push(entry); } console.log("Les points : ", result); if (map) { addPointsAndLinesToMap(result); } else { console.log("La carte n'est pas encore initialisée."); } } const options = { key: 'c4kP9ZCKUUlyOwoJnq5PYxr7OanKYCiY', verbose: true, lat: 50.4, lon: 14.3, zoom: 5, }; function addPointsAndLinesToMap(points) { if (!points || points.length === 0) { console.log("Aucun point à afficher sur la carte."); return; } const latLngs = []; points.forEach((point, index) => { const { Latitude, Longitude, DateHeureUTC } = point; if (isNaN(Latitude) || isNaN(Longitude)) { console.log(`Coordonnées invalides pour le point: ${point}`); return; } L.circleMarker([Latitude, Longitude], { color: 'blue', radius: 5, fillColor: 'blue', fillOpacity: 0.6 }).addTo(map).bindTooltip(DateHeureUTC); latLngs.push([Latitude, Longitude]); if (index > 0) { const prevPoint = points[index - 1]; const prevTime = new Date(prevPoint.DateHeureUTC).getTime(); const currTime = new Date(DateHeureUTC).getTime(); if (currTime - prevTime >= 600000) { L.polyline([latLngs[latLngs.length - 2], [Latitude, Longitude]], { color: 'red', weight: 2, opacity: 0.7 }).addTo(map); } } }); if (latLngs.length > 1) { L.polyline(latLngs, { color: 'green', weight: 2, opacity: 0.7 }).addTo(map); } } windyInit(options, windyAPI => { map = windyAPI.map; console.log("Carte Windy initialisée"); if (result.length > 0) { addPointsAndLinesToMap(result); } });
Windyty, S.E. - all rights reserved. Powered by excellent NodeBB
NodeBB & contributors, OSM & contributors, HERE maps