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


C# Extent.Intersection方法代码示例

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


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

示例1: GetBitmap

        /// <summary>
        /// Gets the bitmap for the specified geographic envelope scaled to fit on a bitmap of the specified size in pixels.
        /// </summary>
        /// <param name="envelope"></param>
        /// <param name="pixelSize"></param>
        /// <returns></returns>
        public virtual Bitmap GetBitmap(Extent envelope, Size pixelSize)
        {
            Bitmap result = new Bitmap(pixelSize.Width, pixelSize.Height);
            Graphics g = Graphics.FromImage(result);
            foreach (ImageData image in _images)
            {
                Extent bounds = envelope.Intersection(image.Extent);

                Size ps = new Size((int)(pixelSize.Width * bounds.Width / envelope.Width),
                                   (int)(pixelSize.Height * bounds.Height / envelope.Height));
                int x = pixelSize.Width * (int)((bounds.X - envelope.X) / envelope.Width);
                int y = pixelSize.Height * (int)((envelope.Y - bounds.Y) / envelope.Height);
                if (ps.Width > 0 && ps.Height > 0)
                {
                    Bitmap tile = image.GetBitmap(bounds, ps);
                    g.DrawImageUnscaled(tile, x, y);
                }
            }
            return result;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:26,代码来源:ImageCoverage.cs

示例2: GetSeriesListForExtent

        private List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart> GetSeriesListForExtent(Extent extent, IEnumerable<string> keywords, double tileWidth, double tileHeight,
            DateTime startDate, DateTime endDate, ICollection<WebServiceNode> serviceIDs,
            BusinessObjects.Models.IProgressHandler bgWorker, Func<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart, bool> seriesFilter)
        {
            var servicesToSearch = new List<Tuple<WebServiceNode[], Extent>>();
            if (serviceIDs.Count > 0)
            {
                foreach (var webService in serviceIDs)
                {
                    if (webService.ServiceBoundingBox == null)
                    {
                        servicesToSearch.Add(new Tuple<WebServiceNode[], Extent>(new[] { webService }, extent));
                        continue;
                    }
                    const double eps = 0.05; //tolerance (0.05 deg) used for services whose bounding box is one point
                    var wsBox = webService.ServiceBoundingBox;
                    var wsExtent = new Extent(wsBox.XMin - eps, wsBox.YMin - eps, wsBox.XMax + eps, wsBox.YMax + eps);
                    if (wsExtent.Intersects(extent))
                    {
                        servicesToSearch.Add(new Tuple<WebServiceNode[], Extent>(new[] { webService }, wsExtent.Intersection(extent)));
                    }
                }
            }
            else
            {
                servicesToSearch.Add(new Tuple<WebServiceNode[], Extent>(new WebServiceNode[] { }, extent));
            }

            var servicesWithExtents = new List<Tuple<WebServiceNode[], List<Extent>>>(servicesToSearch.Count);
            int totalTilesCount = 0;
            foreach (var wsInfo in servicesToSearch)
            {
                var tiles = SearchHelper.CreateTiles(wsInfo.Item2, tileWidth, tileHeight);
                servicesWithExtents.Add(new Tuple<WebServiceNode[], List<Extent>>(wsInfo.Item1, tiles));
                totalTilesCount += tiles.Count;
            }

            var fullSeriesList = new List<List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>>();
            long  currentTileIndex = 0;
            int tilesFinished = 0;
            totalSeriesCount = 0;

            bgWorker.ReportProgress(0, "0 Series found");

            var serviceLoopOptions = new ParallelOptions
                {
                        CancellationToken = bgWorker.CancellationToken,
                        MaxDegreeOfParallelism = 2,
                };
            var tileLoopOptions = new ParallelOptions
                {
                        CancellationToken = bgWorker.CancellationToken,
                        // Note: currently HIS Central returns timeout if many requests are sent in the same time.
                        // To test set  MaxDegreeOfParallelism = -1
                        MaxDegreeOfParallelism = 4,
                };

            Parallel.ForEach(servicesWithExtents, serviceLoopOptions, wsInfo =>
            {
                bgWorker.CheckForCancel();
                var ids = wsInfo.Item1.Select(item => item.ServiceID).ToArray();
                var tiles = wsInfo.Item2;

                Parallel.ForEach(tiles, tileLoopOptions, tile =>
                {
                    var current = Interlocked.Add(ref currentTileIndex, 1);
                    bgWorker.CheckForCancel();

                    // Do the web service call
                    var tileSeriesList = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();

                    if (SearchSettings.AndSearch == true)
                    {
                        //CHANGES FOR "AND" SEARCH
                        var totalTileSeriesList = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
                        var tileSeriesList2 = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
                        var tileSeriesList3 = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
                        var tileSeriesList4 = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();

                        SeriesComparer sc = new SeriesComparer();

                        for (int i = 0; i < keywords.Count(); i++)
                        {
                            String keyword = keywords.ElementAt(i);

                            bgWorker.CheckForCancel();
                            var series = GetSeriesCatalogForBox(tile.MinX, tile.MaxX, tile.MinY, tile.MaxY, keyword, startDate, endDate, ids, bgWorker, current, totalTilesCount);
                            totalTileSeriesList.AddRange(series);
                            if (tileSeriesList.Count() == 0)
                            {
                                if (i == 0)
                                {
                                    tileSeriesList.AddRange(series);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
//.........这里部分代码省略.........
开发者ID:CUAHSI,项目名称:HydroClient,代码行数:101,代码来源:Seriessearcher.cs


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