refactor: lake name generator

This commit is contained in:
max 2022-07-23 20:10:44 +03:00
parent 4b874246e3
commit b2f16c4b8f
6 changed files with 25 additions and 27 deletions

View file

@ -1,9 +1,10 @@
// @ts-nocheckd
import * as d3 from "d3";
import {rn} from "utils/numberUtils";
import {getRealHeight} from "utils/unitUtils";
const {Names} = window;
export interface ILakeClimateData extends IPackFeatureLake {
flux: number;
temp: number;
@ -45,7 +46,7 @@ export const getClimateData = function (
return lakeData;
};
export const mergeLakeDataToFeatures = function (
export const mergeLakeData = function (
features: TPackFeatures,
lakeData: ILakeClimateData[],
rivers: Pick<IRiver, "i">[]
@ -101,3 +102,17 @@ function defineLakeGroup({
return "freshwater";
}
export function generateLakeNames(features: TPackFeatures, culture: UintArray) {
const updatedFeatures = features.map(feature => {
if (!feature) return 0;
if (feature.type !== "lake") return feature;
const landCell = feature.shoreline[0];
const cultureId = culture[landCell];
const name = Names.getCulture(cultureId) as string;
return {...feature, name};
});
return updatedFeatures as TPackFeatures;
}