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


C# SharpMap.Map.WorldToImage方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: InitializeMap

        public static SharpMap.Map InitializeMap(int angle, string[] filenames)
        {
            var map = new SharpMap.Map();
            for (int i = 0; i < filenames.Length; i++)
                map.Layers.Add(new SharpMap.Layers.GdalRasterLayer(System.IO.Path.GetFileName(filenames[i]), filenames[i]));

            System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;
            map.ZoomToExtents();
            return map;
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:12,代码来源:GdalSample.cs

示例5: InitializeMap

        internal static SharpMap.Map InitializeMap(float angle, string[] filenames)
        {
            var map = new SharpMap.Map();

            try
            {
                foreach (var filename in filenames)
                {
                    var connectionString = string.Format("Data Source={0}", filename);
                    foreach (var provider in SharpMap.Data.Providers.SpatiaLite.GetSpatialTables(connectionString))
                    {
                        map.Layers.Add(
                            new SharpMap.Layers.VectorLayer(
                                string.Format("{0} - {1}", provider.Table, provider.GeometryColumn), provider) { Style = LayerTools.GetRandomVectorStyle() });
                    }
                }
                if (map.Layers.Count > 0)
                {
                    map.ZoomToExtents();

                    System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
                    mat.RotateAt(angle, map.WorldToImage(map.Center));
                    map.MapTransform = mat;
                    return map;
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            return null;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:32,代码来源:SpatiaLiteSample.cs

示例6: InitializeMap

        public static SharpMap.Map InitializeMap(float angle)
        {
            //Initialize a new map of size 'imagesize'
            SharpMap.Map map = new SharpMap.Map();

            //Set up the countries layer
            SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries");

            //Set the datasource to a shapefile in the App_data folder
            layCountries.DataSource = new SharpMap.Data.Providers.PostGIS(Properties.Settings.Default.PostGisConnectionString, "countries", "ogc_fid");

            //Set fill-style to green
            layCountries.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
            //Set the polygons to have a black outline
            layCountries.Style.Outline = System.Drawing.Pens.Black;
            layCountries.Style.EnableOutline = true;

            //Set up a river layer
            SharpMap.Layers.VectorLayer layRivers = new SharpMap.Layers.VectorLayer("Rivers");
            //Set the datasource to a shapefile in the App_data folder
            layRivers.DataSource = new SharpMap.Data.Providers.PostGIS(Properties.Settings.Default.PostGisConnectionString, "rivers", "ogc_fid");
            //Define a blue 1px wide pen
            layRivers.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Blue, 1);

            //Set up a river layer
            SharpMap.Layers.VectorLayer layCities = new SharpMap.Layers.VectorLayer("Cities");
            //Set the datasource to a shapefile in the App_data folder
            layCities.DataSource = new SharpMap.Data.Providers.PostGIS(Properties.Settings.Default.PostGisConnectionString, "cities", "ogc_fid");
            layCities.Style.SymbolScale = 0.8f;
            layCities.MaxVisible = 40;

            //Set up a country label layer
            SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Country labels")
            {
                DataSource = layCountries.DataSource,
                Enabled = true,
                LabelColumn = "Name",
                MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest,
                LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection,
                PriorityColumn = "popdens",
                Style = new SharpMap.Styles.LabelStyle()
                {
                    ForeColor = System.Drawing.Color.White,
                    Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 12),
                    BackColor = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, 255, 0, 0)),
                    HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center,
                    CollisionDetection = true,
                    MaxVisible = 90,
                    MinVisible = 30
                }
            };

            //Set up a city label layer
            SharpMap.Layers.LabelLayer layCityLabel = new SharpMap.Layers.LabelLayer("City labels")
            {
                DataSource = layCities.DataSource,
                Enabled = true,
                LabelColumn = "name",
                PriorityColumn = "population",
                PriorityDelegate = delegate(SharpMap.Data.FeatureDataRow fdr)
                {
                    Int32 retVal = 10000000 * (Int32)( (String)fdr["capital"] == "Y" ? 1 : 0 );
                    return  retVal + Convert.ToInt32(fdr["population"]);
                },
                TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias,
                SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias,
                LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection,
                Style = new SharpMap.Styles.LabelStyle()
                {
                    ForeColor = System.Drawing.Color.White,
                    Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 11),
                    MaxVisible = layLabel.MinVisible,
                    HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left,
                    VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom,
                    Offset = new System.Drawing.PointF(3, 3),
                    Halo = new System.Drawing.Pen(System.Drawing.Color.Black, 2),
                    CollisionDetection = true
                }
            };

            //Add the layers to the map object.
            //The order we add them in are the order they are drawn, so we add the rivers last to put them on top
            map.Layers.Add(layCountries);
            map.Layers.Add(layRivers);
            map.Layers.Add(layCities);
            map.Layers.Add(layLabel);
            map.Layers.Add(layCityLabel);

            //limit the zoom to 360 degrees width
            map.MaximumZoom = 360;
            map.BackColor = System.Drawing.Color.LightBlue;

            map.ZoomToExtents(); // = 360;
            map.Center = new GeoAPI.Geometries.Coordinate(0, 0);

            Matrix mat = new Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;

            return map;
