public MapObjectEditing(MapControl mapControl, WritableLayer targetLayer)
        {
            this.mapControl  = mapControl;
            this.targetLayer = targetLayer;

            draggingLayer = new DraggingLayer();
            this.mapControl.Map.Layers.Add(draggingLayer);
        }
Пример #2
0
 private void InitLayers()
 {
     draggingLayer      = new WritableLayer();
     workingRadiusLayer = new WritableLayer {
         Opacity = 0.3
     };
     this.mapControl.Map.Layers.Add(workingRadiusLayer);
     this.mapControl.Map.Layers.Add(draggingLayer);
 }
        private void InitLayers()
        {
            mapObjectLayer    = new MapObjectLayer();
            boundingAreaLayer = new BoundingAreaLayer();
            attractorLayer    = new WritableLayer();

            edgeLayer            = new WritableLayer();
            edgeRasterizingLayer = new RasterizingLayer(edgeLayer,
                                                        delayBeforeRasterize: 0, renderResolutionMultiplier: 1,
                                                        rasterizer: null, overscanRatio: 2);
        }
Пример #4
0
        public AttractorEditing(MapControl mapControl, WritableLayer targetLayer, UIElement editingUIRoot, ComboBox typeComboBox, ComboBox performanceComboBox, IntegerUpDown workingRadiusUpDown)
        {
            this.mapControl          = mapControl;
            this.targetLayer         = targetLayer;
            this.editingUIRoot       = editingUIRoot;
            this.typeComboBox        = typeComboBox;
            this.performanceComboBox = performanceComboBox;
            this.workingRadiusUpDown = workingRadiusUpDown;

            InitLayers();
        }
Пример #5
0
        private Map CreateMap()
        {
            var map = new Map();

            map.Layers.Add(OpenStreetMap.CreateTileLayer());
            var writableLayer = new WritableLayer();

            writableLayer.Add(new GeometryFeature());
            map.Layers.Add(writableLayer);

            return(map);
        }
Пример #6
0
        private static WritableLayer CreateLineLayer()
        {
            var lineLayer = new WritableLayer
            {
                Name  = "LineLayer",
                Style = CreateLineStyle()
            };

            // todo: add data

            return(lineLayer);
        }
Пример #7
0
        private void InitializeEditSetup()
        {
            _editManager.Layer = (WritableLayer)MapControl.Map.Layers.First(l => l.Name == "EditLayer");
            _targetLayer       = (WritableLayer)MapControl.Map.Layers.First(l => l.Name == "PolygonLayer");

            // Load the polygon layer on startup so you can start modifying right away
            _editManager.Layer.AddRange(_targetLayer.GetFeatures().Copy());
            _targetLayer.Clear();

            _editManager.EditMode = EditMode.Modify;
            Loaded += (sender, args) => MapControl.Map.NavigateTo(_editManager.Layer.Envelope.Grow(_editManager.Layer.Envelope.Width * 0.2));
        }
Пример #8
0
        private WritableLayer GetNodeLayer(IEnumerable <Node2> nodes)
        {
            var layer = new WritableLayer();

            foreach (var node in nodes)
            {
                var feature = new Mapsui.Providers.Feature();
                feature.Geometry = ToMapsuiPoint(node);
                layer.Add(feature);
                _nodes.Add(feature, node);
            }
            return(layer);
        }
Пример #9
0
        public void DoNotCrashOnNullOrEmptyGeometries()
        {
            // arrange
            using var writableLayer = new WritableLayer();
            writableLayer.Add(new GeometryFeature());
            writableLayer.Add(new GeometryFeature((Point?)null));
            writableLayer.Add(new GeometryFeature((LineString?)null));
            writableLayer.Add(new GeometryFeature((Polygon?)null));
            // act
            var extent = writableLayer.Extent;

            // assert
            Assert.IsNull(extent);
        }
Пример #10
0
        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();
                }
            }
        }
Пример #11
0
        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);
        }
Пример #12
0
        private static WritableLayer CreatePointLayer()
        {
            var pointLayer = new WritableLayer
            {
                Name  = "PointLayer",
                Style = CreatePointStyle()
            };

            var dgt = new Feature {
                Geometry = SphericalMercator.FromLonLat(18.568066, 54.277201)
            };

            pointLayer.Add(dgt);

            return(pointLayer);
        }
Пример #13
0
        private static WritableLayer CreatePolygonLayer()
        {
            var polygonLayer = new WritableLayer
            {
                Name  = "PolygonLayer",
                Style = CreatePolygonStyle()
            };

            var wkt     = "POLYGON ((1261416.17275404 5360656.05714234, 1261367.50386493 5360614.2556425, 1261353.47050427 5360599.62511755, 1261338.83997932 5360576.03712836, 1261337.34706862 5360570.6626498, 1261375.8641649 5360511.2448036, 1261383.92588273 5360483.17808227, 1261391.98760055 5360485.56673941, 1261393.48051126 5360480.490843, 1261411.99260405 5360487.6568144, 1261430.50469684 5360496.9128608, 1261450.21111819 5360507.06465361, 1261472.00761454 5360525.5767464, 1261488.13105019 5360544.98458561, 1261488.1310502 5360545.28316775, 1261481.26366093 5360549.76189988, 1261489.6239609 5360560.21227484, 1261495.59560374 5360555.13637843, 1261512.91336796 5360573.05130694, 1261535.00844645 5360598.43078898, 1261540.08434286 5360619.03295677, 1261535.90419287 5360621.12303176, 1261526.64814648 5360623.21310675, 1261489.32537876 5360644.41243881, 1261458.27283602 5360661.73020303, 1261438.26783253 5360662.02878517, 1261427.22029328 5360660.23729232, 1261416.17275404 5360656.05714234))";
            var polygon = GeometryFromWKT.Parse(wkt);

            polygonLayer.Add(new Feature {
                Geometry = polygon
            });

            return(polygonLayer);
        }
