コード例 #1
0
ファイル: SelectToolTest.cs プロジェクト: lishxi/_SharpMap
        public void ClearSelectionOnParentGroupLayerRemove()
        {
            var featureProvider = new DataTableFeatureProvider();
            featureProvider.Add(new WKTReader().Read("POINT(0 0)"));
            var layer = new VectorLayer { DataSource = featureProvider };
            var groupLayer = new GroupLayer { Layers = { layer } };

            using (var mapControl = new MapControl { Map = { Layers = { groupLayer } }, AllowDrop = false })
            {
                var selectTool = mapControl.SelectTool;

                selectTool.Select(featureProvider.Features.Cast<IFeature>());

                WindowsFormsTestHelper.Show(mapControl);

                mapControl.Map.Layers.Remove(groupLayer);

                mapControl.WaitUntilAllEventsAreProcessed();

                selectTool.Selection
                    .Should("selection is cleared on layer remove").Be.Empty();
            }

            WindowsFormsTestHelper.CloseAll();
        }
コード例 #2
0
        public void SetAttributes()
        {
            Collection<IGeometry> geometries = new Collection<IGeometry>();
            
            geometries.Add(GeometryFromWKT.Parse("LINESTRING (20 20, 20 30, 30 30, 30 20, 40 20)"));
            geometries.Add(GeometryFromWKT.Parse("LINESTRING (21 21, 21 31, 31 31, 31 21, 41 21)"));
            geometries.Add(GeometryFromWKT.Parse("LINESTRING (22 22, 22 32, 32 32, 32 22, 42 22)"));

            DataTableFeatureProvider dataTableFeatureFeatureProvider = new DataTableFeatureProvider(geometries);


            VectorLayer vectorLayer = new VectorLayer();
            vectorLayer.DataSource = dataTableFeatureFeatureProvider;

            // add column
            FeatureDataRow r = (FeatureDataRow)vectorLayer.DataSource.GetFeature(0);
            r.Table.Columns.Add("Value", typeof(float));

            // set value attribute
            for (int i = 0; i < dataTableFeatureFeatureProvider.GetFeatureCount(); i++)
            {
                r = (FeatureDataRow)dataTableFeatureFeatureProvider.GetFeature(i);
                r[0] = i;
            }

            FeatureDataRow row = (FeatureDataRow)dataTableFeatureFeatureProvider.GetFeature(2);
            Assert.AreEqual(2, row[0], "Attribute 0 in the second feature must be set to 2");
        }
コード例 #3
0
        public void Contains()
        {
            var provider = new DataTableFeatureProvider("LINESTRING(20 20,40 40)");

            Assert.IsFalse(provider.Contains(mocks.Stub<IFeature>()));
            Assert.IsTrue(provider.Contains((IFeature) provider.Features[0]));
        }
コード例 #4
0
ファイル: SnapTool.cs プロジェクト: lishxi/_SharpMap
        public SnapTool()
        {
            activeTracker = TrackerSymbolHelper.GenerateSimple(new Pen(Color.DarkGreen),
                                                               new SolidBrush(Color.Orange), 8, 8);
            Failed = true;
            snapLayer.Name = "snapping";
            
            var provider = new DataTableFeatureProvider(geometries);
            snapLayer.DataSource = provider;
            snapLayer.Style.Line = new Pen(Color.DarkViolet, 2);
            snapLayer.Style.Fill = new SolidBrush(Color.FromArgb(127, Color.DarkSlateBlue));
            snapLayer.Style.Symbol = activeTracker;
            provider.Attributes.Columns.Add("id", typeof(string));

            var iTheme = new Rendering.Thematics.CustomTheme(GetTrackerStyle);
            snapLayer.Theme = iTheme;
        }
コード例 #5
0
ファイル: GdalProviderTest.cs プロジェクト: lishxi/_SharpMap
        public void ReadGdalRasterLayer()
        {
            var map = new Map {Name = "map1"};

            var provider = new DataTableFeatureProvider("LINESTRING(90 0,100 0,100 90)");
            var vectorLayer = new VectorLayer("test", provider);
            map.Layers.Add(vectorLayer);

            string fileName = DataPath + "wsiearth.tif";
            var rasterLayer = new RegularGridCoverageLayer();
            var rasterFeatureProvider = new GdalFeatureProvider {Path = fileName};

            rasterLayer.DataSource = rasterFeatureProvider;
            rasterLayer.CustomRenderers.Add(new GdalRenderer(rasterLayer)); // add optimized custom gdal renderer

            map.Layers.Add(rasterLayer);
            MapTestHelper.ShowModal(map);
        }
コード例 #6
0
ファイル: NewArrowLineTool.cs プロジェクト: lishxi/_SharpMap
        private void AddDrawingLayer()
        {
            newArrowLineLayer = new VectorLayer(VectorLayer)
                                    {
                                        RenderRequired = true,
                                        Name = "newArrowLine",
                                        Map = VectorLayer.Map,
                                        Style =
                                            {
                                                Line =
                                                    {
                                                        StartCap = LineCap.Round,
                                                        EndCap = LineCap.ArrowAnchor
                                                    }
                                            }
                                    };

            var trackingProvider = new DataTableFeatureProvider(newArrowLineGeometry);
            newArrowLineLayer.DataSource = trackingProvider;
            MapControlHelper.PimpStyle(newArrowLineLayer.Style, true);
        }
コード例 #7
0
ファイル: MapTest.cs プロジェクト: lishxi/_SharpMap
        public void AddingALayerShouldCauseZoomToExtendsIfNoValidExtendsBefore()
        {
            var map = new Map(new Size(10, 100))
            {
                Center = GeometryFactory.CreateCoordinate(90, 900)
            };
            
            //now add a layer with defined extends 
            var geometry = GeometryFromWKT.Parse("LINESTRING (20 20, 20 30, 30 30, 30 20, 40 20)");
            var dataSource = new DataTableFeatureProvider(geometry);

            var vectorLayerWithExtends = new VectorLayer("Layer with extends") {DataSource = dataSource};
            map.Layers.Add(vectorLayerWithExtends);
            
            Assert.AreEqual(new Envelope(19,41,-85,135) ,map.Envelope);

        }
コード例 #8
0
ファイル: MapTest.cs プロジェクト: lishxi/_SharpMap
        public void DefaultExtentForVectorLayer()
        {
            var geometry = GeometryFromWKT.Parse("LINESTRING (20 20, 20 30, 30 30, 30 20, 40 20)");
            var provider = new DataTableFeatureProvider(geometry);
            var map = new Map
                          {
                              Layers = {new VectorLayer {DataSource = provider}}
                          };

            Assert.IsTrue(map.GetExtents().Contains(geometry.EnvelopeInternal));
        }
コード例 #9
0
ファイル: NewLineTool.cs プロジェクト: lishxi/_SharpMap
        private void AddDrawingLayer()
        {
            newLineLayer = new VectorLayer((VectorLayer)Layer)
                               {
                                   RenderRequired = true,
                                   Name = "newLine",
                                   Map = Layer.Map
                               };

            DataTableFeatureProvider trackingProvider = new DataTableFeatureProvider(newLineGeometry);
            newLineLayer.DataSource = trackingProvider;
            MapControlHelper.PimpStyle(newLineLayer.Style, true);
        }
コード例 #10
0
        private void AddDrawingLayer()
        {
            newNetworkFeatureLayer = new VectorLayer(VectorLayer) { Name = "newNetworkFeature", Map = VectorLayer.Map };

            DataTableFeatureProvider trackingProvider = new DataTableFeatureProvider(newNetworkFeatureGeometry);
            newNetworkFeatureLayer.DataSource = trackingProvider;

            networkFeatureStyle = (VectorStyle)newNetworkFeatureLayer.Style.Clone();
            errorNetworkFeatureStyle = (VectorStyle)newNetworkFeatureLayer.Style.Clone();
            MapControlHelper.PimpStyle(networkFeatureStyle, true);
            MapControlHelper.PimpStyle(errorNetworkFeatureStyle, false);
            newNetworkFeatureLayer.Style = networkFeatureStyle;
        }
コード例 #11
0
 public void InitializationTest()
 {
     DataTableFeatureProvider gp = new DataTableFeatureProvider("LINESTRING(20 20,40 40)");
     Assert.AreEqual(1, gp.Geometries.Count);
 }
コード例 #12
0
ファイル: VectorLayerTest.cs プロジェクト: lishxi/_SharpMap
        public void DoNotRenderLabelsForVectorLayerFeaturesWhenLabelsAreNotVisible()
        {
            var featureProvider = new DataTableFeatureProvider();
            featureProvider.Add(new WKTReader().Read("POINT(0 0)"));
            featureProvider.Add(new WKTReader().Read("POINT(100 100)"));

            var layer = new VectorLayer
                            {
                                DataSource = featureProvider
                            };

            // make label layer use delegate so that we can check if it renders
            var callCount = 0;
            layer.LabelLayer.LabelStringDelegate = delegate(IFeature feature)
                                                       {
                                                           callCount++;
                                                           return feature.ToString();
                                                       };

            var map = new Map {Layers = {layer}, Size = new Size(1000, 1000)};
            map.Render();

            callCount
                .Should("labels are not rendered when label layer is not visible").Be.EqualTo(0);
        }
コード例 #13
0
ファイル: VectorLayerTest.cs プロジェクト: lishxi/_SharpMap
        public void RenderLabelsForVectorLayerFeatures()
        {
            var featureProvider = new DataTableFeatureProvider();
            featureProvider.Add(new WKTReader().Read("POINT(0 0)"));
            featureProvider.Add(new WKTReader().Read("POINT(100 100)"));

            var layer = new VectorLayer
                            {
                                DataSource = featureProvider,
                                LabelLayer = { Visible = true } // set labels on, happens in ThemeEditorDialog
                            };

            // make label layer use delegate so that we can check if it renders
            var callCount = 0;
            layer.LabelLayer.LabelStringDelegate = delegate(IFeature feature)
                                                       {
                                                           callCount++;
                                                           return feature.ToString();
                                                       };


            var map = new Map { Layers = { layer }, Size = new Size(1000, 1000) };
            map.Render();

            callCount
                .Should("labels are rendered for 2 features of the vector layer").Be.EqualTo(2);
        }
コード例 #14
0
ファイル: VectorLayerTest.cs プロジェクト: lishxi/_SharpMap
        public void NoExceptionShouldBeThrownWhenZoomLevelIsTooLarge()
        {
            var featureProvider = new DataTableFeatureProvider();
            featureProvider.Add(new WKTReader().Read("LINESTRING(0 0,80000000 0)"));
            featureProvider.Add(new WKTReader().Read("POINT(50000000 0)"));
            var layer = new VectorLayer { DataSource = featureProvider };
            var map = new Map { Layers = { layer }, Size = new Size(1000, 1000) };
            map.Render();
            map.ZoomToFit(new Envelope(50000000, 50000001, 0, 1));

            map.Render();
        }