Mercurial > dive4elements > river
changeset 7696:feb23ab736f4
(issue1649) Better check for waterlevel data and accept wkms data
Fixes calculation of differences with old differences calculations
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 16 Dec 2013 16:00:10 +0100 |
parents | 75ef6963f1c9 |
children | 640342d9ab8a |
files | artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java |
diffstat | 1 files changed, 25 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java Mon Dec 16 15:14:40 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java Mon Dec 16 16:00:10 2013 +0100 @@ -786,13 +786,31 @@ return null; } else{ - WQKms[] wqkms = (WQKms[]) flys.getWaterlevelData(). - getData(); - if (wqkms == null) - logger.warn("not waterlevels in artifact"); - else if (wqkms.length < idx) - logger.warn("not enough waterlevels in artifact"); - return wqkms[idx]; + Object data = flys.getWaterlevelData(context).getData(); + + if (data == null) { + logger.error("No waterlevel Data in artifact"); + return null; + } + + if (data instanceof WQKms[]) { + WQKms[] wqkms = (WQKms[]) data; + if (wqkms.length < idx) { + logger.error("not enough waterlevels in artifact"); + return null; + } + return wqkms[idx]; + } else if (data instanceof WKms[]) { + WKms[] wkms = (WKms[]) data; + if (wkms.length < idx) { + logger.error("not enough wkms in artifact"); + return null; + } + return wkms[idx]; + } + + logger.error("unknown Waterlevel Data."); + return null; } }