comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java @ 3924:5fced192b95c

Towards fix of issue863 (gaps in middle heigh bed data). flys-artifacts/trunk@5613 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 27 Sep 2012 11:12:38 +0000
parents 4bd3d8bbb60c
children
comparison
equal deleted inserted replaced
3923:9fac337192c9 3924:5fced192b95c
1 package de.intevation.flys.artifacts.model; 1 package de.intevation.flys.artifacts.model;
2 2
3 import java.io.Serializable; 3 import java.io.Serializable;
4
5 import java.util.ArrayList;
4 6
5 import gnu.trove.TDoubleArrayList; 7 import gnu.trove.TDoubleArrayList;
6 8
7 import de.intevation.artifacts.CallContext; 9 import de.intevation.artifacts.CallContext;
8 10
9 import de.intevation.flys.artifacts.resources.Resources; 11 import de.intevation.flys.artifacts.resources.Resources;
10 12
13 import org.apache.log4j.Logger;
14
11 15
12 public class MiddleBedHeightData implements Serializable { 16 public class MiddleBedHeightData implements Serializable {
17
18 /** Very private logger. */
19 private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class);
13 20
14 public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single"; 21 public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single";
15 public static final String I18N_EPOCH_NAME = "facet.bedheight_middle.epoch"; 22 public static final String I18N_EPOCH_NAME = "facet.bedheight_middle.epoch";
16 23
17 private int startYear; 24 private int startYear;
23 private TDoubleArrayList middleHeight; 30 private TDoubleArrayList middleHeight;
24 private TDoubleArrayList uncertainty; 31 private TDoubleArrayList uncertainty;
25 private TDoubleArrayList soundingWidth; 32 private TDoubleArrayList soundingWidth;
26 private TDoubleArrayList dataGap; 33 private TDoubleArrayList dataGap;
27 private TDoubleArrayList width; 34 private TDoubleArrayList width;
35 private ArrayList empty;
28 36
29 37
30 protected MiddleBedHeightData(int start, int end, String eval, String desc) { 38 protected MiddleBedHeightData(int start, int end, String eval, String desc) {
31 this.startYear = start; 39 this.startYear = start;
32 this.endYear = end; 40 this.endYear = end;
37 this.middleHeight = new TDoubleArrayList(); 45 this.middleHeight = new TDoubleArrayList();
38 this.uncertainty = new TDoubleArrayList(); 46 this.uncertainty = new TDoubleArrayList();
39 this.soundingWidth = new TDoubleArrayList(); 47 this.soundingWidth = new TDoubleArrayList();
40 this.dataGap = new TDoubleArrayList(); 48 this.dataGap = new TDoubleArrayList();
41 this.width = new TDoubleArrayList(); 49 this.width = new TDoubleArrayList();
50 this.empty = new ArrayList();
51 }
52
53 public void addAll(double station, double height, double uncertainty,
54 double soundingWidth, double dataGap, double width, boolean isEmpty) {
55 addKM(station);
56 addMiddleHeight(height);
57 addUncertainty(uncertainty);
58 addSoundingWidth(soundingWidth);
59 addDataGap(dataGap);
60 addWidth(width);
61 addIsEmpty(isEmpty);
42 } 62 }
43 63
44 64
45 public int getStartYear() { 65 public int getStartYear() {
46 return startYear; 66 return startYear;
57 public String getDescription() { 77 public String getDescription() {
58 return description; 78 return description;
59 } 79 }
60 80
61 81
62 public void addKM(double km) { 82 protected void addKM(double km) {
63 this.km.add(km); 83 this.km.add(km);
64 } 84 }
65 85
66 public double getKM(int idx) { 86 public double getKM(int idx) {
67 return km.get(idx); 87 return km.get(idx);
68 } 88 }
69 89
70 public void addMiddleHeight(double middleHeight) { 90 protected void addMiddleHeight(double middleHeight) {
71 this.middleHeight.add(middleHeight); 91 this.middleHeight.add(middleHeight);
72 } 92 }
73 93
74 public double getMiddleHeight(int idx) { 94 public double getMiddleHeight(int idx) {
75 return middleHeight.get(idx); 95 return middleHeight.get(idx);
76 } 96 }
77 97
78 public void addUncertainty(double uncertainty) { 98 protected void addUncertainty(double uncertainty) {
79 this.uncertainty.add(uncertainty); 99 this.uncertainty.add(uncertainty);
80 } 100 }
81 101
82 public double getUncertainty(int idx) { 102 public double getUncertainty(int idx) {
83 return uncertainty.get(idx); 103 return uncertainty.get(idx);
84 } 104 }
85 105
86 public void addSoundingWidth(double soundingWidth) { 106 protected void addSoundingWidth(double soundingWidth) {
87 this.soundingWidth.add(soundingWidth); 107 this.soundingWidth.add(soundingWidth);
88 } 108 }
89 109
90 public double getSoundingWidth(int idx) { 110 public double getSoundingWidth(int idx) {
91 return soundingWidth.get(idx); 111 return soundingWidth.get(idx);
92 } 112 }
93 113
94 public void addDataGap(double gap) { 114 protected void addDataGap(double gap) {
95 this.dataGap.add(gap); 115 this.dataGap.add(gap);
96 } 116 }
97 117
98 public double getDataGap(int idx) { 118 public double getDataGap(int idx) {
99 return dataGap.get(idx); 119 return dataGap.get(idx);
100 } 120 }
101 121
102 public void addWidth(double width) { 122 protected void addIsEmpty(boolean empty) {
123 this.empty.add(empty);
124 }
125
126 public boolean isEmpty(int idx) {
127 return (Boolean) empty.get(idx);
128 }
129
130
131 protected void addWidth(double width) {
103 this.width.add(width); 132 this.width.add(width);
104 } 133 }
105 134
106 public double getWidth(int idx) { 135 public double getWidth(int idx) {
107 return width.get(idx); 136 return width.get(idx);
110 public int size() { 139 public int size() {
111 return km.size(); 140 return km.size();
112 } 141 }
113 142
114 143
144 /**
145 * Get the points, ready to be drawn
146 * @return [[km1, km2,...],[height1,height2,...]]
147 */
115 public double[][] getMiddleHeightsPoints() { 148 public double[][] getMiddleHeightsPoints() {
116 double[][] points = new double[2][size()]; 149 double[][] points = new double[2][size()];
117 150
118 for (int i = 0, n = size(); i < n; i++) { 151 for (int i = 0, n = size(); i < n; i++) {
119 points[0][i] = getKM(i); 152 if (isEmpty(i)) {
120 points[1][i] = getMiddleHeight(i); 153 points[0][i] = getKM(i);
154 points[1][i] = Double.NaN;
155 }
156 else {
157 points[0][i] = getKM(i);
158 points[1][i] = getMiddleHeight(i);
159 }
121 } 160 }
122 161
123 return points; 162 return points;
124 } 163 }
125 164

http://dive4elements.wald.intevation.org