Пример #14
0
        private static WritableLayer CreatePolygonLayer()
        {
            var polygonLayer = new WritableLayer
            {
                Name  = "PolygonLayer",
                Style = CreatePolygonStyle()
            };

            var wkt     = "POLYGON ((1974872.59075918 7096958.21959246, 1954081.71906561 7092066.24978221, 1949801.24548164 7096958.21959246, 1942463.29076626 7093289.24223477, 1929621.87001435 7068217.89695723, 1920449.42662013 7054153.48375276, 1931456.3586932 7046815.52903738, 1935125.33605089 7037643.08564316, 1947355.26057651 7028470.64224894, 1956527.70397074 7030305.13092778, 1962642.66623355 7031528.12338035, 1958973.68887586 7042535.05545341, 1958973.68887586 7052930.4913002, 1963254.16245983 7064548.91959954, 1973038.10208033 7063325.92714698, 1973038.10208033 7078001.83657773, 1978541.56811687 7081059.31770914, 1977930.07189058 7088397.27242452, 1974872.59075918 7096958.21959246))";
            var polygon = GeometryFromWKT.Parse(wkt);

            polygonLayer.Add(new Feature {
                Geometry = polygon
            });

            return(polygonLayer);
        }
Пример #15
0
        private WritableLayer GetLinkLayer(IEnumerable <Link> links)
        {
            var layer = new WritableLayer();

            foreach (var link in links)
            {
                var vertices = new List <Mapsui.Geometries.Point>();
                vertices.Add(ToMapsuiPoint(link.FirstNode));
                foreach (var v in link.Vertices)
                {
                    vertices.Add(ToMapsuiPoint(v));
                }
                vertices.Add(ToMapsuiPoint(link.SecondNode));
                var lineString = new Mapsui.Geometries.LineString(vertices);
                var feature    = new Mapsui.Providers.Feature();
                feature.Geometry = lineString;
                layer.Add(feature);
                _links.Add(feature, link);
            }
            return(layer);
        }
Пример #16
0
        private void TargetLayerOnSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
        {
            var selectedValue = ((ComboBoxItem)((ComboBox)sender).SelectedItem).Content.ToString();

            if (selectedValue.ToLower().Contains("point"))
            {
                _targetLayer = (WritableLayer)MapControl.Map.Layers.First(l => l.Name == "PointLayer");
            }
            else if (selectedValue.ToLower().Contains("line"))
            {
                _targetLayer = (WritableLayer)MapControl.Map.Layers.First(l => l.Name == "LineLayer");
            }
            else if (selectedValue.ToLower().Contains("polygon"))
            {
                _targetLayer = (WritableLayer)MapControl.Map.Layers.First(l => l.Name == "PolygonLayer");
            }
            else
            {
                throw new Exception("Unknown ComboBox item");
            }
        }
Пример #17
0
        private Map CreateMap()
        {
            var map = new Map();

            map.Layers.Add(OpenStreetMap.CreateTileLayer());
            var writableLayer = new WritableLayer();

            writableLayer.Add(new Feature());
            writableLayer.Add(new Feature {
                Geometry = new Point()
            });
            writableLayer.Add(new Feature {
                Geometry = new LineString()
            });
            writableLayer.Add(new Feature {
                Geometry = new Polygon()
            });
            map.Layers.Add(writableLayer);

            return(map);
        }
Пример #18
0
        public void DoNotCrashOnNullOrEmptyGeometries()
        {
            // arrange
            var writableLayer = new WritableLayer();

            writableLayer.Add(new Feature());
            writableLayer.Add(new Feature {
                Geometry = new Point()
            });
            writableLayer.Add(new Feature {
                Geometry = new LineString()
            });
            writableLayer.Add(new Feature {
                Geometry = new Polygon()
            });

            // act
            var extents = writableLayer.Envelope;

            // assert
            Assert.IsNull(extents);
        }
 public MapObjectTool(MapControl mapControl, WritableLayer targetLayer)
 {
     this.MapControl  = mapControl;
     this.TargetLayer = targetLayer;
 }
Пример #20
0
 public AttractorTool(MapControl mapControl, WritableLayer targetLayer)
 {
     this.mapControl  = mapControl;
     this.targetLayer = targetLayer;
 }
Пример #21
0
 public void Setup(IMapControl mapControl)
 {
     mapControl.Map   = CreateMap();
     _writableLayer   = (WritableLayer)mapControl.Map.Layers[1];
     mapControl.Info += MapControlOnInfo;
 }
 public PolygonTool(MapControl mapControl, WritableLayer targetLayer)
     : base(mapControl, targetLayer)
 {
 }