Mercurial > dive4elements > river
changeset 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 | c5ce9812388b |
children | d9dfa52f69eb |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java |
diffstat | 1 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java Mon Aug 19 22:04:03 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java Mon Aug 19 22:19:09 2013 +0200 @@ -76,19 +76,25 @@ FixResult result = (FixResult) res.getData(); double currentKm = getCurrentKm(context); - logger.debug("current km in FRE: " + currentKm); + if (logger.isDebugEnabled()) { + logger.debug("current km in FRE: " + currentKm); + } KMIndex<QWD []> kmQWs = result.getReferenced(); KMIndex.Entry<QWD []> kmQWsEntry = kmQWs.binarySearch(currentKm); - if (kmQWsEntry != null) { - int ndx = index & 255; - for (QWD qwd: kmQWsEntry.getValue()) { - if (qwd.getIndex() == ndx) { - return qwd; - } - } + + if (kmQWsEntry == null) { + return null; } - return null; + + // The lower eight bits contain the index of the point. + int ndx = index & 255; + QWD [] qwds = kmQWsEntry.getValue(); + if (ndx >= qwds.length) { + logger.error("index too large: " + ndx + " " + qwds.length); + return null; + } + return qwds[ndx]; }