private static ILayer GetLayerByNameInternal(string layerName, System.Collections.Generic.IEnumerable <ILayer> lays) { foreach (ILayer layer in lays) { int comparison = String.Compare(layer.LayerName, layerName, StringComparison.CurrentCultureIgnoreCase); if (comparison == 0) { return(layer); } //If this is a layergroup, check sublayers also if (layer is LayerGroup) { LayerGroup lg = layer as LayerGroup; ILayer lay = GetLayerByNameInternal(layerName, ToILayerEnumberable(lg.Layers)); if (lay != null) { return(lay); } } } return(null); }
/// <summary> /// Clones the layer /// </summary> /// <returns>cloned object</returns> public override object Clone() { var clonedLayerGroup = new LayerGroup(name.Clone() as string); foreach (var layer in Layers) { var layerToAdd = layer.Clone() as Layer; clonedLayerGroup.Layers.Add(layerToAdd); } return(clonedLayerGroup); }
public void ReverseCoordinateTransformation_SettingValue_PropagatesTransformation() { var group = new LayerGroup("group"); group.Layers.Add(new DummyLayer()); var transf = CreateTransformation(); group.ReverseCoordinateTransformation = transf; Assert.That(((Layer)group.Layers[0]).ReverseCoordinateTransformation, Is.EqualTo(transf), "LayerGroup.ReverseCoordinateTransformation should propagate to inner layers"); }
public void CoordinateTransformation_SettingValueWhenSkipIsOn_DoesNotPropagateTransformation() { var group = new LayerGroup("group"); group.Layers.Add(new DummyLayer()); var transf = CreateTransformation(); group.SkipTransformationPropagation = true; group.CoordinateTransformation = transf; Assert.That(((Layer)group.Layers[0]).CoordinateTransformation, Is.Not.EqualTo(transf), "LayerGroup.CoordinateTransformation should NOT propagate to inner layers because SkipTransformationPropagation was true"); }
private SharpMap.Layers.ILayer toggleLayer(string id, SharpMap.Map map) { string[] layerId = id.Split(new char[] { '_' }); if (layerId.Length <= 1) { return(map.Layers[Int32.Parse(layerId[0])]); } SharpMap.Layers.LayerGroup myGroup = (map.Layers[Int32.Parse(layerId[0])] as SharpMap.Layers.LayerGroup); for (int i = 1; i < layerId.Length - 1; i++) { myGroup = (myGroup.Layers[Int32.Parse(layerId[i])] as SharpMap.Layers.LayerGroup); } return(myGroup.Layers[Int32.Parse(layerId[layerId.Length - 1])]); }
public static Map InitializeMapGdal(Size size) { HttpContext.Current.Trace.Write("Initializing map..."); //Initialize a new map of size 'imagesize' Map map = new Map(size); //Set up the gdal layer LayerGroup g = new LayerGroup("OS"); g.SRID = 27700; //D:\Raster\Ordnance Survey\OS Street View SM\data\sm System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal")); foreach (System.IO.FileInfo fi in di.GetFiles("*.tif")) { try { SharpMap.Layers.GdalRasterLayer layer = new SharpMap.Layers.GdalRasterLayer( fi.Name, HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal\" + fi.Name)); //layer.SRID = 27700; g.Layers.Add(layer); } catch (TypeInitializationException ex) { if (ex.GetType() == typeof(TypeInitializationException)) throw new Exception( "Please copy the umanaged dll's into your bin folder from javascript:window.location.href='http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=Extensions';."); } } map.Layers.Add(g); map.ZoomToExtents(); HttpContext.Current.Trace.Write("Map initialized"); return map; }
public void Map_GetLayerByNameInGroupLayer() { Map m = new Map(); VectorLayer vlay1 = new VectorLayer("1"); VectorLayer vlay2 = new VectorLayer("2"); VectorLayer vlay3 = new VectorLayer("3"); m.Layers.Add(vlay1); LayerGroup lg = new LayerGroup("Group"); lg.Layers.Add(vlay2); lg.Layers.Add(vlay3); m.Layers.Add(lg); var lay = m.GetLayerByName("1"); Assert.IsNotNull(lay); Assert.AreEqual("1",lay.LayerName); lay = m.GetLayerByName("2"); Assert.IsNotNull(lay); Assert.AreEqual("2", lay.LayerName); lay = m.GetLayerByName("3"); Assert.IsNotNull(lay); Assert.AreEqual("3", lay.LayerName); lay = m.GetLayerByName("Group"); Assert.IsNotNull(lay); Assert.AreEqual("Group", lay.LayerName); }
/// <summary> /// Clones the layer /// </summary> /// <returns>cloned object</returns> public override object Clone() { var clonedLayerGroup = new LayerGroup(name.Clone() as string); foreach (var layer in Layers) { var layerToAdd = layer.Clone() as Layer; clonedLayerGroup.Layers.Add(layerToAdd); } return clonedLayerGroup; }
private void AddTileLayerToLayerGroup(Tuple<Mock<ILayer>, Mock<ITileAsyncLayer>> tileLayer, LayerGroup group) { group.Layers.Add(tileLayer.Item1.Object); }
private void RemoveTileLayerFromGroup(LayerGroup group, Tuple<Mock<ILayer>, Mock<ITileAsyncLayer>> tileLayer) { group.Layers.Remove(tileLayer.Item1.Object); }
private void ReplaceExistingAsyncLayerFromGroup(LayerGroup group, Tuple<Mock<ILayer>, Mock<ITileAsyncLayer>> oldTileLayer, Tuple<Mock<ILayer>, Mock<ITileAsyncLayer>> newTileLayer) { var oldLayer = oldTileLayer.Item1.Object; var idx = group.Layers.IndexOf(oldLayer); group.Layers[idx] = newTileLayer.Item1.Object; }
public void Clone_ClonesTheProperties() { var group = new LayerGroup("group"); group.CoordinateTransformation = CreateTransformation(); group.Enabled = true; group.IsQueryEnabled = true; group.MinVisible = 10; group.MaxVisible = 100; group.SRID = 4326; group.Proj4Projection = "dummy"; group.TargetSRID = 4327; group.Style = new LabelStyle(); var clonedGroup = (LayerGroup)group.Clone(); Assert.That(clonedGroup.CoordinateTransformation, Is.EqualTo(group.CoordinateTransformation), "CoordinateTransformation mismatch"); Assert.That(clonedGroup.Enabled, Is.EqualTo(group.Enabled), "Enabled mismatch"); Assert.That(clonedGroup.IsQueryEnabled, Is.EqualTo(group.IsQueryEnabled), "IsQueryEnabled mismatch"); Assert.That(clonedGroup.MinVisible, Is.EqualTo(group.MinVisible), "MinVisible mismatch"); Assert.That(clonedGroup.MaxVisible, Is.EqualTo(group.MaxVisible), "MaxVisible mismatch"); Assert.That(clonedGroup.SRID, Is.EqualTo(group.SRID), "SRID mismatch"); Assert.That(clonedGroup.Proj4Projection, Is.EqualTo(group.Proj4Projection), "Proj4Projection mismatch"); Assert.That(clonedGroup.TargetSRID, Is.EqualTo(group.TargetSRID), "TargetSRID mismatch"); Assert.That(clonedGroup.Style, Is.EqualTo(group.Style), "Style mismatch"); }
public void Envelope_SomeInnerLayerWithNullEnvelope_SkipNulls() { var group = new LayerGroup("group"); group.Layers.Add(new DummyLayer()); group.Layers.Add(new FooLayer()); Assert.That(group.Envelope, Is.EqualTo(new Envelope(5, 10, 5, 10))); }
public void Envelope_NoInnerLayers_ReturnsNull() { var group = new LayerGroup("group"); Assert.IsNull(group.Envelope); }
public void Envelope_WhenInnerLayerEnvelopeIsNull_ReturnsNull() { var group = new LayerGroup("group"); group.Layers.Add(new DummyLayer()); Assert.That(group.Envelope, Is.Null, "LayerGroup envelope should be null since we added a layer with a null envelope"); }