Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityResultValue.java @ 8653:dbec49147f54
(issue1755) Do not create interpolated themes and disable export of non interpolatable data.
Due to the fact that data can contain NaN's which will be filtered out
before creating the interpolator this requires the actual check
for interpolatable data when data is set in the ResultValue
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 01 Apr 2015 17:10:03 +0200 |
parents | 3c78fc83fc6d |
children | 0c241f03ebcd |
comparison
equal
deleted
inserted
replaced
8652:22f01b7e802e | 8653:dbec49147f54 |
---|---|
54 | 54 |
55 private String name; | 55 private String name; |
56 private String type; | 56 private String type; |
57 private double [][] data; | 57 private double [][] data; |
58 private transient PolynomialSplineFunction interpolFunc; | 58 private transient PolynomialSplineFunction interpolFunc; |
59 private boolean isInterpolatableData; | |
59 | 60 |
60 public BedQualityResultValue() { | 61 public BedQualityResultValue() { |
62 isInterpolatableData = false; | |
61 } | 63 } |
62 | 64 |
63 public BedQualityResultValue(String name, double [][] data, String type) { | 65 public BedQualityResultValue(String name, double [][] data, String type) { |
64 this.name = name; | 66 this.name = name; |
67 isInterpolatableData = false; | |
65 setData(data); | 68 setData(data); |
66 this.type = type; | 69 this.type = type; |
67 } | 70 } |
68 | 71 |
69 public String getName() { | 72 public String getName() { |
70 return name; | 73 return name; |
71 } | 74 } |
72 | 75 |
73 public boolean isEmpty() { | 76 public boolean isEmpty() { |
74 return data == null || data.length < 2 || data[0].length == 0; | 77 return data == null || data.length < 2 || data[0].length == 0; |
78 } | |
79 | |
80 public boolean isInterpolateable() { | |
81 return isInterpolatableData; | |
75 } | 82 } |
76 | 83 |
77 public void setName(String name) { | 84 public void setName(String name) { |
78 this.name = name; | 85 this.name = name; |
79 } | 86 } |
111 return new double[][] {x, y}; | 118 return new double[][] {x, y}; |
112 } | 119 } |
113 | 120 |
114 public void setData(double [][] data) { | 121 public void setData(double [][] data) { |
115 this.data = data; | 122 this.data = data; |
123 | |
124 if (!isEmpty() && data[0].length > 1 && data[0].length == data[1].length) { | |
125 int usable_points = 0; | |
126 for (double val :data[1]) { | |
127 if (!Double.isNaN(val)) { | |
128 usable_points++; | |
129 } | |
130 if (usable_points == 2) { | |
131 isInterpolatableData = true; | |
132 return; | |
133 } | |
134 } | |
135 } | |
116 } | 136 } |
117 | 137 |
118 public void setType(String type) { | 138 public void setType(String type) { |
119 this.type = type; | 139 this.type = type; |
120 } | 140 } |