fixing issue on parsing lat/long

This commit is contained in:
Francesco Mangiacrapa 2020-12-10 11:25:45 +01:00
parent c6c9c7aa3a
commit 363bc89550
1 changed files with 10 additions and 6 deletions

View File

@ -155,20 +155,24 @@ public class ConvertToServiceModel {
} }
List<String> latList = mapFields.get("Latitudine Centroide"); List<String> latList = mapFields.get("Latitudine Centroide");
if(latList!=null){ if(latList!=null && latList.size()>0){
try { try {
Double centroidLat = Double.parseDouble(latList.get(0)); if(!latList.get(0).isEmpty()) {
concessione.setCentroidLat(centroidLat); Double centroidLat = Double.parseDouble(latList.get(0));
concessione.setCentroidLat(centroidLat);
}
}catch (Exception e) { }catch (Exception e) {
throw new Exception("Unable to parse "+latList.get(0)+" as valid latitude"); throw new Exception("Unable to parse "+latList.get(0)+" as valid latitude");
} }
} }
List<String> longList = mapFields.get("Longitudine Centroide"); List<String> longList = mapFields.get("Longitudine Centroide");
if(longList!=null){ if(longList!=null && longList.size()>0){
try { try {
Double centroidLong = Double.parseDouble(longList.get(0)); if(!longList.get(0).isEmpty()) {
concessione.setCentroidLong(centroidLong); Double centroidLong = Double.parseDouble(longList.get(0));
concessione.setCentroidLong(centroidLong);
}
}catch (Exception e) { }catch (Exception e) {
throw new Exception("Unable to parse "+longList.get(0)+" as valid longitude"); throw new Exception("Unable to parse "+longList.get(0)+" as valid longitude");
} }