Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixZone.java @ 9238:1c756bfee472
salix.supraregional table revision -> Anschluss
author | gernotbelger |
---|---|
date | Tue, 10 Jul 2018 13:27:17 +0200 |
parents | 972e10522ed6 |
children | cbe393451ab0 |
comparison
equal
deleted
inserted
replaced
9237:972e10522ed6 | 9238:1c756bfee472 |
---|---|
103 public static final boolean hasGaps(final List<SalixZone> list, final double lower, final double upper) { | 103 public static final boolean hasGaps(final List<SalixZone> list, final double lower, final double upper) { |
104 | 104 |
105 if (((upper - lower) > DELTA) && list.size() == 0) | 105 if (((upper - lower) > DELTA) && list.size() == 0) |
106 return true; | 106 return true; |
107 | 107 |
108 final TreeSet<SalixZone> treeList = new TreeSet<SalixZone>(); | 108 final TreeSet<SalixZone> treeList = new TreeSet<>(); |
109 treeList.addAll(list); | 109 treeList.addAll(list); |
110 double lowerCompare = lower + DELTA; | 110 double lowerCompare = lower + DELTA; |
111 for (final SalixZone zone : treeList) { | 111 for (final SalixZone zone : treeList) { |
112 if (zone.getLowerFromTo() > lowerCompare) { | 112 if (zone.getLowerFromTo() > lowerCompare) { |
113 return true; | 113 return true; |
149 public int compareTo(final SalixZone o) { | 149 public int compareTo(final SalixZone o) { |
150 final int basicCompare = this.getLowerFromTo().compareTo(o.getLowerFromTo()); | 150 final int basicCompare = this.getLowerFromTo().compareTo(o.getLowerFromTo()); |
151 return basicCompare; | 151 return basicCompare; |
152 } | 152 } |
153 | 153 |
154 public static boolean isValidAnschlussRange(final double fromTest, final double toTest, final List<SalixZone> list, final double minKm) { | |
155 final SalixZone zone = new SalixZone(0, fromTest, toTest); | |
156 final double lower = zone.getLowerFromTo(); | |
157 final double anschluss = getAnschluss(list, minKm); | |
158 final double differenceAbs = (lower - anschluss) > 0 ? (lower - anschluss) : (anschluss - lower); // no Math.abs allowed :-( | |
159 if (differenceAbs > DELTA) { | |
160 return false; | |
161 } | |
162 | |
163 return true; | |
164 } | |
165 | |
166 private static double getAnschluss(final List<SalixZone> list, final double minKm) { | |
167 | |
168 if (list.size() > 0) { | |
169 return list.get(list.size() - 1).getUpperFromTo(); | |
170 } | |
171 return minKm; | |
172 } | |
173 | |
154 } | 174 } |