Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/injector/DischargeInjector.java @ 8251:c7ca9c228314
Added context injectors for discharge curves.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 10 Sep 2014 10:01:11 +0200 |
parents | |
children | b5bef15c982e |
comparison
equal
deleted
inserted
replaced
8240:61fd22f65bd4 | 8251:c7ca9c228314 |
---|---|
1 package org.dive4elements.river.exports.injector; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 import org.dive4elements.artifacts.Artifact; | |
5 import org.dive4elements.artifacts.CallContext; | |
6 import org.dive4elements.artifacts.ContextInjector; | |
7 import org.dive4elements.river.artifacts.D4EArtifact; | |
8 import org.dive4elements.river.artifacts.access.RangeAccess; | |
9 import org.dive4elements.river.model.Gauge; | |
10 import org.w3c.dom.Document; | |
11 import org.w3c.dom.Element; | |
12 | |
13 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; | |
14 import static org.dive4elements.river.exports.injector.InjectorConstants.GAUGE_EPSILON;; | |
15 | |
16 | |
17 public class DischargeInjector | |
18 implements ContextInjector | |
19 { | |
20 | |
21 private static Logger log = Logger.getLogger(DischargeInjector.class); | |
22 | |
23 @Override | |
24 public void setup(Element cfg) { | |
25 } | |
26 | |
27 @Override | |
28 public void injectContext(CallContext ctx, Artifact artifact, Document doc) { | |
29 RangeAccess access = new RangeAccess((D4EArtifact)artifact); | |
30 double km = access.getFrom(); | |
31 Gauge gauge = access.getRiver().determineGaugeByStation( | |
32 km - GAUGE_EPSILON, km + GAUGE_EPSILON); | |
33 if (gauge == null) { | |
34 log.error("No Gauge could be found at station " + km + "!"); | |
35 return; | |
36 } | |
37 ctx.putContextValue(CURRENT_KM, km); | |
38 } | |
39 | |
40 } |