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


C# Envelope.TopLeft方法代码示例

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


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

示例1: GetBitmap

        public override Bitmap GetBitmap(int x, int y, Envelope envelope, int zoom)
        {
            var ts = TileSource;
            if (ts == null) return null;

            var zoomS = zoom.ToString(CultureInfo.InvariantCulture);
            try
            {
                var index = new TileIndex(x, y, zoom.ToString(CultureInfo.InvariantCulture));
                var tc = TileCache;
                var bytes = tc != null ? tc.Find(index) : null;
                if (bytes == null)
                {
                    var mapVertices = new[]
                    {
                        envelope.TopLeft().X, envelope.TopLeft().Y,
                        envelope.BottomRight().X, envelope.BottomRight().Y
                    };
                    double[] viewExtentZ = { 0.0, 0.0 };
                    Reproject.ReprojectPoints(mapVertices, viewExtentZ, Wgs84Proj, _data.CrsProjectionInfo, 0, mapVertices.Length / 2);
                    var geogEnv = new Envelope(mapVertices[0], mapVertices[2], mapVertices[1], mapVertices[3]);
                    bytes = ts.Provider.GetTile(new TileInfo {Extent = ToBrutileExtent(geogEnv), Index = index});
                    var bm = new Bitmap(new MemoryStream(bytes));
                    if (tc != null)
                    {
                        tc.Add(index, bytes);
                    }
                    return bm;
                }
                return new Bitmap(new MemoryStream(bytes));
            }
            catch (Exception ex)
            {
                if (ex is WebException ||
                    ex is TimeoutException)
                {
                    return ExceptionToBitmap(ex, TileSource.Schema.GetTileWidth(zoomS), TileSource.Schema.GetTileHeight(zoomS));
                }
                Debug.WriteLine(ex.Message);
            }
            return null;
        }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:42,代码来源:WmsServiceProvider.cs

示例2: GetTiles

        public Tile[,] GetTiles(Envelope envelope, Rectangle bounds)
        {
            Coordinate mapTopLeft = envelope.TopLeft();
            Coordinate mapBottomRight = envelope.BottomRight();

            //Clip the coordinates so they are in the range of the web mercator projection
            mapTopLeft.Y = TileCalculator.Clip(mapTopLeft.Y, TileCalculator.MinLatitude, TileCalculator.MaxLatitude);
            mapTopLeft.X = TileCalculator.Clip(mapTopLeft.X, TileCalculator.MinLongitude, TileCalculator.MaxLongitude);

            mapBottomRight.Y = TileCalculator.Clip(mapBottomRight.Y, TileCalculator.MinLatitude, TileCalculator.MaxLatitude);
            mapBottomRight.X = TileCalculator.Clip(mapBottomRight.X, TileCalculator.MinLongitude, TileCalculator.MaxLongitude);

            int zoom = TileCalculator.DetermineZoomLevel(envelope, bounds);

            Point topLeftTileXY = TileCalculator.LatLongToTileXY(mapTopLeft, zoom);
            Point btmRightTileXY = TileCalculator.LatLongToTileXY(mapBottomRight, zoom);

            var tileMatrix = new Tile[(int)(btmRightTileXY.X - topLeftTileXY.X) + 1, (int)(btmRightTileXY.Y - topLeftTileXY.Y) + 1];

            Parallel.For((int) topLeftTileXY.Y, (int) btmRightTileXY.Y + 1,
                         y => Parallel.For((int) topLeftTileXY.X, (int) btmRightTileXY.X + 1,
                                           x =>
                                               {
                                                   var currTopLeftPixXY = TileCalculator.TileXYToTopLeftPixelXY(x, y);
                                                   var currTopLeftCoord =TileCalculator.PixelXYToLatLong((int) currTopLeftPixXY.X,
                                                                                       (int) currTopLeftPixXY.Y, zoom);

                                                   var currBtmRightPixXY = TileCalculator.TileXYToBottomRightPixelXY(x,
                                                                                                                     y);
                                                   var currBtmRightCoord =TileCalculator.PixelXYToLatLong((int) currBtmRightPixXY.X,
                                                                                       (int) currBtmRightPixXY.Y, zoom);

                                                   var currEnv = new Envelope(currTopLeftCoord, currBtmRightCoord);

                                                   var tile = GetTile(x, y, currEnv, zoom);
                                                   tileMatrix[x - (int) topLeftTileXY.X, y - (int) topLeftTileXY.Y] =tile;
                                               }
                                  ));

            return tileMatrix;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:41,代码来源:TileManager.cs

示例3: GetTiles

        public Tiles GetTiles(Envelope envelope, Rectangle bounds, BackgroundWorker bw)
        {
            var mapTopLeft = envelope.TopLeft();
            var mapBottomRight = envelope.BottomRight();

            //Clip the coordinates so they are in the range of the web mercator projection
            mapTopLeft.Y = TileCalculator.Clip(mapTopLeft.Y, TileCalculator.MinLatitude, TileCalculator.MaxLatitude);
            mapTopLeft.X = TileCalculator.Clip(mapTopLeft.X, TileCalculator.MinLongitude, TileCalculator.MaxLongitude);

            mapBottomRight.Y = TileCalculator.Clip(mapBottomRight.Y, TileCalculator.MinLatitude, TileCalculator.MaxLatitude);
            mapBottomRight.X = TileCalculator.Clip(mapBottomRight.X, TileCalculator.MinLongitude, TileCalculator.MaxLongitude);

            var zoom = TileCalculator.DetermineZoomLevel(envelope, bounds);

            var topLeftTileXY = TileCalculator.LatLongToTileXY(mapTopLeft, zoom);
            var btmRightTileXY = TileCalculator.LatLongToTileXY(mapBottomRight, zoom);

            var tileMatrix = new Bitmap[(int)(btmRightTileXY.X - topLeftTileXY.X) + 1, (int)(btmRightTileXY.Y - topLeftTileXY.Y) + 1];
            var po = new ParallelOptions { MaxDegreeOfParallelism = -1 };
            Parallel.For((int)topLeftTileXY.Y, (int)btmRightTileXY.Y + 1, po,
                         (y, loopState) => Parallel.For((int)topLeftTileXY.X, (int)btmRightTileXY.X + 1, po,
                                           (x, loopState2) =>
                                           {
                                               if (bw.CancellationPending)
                                               {
                                                   loopState.Stop();
                                                   loopState2.Stop();
                                                   return;
                                               }
                                               var currEnv = GetTileEnvelope(x, y, zoom);
                                               tileMatrix[x - (int)topLeftTileXY.X, y - (int)topLeftTileXY.Y] = GetTile(x, y, currEnv, zoom);
                                           }
                                  ));

            return new Tiles(tileMatrix,
                GetTileEnvelope((int)topLeftTileXY.X, (int)topLeftTileXY.Y, zoom),  // top left tile = tileMatrix[0,0]
                GetTileEnvelope((int)btmRightTileXY.X, (int)btmRightTileXY.Y, zoom) // bottom right tile = tileMatrix[last, last]
                );
        }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:39,代码来源:TileManager.cs


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