Я хотел бы получить какое-либо мнение или помощь в отношении моего кода для тепловой карты, основанной на количестве случаев Ухани в каждой стране, код, как показано ниже.
В настоящее время я сохранил все координаты страны в hashmap, и я удалил данные из https://www.worldometers.info/coronavirus/, где я сохранил название страны и количество дел в файле CSV.
Я пытаюсь сравнить названия стран из CSV-файла с названием страны (ключом) в хэш-карте, так что если такая страна существует, нанесите «область нагрева» на карту. Однако в настоящее время, когда я пытаюсь выполнить сравнение, используя оператор if-else, как показано в моих кодах. Однако проблема, с которой я сталкиваюсь, заключается в том, что если в файле csv отсутствует 1 страна и он не совпадает с хэш-картой, код не запустится. Только когда файл csv содержит все названия стран и совпадает с хэш-картой, код будет отображать приложение, как показано ниже. Как мне go построить график "зоны нагрева" при сравнении названий стран из CSV-файла и хэш-карты?
КОД
@Override public void init() {
//Input the coordinates of the country, based on the size of the javafx.
//Limitation is the current coordinates are not the entire list of country in the world.
HashMap<String, List<Integer>> countryCoordinates = new HashMap<>();
Integer[] coordinates = {};
countryCoordinates.put("China", Arrays.asList(700, 180));
countryCoordinates.put("Diamond Princess", Arrays.asList(810, 170));
countryCoordinates.put("Singapore", Arrays.asList(726, 310));
countryCoordinates.put("Japan", Arrays.asList(810, 170));
countryCoordinates.put("Hong Kong", Arrays.asList(755, 225));
countryCoordinates.put("Thailand", Arrays.asList(720, 250));
countryCoordinates.put("S. Korea", Arrays.asList(780, 170));
countryCoordinates.put("Taiwan", Arrays.asList(775, 220));
countryCoordinates.put("Malaysia", Arrays.asList(725, 300));
countryCoordinates.put("Germany", Arrays.asList(440, 115));
countryCoordinates.put("Vietnam", Arrays.asList(740, 260));
.
.
.
Reader reader;
try {
//Retrieving the data from WorldMap CSV
reader = Files.newBufferedReader(Paths.get("C:\\Users\\User\\Desktop\\ICT1009_TESTFILE\\WorldMap.csv"));
CSVReader csvReader = new CSVReader(reader);
String[] nextRecord;
while((nextRecord = csvReader.readNext()) != null) {
String retrieveCountry = nextRecord[0];
//Comparing the hashmap key with the country name retrieve from CSV file
//If the names matches, plot the heat area
List<Integer> coordinatesOfThisCountry = countryCoordinates.get(retrieveCountry);
if (coordinatesOfThisCountry != null) {
events = new Point2D[] {
asPoint2D(countryCoordinates.get(retrieveCountry)),
};
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
ВЫХОД