//.........这里部分代码省略.........
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:101,代码来源:PostGisSample.cs

示例7: InitializeGeoTiff

        private static SharpMap.Map InitializeGeoTiff(int index, float angle)
        {
            try
            {
                //Sample provided by Dan Brecht and Joel Wilson
                var map = new SharpMap.Map();
                map.BackColor = System.Drawing.Color.White;
                const string relativePath = "GeoData/GeoTiff/";

                SharpMap.Layers.GdalRasterLayer layer;

                switch (index)
                {
                    case 2:
                        layer = new SharpMap.Layers.GdalRasterLayer("GeoTiff", relativePath + "utm.tif");
                        layer.UseRotation = true;
                        map.Layers.Add(layer);
                        break;
                    case 3:
                        layer = new SharpMap.Layers.GdalRasterLayer("GeoTiff", relativePath + "utm.jp2");
                        layer.UseRotation = true;
                        map.Layers.Add(layer);
                        break;

                    case 4:
                        layer = new SharpMap.Layers.GdalRasterLayer("GeoTiff", relativePath + "world_raster_mod.tif");
                        layer.UseRotation = true;
                        map.Layers.Add(layer);
                        break;

                    default:
                        if (!System.IO.File.Exists(relativePath + "format01-image_a.tif"))
                        {
                            throw new System.Exception("Make sure the data is in the relative directory: " + relativePath);
                        }

                        layer = new SharpMap.Layers.GdalRasterLayer("GeoTiffA", relativePath + "format01-image_a.tif");
                        map.Layers.Add(layer);
                        layer = new SharpMap.Layers.GdalRasterLayer("GeoTiffB", relativePath + "format01-image_b.tif");
                        map.Layers.Add(layer);
                        layer = new SharpMap.Layers.GdalRasterLayer("GeoTiffC", relativePath + "format01-image_c.tif");
                        map.Layers.Add(layer);
                        layer = new SharpMap.Layers.GdalRasterLayer("GeoTiffD", relativePath + "format01-image_d.tif");
                        map.Layers.Add(layer);

                        SharpMap.Layers.VectorLayer shapeLayer;

                        if (!System.IO.File.Exists(relativePath + "outline.shp"))
                        {
                            throw new System.Exception("Make sure the data is in the relative directory: " + relativePath);
                        }

                        shapeLayer = new SharpMap.Layers.VectorLayer("outline", new SharpMap.Data.Providers.ShapeFile(relativePath + "outline.shp"));
                        shapeLayer.Style.Fill = System.Drawing.Brushes.Transparent;
                        shapeLayer.Style.Outline = System.Drawing.Pens.Black;
                        shapeLayer.Style.EnableOutline = true;
                        shapeLayer.Style.Enabled = true;
                        map.Layers.Add(shapeLayer);
                        break;
                }

                map.ZoomToExtents();

                System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
                mat.RotateAt(angle, map.WorldToImage(map.Center));
                map.MapTransform = mat;

                if (_num > 5) _num = 1;
                _gdalSampleDataset = "GeoTiff" + _num;
                return map;
            }
            catch (System.TypeInitializationException ex)
            {
                if (ex.Message == "The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception.")
                {
                    throw new System.Exception(
                        string.Format(
                            "The application threw a PINVOKE exception. You probably need to copy the unmanaged dll's to your bin directory. They are a part of fwtools {0}. You can download it from: http://home.gdal.org/fwtools/",
                            SharpMap.Layers.GdalRasterLayer.FWToolsVersion));
                }
                throw;
            }
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:83,代码来源:GdalSample.cs

示例8: InitializeVRT

        private static SharpMap.Map InitializeVRT(ref int index, float angle)
        {
            SharpMap.Map map = new SharpMap.Map();
            int ind = index - 6;
            if (ind >= Vrts.Length) ind = 0;

            if (!System.IO.File.Exists(RelativePath + Vrts[ind]))
            {
                throw new System.Exception("Make sure the data is in the relative directory: " + RelativePath);
            }

            SharpMap.Layers.GdalRasterLayer layer = new SharpMap.Layers.GdalRasterLayer("VirtualRasterTable", RelativePath + Vrts[ind]);

            var ext = System.IO.Path.GetExtension(layer.Filename);
            map.Layers.Add(layer);
            _gdalSampleDataset = string.Format("'{0}'", ext != null ? ext.ToUpper() : string.Empty);
            map.ZoomToExtents();

            System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;
            //index++;
            return map;
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:24,代码来源:GdalSample.cs

示例9: WorldToMap_DefaultMap_ReturnValue

		public void WorldToMap_DefaultMap_ReturnValue()
		{
			SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(500,200));
			map.Center = new SharpMap.Geometries.Point(23, 34);
			map.Zoom = 1000;
			System.Drawing.PointF p = map.WorldToImage(new SharpMap.Geometries.Point(8, 50));
			Assert.AreEqual(new System.Drawing.PointF(242.5f, 92), p);
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:MapTest.cs


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