public override object Clone(bool copyValues) { // do not let Function Clone the values; function clone will not clone the networklocations but copy a reference NetworkCoverage clone = (NetworkCoverage)base.Clone(false); if (copyValues) { foreach (INetworkLocation location in Locations.Values) { clone[location.Clone()] = this[location]; } } clone.Network = Network; return(clone); }
/// <summary> /// Creates a route with the given locations. Now route is stored in argument. /// This makes it impossible to have doubles. :( But makes drawing etc easy. /// </summary> /// <param name="locations"></param> /// <returns></returns> public static INetworkCoverage CreateRoute(params INetworkLocation[] locations) { var network = locations[0].Branch.Network; ThrowIfInputInvalid(locations, network); var route = new NetworkCoverage { Network = network, SegmentGenerationMethod = SegmentGenerationMethod.RouteBetweenLocations }; route.Components[0].Unit = new Unit("meters", "m"); route.Locations.AutoSort = false; route.SetLocations(locations); return(route); }
public IFunction CreateFunction(IEnumerable <IVariable> variables) { IVariable component = variables.First(f => !f.IsIndependent); //TODO: set name correctly INetworkCoverage networkCoverage = new NetworkCoverage { Name = "networkcoverage", Arguments = new EventedList <IVariable>(component.Arguments), Components = new EventedList <IVariable>(new[] { component }), Network = network }; //component.Store.Functions.Add(networkCoverage); return(networkCoverage); }
/// <summary> /// Extract a time slice for 1 time step out a time dependent network coverage /// </summary> /// <param name="source"></param> /// <param name="dateTime"></param> /// <returns></returns> public static INetworkCoverage ExtractTimeSlice(INetworkCoverage source, DateTime dateTime) { if (!source.Arguments[0].Values.Contains(dateTime)) { throw new ArgumentException("ExtractTimeSlice: invalid time.", "dateTime"); } INetworkCoverage slice = new NetworkCoverage(source.Name, false); //slice.Components[0].NoDataValues = new ArrayList(source.Components[0].NoDataValues); //slice.Locations.Values.AddRange(source.Arguments[1].Values); //var values = source.GetValues(new VariableValueFilter(source.Arguments[0], new [] {dateTime})); //slice.SetValues(values); // extract a time slice from the source and also copy the networklocations. ExtractTimeSlice(source, slice, dateTime, true); return(slice); }
private static INetworkCoverage CopyNetworkCoverage(INetworkCoverage originalCoverage) { //clone works strange for NetCdf, for now just create a manual copy var result = new NetworkCoverage("", originalCoverage.IsTimeDependent) { Network = originalCoverage.Network }; if (originalCoverage.IsTimeDependent) { result.Time.SetValues(originalCoverage.Time.Values); } result.Locations.SetValues(originalCoverage.Locations.Values.Select(loc => (INetworkLocation)loc.Clone())); result.Components[0].SetValues(originalCoverage.Components[0].Values); if (result.Components.Count > 1) { throw new NotImplementedException("Support for coverages with multiple components is not implemented"); } return(result); }