mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v1.22.04
This commit is contained in:
parent
41643ee5ac
commit
e21aed5188
3 changed files with 30 additions and 5 deletions
|
|
@ -3221,8 +3221,9 @@
|
|||
</div>
|
||||
|
||||
<div id="cellInfo" style="display: none" class="dialog stable">
|
||||
<p><b>Cell:</b> <span id="infoCell">0</span></p>
|
||||
<p><b>Coord:</b> <span id="infoX">0</span>/<span id="infoY">0</span></p>
|
||||
<p><b>Cell:</b> <span id="infoCell"></span> <b>X:</b> <span id="infoX"></span> <b>Y:</b> <span id="infoY"></span></p>
|
||||
<p><b>Latitude:</b> <span id="infoLat"></span></p>
|
||||
<p><b>Longitude:</b> <span id="infoLon"></span></p>
|
||||
<p><b>Area:</b> <span id="infoArea">0</span></p>
|
||||
<p><b>Type:</b> <span id="infoFeature">n/a</span></p>
|
||||
<p><b>Precipitation:</b> <span id="infoPrec">0</span></p>
|
||||
|
|
|
|||
|
|
@ -128,8 +128,11 @@ function getRiverName(id) {
|
|||
// get cell info on mouse move
|
||||
function updateCellInfo(point, i, g) {
|
||||
const cells = pack.cells;
|
||||
infoX.innerHTML = rn(point[0]);
|
||||
infoY.innerHTML = rn(point[1]);
|
||||
const x = infoX.innerHTML = rn(point[0]);
|
||||
const y = infoY.innerHTML = rn(point[1]);
|
||||
infoLat.innerHTML = toDMS(mapCoordinates.latN - (y / graphHeight) * mapCoordinates.latT, "lat");
|
||||
infoLon.innerHTML = toDMS(mapCoordinates.lonW + (x / graphWidth) * mapCoordinates.lonT, "lon");
|
||||
|
||||
infoCell.innerHTML = i;
|
||||
const unit = areaUnit.value === "square" ? " " + distanceUnitInput.value + "²" : " " + areaUnit.value;
|
||||
infoArea.innerHTML = cells.area[i] ? si(cells.area[i] * distanceScaleInput.value ** 2) + unit : "n/a";
|
||||
|
|
@ -149,6 +152,16 @@ function updateCellInfo(point, i, g) {
|
|||
infoBiome.innerHTML = biomesData.name[cells.biome[i]];
|
||||
}
|
||||
|
||||
// convert coordinate to DMS format
|
||||
function toDMS(coord, c) {
|
||||
const degrees = Math.floor(Math.abs(coord));
|
||||
const minutesNotTruncated = (Math.abs(coord) - degrees) * 60;
|
||||
const minutes = Math.floor(minutesNotTruncated);
|
||||
const seconds = Math.floor((minutesNotTruncated - minutes) * 60);
|
||||
const cardinal = c === "lat" ? coord >= 0 ? "N" : "S" : coord >= 0 ? "E" : "W";
|
||||
return degrees + "° " + minutes + "′ " + seconds + "″ " + cardinal;
|
||||
}
|
||||
|
||||
// get user-friendly (real-world) height value from map data
|
||||
function getFriendlyHeight(p) {
|
||||
const packH = pack.cells.h[findCell(p[0], p[1])];
|
||||
|
|
|
|||
|
|
@ -307,9 +307,20 @@ function editHeightmap() {
|
|||
pack.cells.religion[i] = religion[g];
|
||||
}
|
||||
|
||||
// find closest land cell to burg
|
||||
const findBurgCell = function(x, y) {
|
||||
let i = findCell(x, y);
|
||||
if (pack.cells.h[i] >= 20) return i;
|
||||
const dist = pack.cells.c[i].map(c =>
|
||||
pack.cells.h[c] < 20 ? Infinity : (pack.cells.p[c][0] - x) ** 2 + (pack.cells.p[c][1] - y) ** 2
|
||||
);
|
||||
return pack.cells.c[i][d3.scan(dist)];
|
||||
}
|
||||
|
||||
// find best cell for burgs
|
||||
for (const b of pack.burgs) {
|
||||
if (!b.i || b.removed) continue;
|
||||
b.cell = findCell(b.x, b.y);
|
||||
b.cell = findBurgCell(b.x, b.y);
|
||||
b.feature = pack.cells.f[b.cell];
|
||||
pack.cells.burg[b.cell] = b.i;
|
||||
if (!b.capital && pack.cells.h[b.cell] < 20) removeBurg(b.i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue