teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.access; ingo@3230: teichmann@5867: import org.dive4elements.river.artifacts.D4EArtifact; teichmann@5831: import org.dive4elements.river.artifacts.states.SoundingsSelect; christian@4150: ingo@3230: import gnu.trove.TIntArrayList; ingo@3230: ingo@3230: import org.apache.log4j.Logger; ingo@3230: ingo@3230: felix@4826: public class BedHeightAccess felix@4826: extends RangeAccess felix@4826: { teichmann@8202: private static final Logger log = Logger.getLogger(BedHeightAccess.class); sascha@3232: sascha@3258: private int[] singleIDs; sascha@3258: private int[] epochIDs; sascha@3232: felix@7356: private String yearEpoch; felix@7356: felix@7357: private String type; felix@7357: felix@7356: private Integer heightId; sascha@3232: felix@7357: private Integer time; felix@7357: teichmann@6101: public BedHeightAccess(D4EArtifact artifact) { teichmann@6101: super(artifact); sascha@3258: } sascha@3232: sascha@3232: tom@8559: public int[] getBedHeightIDs() { sascha@3258: if (singleIDs == null) { sascha@3258: String data = getString("soundings"); sascha@3232: sascha@3258: if (data == null) { teichmann@8202: log.warn("No 'soundings' parameter specified!"); sascha@3258: return null; sascha@3258: } christian@4150: else { tom@8559: log.debug("getBedHeightIDs(): data=" + data); christian@4150: } sascha@3232: sascha@3258: String[] parts = data.split(";"); sascha@3232: sascha@3258: TIntArrayList ids = new TIntArrayList(); ingo@3230: sascha@3258: for (String part: parts) { sascha@3258: if (part.indexOf(SoundingsSelect.PREFIX_SINGLE) >= 0) { tom@8856: String tmp = part.replace( tom@8856: SoundingsSelect.PREFIX_SINGLE, ""); sascha@3258: sascha@3258: try { christian@4150: int i = Integer.parseInt(tmp); christian@4150: if (!ids.contains(i)) { christian@4150: ids.add(i); christian@4150: } sascha@3258: } sascha@3258: catch (NumberFormatException nfe) { tom@8856: log.warn( tom@8856: "Cannot parse int from string: '" + tmp + "'"); sascha@3258: } sascha@3258: } sascha@3258: } sascha@3258: sascha@3258: singleIDs = ids.toNativeArray(); sascha@3258: } sascha@3258: sascha@3258: return singleIDs; ingo@3230: } ingo@3230: ingo@3230: felix@7357: public String getType() { felix@7357: if (type == null) { felix@7357: type = getString("type"); raimund@3614: } felix@7357: return type; felix@7356: } felix@7356: felix@7357: public Integer getHeightId() { felix@7357: if (heightId == null) { felix@7357: heightId = getInteger("height_id"); felix@7357: } felix@7357: return heightId; bjoern@4655: } bjoern@4655: felix@7357: public Integer getTime() { felix@7357: if (time == null) { felix@7357: time = getInteger("time"); felix@7357: } felix@7357: return time; bjoern@4655: } ingo@3230: } sascha@3259: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :