当前位置: 首页>>代码示例>>C#>>正文


C# SharpMap.Map类代码示例

本文整理汇总了C#中SharpMap.Map的典型用法代码示例。如果您正苦于以下问题:C# SharpMap.Map类的具体用法?C# SharpMap.Map怎么用?C# SharpMap.Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SharpMap.Map类属于命名空间,在下文中一共展示了SharpMap.Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeMap

        public static SharpMap.Map InitializeMap(float angle)
        {
            var dataSource = new SharpMap.Data.Providers.ShapeFile(
                string.Format("{0}/roads.shp", ShapefileSample.PathOsm), true);
            
            var fds = new SharpMap.Data.FeatureDataSet();
            dataSource.Open();
            dataSource.ExecuteIntersectionQuery(dataSource.GetExtents(), fds);
            dataSource.Close();

            var gfp = new SharpMap.Data.Providers.GeometryFeatureProvider(fds.Tables[0]);
            var vl = new SharpMap.Layers.VectorLayer("roads", gfp)
                         {
                             CoordinateTransformation = LayerTools.Dhdn2ToWgs84
                         };
            var ll = new SharpMap.Layers.LabelLayer("labels")
                         {
                             DataSource = gfp,
                             CoordinateTransformation = LayerTools.Dhdn2ToWgs84,
                             LabelColumn = "name",
                             MultipartGeometryBehaviour =
                                 SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest,
                         };
            ll.Style.Halo = new System.Drawing.Pen(System.Drawing.Color.Red);
            //ll.Style.IgnoreLength = true;

            var map = new SharpMap.Map();
            map.Layers.Add(vl);
            map.Layers.Add(ll);

            map.Layers.Add(vl);
            map.ZoomToExtents();
            return map;
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:34,代码来源:GeometryFeatureProviderSample.cs

示例2: render2d

        public void render2d(Project project, PictureBox picBox)
        {

            SharpMap.Map myMap = new SharpMap.Map();

            foreach (BuildLayer layer in project.getLayers())
            {
                Source source = layer.getSource();

                BoundingBox envelope = new BoundingBox(-1000.0, -1000.0, 1000.0, 1000.0);//TODO
                FeatureDataSet ds = new FeatureDataSet();
                source.DataSource.Open();
                source.DataSource.ExecuteIntersectionQuery(envelope, ds);
                source.DataSource.Close();

                FeatureDataTable features = (FeatureDataTable)ds.Tables[0];

                string label = "Trace test:\n";

                foreach (FeatureDataRow row in features)
                {
                    foreach (Object item in row.ItemArray)
                        label += " - " + item;
                    label += "\n";
                }

                setLabel(label);

                //Show map

                //Filters
                FilterGraph graph = project.getFilterGraph(source.getName());
                if (graph != null)
                {
                    foreach (FeatureFilter filter in graph.getFilters())
                    {
                        //aplicar filtro segun el tipo
                        Mogre.DefaultSceneManagerFactory dsmf = new DefaultSceneManagerFactory();
                        Mogre.SceneManager sm = dsmf.CreateInstance("scenemanager");
                        FilterEnv env = new FilterEnv(sm, "env");
                        foreach (MogreGis.Resource resource in project.getResources())
                        {
                            env.getSession().Resources.addResource(resource);
                        }
                        FeatureList list = Feature.DataTableToList(features);
                        filter.process(list, env);
                        //falta devolver la lista y procesarla ***************************************
                    }
                }

                SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer(layer.getName());
                myLayer.DataSource = source.DataSource;
                myMap.Layers.Add(myLayer);
            }

            myMap.Size = new Size(picBox.Width, picBox.Height);
            myMap.ZoomToExtents();
            picBox.Image = myMap.GetMap();
            this.map = myMap;
        }
开发者ID:agustinsantos,项目名称:mogregis3d,代码行数:60,代码来源:RenderProject.cs

示例3: TestCharacterPointSymbolizer

        public void TestCharacterPointSymbolizer()
        {
            var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
                TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var cps  = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
                                              {
                                                  Halo = 1,
                                                  HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Wheat),
                                                  //Font = new System.Drawing.Font("Arial", 12),
                                                  CharacterIndex = 0xcc,
                                              };
            layer.Style.PointSymbolizer = cps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));

            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("CharacterPointSymbolizer1.bmp");

            cps.Rotation = -30;
            cps.Offset = new System.Drawing.PointF(4, 4);
            map.GetMap().Save("CharacterPointSymbolizer2.bmp");

            cps.Font = new System.Drawing.Font("Arial", 12);
            cps.Text = "ABC";
            cps.Offset = System.Drawing.PointF.Empty;
            cps.Rotation = -90;
            map.GetMap().Save("CharacterPointSymbolizer3.bmp");
        }
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:30,代码来源:PointSymbolizerTest.cs

示例4: TestListPointSymbolizer

        public void TestListPointSymbolizer()
        {
            var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
                TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var pps =
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
                                                                    new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.DodgerBlue), 20);

            var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
            {
                Halo = 1,
                HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke),
                Foreground = new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                Font = new System.Drawing.Font("Arial", 12),
                CharacterIndex = 65
            };

            var lps = new SharpMap.Rendering.Symbolizer.ListPointSymbolizer { pps, cps };

            layer.Style.PointSymbolizer = lps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("ListPointSymbolizer1.bmp");
        }
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:28,代码来源:PointSymbolizerTest.cs

示例5: Example2

        public static void Example2()
        {
            var map = new SharpMap.Map(new Size(1280, 1084));

            SharpMap.Data.Providers.IProvider provider =
                new SharpMap.Data.Providers.ShapeFile(
                    @"C:\temp\Data\niedersachsen.shp\railways.shp");

            var style = new SharpMap.Styles.VectorStyle();
            style.Line.Brush = Brushes.White;
            style.Line.DashPattern = new float[] { 4f, 4f };
            style.Line.Width = 4;
            style.EnableOutline = true;
            style.Outline.Brush = Brushes.Black;
            style.Outline.Width = 6;

            var vl = new SharpMap.Layers.VectorLayer("Railways", provider)
                         {Style = style};


            map.Layers.Add(vl);

            var env = vl.Envelope;
            env.ExpandBy(-0.45f *env.Width, -0.45 * env.Height);
            
            map.ZoomToBox(env);

            var mapImage = map.GetMap();
            mapImage.Save("Example2.png",
                System.Drawing.Imaging.ImageFormat.Png);
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:31,代码来源:Examples.cs

示例6: TestSymbolSelectionTheming

        public void TestSymbolSelectionTheming()
        {
            //Create a map
            SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720, 360));

            //Create some random sample data
            SharpMap.Data.FeatureDataTable fdt =
                cd.CreatePointFeatureDataTableFromArrays(cd.GetRandomOrdinates(80, -180, 180),
                                                         cd.GetRandomOrdinates(80, -90, 90), null);

            //Add rotation column and fill with random rotation values
            fdt.Columns.Add("Symbol", typeof(System.Byte[]));
            foreach (SharpMap.Data.FeatureDataRow row in fdt.Rows)
                row["Symbol"] = RandomSymbol((int)System.Math.Floor(cd.RandomNumberGenerator.NextDouble() * 360d));

            //Create layer and datasource
            SharpMap.Layers.VectorLayer vl = new SharpMap.Layers.VectorLayer("Points", new SharpMap.Data.Providers.GeometryFeatureProvider(fdt));

            //Create default style
            SharpMap.Styles.VectorStyle defaultStyle = new SharpMap.Styles.VectorStyle();
            defaultStyle.Symbol = new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png");
            defaultStyle.SymbolScale = 0.5f;

            //Create theming class and apply to layer
            SymbolFromFeatureDataRowTheming srt = new SymbolFromFeatureDataRowTheming("Symbol", defaultStyle);
            vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(srt.GetRotatedSymol);

            map.Layers.Add(vl);
            map.ZoomToExtents();
            System.Drawing.Image mapImage = map.GetMap();
            mapImage.Save("SymbolFromFDR.bmp");
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:32,代码来源:Theming.cs

示例7: MainWindow

        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            try
            {
                GeoAPI.GeometryServiceProvider.Instance = new NtsGeometryServices();

                Build();

                Size mapSize = new Size(800, 500);
                myMap = new SharpMap.Map(mapSize);

                SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();
                style.Outline = new Pen(Color.Green, 1);
                style.EnableOutline = true;
                SharpMap.Layers.VectorLayer layWorld = new SharpMap.Layers.VectorLayer("States");
                layWorld.DataSource =
                    new SharpMap.Data.Providers.ShapeFile(
                        @"data" + System.IO.Path.DirectorySeparatorChar + @"states.shp", true);
                layWorld.Style = style;

                myMap.Layers.Add(layWorld);
                myMap.MaximumZoom = 360;
                myMap.BackColor = Color.LightBlue;
                myMap.Center = new GeoAPI.Geometries.Coordinate(0, 0);
                myMap.Zoom = 360;

                Bitmap img = (Bitmap)myMap.GetMap();
                image3.Pixbuf = ImageToPixbuf(img);
            }
            catch (Exception ex)
            {
                label1.Text = ex.Message;
            }
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:35,代码来源:MainWindow.cs

示例8: InitializeMap

        public static SharpMap.Map InitializeMap(float angle)
        {
            using (var ofn = new System.Windows.Forms.OpenFileDialog())
            {
                ofn.Filter = "All files|*.*";
                ofn.FilterIndex = 0;

                if (ofn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var m = new SharpMap.Map();
                    var l = new SharpMap.Layers.GdiImageLayer(ofn.FileName);
                    m.Layers.Add(l);

                    m.ZoomToExtents();

                    var mat = new System.Drawing.Drawing2D.Matrix();
                    mat.RotateAt(angle, m.WorldToImage(m.Center));
                    m.MapTransform = mat;
                    m.MaximumExtents = m.GetExtents();
                    m.EnforceMaximumExtents = true;
                    return m;
                }
            }
            return null;

        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:26,代码来源:GdiImageLayerSample.cs

示例9: TestPathPointSymbolizer

        public void TestPathPointSymbolizer()
        {
            var fdt = CreatingData.CreatePointFeatureDataTableFromArrays(
                CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var pps =
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
                                                                    new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.DodgerBlue), 20);
            layer.Style.PointSymbolizer = pps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("PathPointSymbolizer1.bmp");

            pps.Rotation = -30;
            map.GetMap().Save("PathPointSymbolizer2.bmp");

            pps.Rotation = 0f;
            pps.Offset = new System.Drawing.PointF(4, 4);
            map.GetMap().Save("PathPointSymbolizer3.bmp");

            var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath();
            gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), });
            var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath();
            gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), });
            pps = new
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer(new[]
                                                        {
                                                            new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
                                                                {
                                                                    Path = gpTriangle1,
                                                                    Line =
                                                                        new System.Drawing.Pen(
                                                                        System.Drawing.Color.Red, 2),
                                                                    Fill =
                                                                        new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.DodgerBlue)
                                                                },
                                                            new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
                                                                {
                                                                    Path = gpTriangle2,
                                                                    Line =
                                                                        new System.Drawing.Pen(
                                                                        System.Drawing.Color.DodgerBlue, 2),
                                                                    Fill =
                                                                        new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.Red)
                                                                }

                                                        }){ Rotation = 45 };

            layer.Style.PointSymbolizer = pps;
            map.GetMap().Save("PathPointSymbolizer4.bmp");
            pps.Rotation = 180;
            map.GetMap().Save("PathPointSymbolizer5.bmp");

        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:59,代码来源:PointSymbolizerTest.cs

示例10: InitializeMapOsm

        private static SharpMap.Map InitializeMapOsm()
        {
            var map = new SharpMap.Map();

            var tileLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.OsmTileSource(), "TileLayer - OSM");
            map.BackgroundLayer.Add(tileLayer);
            map.ZoomToBox(tileLayer.Envelope);
            
            return map;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:TileLayerSample.cs

示例11: OnInvokeSharpMapLayerDialog

        private void OnInvokeSharpMapLayerDialog(object sender, EventArgs e)
        {
            var map = new SharpMap.Map();
            var ts = new BruTile.Web.OsmTileSource();
            var tl = new SharpMap.Layers.TileLayer(ts, "OSM");
            map.Layers.Add(tl);

            var sml = new SharpMapLayer(map);
            App.Map.Layers.Add(sml);
        }
开发者ID:haoas,项目名称:DotSpatial.Plugins,代码行数:10,代码来源:SharpMapLayerPlugin.cs

示例12: GetLayerByName_Indexer

        public void GetLayerByName_Indexer()
        {
            SharpMap.Map map = new SharpMap.Map();
            map.Layers.Add(new SharpMap.Layers.VectorLayer("Layer 1"));
            map.Layers.Add(new SharpMap.Layers.VectorLayer("Layer 3"));
            map.Layers.Add(new SharpMap.Layers.VectorLayer("Layer 2"));

            SharpMap.Layers.ILayer layer = map.Layers["Layer 2"];
            Assert.IsNotNull(layer);
            Assert.AreEqual("Layer 2", layer.LayerName);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:11,代码来源:MapTest.cs

示例13: WorldToImage

		public void WorldToImage()
		{
			SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(1000, 500));
			map.Zoom = 360;
			map.Center = new SharpMap.Geometries.Point(0, 0);
			Assert.AreEqual(new System.Drawing.PointF(500, 250), map.WorldToImage(new SharpMap.Geometries.Point(0, 0)));
			Assert.AreEqual(new System.Drawing.PointF(0, 0), map.WorldToImage(new SharpMap.Geometries.Point(-180, 90)));
			Assert.AreEqual(new System.Drawing.PointF(0, 500), map.WorldToImage(new SharpMap.Geometries.Point(-180, -90)));
			Assert.AreEqual(new System.Drawing.PointF(1000, 0), map.WorldToImage(new SharpMap.Geometries.Point(180, 90)));
			Assert.AreEqual(new System.Drawing.PointF(1000, 500), map.WorldToImage(new SharpMap.Geometries.Point(180, -90)));
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:11,代码来源:MapTest.cs

示例14: WorldToImage

		public void WorldToImage()
		{
			SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(1000, 500));
			map.Zoom = 360;
			map.Center = GeometryFactory.CreateCoordinate(0, 0);
			Assert.AreEqual(new System.Drawing.PointF(500, 250), map.WorldToImage(GeometryFactory.CreateCoordinate(0, 0)));
			Assert.AreEqual(new System.Drawing.PointF(0, 0), map.WorldToImage(GeometryFactory.CreateCoordinate(-180, 90)));
			Assert.AreEqual(new System.Drawing.PointF(0, 500), map.WorldToImage(GeometryFactory.CreateCoordinate(-180, -90)));
			Assert.AreEqual(new System.Drawing.PointF(1000, 0), map.WorldToImage(GeometryFactory.CreateCoordinate(180, 90)));
			Assert.AreEqual(new System.Drawing.PointF(1000, 500), map.WorldToImage(GeometryFactory.CreateCoordinate(180, -90)));
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:11,代码来源:MapTest.cs

示例15: MapImage

		/// <summary>
		/// Initializes a new map
		/// </summary>
		public MapImage()
		{
			_Map = new SharpMap.Map(base.Size);
			_Activetool = Tools.None;
			base.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MapImage_MouseMove);
			base.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MapImage_MouseUp);
			base.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MapImage_MouseDown);
			base.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.MapImage_Wheel);
			this.Cursor = Cursors.Cross;
			this.DoubleBuffered = true;
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:MapImage.cs


注:本文中的SharpMap.Map类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。