seismicV3
Makro Zonlama (Missenard)
Moderate Zonlama (Öncel & Wyss)
Mikro Zonlama (Ben-Zion)
// ============================================================= // BÖLÜM 2 – ZONLAMA FONKSİYONLARI + NORMALİZASYON + PARAMETRELER (TAM HALİ) // ============================================================= // ZONLAMA FİLTRESİ (zoneMode parametresiyle) function applyZoning(data, zoneMode) { let filtered = data; switch (zoneMode) { case 'missenard': filtered = data.filter(d => d.mag >= 2.5); break; case 'oncelwyss': filtered = data.filter(d => d.mag >= 2.5 && d.depth < 30); break; case 'aftershock': const cutoff = new Date(Date.now() - 24 * 60 * 60 * 1000); filtered = data.filter(d => d.time >= cutoff && d.mag >= 1.5); break; default: filtered = data; } return filtered; } // HEAT PARAMETRELERİ (ZONLAMA TİPİNE GÖRE) function getHeatParamsByZone(mode) { if (mode === 'missenard') return { radius: 40, blur: 30, max: 0.9 }; if (mode === 'oncelwyss') return { radius: 25, blur: 18, max: 0.8 }; if (mode === 'aftershock') return { radius: 15, blur: 10, max: 0.6 }; return { radius: 25, blur: 18, max: 0.8 }; } // NORMALİZASYON FAKTÖRÜ (T ve A) function getNormalizationFactor(d) { const tobsMode = document.getElementById('tobsMode')?.value || 'none'; const areaMode = document.getElementById('areaNorm')?.value || 'none'; let T = 1, A = 1; if (tobsMode === 'year') { const now = new Date(); const years = (now - d.time) / (1000 * 60 * 60 * 24 * 365.25); T = Math.max(0.1, years); } else if (tobsMode === 'day') { const now = new Date(); const days = (now - d.time) / (1000 * 60 * 60 * 24); T = Math.max(0.1, days); } if (areaMode === 'circle') A = Math.PI * Math.pow(50, 2); else if (areaMode === 'square') A = 100 * 100; return 1 / (T * A); } // B-DEĞERİ HESAPLAMA function computeBValue(mags) { if (mags.length < 2) return { b: 1.0 }; const Mc = Math.min(...mags); const meanM = mags.reduce((a, b) => a + b, 0) / mags.length; return { b: parseFloat((1 / Math.log(10) / (meanM - Mc + 0.0001)).toFixed(3)) }; } // TL (Threshold Level) HESAPLAMA function computeTL(mags) { return Math.min(...mags); } // ============================================================= // BÖLÜM 3 – ÜÇ HARİTA ÇİZİM + LEGEND + BUTON (TAM HALİ) // ============================================================= function renderMapForZone(zoneMode, mapId, legendId) { const mapEl = document.getElementById(mapId); if (!mapEl || !current.length) return; const displayData = applyZoning(current, zoneMode); const { radius, blur } = getHeatParamsByZone(zoneMode); const getBaseIntensity = (d) => { const mode = document.getElementById('mapMode').value; if (mode === 'bmap') return computeBValue(displayData.map(d => d.mag)).b; if (mode === 'tlmap') return Math.max(0.1, d.mag - computeTL(displayData.map(d => d.mag))); if (mode === 'depth') return Math.max(0.1, d.depth / 10); return Math.max(0.1, d.mag - 2.0); }; const heatPoints = displayData.map(d => { const base = getBaseIntensity(d); const norm = getNormalizationFactor(d); const scaled = base * norm * 100; return [d.lat, d.lon, Math.max(0.1, scaled)]; }); mapEl.innerHTML = ''; const map = L.map(mapId).setView([39, 35], 6); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap' }).addTo(map); L.heatLayer(heatPoints, { radius, blur, maxZoom: 10 }).addTo(map); if (heatPoints.length) { const bounds = L.latLngBounds(heatPoints.map(p => [p[0], p[1]])); map.fitBounds(bounds, { padding: [30, 30] }); } updateLegendForZone(zoneMode, legendId, displayData.length); } function updateLegendForZone(zoneMode, legendId, count) { const legendEl = document.getElementById(legendId); if (!legendEl) return; const tobs = document.getElementById('tobsMode').value; const area = document.getElementById('areaNorm').value; const tobsLabel = { none: 'TOBS Yok', year: 'Yıla Göre', day: 'Güne Göre' }; const areaLabel = { none: 'A Yok', circle: 'Daire (π·R²)', square: 'Kare (2R·2R)' }; const zoneLabel = { missenard: 'Makro (Missenard)', oncelwyss: 'Moderate (Öncel & Wyss)', aftershock: 'Mikro (Ben-Zion)' }; const thermalEffect = zoneMode === 'missenard' ? '≈ %33' : zoneMode === 'oncelwyss' ? '≈ %50' : zoneMode === 'aftershock' ? '≈ %100' : '-'; let html = `Zonlama: ${zoneLabel[zoneMode]}`; html += `Normalize: T=${tobsLabel[tobs]}, A=${areaLabel[area]}
`; html += `Termal Katkı: ${thermalEffect}
`; html += `Deprem: ${count} adet`; legendEl.innerHTML = html; } // ANA TETİKLEYİCİ function renderAllZones() { renderMapForZone('missenard', 'mapMacro', 'legendMacro'); renderMapForZone('oncelwyss', 'mapModerate', 'legendModerate'); renderMapForZone('aftershock', 'mapMicro', 'legendMicro'); updateResults('Üçlü Zonlama: Tamamlandı'); } // BUTON GÜNCELLE document.getElementById('generateMap').addEventListener('click', () => renderAllZones()); // T ve A DEĞİŞİMİ → YENİDEN ÇİZ document.getElementById('tobsMode').addEventListener('change', () => renderAllZones()); document.getElementById('areaNorm').addEventListener('change', () => renderAllZones()); document.getElementById('mapMode').addEventListener('change', () => renderAllZones());
Comments
Post a Comment