comparison flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultArtifactDescription.java @ 1279:af6ad7522351

Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription. flys-client/trunk@2861 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 29 Sep 2011 09:14:41 +0000
parents 6f65e70fa11d
children 070321cf17e1
comparison
equal deleted inserted replaced
1278:4c3329db2536 1279:af6ad7522351
1 package de.intevation.flys.client.shared.model; 1 package de.intevation.flys.client.shared.model;
2
3 import java.util.List;
4
5 import de.intevation.flys.client.shared.DoubleUtils;
2 6
3 7
4 /** 8 /**
5 * The default implementation of an {@link ArtifactDescription}. This class just 9 * The default implementation of an {@link ArtifactDescription}. This class just
6 * implements constructors to create new instances and the necessary methods of 10 * implements constructors to create new instances and the necessary methods of
103 107
104 108
105 public Recommendation[] getRecommendations() { 109 public Recommendation[] getRecommendations() {
106 return recommendations; 110 return recommendations;
107 } 111 }
112
113
114 public String getRiver() {
115 for (DataList list: oldData) {
116 List<Data> dataList = list.getAll();
117
118 for (Data d: dataList) {
119 String dataName = d.getLabel();
120 DataItem item = d.getItems()[0];
121
122 if (dataName.equals("river")) {
123 return item.getStringValue();
124 }
125 }
126 }
127
128 return null;
129 }
130
131
132 public double[] getKMRange() {
133 Double[] mm = new Double[2];
134
135 for (DataList list: oldData) {
136 List<Data> dataList = list.getAll();
137
138 for (Data data: dataList) {
139 String dataName = data.getLabel();
140 DataItem item = data.getItems()[0];
141
142 if (dataName.equals("ld_from")) {
143 Double d = DoubleUtils.getDouble(item.getStringValue());
144
145 if (d != null) {
146 mm[0] = d;
147 }
148 }
149 else if (dataName.equals("ld_to")) {
150 Double d = DoubleUtils.getDouble(item.getStringValue());
151
152 if (d != null) {
153 mm[1] = d;
154 }
155 }
156 else if (dataName.equals("ld_locations")) {
157 return DoubleUtils.getMinMax(item.getStringValue());
158 }
159 }
160
161 if (mm[0] != null && mm[1] != null) {
162 return new double[] { mm[0], mm[1] };
163 }
164 }
165
166 return null;
167 }
108 } 168 }
109 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 169 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org