public static void LongLatToPixelXY(double longitude, double latitude, double levelOfDetail, out double pixelX, out double pixelY)
        {
            latitude  = VirtualEarthTileSystem.Clip(latitude, -85.05112878, 85.05112878);
            longitude = VirtualEarthTileSystem.Clip(longitude, -180.0, 180.0);
            double num  = (longitude + 180.0) / 360.0;
            double num2 = Math.Sin(latitude * 3.1415926535897931 / 180.0);
            double num3 = 0.5 - Math.Log((1.0 + num2) / (1.0 - num2)) / 12.566370614359172;
            uint   num4 = VirtualEarthTileSystem.MapSize(levelOfDetail);

            pixelX = VirtualEarthTileSystem.Clip(num * (double)num4 + 0.5, 0.0, (double)(num4 - 1));
            pixelY = VirtualEarthTileSystem.Clip(num3 * (double)num4 + 0.5, 0.0, (double)(num4 - 1));
        }
Пример #2
0
 public bool QueryVirtualEarthService(bool asyncQuery)
 {
     if (!string.IsNullOrEmpty(this.Common.MapCore.TileServerAppId) && !(this.Common.MapCore.TileServerAppId.ToUpper(CultureInfo.InvariantCulture) == "(DEFAULT)"))
     {
         try
         {
             ImageryMetadataRequest imageryMetadataRequest = new ImageryMetadataRequest();
             imageryMetadataRequest.BingMapsKey             = base.common.MapCore.TileServerAppId;
             imageryMetadataRequest.ImagerySet              = VirtualEarthTileSystem.TileSystemToMapStyle(this.TileSystem);
             imageryMetadataRequest.IncludeImageryProviders = true;
             imageryMetadataRequest.UseHTTPS = true;
             ImageryMetadataRequest imageryRequest = imageryMetadataRequest;
             if (asyncQuery)
             {
                 BingMapsService.GetImageryMetadataAsync(imageryRequest, this.ProcessImageryMetadataResponse, delegate(Exception ex)
                 {
                     lock (this.TileError)
                     {
                         this.TileError = ex.Message;
                     }
                 });
             }
             else
             {
                 Response imageryMetadata = BingMapsService.GetImageryMetadata(imageryRequest);
                 this.ProcessImageryMetadataResponse(imageryMetadata);
             }
         }
         catch (Exception ex2)
         {
             lock (this.TileError)
             {
                 this.TileError = ex2.Message;
             }
             return(false);
         }
         return(true);
     }
     lock (this.TileError)
     {
         this.TileError = SR.ProvideBingMapsAppID;
     }
     return(false);
 }
Пример #3
0
        public string GetAttributionStrings()
        {
            if (this.TileImageryProviders == null)
            {
                return(string.Empty);
            }
            StringBuilder stringBuilder = new StringBuilder();
            RectangleF    rectangleF    = new RectangleF(this.Common.MapCore.Viewport.GetAbsoluteLocation(), this.Common.MapCore.Viewport.GetAbsoluteSize());
            MapPoint      minimumPoint  = this.Common.MapCore.PixelsToGeographic(new PointF(rectangleF.Left, rectangleF.Bottom));
            MapPoint      maximumPoint  = this.Common.MapCore.PixelsToGeographic(new PointF(rectangleF.Right, rectangleF.Top));
            MapBounds     a             = new MapBounds(minimumPoint, maximumPoint);
            int           num           = Math.Max((int)VirtualEarthTileSystem.LevelOfDetail(this.Common.MapCore.Viewport.GetGroundResolutionAtEquator()), 1);

            ImageryProvider[] array = this.TileImageryProviders;
            foreach (ImageryProvider imageryProvider in array)
            {
                CoverageArea[] coverageAreas = imageryProvider.CoverageAreas;
                foreach (CoverageArea coverageArea in coverageAreas)
                {
                    if (num >= coverageArea.ZoomMin && num <= coverageArea.ZoomMax)
                    {
                        MapBounds b = new MapBounds(new MapPoint(coverageArea.BoundingBox[1], coverageArea.BoundingBox[1]), new MapPoint(coverageArea.BoundingBox[3], coverageArea.BoundingBox[3]));
                        if (MapBounds.Intersect(a, b))
                        {
                            if (stringBuilder.Length > 0)
                            {
                                stringBuilder.Append("|");
                            }
                            stringBuilder.Append(imageryProvider.Attribution);
                            break;
                        }
                    }
                }
            }
            return(stringBuilder.ToString());
        }
 public static double MapScale(double latitude, int levelOfDetail, int screenDpi)
 {
     return(VirtualEarthTileSystem.GroundResolution(latitude, levelOfDetail) * (double)screenDpi / 0.0254);
 }
 public static double GroundResolution(double latitude, int levelOfDetail)
 {
     latitude = VirtualEarthTileSystem.Clip(latitude, -85.05112878, 85.05112878);
     return(Math.Cos(latitude * 3.1415926535897931 / 180.0) * 2.0 * 3.1415926535897931 * 6378137.0 / (double)VirtualEarthTileSystem.MapSize(levelOfDetail));
 }