2013-03-04 78 views
1

我最近開始使用[Bing Api]在我的webService [wcf] in c#中。 我想用Bing恢復給定比例的衛星圖像! 例如如何根據給定比例[Bing Map]生成地圖?

比例1:200(1釐米地圖等於200釐米在世界上)

當然,我發現這個功能,解釋如何計算圖像分辨率衛星兵,但是這不是我在找..

Map resolution = 156543.04 meters/pixel * cos(latitude)/(2^zoomlevel) 

下面是用我的功能來生成我冰的地圖,但我不知道送什麼參數來檢索的1圖像縮放:200。

我需要:

比例= 1:200

我搜索:

INT mapSizeHeight =?

int mapSizeWidth =?

int zoomLevel =?

public string GetImageMap(double latitude,double longitude,int mapSizeHeight, int mapSizeWidth, int zoomLevel) 
    { 
     string key = "ddsaAaasm5vwsdfsfd2ySYBxfEFsdfsdfcFh6iUO5GI4v"; 
     MapUriRequest mapUriRequest = new MapUriRequest(); 

     // Set credentials using a valid Bing Maps key 
     mapUriRequest.Credentials = new ImageryService.Credentials(); 
     mapUriRequest.Credentials.ApplicationId = key; 

     // Set the location of the requested image 
     mapUriRequest.Center = new ImageryService.Location(); 
     mapUriRequest.Center.Latitude = latitude; 
     mapUriRequest.Center.Longitude = longitude; 

     // Set the map style and zoom level 
     MapUriOptions mapUriOptions = new MapUriOptions(); 
     mapUriOptions.Style = MapStyle.Aerial; 
     mapUriOptions.ZoomLevel = zoomLevel; 
     mapUriOptions.PreventIconCollision = true; 
     // Set the size of the requested image in pixels 
     mapUriOptions.ImageSize = new ImageryService.SizeOfint(); 
     mapUriOptions.ImageSize.Height = mapSizeHeight; 
     mapUriOptions.ImageSize.Width = mapSizeWidth; 

     mapUriRequest.Options = mapUriOptions; 

     //Make the request and return the URI 
     ImageryServiceClient imageryService = new ImageryServiceClient(); 
     MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); 
     return mapUriResponse.Uri; 
    } 

回答

2

如果您還沒有準備好,你可能想看看this article on the Bing Maps tile system calculations,內你會發現一個部分討論地面分辨率和地圖的比例尺。從那篇文章:

map scale = 1 : ground resolution * screen dpi/0.0254 meters/inch 

根據您使用的Bing地圖的實施,可能無法通過精確的地圖比例指定視圖。我認爲這是由於您無法精確控制縮放級別。例如,在javascript ajax版本中,您只能以整數值指定縮放級別,因此上述公式的ground resolution部分將以謹慎的步驟跳轉。在赤道地區,使用縮放級別21會給你一個1: 282的比例,並且縮放級別22會給你1:141。由於您無法爲縮放級別指定小數值,因此無法使用ajax控件獲取精確的1:200比例。我對.net Bing地圖控件沒有豐富的經驗,因此您可能需要調查該API以查看是否可以指定任意縮放級別。

如果您可以精確控制縮放級別並瞭解dpi值,那麼可以使用上述鏈接文章中描述的公式實現1:200比例。

+0

我很抱歉,但經過反思,我沒有看到如何計算縮放比例以及已知比例的圖像分辨率..我不需要看比例尺,因爲我已經知道 - >地圖scale = 1:200但是zoomLevel =?..等 – 2013-03-05 09:27:45

+1

首先要研究的是,您是否可以將縮放級別設置爲API中的十進制值。如果您只能將縮放級別設置爲整數值,那麼您會被上面鏈接中定義的地圖比例的謹慎步驟卡住。然後您必須拍攝照片並手動將其縮放到您想要的1:200比例。基本上,如果您可以將縮放級別設置爲十進制值,那麼縮放圖像的工作就已經完成了。請記住,衛星圖像本身是在謹慎的尺度下進行的,所以任何尺度變化都需要用軟件來完成。 – 2013-03-05 17:45:01

+0

我相信你可以找出數學推導縮放級別值給定的地圖比例尺,你有所有的方程,並只解決一個變量... – 2013-03-05 17:45:52