예제 #1
0
        private double GetLinkValue(EpanetService service, string nodeId)
        {
            var link  = service.Native.GetLinkById(nodeId);
            var value = link.GetValue(_timeStep);

            return(_linkValueselector.Invoke(value));
        }
예제 #2
0
        private double GetNodeValue(EpanetService service, string nodeId)
        {
            var node  = service.Native.GetNodeById(nodeId);
            var value = node.GetValue(_timeStep);

            return(_nodeValueselector.Invoke(value));
        }
        private async Task Animation(EpanetService service, WritableLayer nodeLayer)
        {
            while (true)
            {
                foreach (var t in service.TimeSteps)
                {
                    await Task.Delay(200);

                    foreach (var n in service.Nodes)
                    {
                        var value = n.GetValue(t);
                        var f     = nodeLayer
                                    .GetFeatures()
                                    .Where(x => ((Mapsui.Geometries.Point)x.Geometry).X == n.X)
                                    .Where(x => ((Mapsui.Geometries.Point)x.Geometry).Y == n.Y)
                                    .FirstOrDefault();
                        if (f == null)
                        {
                            continue;
                        }
                        f.Styles.Clear();
                        if (value.Pressure <= 0)
                        {
                            f.Styles.Add(_nodeP00Style);
                        }
                        else
                        if (value.Pressure <= 20)
                        {
                            f.Styles.Add(_nodeP20Style);
                        }
                        else
                        if (value.Pressure <= 40)
                        {
                            f.Styles.Add(_nodeP40Style);
                        }
                        else
                        if (value.Pressure <= 70)
                        {
                            f.Styles.Add(_nodeP70Style);
                        }
                        else
                        {
                            f.Styles.Add(_nodeP99Style);
                        }
                    }
                    //txtTimeStep.Text = t.ToString();
                    mapControl.Refresh();
                }
            }
        }
        private async Task Load()
        {
            var service = new EpanetService();

            service.InpPath = @"Samples\INP(Dr-누수량배분-연결요소수정).inp";
            service.Run();

            var nodeLayer = new WritableLayer()
            {
                Style = GetNodeLayerStyle()
            };
            var linkLayer = new WritableLayer()
            {
                Style = GetLinkLayerStyle()
            };

            foreach (var node in service.Nodes)
            {
                var point   = new Mapsui.Geometries.Point(node.X, node.Y);
                var feature = new Mapsui.Providers.Feature();
                feature.Geometry = point;
                nodeLayer.Add(feature);
            }

            foreach (var link in service.Links)
            {
                var vertices = new List <Mapsui.Geometries.Point>();
                vertices.Add(new Mapsui.Geometries.Point(link.Node1.X, link.Node1.Y));
                foreach (var v in link.Vertices)
                {
                    vertices.Add(new Mapsui.Geometries.Point(v.X, v.Y));
                }
                vertices.Add(new Mapsui.Geometries.Point(link.Node2.X, link.Node2.Y));
                var lineString = new Mapsui.Geometries.LineString(vertices);
                var feature    = new Mapsui.Providers.Feature();
                feature.Geometry = lineString;
                linkLayer.Add(feature);
            }

            mapControl.Map.Layers.Add(nodeLayer);
            mapControl.Map.Layers.Add(linkLayer);

            var p = (Mapsui.Geometries.Point)nodeLayer.GetFeatures().First().Geometry;

            mapControl.Navigator.NavigateTo(p, 11);

            await Animation(service, nodeLayer);
        }
예제 #5
0
        public void LoadInp(EpanetService service)
        {
            Clear();

            var nodeLayer = GetNodeLayer(service.Network.Nodes);
            var linkLayer = GetLinkLayer(service.Network.Links);

            nodeLayer.Style = GetNodeLayerStyle();
            linkLayer.Style = GetLinkLayerStyle();
            mapControl.Map.Layers.Add(linkLayer);
            mapControl.Map.Layers.Add(nodeLayer);

            if (!IsInViewport(nodeLayer) &&
                !IsInViewport(linkLayer))
            {
                NavigateTo(nodeLayer);
            }
        }
예제 #6
0
 public void Browse(EpanetService service)
 {
     if (_nodeLegend != null)
     {
         _networkMap
         .BrowseNode(
             _nodeLegend.Colors.Select(ToWpfColor).ToArray(),
             _nodeLegend.BoundaryValues,
             (nodeId) => GetNodeValue(service, nodeId));
     }
     if (_linkLegend != null)
     {
         _networkMap
         .BrowseLink(
             _linkLegend.Colors.Select(ToWpfColor).ToArray(),
             _linkLegend.BoundaryValues,
             (linkId) => GetLinkValue(service, linkId));
     }
     _networkMap.RefreshGraphics();
 }
예제 #7
0
 public void LoadInp(EpanetService service)
 {
     Clear();
     _networkMap.LoadInp(service);
 }