From 96b22d1fc036f65a06b2b55494a18a2d5f1d43f7 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 21 Aug 2026 02:49:41 +0300 Subject: [PATCH] fix(elevation): Restore smooth non-zero continuous terrain differentials --- apps/api/src/maps/maps.service.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/api/src/maps/maps.service.ts b/apps/api/src/maps/maps.service.ts index b1bf4ca..074c979 100644 --- a/apps/api/src/maps/maps.service.ts +++ b/apps/api/src/maps/maps.service.ts @@ -608,8 +608,8 @@ export class MapsService { } /** - * High-Precision Multi-Scale Topographic Elevation Model for Jordan - * Combines regional DEM baseline with realistic wadi systems, ridge crests, and urban hill models (Amman 7 hills, Zarqa Basin & North). + * High-Precision Topographic Elevation Model for Jordan + * Continuous multi-scale terrain incorporating valley relief, ridge crests, and natural drainage slopes. */ private estimateElevation(lat: number, lng: number): number { // 1. Regional Base Elevation Surface (Western Rift to Eastern Desert) @@ -631,17 +631,20 @@ export class MapsService { } // Central Urban Basin (East Amman, Zarqa, Rusaifa, Madaba, Irbid Plateau) else if (lng >= 35.88 && lng < 36.25) { - if (lat >= 32.4) { - baseElev = 580 + (lat - 32.4) * 80; // Irbid Plateau (580m - 620m) - } else if (lat >= 32.0 && lat < 32.25) { - // Zarqa & Sukhna River Basin (520m in river bed, 680m on surrounding hills) - const riverAxisLat = 32.06 + (lng - 36.05) * 0.7; // Zarqa river path - const distFromRiver = Math.abs(lat - riverAxisLat) * 111.32; // km from river - const localWadiRelief = Math.min(140, distFromRiver * 70); // 0m in wadi, +140m on hill crests - baseElev = 530 + localWadiRelief + (lng - 36.0) * 45; + if (lat >= 32.35) { + baseElev = 580 + (lat - 32.35) * 80; // Irbid Plateau + } else if (lat >= 32.0 && lat < 32.35) { + // Zarqa & Sukhna Basin Topography (Parabolic valley profile with natural drainage) + const riverAxisLat = 32.06 + (lng - 36.05) * 0.65; + const distFromRiverKm = Math.abs(lat - riverAxisLat) * 111.32; + // Parabolic rise from riverbed (530m) up to surrounding hills (660m) + const valleyRelief = 120 * (1 - Math.exp(-Math.pow(distFromRiverKm / 1.5, 2))); + const longitudinalSlope = (32.15 - lat) * 60; // Slopes downwards northwards + const localHillWave = Math.sin(lat * 80.0) * 18.0 + Math.cos(lng * 90.0) * 14.0; + baseElev = 540 + valleyRelief + longitudinalSlope + localHillWave; } else if (lat >= 31.85 && lat < 32.0) { // Amman 7 Hills & Valleys Topography - const localAmmanHill = Math.sin((lat - 31.95) * 180) * 70 + Math.cos((lng - 35.92) * 180) * 60; + const localAmmanHill = Math.sin((lat - 31.95) * 120) * 45 + Math.cos((lng - 35.92) * 120) * 40; baseElev = 840 - (lng - 35.90) * 350 + localAmmanHill; } else if (lat < 31.85 && lat >= 31.6) { baseElev = 740 + (lat - 31.6) * 100; // Airport / Madaba plains @@ -654,7 +657,7 @@ export class MapsService { baseElev = 640 + (lng - 36.25) * 20 - (lat - 32.0) * 30; } - return Math.round(baseElev); + return baseElev; } private haversineDistance(lat1: number, lon1: number, lat2: number, lon2: number): number {