Skip to content
Snippets Groups Projects
Commit 3b0c62d9 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Handling observations without observation data

parent 48579663
Branches
Tags
No related merge requests found
...@@ -339,15 +339,15 @@ public class DeliaRadicumFloralisObservationModel extends I18nImpl implements Mo ...@@ -339,15 +339,15 @@ public class DeliaRadicumFloralisObservationModel extends I18nImpl implements Mo
{ {
try try
{ {
Map<String, Double> data = this.getObjectMapper().readValue(new ByteArrayInputStream(observationData.getBytes("UTF-8")), new TypeReference<HashMap<String,Double>>() {}); Map<String, Double> data = this.getObjectMapper().readValue(new ByteArrayInputStream(observationData.getBytes("UTF-8")), new TypeReference<HashMap<String,Double>>() {});
Double sum = 0.0; Double sum = 0.0;
for(String key:data.keySet()) for(String key:data.keySet())
{ {
sum += data.get(key); sum += data.get(key);
} }
return sum/data.size(); return sum/data.size();
} }
catch(IOException ex) catch(IOException | NullPointerException ex)
{ {
return 0.0; return 0.0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment