effective distanceScale

This commit is contained in:
Mészáros Gergely 2021-08-15 04:41:59 +02:00
parent 1b7fe659c1
commit 01cc1eec30
5 changed files with 23 additions and 12 deletions

View file

@ -3506,14 +3506,22 @@
<div id="submapOptionsDialog" style="display: none; max-width:300px;" class="dialog">
<p style="font-style: italic; color: red; font-weight:bold;">Original map will be destroyed! Don't forget to save your work!</p>
<p>Population rate (Units editor -> population) and map pixel size will
be automatically update according to the current scale factor. Options are interpreted as usual.</p>
<hl />
be automatically updated according to the current scale factor. If you'd like
to generate a new parent-map, <b>don't forget to reset them!</b> Options are interpreted as usual.</p>
<hr />
<div data-tip="All small cities of the parent map will be promoted to Capitals." >
<input id="submapPromoteTown" class="checkbox" type="checkbox">
<label for="submapPromoteTown" class="checkbox-label">Promote towns to cities.</label>
<input id="submapDepressRivers" class="checkbox" type="checkbox">
<label for="submapDepressRivers" class="checkbox-label">Errode riverbeds.</label>
<input id="submapPromoteTown" class="checkbox" type="checkbox">
<label for="submapPromoteTown" class="checkbox-label">Promote towns to cities.</label>
</div>
<div data-tip="Rivers on the parent map errode land (helps to get similar river network.)" >
<input id="submapDepressRivers" class="checkbox" type="checkbox">
<label for="submapDepressRivers" class="checkbox-label">Errode riverbeds.</label>
</div>
<div data-tip="Add lakes in depressions. (Can be very slow on big landmass!)" >
<input id="submapAddLakeInDepression" class="checkbox" type="checkbox">
<label for="submapAddLakeInDepression" class="checkbox-label">Add lakes in depressions.</label>
</div>
<hr/>
<button id="start" data-tip="Start submap resampling" class="options glow" onclick="generateSubmap()">Generate</button>
</div>

View file

@ -153,6 +153,7 @@ let mapCoordinates = {}; // map coordinates on globe
options.winds = [225, 45, 225, 315, 135, 315]; // default wind directions
let populationRate = +document.getElementById("populationRateInput").value;
let distanceScale = +document.getElementById("distanceScaleInput").value;
let urbanization = +document.getElementById("urbanizationInput").value;
applyStoredOptions();

View file

@ -31,14 +31,14 @@ window.Rivers = (function () {
TIME && console.timeEnd("generateRivers");
function drainWater() {
const MIN_FLUX_TO_FORM_RIVER = 30;
const MIN_FLUX_TO_FORM_RIVER = 10 * distanceScale;
const prec = grid.cells.prec;
const area = pack.cells.area;
const area = c => pack.cells.area[c] * distanceScale * distanceScale;
const land = cells.i.filter(i => h[i] >= 20).sort((a, b) => h[b] - h[a]);
const lakeOutCells = Lakes.setClimateData(h);
land.forEach(function (i) {
cells.fl[i] += prec[cells.g[i]] * area[i] / 100; // add flux from precipitation
cells.fl[i] += prec[cells.g[i]] * area(i) / 1000; // add flux from precipitation
// create lake outlet if lake is not in deep depression and flux > evaporation
const lakes = lakeOutCells[i] ? features.filter(feature => i === feature.outCell && feature.flux > feature.evaporation) : [];
@ -166,7 +166,7 @@ window.Rivers = (function () {
const mouth = riverCells[riverCells.length - 2];
const parent = riverParents[key] || 0;
const widthFactor = !parent || parent === riverId ? 1.2 : 1;
const widthFactor = (!parent || parent === riverId ? 3.6 : 3) / distanceScale;
const meanderedPoints = addMeandering(riverCells);
const discharge = cells.fl[mouth]; // m3 in second
const length = rn(getApproximateLength(meanderedPoints), 2);

View file

@ -33,8 +33,8 @@ const generateSubmap = debounce(async function () {
}
// fix scale
distanceScaleInput.value = distanceScaleOutput.value = distanceScaleOutput.value / scale;
populationRateInput.value = populationRateOutput.value = populationRateOutput.value / scale;
distanceScale = distanceScaleInput.value = distanceScaleOutput.value = distanceScaleOutput.value / scale;
populationRate = populationRateInput.value = populationRateOutput.value = populationRateOutput.value / scale;
customization = 0;
undraw();

View file

@ -55,6 +55,7 @@ function editUnits() {
}
function changeDistanceScale() {
distanceScale = +document.getElementById("distanceScaleInput").value;
drawScaleBar();
calculateFriendlyGridSize();
}
@ -95,6 +96,7 @@ function editUnits() {
function restoreDefaultUnits() {
// distanceScale
distanceScale = 3;
document.getElementById("distanceScaleOutput").value = 3;
document.getElementById("distanceScaleInput").value = 3;
unlock("distanceScale");