M src/main/java/DBObjects/CalculatedObjects/CurrencyFigure.java +3 -0
@@ 34,6 34,9 @@ public class CurrencyFigure {
}
public CurrencyFigure convertTo(String resultCurrency) throws CurrencyConversionException {
+ if (currency.equals(resultCurrency)) {
+ return this;
+ }
ExchangeRates rates = ExchangeRates.getExchangeOptions(new ExchangeRateKey(currency, year));
if (rates == null) {
rates = ExchangeRates.getInterpolatedExchangeOptions(new ExchangeRateKey(currency, year));
M src/main/java/com/ajtjp/gearCity/CityInfoFile/City.java +5 -1
@@ 78,7 78,8 @@ public class City {
this.cORDS = new CORDS(city.getLongitude() - 0.2, city.getLatitude() - 0.3);
}
else {
- this.cORDS = new CORDS(city.getLongitude() - 0.1, city.getLatitude() - 0.2);
+ //Should be map specific, this doesn't apply for all maps
+ this.cORDS = new CORDS(city.getLongitude(), city.getLatitude());
}
int region = 1;
switch (city.getCountry().getDistrict()) {
@@ 108,6 109,9 @@ public class City {
public void setFlag(String countryName, int year) {
switch (countryName) {
+ case "United States":
+ this.fLAG = new FLAG("UnitedStates.dds");
+ break;
case "United Kingdom":
this.fLAG = new FLAG("UK.dds");
break;
M src/main/java/com/ajtjp/gearCity/DBReader.java +1 -1
@@ 170,7 170,7 @@ public class DBReader {
List<UrbanPopulationDB> demographics = new ArrayList<>();
try {
PreparedStatement stmt = conn.prepareStatement(
- "SELECT City, Year, Population from UrbanPopulation"
+ "SELECT City, Year, Population from CityPopulation"
);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
M src/main/java/com/ajtjp/gearCity/Main.java +28 -20
@@ 69,6 69,9 @@ public class Main {
private static DecimalFormat percentFormat = new DecimalFormat("0.00");
+ final static String sqliteFile = "C:/Development/Gear City/North America/NorthAmerica.sqlite";
+ final static String modPath = "D:\\Gear City Mods\\Great Lakes\\";
+
public static void main(String[] args) throws Exception {
// testXMLExport();
Logger.getRootLogger().setLevel(Level.INFO);
@@ 81,7 84,7 @@ public class Main {
citiesXML = ImportCitiesFromXMLFile(citiesXML, citiesAlreadyExisting);
Main.nextXMLID = citiesXML.getCityList().size() + 1;
- DBReader dbReader = new DBReader("D:/Gear City Mods/CityInfo.sqlite");
+ DBReader dbReader = new DBReader(sqliteFile);
List<CountryDB> countries = dbReader.readCountryInfo();
List<RegionDB> regions = dbReader.readRegionInfo();
List<CityDB> cities = dbReader.readCityInfo();
@@ 92,20 95,23 @@ public class Main {
ConflictChange.read(dbReader.getConn());
//Test our currency conversion
- CurrencyFigure oneThousandNorwegianKroner = new CurrencyFigure(1900, 1000, "NOK");
- //Easy test: Convert to British pounds
- CurrencyFigure britishPounds = oneThousandNorwegianKroner.convertTo("GBP");
- System.out.println("1000 NOK is worth " + britishPounds + " pounds sterling in 1900");
- //A bit tougher, needs a hop: Convert to U.S. dollars
- CurrencyFigure americanDollars = oneThousandNorwegianKroner.convertTo("USD");
- System.out.println("1000 NOK is worth " + americanDollars + " U.S. in 1900");
- //BEF intermediary. Must go BEF -> NOK -> GBP
- CurrencyFigure oneThousandBelgianFrancs = new CurrencyFigure(1900, 1000, "BEF");
- CurrencyFigure francsInPounds = oneThousandBelgianFrancs.convertTo("GBP");
- System.out.println("1000 BEF is worth " + francsInPounds + " U.S. dollars in 1900");
- //Toughest one: Belgian Francs. Must go BEF -> NOK -> GBP -> USD
- CurrencyFigure francsInDollars = oneThousandBelgianFrancs.convertTo("USD");
- System.out.println("1000 BEF is worth " + francsInDollars + " U.S. dollars in 1900");
+ boolean testCurrencyConversion = false;
+ if (testCurrencyConversion) {
+ CurrencyFigure oneThousandNorwegianKroner = new CurrencyFigure(1900, 1000, "NOK");
+ //Easy test: Convert to British pounds
+ CurrencyFigure britishPounds = oneThousandNorwegianKroner.convertTo("GBP");
+ System.out.println("1000 NOK is worth " + britishPounds + " pounds sterling in 1900");
+ //A bit tougher, needs a hop: Convert to U.S. dollars
+ CurrencyFigure americanDollars = oneThousandNorwegianKroner.convertTo("USD");
+ System.out.println("1000 NOK is worth " + americanDollars + " U.S. in 1900");
+ //BEF intermediary. Must go BEF -> NOK -> GBP
+ CurrencyFigure oneThousandBelgianFrancs = new CurrencyFigure(1900, 1000, "BEF");
+ CurrencyFigure francsInPounds = oneThousandBelgianFrancs.convertTo("GBP");
+ System.out.println("1000 BEF is worth " + francsInPounds + " U.S. dollars in 1900");
+ //Toughest one: Belgian Francs. Must go BEF -> NOK -> GBP -> USD
+ CurrencyFigure francsInDollars = oneThousandBelgianFrancs.convertTo("USD");
+ System.out.println("1000 BEF is worth " + francsInDollars + " U.S. dollars in 1900");
+ }
PrintDBDiagnostics(countries, regions, cities, regionalDemographics, urbanPopulation);
@@ 158,15 164,17 @@ cityDBLoop: for (CityDB city : cities) {
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(document);
- ExportToCityFile("D:\\Gear City Mods\\Europe Expanded II\\Maps\\Europe Expanded II\\scripts\\City" + year + ".xml", transformer, source);
- ExportToCityFile("D:\\Gear City Mods\\Europe Expanded II\\Maps\\Europe Expanded II\\scripts\\City2020.xml", transformer, source);
+ ExportToCityFile(modPath + "Maps\\Great Lakes\\scripts\\City" + year + ".xml", transformer, source);
+ ExportToCityFile(modPath + "Maps\\Great Lakes\\scripts\\City2020.xml", transformer, source);
}
//Update TurnEvents.xml
- updateTurnEvents(cities);
+ if (false) {
+ updateTurnEvents(cities);
+ }
//Copy things over
- Process proc = Runtime.getRuntime().exec("D:\\Gear City Mods\\Europe Expanded II\\desktopCopy.bat", null, new File("D:/Gear City Mods/Europe Expanded II/"));
+ Process proc = Runtime.getRuntime().exec(modPath + "desktopCopy.bat", null, new File(modPath));
int result = proc.waitFor();
InputStream es = proc.getErrorStream();
System.out.println("Result of copy process = " + result);
@@ 425,7 433,7 @@ cityDBLoop: for (CityDB city : cities) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = factory.newDocumentBuilder();
- Document doc = dBuilder.parse(new File("D:\\Gear City Mods\\Europe Expanded\\Maps\\Europe Expanded\\scripts\\City1900.xml"));
+ Document doc = dBuilder.parse(new File("C:\\Software\\Games\\Steam\\steamapps\\common\\GearCity\\media\\Maps\\Great Lakes\\scripts\\City1900.xml"));
cityDB = XMLToBeanObjUtil.convertXmlToBeanObject(doc);
List<City> cities = cityDB.getCityList();