Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java @ 8562:c62837ba37f3
(issue1755) Move KM Step handling from Winfo artifact to RangeAccess
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 16 Feb 2015 15:58:52 +0100 |
parents | 27d42c9ee367 |
children | ea17665c5aad |
comparison
equal
deleted
inserted
replaced
8561:2b3c8ea6cbee | 8562:c62837ba37f3 |
---|---|
82 public static final String XPATH_STATIC_UI ="/art:result/art:ui/art:static"; | 82 public static final String XPATH_STATIC_UI ="/art:result/art:ui/art:static"; |
83 | 83 |
84 /** The default number of steps between the start end end of a selected Q | 84 /** The default number of steps between the start end end of a selected Q |
85 * range. */ | 85 * range. */ |
86 public static final int DEFAULT_Q_STEPS = 30; | 86 public static final int DEFAULT_Q_STEPS = 30; |
87 | |
88 /** The default step width between the start end end kilometer. */ | |
89 public static final double DEFAULT_KM_STEPS = 0.1; | |
90 | 87 |
91 private static final String [] INACTIVES = new String[] { | 88 private static final String [] INACTIVES = new String[] { |
92 LONGITUDINAL_Q, | 89 LONGITUDINAL_Q, |
93 DURATION_Q, | 90 DURATION_Q, |
94 STATIC_WQKMS_Q | 91 STATIC_WQKMS_Q |
821 | 818 |
822 | 819 |
823 /** | 820 /** |
824 * Returns the selected Kms. | 821 * Returns the selected Kms. |
825 * | 822 * |
826 * @param distance An 2dim array with [lower, upper] values. | |
827 * | |
828 * @return the selected Kms. | |
829 */ | |
830 public double[] getKms(double[] distance) { | |
831 StateData dStep = getData("ld_step"); | |
832 | |
833 if (dStep == null) { | |
834 log.warn("No step width given. Cannot compute Kms."); | |
835 return null; | |
836 } | |
837 | |
838 double step = Double.parseDouble((String) dStep.getValue()); | |
839 | |
840 // transform step from 'm' into 'km' | |
841 step = step / 1000; | |
842 | |
843 if (step == 0d) { | |
844 step = DEFAULT_KM_STEPS; | |
845 } | |
846 | |
847 return DoubleUtil.explode(distance[0], distance[1], step); | |
848 } | |
849 | |
850 | |
851 /** | |
852 * Returns the selected Kms. | |
853 * | |
854 * @return the selected kms. | 823 * @return the selected kms. |
855 */ | 824 */ |
856 public double[] getKms() { | 825 public double[] getKms() { |
857 if (isRange()) { | 826 if (isRange()) { |
858 RangeAccess rangeAccess = new RangeAccess(this); | 827 RangeAccess rangeAccess = new RangeAccess(this); |
859 double [] distance = rangeAccess.getKmRange(); | 828 return rangeAccess.getKmSteps(); |
860 return getKms(distance); | |
861 | |
862 } | 829 } |
863 else { | 830 else { |
864 return LocationDistanceSelect.getLocations(this); | 831 return LocationDistanceSelect.getLocations(this); |
865 } | 832 } |
866 } | 833 } |