Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/utils/DataUtil.java @ 7081:3c4efd4b2c19 generator-refactoring
Simplyfy / unify "invert axis" logic
- DataUtil now can check if two datasets are in the same direction
- In the case of WKM data a no means that the Water flows Right to Left
- If the water flows from right to left do inversion of diagrams
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 20 Sep 2013 17:36:11 +0200 |
parents | af13ceeba52a |
children | 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
7080:02a704a37323 | 7081:3c4efd4b2c19 |
---|---|
12 | 12 |
13 import gnu.trove.TDoubleArrayList; | 13 import gnu.trove.TDoubleArrayList; |
14 | 14 |
15 public class DataUtil | 15 public class DataUtil |
16 { | 16 { |
17 public static boolean guessWaterIncreasing(TDoubleArrayList data) { | 17 public static boolean guessDataIncreasing(TDoubleArrayList data) { |
18 return guessWaterIncreasing(data, 0.05f); | 18 return guessDataIncreasing(data, 0.05f); |
19 } | 19 } |
20 | 20 |
21 public static boolean guessWaterIncreasing(TDoubleArrayList data, float factor) { | 21 /** Guess if data1 and data2 both grow in the same direction */ |
22 public static boolean guessSameDirectionData(TDoubleArrayList data1, | |
23 TDoubleArrayList data2) { | |
24 boolean d1dir = DataUtil.guessDataIncreasing(data1, 0.05f); | |
25 boolean d2dir = DataUtil.guessDataIncreasing(data2, 0.05f); | |
26 int size = data1.size(); | |
27 return ((d1dir && d2dir) || (!d1dir && !d2dir)) && size > 1; | |
28 } | |
29 | |
30 public static boolean guessDataIncreasing(TDoubleArrayList data, float factor) { | |
22 int N = data.size(); | 31 int N = data.size(); |
23 if (N < 2) return false; | 32 if (N < 2) return false; |
24 | 33 |
25 int samples = (int)(factor*N) + 1; | 34 int samples = (int)(factor*N) + 1; |
26 | 35 |