border tweak
This commit is contained in:
parent
4f0df3f6c5
commit
71b58cf033
7 changed files with 514 additions and 68 deletions
37
mapOutput.js
37
mapOutput.js
|
|
@ -24,6 +24,28 @@ function municipalityNameFromRoot(root, center, fields, seed, ordinal = 0) {
|
|||
return `${value}${municipalitySuffixForCenter(center, fields, seed, ordinal)}`;
|
||||
}
|
||||
|
||||
|
||||
function assignMunicipalityPopulations(adminCenters, adminId, fields) {
|
||||
if (!adminCenters?.length || !adminId) return;
|
||||
const totals = new Float64Array(adminCenters.length);
|
||||
for (let i = 0; i < adminId.length; i++) {
|
||||
const id = adminId[i];
|
||||
if (id < 0 || id >= totals.length || fields.sea?.[i]) continue;
|
||||
const density = fields.populationDensity?.[i] || 0;
|
||||
const lu = fields.landuse?.[i] ?? 0;
|
||||
const plain = fields.plain?.[i] || 0;
|
||||
const agri = fields.agriculture?.[i] || 0;
|
||||
const builtWeight = lu === 3 ? 520 : lu === 2 ? 360 : lu === 4 || lu === 7 || lu === 8 ? 260 : lu === 5 || lu === 6 ? 160 : lu === 1 ? 82 : 22;
|
||||
const ruralFloor = lu === 1 ? 10 + agri * 18 + plain * 10 : 0;
|
||||
totals[id] += density * builtWeight + ruralFloor;
|
||||
}
|
||||
for (let id = 0; id < adminCenters.length; id++) {
|
||||
const raw = totals[id] || 0;
|
||||
const rounded = raw >= 10000 ? Math.round(raw / 1000) * 1000 : Math.round(raw / 100) * 100;
|
||||
adminCenters[id].municipalityPopulation = Math.max(0, rounded);
|
||||
}
|
||||
}
|
||||
|
||||
function buildPrefectureRegions(prefectureRegionId, sea, fields, seed, usedNames, nameDebug) {
|
||||
if (!prefectureRegionId) return [];
|
||||
const byId = new Map();
|
||||
|
|
@ -264,19 +286,24 @@ export function finishMapOutput({
|
|||
center.municipalityId = index;
|
||||
let candidate = center.canonicalSettlementName || municipalityNameFromRoot(center.municipalityRootName || center.generatedMunicipalityName || center.name, center, nameFields, seed, index);
|
||||
const generated = municipalityNameFromRoot(center.generatedMunicipalityName || center.name, center, nameFields, seed + 177, index);
|
||||
if (!center.canonicalSettlementName && usedAdminNames.has(candidate) && Array.from(generated).length >= 2 && !usedAdminNames.has(generated)) {
|
||||
if (usedAdminNames.has(candidate) && Array.from(generated).length >= 2 && !usedAdminNames.has(generated)) {
|
||||
candidate = generated;
|
||||
}
|
||||
if (!center.canonicalSettlementName && usedAdminNames.has(candidate)) {
|
||||
if (usedAdminNames.has(candidate)) {
|
||||
const suffix = municipalitySuffixForCenter(center, nameFields, seed + 313, index);
|
||||
const base = String(center.generatedMunicipalityName || center.municipalityRootName || center.name || `自治${index + 1}`).replace(/[市町村区]$/u, "");
|
||||
candidate = `${base}${index + 1}${suffix}`;
|
||||
const root = String(center.municipalityRootName || center.canonicalSettlementName || center.generatedMunicipalityName || center.name || `自治${index + 1}`).replace(/[市町村区]$/u, "");
|
||||
const directions = ["東", "西", "南", "北", "上", "下", "中"];
|
||||
for (let attempt = 0; attempt < directions.length + 3 && usedAdminNames.has(candidate); attempt++) {
|
||||
const prefix = directions[attempt % directions.length];
|
||||
candidate = attempt < directions.length ? `${prefix}${root}${suffix}` : `${root}${index + 1}${suffix}`;
|
||||
}
|
||||
}
|
||||
center.name = candidate;
|
||||
center.labelName = candidate;
|
||||
center.municipalityName = candidate;
|
||||
usedAdminNames.add(center.name);
|
||||
}
|
||||
assignMunicipalityPopulations(adminCenters, adminId, nameFields);
|
||||
nameDebug.maxDerivedPerBase = 0;
|
||||
const prefectureRegions = buildPrefectureRegions(prefectureRegionId, sea, nameFields, seed, usedNames, nameDebug);
|
||||
const regionalPrefectureBorders = adminRegionalPrefectureBorders || [];
|
||||
|
|
@ -311,7 +338,7 @@ export function finishMapOutput({
|
|||
seaLevel,
|
||||
prefectureMask,
|
||||
humanRegionMask,
|
||||
prefectureBorder,
|
||||
prefectureBorder: regionalPrefectureBorders.length ? regionalPrefectureBorders : prefectureBorder,
|
||||
prefectureRegionId,
|
||||
municipalityToPrefectureId,
|
||||
prefectureRegions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue