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(); }
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"); }
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])); }
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; }
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); }
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); }
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); }
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)); }
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); }
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; }
public void InitializationTest() { DataTableFeatureProvider gp = new DataTableFeatureProvider("LINESTRING(20 20,40 40)"); Assert.AreEqual(1, gp.Geometries.Count); }
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); }
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); }
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(); }