Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/Porosity.java @ 7846:e84726b48484
New Facet, datatype and data factory for porosities.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 30 Apr 2014 15:20:11 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7845:4e264d6c6e06 | 7846:e84726b48484 |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.model.minfo; | |
10 | |
11 import java.util.HashMap; | |
12 import java.util.Map; | |
13 | |
14 | |
15 public class Porosity | |
16 { | |
17 | |
18 private Map<Double, Double> pairs; | |
19 | |
20 | |
21 public Porosity() { | |
22 pairs = new HashMap<Double, Double>(); | |
23 } | |
24 | |
25 public void add(double station, double porosity) { | |
26 this.pairs.put(station, porosity); | |
27 } | |
28 | |
29 public Map<Double, Double> getAll() { | |
30 return this.pairs; | |
31 } | |
32 | |
33 public double[][] getAsArray() { | |
34 double [][] array = new double[2][pairs.size()]; | |
35 Double[] kms = pairs.keySet().toArray(new Double[pairs.size()]); | |
36 Double[] porosity = pairs.values().toArray(new Double[pairs.size()]); | |
37 int realIndex = 0; | |
38 for (int i = 0; i < kms.length; i++) { | |
39 if (kms[i] == null || porosity[i] == null) { | |
40 continue; | |
41 } | |
42 array[0][realIndex] = kms[i]; | |
43 array[1][realIndex] = porosity[i]; | |
44 realIndex++; | |
45 } | |
46 return array; | |
47 } | |
48 | |
49 | |
50 public Double getWidth(double station) { | |
51 if (this.pairs.containsKey(station)) { | |
52 return this.pairs.get(station); | |
53 } | |
54 return null; | |
55 } | |
56 } |