@@ 85,7 85,10 @@ public class CityDB {
return populationByYear.get(year);
}
else {
- return getPopFigureNearestYear(year, BEFORE).getPopulation();
+ AnnualPopFigure before = getPopFigureNearestYear(year, BEFORE);
+ AnnualPopFigure after = getPopFigureNearestYear(year, AFTER);
+ double pop = Interpolater.Interpolate(year, before.getYear(), after.getYear(), before.getPopulation(), after.getPopulation());
+ return (int)pop;
}
}
@@ 209,7 212,7 @@ public class CityDB {
try {
CurrencyFigure usDosh = nationalGNPInYear.convertTo("USD");
Double regionalWealthComparedToNational = this.region.getRegionalWealthComparedToNational(year);
- System.out.println(" " + this.region.getName() + " wealth relative to " + this.country.getName() + " = " + regionalWealthComparedToNational);
+// System.out.println(" " + this.region.getName() + " wealth relative to " + this.country.getName() + " = " + regionalWealthComparedToNational);
return (int)(usDosh.getAmount() * regionalWealthComparedToNational);
}
catch(CurrencyConversionException ex) {
@@ 228,7 231,7 @@ public class CityDB {
CurrencyFigure endInUSD = nationalGDPInEndYear.convertTo("USD");
double percentagePopGrowth = endInUSD.getAmount()/startInUSD.getAmount();
double annualizedRate = Math.pow(percentagePopGrowth, 1.0/(endYear - startYear));
- System.out.println(" The annualized growth rate in " + this.getCountry().getName() + " is " + percentFormat.format((annualizedRate * 100) - 100) + "%");
+// System.out.println(" The annualized growth rate in " + this.getCountry().getName() + " is " + percentFormat.format((annualizedRate * 100) - 100) + "%");
return annualizedRate;
}
catch(CurrencyConversionException ex) {
@@ 279,6 282,19 @@ public class CityDB {
return Interpolater.CalculateAnnualizedChange(year, nextYear, firstRate, secondRate);
}
+ /**
+ * Formula: 50% the percentage of people in the province who are in cities.
+ * This half is the raw percentage multiplied by 1/3 (capped at 100%).
+ * 50% the size of the city, where every 5000 people gives 1 point.
+ * E.g. a city of 50,000 in a province where 50% of the people in the region
+ * are in cities will get a score of:
+ * - 66.6 from the percentage in cities in the region
+ * - 10 from the size of the city
+ * = 38.3 overall
+ * Another city in the same region with 500,000 people would score (66.6+100)/2 = 88.3
+ * @param year
+ * @return The urbanization level, normalized to a range of 0 to 1
+ */
private double getUrbanizationLevel(int year) {
int regionPop = this.region.getPopulationInYear(year);
double regionalUrbanPop = 0; //for division purposes
@@ 288,9 304,14 @@ public class CityDB {
}
//Scale: 0 = no urbanization. 1 = 75% or higher urbanization
double rawUrbanizationValue = regionalUrbanPop/regionPop;
- double scaledValue = rawUrbanizationValue * (4/3);
- scaledValue = Math.min(scaledValue, 1.0);
- return scaledValue;
+ double scaledRegionalValue = rawUrbanizationValue * (4/3);
+ scaledRegionalValue = Math.min(scaledRegionalValue, 1.0);
+ //City size value
+ int citySize = this.getBaseUrbanPopulation(year);
+ double citySizeScore = citySize/5000.0;
+ citySizeScore = citySizeScore / 100.0;
+
+ return Math.min((scaledRegionalValue + citySizeScore)/2, 1.0);
}
/**
@@ 99,6 99,7 @@ public class City {
region = 6;
break;
}
+ region = 2; //The car popularities are not moddable per-region; see #89 in the FBS. Thus we must stick with Europe
this.rEGION = String.valueOf(region);
this.bUYRATE = "1";
}