añadido proporcionalidad en alturas y distancias de las elevacines con respecto el punto anterior
This commit is contained in:
@@ -1084,7 +1084,7 @@ public partial class PlanificadorRutas : ComponentBase
|
|||||||
if (string.IsNullOrWhiteSpace(_callejeroOrigenResumenRuta))
|
if (string.IsNullOrWhiteSpace(_callejeroOrigenResumenRuta))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
return $"O callejero: {_callejeroOrigenResumenRuta}";
|
return $"O: {_callejeroOrigenResumenRuta}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatearResumenCallejeroDestino()
|
private string FormatearResumenCallejeroDestino()
|
||||||
@@ -1092,7 +1092,7 @@ public partial class PlanificadorRutas : ComponentBase
|
|||||||
if (string.IsNullOrWhiteSpace(_callejeroDestinoResumenRuta))
|
if (string.IsNullOrWhiteSpace(_callejeroDestinoResumenRuta))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
return $"D callejero: {_callejeroDestinoResumenRuta}";
|
return $"D: {_callejeroDestinoResumenRuta}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string FormatearLugarCallejeroResumen(LugarGeocodificadoCercano? cercano)
|
private static string FormatearLugarCallejeroResumen(LugarGeocodificadoCercano? cercano)
|
||||||
|
|||||||
@@ -1181,7 +1181,7 @@ public partial class PlanificadorRutas : ComponentBase
|
|||||||
private bool _elevPopupMinimizado = false;
|
private bool _elevPopupMinimizado = false;
|
||||||
|
|
||||||
|
|
||||||
private const string _versionApp = "(v-20260714a)";
|
private const string _versionApp = "(v-20260715a)";
|
||||||
|
|
||||||
|
|
||||||
private double? _paradaElevG;
|
private double? _paradaElevG;
|
||||||
|
|||||||
@@ -216,7 +216,8 @@ public partial class PlanificadorRutas : ComponentBase
|
|||||||
category = categoria,
|
category = categoria,
|
||||||
slope = pendiente,
|
slope = pendiente,
|
||||||
distance = distancia,
|
distance = distancia,
|
||||||
elevation = elevActual,
|
elevationStart = elevAnterior,
|
||||||
|
elevationEnd = elevActual,
|
||||||
label = pendiente is null
|
label = pendiente is null
|
||||||
? "-"
|
? "-"
|
||||||
: pendiente.Value.ToString("+0.0;-0.0;0.0", CultureInfo.InvariantCulture) + " %"
|
: pendiente.Value.ToString("+0.0;-0.0;0.0", CultureInfo.InvariantCulture) + " %"
|
||||||
|
|||||||
@@ -161,6 +161,59 @@ window.rt.drawRoute = function (id, coords, options) {
|
|||||||
if (elevationSegments.length > 0 && coords && coords.length >= 2) {
|
if (elevationSegments.length > 0 && coords && coords.length >= 2) {
|
||||||
const group = window.L.layerGroup();
|
const group = window.L.layerGroup();
|
||||||
|
|
||||||
|
const progressAlongSegment = function (segmentCoords, latlng) {
|
||||||
|
if (!latlng || !Array.isArray(segmentCoords) || segmentCoords.length < 2) return 0.5;
|
||||||
|
|
||||||
|
const start = segmentCoords[0];
|
||||||
|
const end = segmentCoords[segmentCoords.length - 1];
|
||||||
|
const startLat = Number(start && start[0]);
|
||||||
|
const startLon = Number(start && start[1]);
|
||||||
|
const endLat = Number(end && end[0]);
|
||||||
|
const endLon = Number(end && end[1]);
|
||||||
|
|
||||||
|
if (![startLat, startLon, endLat, endLon, latlng.lat, latlng.lng].every(Number.isFinite))
|
||||||
|
return 0.5;
|
||||||
|
|
||||||
|
const lonScale = Math.cos(((startLat + endLat) / 2) * Math.PI / 180);
|
||||||
|
const dx = (endLon - startLon) * lonScale;
|
||||||
|
const dy = endLat - startLat;
|
||||||
|
const px = (latlng.lng - startLon) * lonScale;
|
||||||
|
const py = latlng.lat - startLat;
|
||||||
|
const lengthSquared = dx * dx + dy * dy;
|
||||||
|
|
||||||
|
if (lengthSquared <= Number.EPSILON) return 0.5;
|
||||||
|
|
||||||
|
const progress = (px * dx + py * dy) / lengthSquared;
|
||||||
|
return Math.max(0, Math.min(1, progress));
|
||||||
|
};
|
||||||
|
|
||||||
|
const elevationTooltip = function (segment, progress) {
|
||||||
|
const t = Number.isFinite(progress) ? Math.max(0, Math.min(1, progress)) : 0.5;
|
||||||
|
const slope = segment && typeof segment.slope === "number" ? segment.slope : null;
|
||||||
|
const distance = segment && typeof segment.distance === "number" ? segment.distance : null;
|
||||||
|
const elevationStart = segment && typeof segment.elevationStart === "number" ? segment.elevationStart : null;
|
||||||
|
const elevationEnd = segment && typeof segment.elevationEnd === "number" ? segment.elevationEnd : null;
|
||||||
|
const slopeText = slope !== null && Number.isFinite(slope)
|
||||||
|
? ((slope > 0 ? "+" : "") + slope.toFixed(1) + " %")
|
||||||
|
: (segment && segment.label ? String(segment.label) : "-");
|
||||||
|
const distanceText = distance !== null && Number.isFinite(distance)
|
||||||
|
? (distance * t).toFixed(2) + " m"
|
||||||
|
: "-";
|
||||||
|
const estimatedElevation = elevationStart !== null && Number.isFinite(elevationStart) &&
|
||||||
|
elevationEnd !== null && Number.isFinite(elevationEnd)
|
||||||
|
? elevationStart + (elevationEnd - elevationStart) * t
|
||||||
|
: null;
|
||||||
|
const elevationText = estimatedElevation !== null
|
||||||
|
? estimatedElevation.toFixed(2) + " m"
|
||||||
|
: "-";
|
||||||
|
|
||||||
|
return [
|
||||||
|
"Pendiente: " + slopeText,
|
||||||
|
"Dist. anterior: " + distanceText,
|
||||||
|
"Altura: " + elevationText
|
||||||
|
].join("<br>");
|
||||||
|
};
|
||||||
|
|
||||||
elevationSegments.forEach(function (segment) {
|
elevationSegments.forEach(function (segment) {
|
||||||
const segmentCoords = segment && segment.coords;
|
const segmentCoords = segment && segment.coords;
|
||||||
if (!Array.isArray(segmentCoords) || segmentCoords.length < 2) return;
|
if (!Array.isArray(segmentCoords) || segmentCoords.length < 2) return;
|
||||||
@@ -177,23 +230,7 @@ window.rt.drawRoute = function (id, coords, options) {
|
|||||||
if (dashArray) segmentOpts.dashArray = dashArray;
|
if (dashArray) segmentOpts.dashArray = dashArray;
|
||||||
|
|
||||||
const segmentLine = buildLine(segmentCoords, segmentOpts);
|
const segmentLine = buildLine(segmentCoords, segmentOpts);
|
||||||
const slope = segment && typeof segment.slope === "number" ? segment.slope : null;
|
const label = elevationTooltip(segment, 0.5);
|
||||||
const distance = segment && typeof segment.distance === "number" ? segment.distance : null;
|
|
||||||
const elevation = segment && typeof segment.elevation === "number" ? segment.elevation : null;
|
|
||||||
const slopeText = slope !== null && Number.isFinite(slope)
|
|
||||||
? ((slope > 0 ? "+" : "") + slope.toFixed(1) + " %")
|
|
||||||
: (segment && segment.label ? String(segment.label) : "-");
|
|
||||||
const distanceText = distance !== null && Number.isFinite(distance)
|
|
||||||
? distance.toFixed(2) + " m"
|
|
||||||
: "-";
|
|
||||||
const elevationText = elevation !== null && Number.isFinite(elevation)
|
|
||||||
? elevation.toFixed(2) + " m"
|
|
||||||
: "-";
|
|
||||||
const label = [
|
|
||||||
"Pendiente: " + slopeText,
|
|
||||||
"Dist. anterior: " + distanceText,
|
|
||||||
"Altura: " + elevationText
|
|
||||||
].join("<br>");
|
|
||||||
|
|
||||||
if (label) {
|
if (label) {
|
||||||
segmentLine.bindTooltip(label, {
|
segmentLine.bindTooltip(label, {
|
||||||
@@ -202,6 +239,12 @@ window.rt.drawRoute = function (id, coords, options) {
|
|||||||
opacity: 0.92,
|
opacity: 0.92,
|
||||||
className: "rt-elev-tooltip"
|
className: "rt-elev-tooltip"
|
||||||
});
|
});
|
||||||
|
const updateTooltipAtCursor = function (e) {
|
||||||
|
const progress = progressAlongSegment(segmentCoords, e && e.latlng);
|
||||||
|
segmentLine.setTooltipContent(elevationTooltip(segment, progress));
|
||||||
|
};
|
||||||
|
segmentLine.on("mouseover", updateTooltipAtCursor);
|
||||||
|
segmentLine.on("mousemove", updateTooltipAtCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
segmentLine.addTo(group);
|
segmentLine.addTo(group);
|
||||||
|
|||||||
Reference in New Issue
Block a user