Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/injector/DischargeInjector.java @ 8326:10917ec29625
Inject current km and pnp into the context used to calculate W in cm at gauge.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 25 Sep 2014 17:23:12 +0200 |
parents | b5bef15c982e |
children | 31272d799dad |
comparison
equal
deleted
inserted
replaced
8321:a5e7e2d833ea | 8326:10917ec29625 |
---|---|
25 } | 25 } |
26 | 26 |
27 @Override | 27 @Override |
28 public void injectContext(CallContext ctx, Artifact artifact, Document doc) { | 28 public void injectContext(CallContext ctx, Artifact artifact, Document doc) { |
29 RangeAccess access = new RangeAccess((D4EArtifact)artifact); | 29 RangeAccess access = new RangeAccess((D4EArtifact)artifact); |
30 if (!access.hasFrom()) { | 30 if (access.hasFrom()) { |
31 ctx.putContextValue(CURRENT_KM, access.getFrom()); | |
31 return; | 32 return; |
32 } | 33 } |
33 double km = access.getFrom(); | 34 D4EArtifact d4e = (D4EArtifact)artifact; |
34 Gauge gauge = access.getRiver().determineGaugeByStation( | 35 String name = d4e.getDataAsString("gauge_name"); |
35 km - GAUGE_EPSILON, km + GAUGE_EPSILON); | 36 if (name == null || name.equals("")) { |
36 if (gauge == null) { | |
37 log.error("No Gauge could be found at station " + km + "!"); | |
38 return; | 37 return; |
39 } | 38 } |
40 ctx.putContextValue(CURRENT_KM, km); | 39 Gauge gauge = access.getRiver().determineGaugeByName(name); |
40 if (gauge == null) { | |
41 log.error("No Gauge could be found for name " + name + "!"); | |
42 return; | |
43 } | |
44 ctx.putContextValue(CURRENT_KM, gauge.getStation()); | |
45 return; | |
41 } | 46 } |
42 | 47 |
43 } | 48 } |