Наследование: Layer, ILayerGroup
Пример #1
0
        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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        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");
        }
Пример #4
0
        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");
        }
Пример #5
0
    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])]);
    }
Пример #6
0
    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;
    }
Пример #7
0
        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);
            
        }
Пример #8
0
		/// <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;
		}
Пример #9
0
 private void AddTileLayerToLayerGroup(Tuple<Mock<ILayer>, Mock<ITileAsyncLayer>> tileLayer, LayerGroup group)
 {
     group.Layers.Add(tileLayer.Item1.Object);
 }
Пример #10
0
 private void RemoveTileLayerFromGroup(LayerGroup group, Tuple<Mock<ILayer>, Mock<ITileAsyncLayer>> tileLayer)
 {
     group.Layers.Remove(tileLayer.Item1.Object);
 }
Пример #11
0
 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;
 }
Пример #12
0
        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");
        }
Пример #13
0
        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)));
        }
Пример #14
0
 public void Envelope_NoInnerLayers_ReturnsNull()
 {
     var group = new LayerGroup("group");
     Assert.IsNull(group.Envelope);
 }
Пример #15
0
        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");
        }