Skip to content

Commit 58b33c1

Browse files
committed
Refactored schematic helper to available to ironpython scripts
1 parent 544567d commit 58b33c1

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

FlowMatters.Source.Veneer/ExchangeObjects/GeoJSONFeature.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Drawing;
33
using System.Linq;
44
using System.Runtime.Serialization;
5+
using FlowMatters.Source.Veneer.RemoteScripting;
56
using FlowMatters.Source.WebServer;
67
using Microsoft.CSharp.RuntimeBinder;
78
using RiverSystem;
@@ -48,7 +49,7 @@ public GeoJSONFeature(Node n,RiverSystemScenario scenario,bool useSchematicLocat
4849
properties.Add("name",n.Name);
4950
properties.Add(FeatureTypeProperty, "node");
5051
Coordinate loc = n.location;
51-
var schematic = GetSchematic(scenario);
52+
var schematic = ScriptHelpers.GetSchematic(scenario);
5253
if (schematic != null)
5354
{
5455
PointF schematicLocation = SchematicLocationForNode(n, schematic);
@@ -67,14 +68,6 @@ private static PointF SchematicLocationForNode(TIME.DataTypes.NodeLinkNetwork.No
6768
return schematic.ExistingFeatureShapeProperties.Where(shape=>shape.Feature==n).Select(shape=>shape.Location).FirstOrDefault();
6869
}
6970

70-
private static SchematicNetworkConfigurationPersistent GetSchematic(RiverSystemScenario scenario)
71-
{
72-
object tmp;
73-
scenario.AuxiliaryInformation.TryGetValue(SchematicNetworkControl.AUX_CONFIG, out tmp);
74-
SchematicNetworkConfigurationPersistent schematic = tmp as SchematicNetworkConfigurationPersistent;
75-
return schematic;
76-
}
77-
7871
private static string ResourceName(Node n)
7972
{
8073
object o = RetrieveNodeModel(n) ?? (object) n.FlowPartitioning;
@@ -114,7 +107,7 @@ public GeoJSONFeature(Link l, RiverSystemScenario scenario, bool useSchematicLoc
114107

115108
if (useSchematicLocation)
116109
{
117-
var schematic = GetSchematic(scenario);
110+
var schematic = ScriptHelpers.GetSchematic(scenario);
118111
if (scenario != null)
119112
{
120113

FlowMatters.Source.Veneer/RemoteScripting/ScriptHelpers.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using RiverSystem.DataManagement.DataManager.DataSources;
2121
using RiverSystem.ManagedExtensions;
2222
using RiverSystem.Quality.SourceSinkModels;
23+
using RiverSystemGUI_II.SchematicBuilder;
2324
using TIME.Core;
2425
using TimeSeries = TIME.DataTypes.TimeSeries;
2526
using TIME.Management;
@@ -142,7 +143,7 @@ public static string FindDataSource(RiverSystemScenario scenario, object target,
142143

143144
DataManager dm = theNetwork.DataManager;
144145

145-
foreach (var name in dm.DataGroups.Select(g => g.GetFullPath(ri,theInputSet)).Where(name => !string.IsNullOrEmpty(name)))
146+
foreach (var name in dm.DataGroups.Select(g => g.GetFullPath(ri,theInputSet)).Where(name => !String.IsNullOrEmpty(name)))
146147
{
147148
return name;
148149
}
@@ -177,7 +178,7 @@ public static void InitialiseModelsForConstituent(RiverSystemScenario s, Constit
177178

178179
public static void EnsureElementsHaveConstituentProviders(RiverSystemScenario scenario)
179180
{
180-
RiverSystem.Network network = scenario.Network;
181+
Network network = scenario.Network;
181182
ConstituentsManagement cm = network.ConstituentsManagement;
182183

183184
Action<INetworkElement> ensure = element =>
@@ -225,5 +226,13 @@ private static Type DefaultSourceSinkType(NetworkElementConstituentData data)
225226

226227
return null;
227228
}
229+
230+
public static SchematicNetworkConfigurationPersistent GetSchematic(RiverSystemScenario scenario)
231+
{
232+
object tmp;
233+
scenario.AuxiliaryInformation.TryGetValue(SchematicNetworkControl.AUX_CONFIG, out tmp);
234+
SchematicNetworkConfigurationPersistent schematic = tmp as SchematicNetworkConfigurationPersistent;
235+
return schematic;
236+
}
228237
}
229238
}

0 commit comments

Comments
 (0)