Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java @ 6873:6848c5c8fc23
FixA: Reference points facets: the index of the point is stored in the lower 8 bits of the facect index. Why was it search via getIndex()?
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 19 Aug 2013 22:19:09 +0200 |
parents | 08e3c22500f3 |
children | 437856cec419 |
comparison
equal
deleted
inserted
replaced
6872:c5ce9812388b | 6873:6848c5c8fc23 |
---|---|
74 false); | 74 false); |
75 | 75 |
76 FixResult result = (FixResult) res.getData(); | 76 FixResult result = (FixResult) res.getData(); |
77 double currentKm = getCurrentKm(context); | 77 double currentKm = getCurrentKm(context); |
78 | 78 |
79 logger.debug("current km in FRE: " + currentKm); | 79 if (logger.isDebugEnabled()) { |
80 logger.debug("current km in FRE: " + currentKm); | |
81 } | |
80 | 82 |
81 KMIndex<QWD []> kmQWs = result.getReferenced(); | 83 KMIndex<QWD []> kmQWs = result.getReferenced(); |
82 KMIndex.Entry<QWD []> kmQWsEntry = kmQWs.binarySearch(currentKm); | 84 KMIndex.Entry<QWD []> kmQWsEntry = kmQWs.binarySearch(currentKm); |
83 if (kmQWsEntry != null) { | 85 |
84 int ndx = index & 255; | 86 if (kmQWsEntry == null) { |
85 for (QWD qwd: kmQWsEntry.getValue()) { | 87 return null; |
86 if (qwd.getIndex() == ndx) { | |
87 return qwd; | |
88 } | |
89 } | |
90 } | 88 } |
91 return null; | 89 |
90 // The lower eight bits contain the index of the point. | |
91 int ndx = index & 255; | |
92 QWD [] qwds = kmQWsEntry.getValue(); | |
93 if (ndx >= qwds.length) { | |
94 logger.error("index too large: " + ndx + " " + qwds.length); | |
95 return null; | |
96 } | |
97 return qwds[ndx]; | |
92 } | 98 } |
93 | 99 |
94 | 100 |
95 /** | 101 /** |
96 * Create a deep copy of this Facet. | 102 * Create a deep copy of this Facet. |