-
Height scale:
-
-
-
Curve:
-
-
+
+
-
diff --git a/modules/ui/elevation-profile.js b/modules/ui/elevation-profile.js
index 9e090a76..209b6ba8 100644
--- a/modules/ui/elevation-profile.js
+++ b/modules/ui/elevation-profile.js
@@ -22,15 +22,12 @@ function showEPForRiver(node) {
showElevationProfile(points, riverLen, true);
}
-function closeElevationProfile() {
- modules.elevation = false;
-}
-
function showElevationProfile(data, routeLen, isRiver) {
// data is an array of cell indexes, routeLen is the distance (in actual metres/feet), isRiver should be true for rivers, false otherwise
document.getElementById("epScaleRange").addEventListener("change", draw);
document.getElementById("epCurve").addEventListener("change", draw);
+ document.getElementById("epSave").addEventListener("click", downloadCSV);
$("#elevationProfile").dialog({
title: "Elevation profile", resizable: false, width: window.width,
@@ -48,14 +45,17 @@ function showElevationProfile(data, routeLen, isRiver) {
}
}
- const chartWidth = window.innerWidth-280;
+ const chartWidth = window.innerWidth-180;
const chartHeight = 300; // height of our land/sea profile, excluding the biomes data below
- const xOffset = 160;
- const yOffset = 70; // this is our drawing starting point from top-left (y = 0) of SVG
+ const xOffset = 80;
+ const yOffset = 20; // this is our drawing starting point from top-left (y = 0) of SVG
const biomesHeight = 40;
+ let lastBurgIndex = 0;
+ let lastBurgCell = 0;
+ let burgCount = 0;
let chartData = {biome:[], burg:[], cell:[], height:[], mi:1000000, ma:0, mih: 100, mah: 0, points:[] }
for (let i=0, prevB=0, prevH=-1; i= chartData.mih; k--) {
- let perc = 1 - (k - chartData.mih) / (chartData.mah - chartData.mih);
- landdef.append("stop").attr("offset", perc*100 + "%").attr("style", "stop-color:" + getColor(k, colors) + ";stop-opacity:1");
+
+ if (chartData.mah == chartData.mih) {
+ landdef.append("stop").attr("offset", "0%").attr("style", "stop-color:" + getColor(chartData.mih, colors) + ";stop-opacity:1");
+ landdef.append("stop").attr("offset", "100%").attr("style", "stop-color:" + getColor(chartData.mah, colors) + ";stop-opacity:1");
+ } else {
+ for (let k=chartData.mah; k >= chartData.mih; k--) {
+ let perc = 1 - (k - chartData.mih) / (chartData.mah - chartData.mih);
+ landdef.append("stop").attr("offset", perc*100 + "%").attr("style", "stop-color:" + getColor(k, colors) + ";stop-opacity:1");
+ }
}
// land
@@ -145,7 +203,7 @@ function showElevationProfile(data, routeLen, isRiver) {
const x = chartData.points[k][0];
const y = yOffset + chartHeight;
const c = biomesData.color[chartData.biome[k]];
- const dataTip = biomesData.name[chartData.biome[k]]+" (" + chartData.height[k] + " " + hu + ")";
+ const dataTip = biomesData.name[chartData.biome[k]]+" (" + chartData.height[k] + " " + hu + ", cell " + chartData.cell[k] + ")";
g.append("rect").attr("stroke", c).attr("fill", c).attr("x", x).attr("y", y).attr("width", xscale(1)).attr("height", 15).attr("data-tip", dataTip);
}
@@ -191,12 +249,17 @@ function showElevationProfile(data, routeLen, isRiver) {
g = chart.append("g").attr("id", "epburglabels");
var y1 = 0;
var add = 15;
+
+ let xwidth = chartData.points[1][0] - chartData.points[0][0];
for (let k=0; k 0) {
let b = chartData.burg[k];
- var x1 = chartData.points[k][0];
+ let x1 = chartData.points[k][0]; // left side of graph by default
+ if (k > 0) x1 += xwidth/2; // center it if not first
+ if (k == chartData.points.length-1)
+ x1 = chartWidth + xOffset; // right part of graph
y1+=add;
if (y1 >= yOffset) { y1 = add; }
var d1 = 0;
@@ -210,5 +273,15 @@ function showElevationProfile(data, routeLen, isRiver) {
}
}
}
+
+ function closeElevationProfile() {
+ document.getElementById("epScaleRange").removeEventListener("change", draw);
+ document.getElementById("epCurve").removeEventListener("change", draw);
+ document.getElementById("epSave").removeEventListener("click", downloadCSV);
+
+ document.getElementById("elevationGraph").innerHTML = "";
+
+ modules.elevation = false;
+ }
}