67377dbc by Nathan Lighthart

Added additional routing information to hru and reach contexts

- Added the routing context arrays for the "to" entities in hru and reach routing
1 parent a8d3f6cf
......@@ -459,6 +459,7 @@ public class AgESModel {
private void initializeSpatialContexts() {
initializeHRUContexts();
initializeReachContexts();
initializeRoutingInformation();
}
private void initializeHRUContexts() {
......@@ -472,23 +473,6 @@ public class AgESModel {
hruContext, temporalContext, agesContext);
hruTemporalContexts.put(hru.ID, hruTemporalContext);
}
// Add routing information to contexts
for (HRU hru : hrus) {
Context hruContext = hruTemporalContexts.get(hru.ID);
HRURoutingInformation routingInformation = routingTable.getRoutingInformationHRU(hru.ID);
List<RoutingEdge> fromHRUs = routingInformation.getFromHRUs();
RoutingContext[] routingContexts = new RoutingContext[fromHRUs.size()];
int i = 0;
for (RoutingEdge edge : fromHRUs) {
Context fromContext = hruTemporalContexts.get(edge.getId());
RoutingContext routingContext = new RoutingContext(fromContext, edge.getWeight());
routingContexts[i++] = routingContext;
}
hruContext.put("routingContexts", routingContexts);
}
}
private Context createHRUContext(HRU hru) {
......@@ -520,42 +504,88 @@ public class AgESModel {
reachContext, temporalContext, agesContext);
reachTemporalContexts.put(reach.ID, reachTemporalContext);
}
}
private Context createReachContext(StreamReach reach) {
Context context = new MapContext();
context.put("reach", reach);
context.put("ID", reach.ID);
return context;
}
private void initializeRoutingInformation() {
initializeHRURoutingInformation();
initializeReachRoutingInformation();
}
private void initializeHRURoutingInformation() {
// Add routing information to contexts
for (HRU hru : hrus) {
Context hruContext = hruTemporalContexts.get(hru.ID);
HRURoutingInformation routingInformation = routingTable.getRoutingInformationHRU(hru.ID);
// Generate from hru routing contexts
List<RoutingEdge> fromHRUs = routingInformation.getFromHRUs();
RoutingContext[] routingContexts = createRoutingContext(fromHRUs, hruTemporalContexts);
hruContext.put("routingContexts", routingContexts);
// Generate to HRU routing contexts
List<RoutingEdge> toHRUs = routingInformation.getToHRUs();
RoutingContext[] hruRoutingContexts = createRoutingContext(toHRUs, hruTemporalContexts);
hruContext.put("hruRoutingContexts", hruRoutingContexts);
// Generate to Reach routing contexts
List<RoutingEdge> toReaches = routingInformation.getToReaches();
RoutingContext[] reachRoutingContexts = createRoutingContext(toReaches, reachTemporalContexts);
hruContext.put("reachRoutingContexts", reachRoutingContexts);
}
}
private void initializeReachRoutingInformation() {
// Add routing information to contexts
for (StreamReach reach : reaches) {
Context reachContext = reachTemporalContexts.get(reach.ID);
ReachRoutingInformation routingInformation = routingTable.getRoutingInformationReach(reach.ID);
// Generate from hru routing contexts
List<RoutingEdge> fromHRUs = routingInformation.getFromHRUs();
RoutingContext[] hruRoutingContexts = new RoutingContext[fromHRUs.size()];
int i = 0;
for (RoutingEdge edge : fromHRUs) {
Context fromContext = hruTemporalContexts.get(edge.getId());
RoutingContext routingContext = new RoutingContext(fromContext, edge.getWeight());
hruRoutingContexts[i++] = routingContext;
}
RoutingContext[] hruRoutingContexts = createRoutingContext(fromHRUs, hruTemporalContexts);
reachContext.put("hruRoutingContexts", hruRoutingContexts);
// Generate from reach routing contexts
List<RoutingEdge> fromReaches = routingInformation.getFromReaches();
RoutingContext[] reachRoutingContexts = new RoutingContext[fromReaches.size()];
i = 0;
for (RoutingEdge edge : fromReaches) {
Context fromContext = reachTemporalContexts.get(edge.getId());
RoutingContext routingContext = new RoutingContext(fromContext, edge.getWeight());
reachRoutingContexts[i++] = routingContext;
}
RoutingContext[] reachRoutingContexts = createRoutingContext(fromReaches, reachTemporalContexts);
reachContext.put("reachRoutingContexts", reachRoutingContexts);
// Generate toReach routing context
RoutingEdge toReach = routingInformation.getToReach();
RoutingContext toReachRoutingContext;
if (toReach == null) {
toReachRoutingContext = null;
} else {
toReachRoutingContext = createRoutingContext(toReach, reachTemporalContexts);
}
reachContext.put("toReachRoutingContext", toReachRoutingContext);
}
}
private Context createReachContext(StreamReach reach) {
Context context = new MapContext();
context.put("reach", reach);
context.put("ID", reach.ID);
private RoutingContext[] createRoutingContext(List<RoutingEdge> edges, Map<Integer, Context> contexts) {
RoutingContext[] routingContexts = new RoutingContext[edges.size()];
int i = 0;
for (RoutingEdge edge : edges) {
RoutingContext routingContext = createRoutingContext(edge, contexts);
routingContexts[i++] = routingContext;
}
return routingContexts;
}
return context;
private RoutingContext createRoutingContext(RoutingEdge edge, Map<Integer, Context> contexts) {
Context context = contexts.get(edge.getId());
return new RoutingContext(context, edge.getWeight());
}
private void initializeCatchmentContexts() {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!