comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java @ 3003:e5e6363e6cba

FixA: Explicit model for date ranges. flys-artifacts/trunk@4559 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 30 May 2012 14:45:36 +0000
parents a2b265b9b2f7
children 9e0500d64524
comparison
equal deleted inserted replaced
3002:e54dd69d306f 3003:e5e6363e6cba
22 22
23 import de.intevation.flys.utils.DoubleUtil; 23 import de.intevation.flys.utils.DoubleUtil;
24 24
25 import java.util.ArrayList; 25 import java.util.ArrayList;
26 import java.util.List; 26 import java.util.List;
27 import java.util.Date;
28 27
29 import org.apache.commons.math.MathException; 28 import org.apache.commons.math.MathException;
30 29
31 import org.apache.commons.math.optimization.fitting.CurveFitter; 30 import org.apache.commons.math.optimization.fitting.CurveFitter;
32 31
37 public class FixCalculation 36 public class FixCalculation
38 extends Calculation 37 extends Calculation
39 { 38 {
40 private static Logger log = Logger.getLogger(FixCalculation.class); 39 private static Logger log = Logger.getLogger(FixCalculation.class);
41 40
42 protected String river; 41 protected String river;
43 protected double from; 42 protected double from;
44 protected double to; 43 protected double to;
45 protected double step; 44 protected double step;
46 protected boolean preprocessing; 45 protected boolean preprocessing;
47 protected String function; 46 protected String function;
48 protected int [] events; 47 protected int [] events;
49 protected long [][] analysisPeriods; 48 protected DateRange [] analysisPeriods;
50 protected int qSectorStart; 49 protected int qSectorStart;
51 protected int qSectorEnd; 50 protected int qSectorEnd;
52 51
53 public FixCalculation() { 52 public FixCalculation() {
54 } 53 }
55 54
56 public FixCalculation(FixationArtifactAccess access) { 55 public FixCalculation(FixationArtifactAccess access) {
57 56
58 String river = access.getRiver(); 57 String river = access.getRiver();
59 Double from = access.getFrom(); 58 Double from = access.getFrom();
60 Double to = access.getTo(); 59 Double to = access.getTo();
61 Double step = access.getStep(); 60 Double step = access.getStep();
62 String function = access.getFunction(); 61 String function = access.getFunction();
63 int [] events = access.getEvents(); 62 int [] events = access.getEvents();
64 long [][] analysisPeriods = access.getAnalysisPeriods(); 63 DateRange [] analysisPeriods = access.getAnalysisPeriods();
65 Integer qSectorStart = access.getQSectorStart(); 64 Integer qSectorStart = access.getQSectorStart();
66 Integer qSectorEnd = access.getQSectorEnd(); 65 Integer qSectorEnd = access.getQSectorEnd();
67 66
68 if (river == null) { 67 if (river == null) {
69 // TODO: i18n 68 // TODO: i18n
70 addProblem("fix.missing.river"); 69 addProblem("fix.missing.river");
71 } 70 }
367 FixingsColumnFactory fcf = FixingsColumnFactory.getInstance(); 366 FixingsColumnFactory fcf = FixingsColumnFactory.getInstance();
368 367
369 for (int i = 0; i < columns.length; ++i) { 368 for (int i = 0; i < columns.length; ++i) {
370 369
371 // Construct filter for period. 370 // Construct filter for period.
372 long [] period = analysisPeriods[i]; 371 DateRange period = analysisPeriods[i];
373 372
374 AndFilter filter = new AndFilter(); 373 AndFilter filter = new AndFilter();
375 374
376 DateRangeFilter dateRangeFilter = 375 DateRangeFilter dateRangeFilter =
377 new DateRangeFilter( 376 new DateRangeFilter(period.getFrom(), period.getTo());
378 new Date(period[0]),
379 new Date(period[1]));
380 377
381 filter.add(dateRangeFilter); 378 filter.add(dateRangeFilter);
382 filter.add(sectorRangeFilter); 379 filter.add(sectorRangeFilter);
383 380
384 List<Fixing.Column> metaCols = overview.filter(range, filter); 381 List<Fixing.Column> metaCols = overview.filter(range, filter);

http://dive4elements.wald.intevation.org