mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
refactor getCoordinates functions
This commit is contained in:
parent
165d8e48be
commit
762ec2c841
4 changed files with 19 additions and 13 deletions
|
|
@ -137,10 +137,16 @@ function generateDate(from = 100, to = 1000) {
|
|||
return new Date(rand(from, to), rand(12), rand(31)).toLocaleDateString("en", {year: "numeric", month: "long", day: "numeric"});
|
||||
}
|
||||
|
||||
function getQGIScoordinates(x, y) {
|
||||
const cx = mapCoordinates.lonW + (x / graphWidth) * mapCoordinates.lonT;
|
||||
const cy = mapCoordinates.latN - (y / graphHeight) * mapCoordinates.latT; // this is inverted in QGIS otherwise
|
||||
return [cx, cy];
|
||||
function getLongitude(x, decimals = 2) {
|
||||
return rn(mapCoordinates.lonW + (x / graphWidth) * mapCoordinates.lonT, decimals);
|
||||
}
|
||||
|
||||
function getLatitude(y, decimals = 2) {
|
||||
return rn(mapCoordinates.latN - (y / graphHeight) * mapCoordinates.latT, decimals);
|
||||
}
|
||||
|
||||
function getCoordinates(x, y, decimals = 2) {
|
||||
return [getLongitude(x, decimals), getLatitude(y, decimals)];
|
||||
}
|
||||
|
||||
// prompt replacer (prompt does not work in Electron)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue