<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 310, comments - 6939, trackbacks - 0, articles - 3
      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
    墨卡托投影(Mercator Projection),又名“等角正軸圓柱投影”,荷蘭地圖學(xué)家墨卡托(Mercator)在1569年擬定, 假設(shè)地球被圍在一個(gè)中空的圓柱里,其赤道與圓柱相接觸,然后再假想地球中心有一盞燈,把球面上的圖形投影到圓柱體上,再把圓柱體展開(kāi),這就是一幅標(biāo)準(zhǔn)緯線 為零度(即赤道)的“墨卡托投影”繪制出的世界地圖。

    一、墨卡托投影坐標(biāo)系(Mercator Projection)
    墨卡托投影以整個(gè)世界范圍,赤道作為標(biāo)準(zhǔn)緯線,本初子午線作為中央經(jīng)線,兩者交點(diǎn)為坐標(biāo)原點(diǎn),向東向北為正,向西向南為負(fù)。南北極在地圖的正下、上 方,而東西方向處于地圖的正右、左。
    由于Mercator Projection在兩極附近是趨于無(wú)限值得,因此它并沒(méi)完整展現(xiàn)了整個(gè)世界,地圖上最高緯度是85.05度。為了簡(jiǎn)化計(jì)算,我們采用球形映射,而不是 橢球體形狀。雖然采用Mercator Projection只是為了方便展示地圖,需要知道的是,這種映射會(huì)給Y軸方向帶來(lái)0.33%的誤差。
    由于赤道半徑為6378137米,則赤道周長(zhǎng)為2*PI*r = 20037508.3427892,因此X軸的取值范圍:[-20037508.3427892,20037508.3427892]。當(dāng)緯度φ接近兩 極,即90°時(shí),Y值趨向于無(wú)窮。因此通常把Y軸的取值范圍也限定在[-20037508.3427892,20037508.3427892]之間。因 此在墨卡托投影坐標(biāo)系(米)下的坐標(biāo)范圍是:最小為(-20037508.3427892, -20037508.3427892 )到最大 坐標(biāo)為(20037508.3427892, 20037508.3427892)。

    二、地理坐標(biāo)系(Geographical coordinates)
    地理經(jīng)度的取值范圍是[-180,180],緯度不可能到達(dá)90°,通過(guò)緯度取值范圍為 [20037508.3427892,20037508.3427892]反計(jì)算可得到緯度值為85.05112877980659。因此緯度取值范圍是 [-85.05112877980659,85.05112877980659]。因此,地理坐標(biāo)系(經(jīng)緯度)對(duì)應(yīng)的范圍是:最小地理坐標(biāo) (-180,-85.05112877980659),最大地理坐標(biāo)(180, 85.05112877980659)。

    三、地面分辨率(Ground Resolution)
      地面分辨率是以一個(gè)像素(pixel)代表的地面尺寸(米)。以微軟Bing Maps為例,當(dāng)Level為1時(shí),圖片大小為512*512(4個(gè)Tile),那么赤道空間分辨率為:赤道周長(zhǎng)/512。其他緯度的空間分辨率則為 緯度圈長(zhǎng)度/512,極端的北極則為0。Level為2時(shí),赤道的空間分辨率為 赤道周長(zhǎng)/1024,其他緯度為 緯度圈長(zhǎng)度1024。很明顯,Ground Resolution取決于兩個(gè)參數(shù),縮放級(jí)別Level和緯度latitude ,Level決定像素的多少,latitude決定地面距離的長(zhǎng)短。
    地面分辨率的公式為,單位:米/像素:
    ground resolution = (cos(latitude * pi/180) * 2 * pi * 6378137 meters) / (256 * 2level pixels)  

    最低地圖放大級(jí)別(1級(jí)),地圖是512 x 512像素。每下一個(gè)放大級(jí)別,地圖的高度和寬度分別乘于2:2級(jí)是1024 x 1024像素,3級(jí)是2048 x 2048像素,4級(jí)是4096 x 4096像素,等等。通常而言,地圖的寬度和高度可以由以下式子計(jì)算得到:map width = map height = 256 * 2^level pixels

    四、地圖比例尺(Map Scale)
    地圖比例尺是指測(cè)量相同目標(biāo)時(shí),地圖上距離與實(shí)際距離的比例。通過(guò)地圖分辨率在計(jì)算可知由Level可得到圖片的像素大小,那么需要把其轉(zhuǎn)換為以米為 單位的距離,涉及到DPI(dot per inch),暫時(shí)可理解為類似的PPI(pixelper inch),即每英寸代表多少個(gè)像素。256 * 2level / DPI 即得到相應(yīng)的英寸inch,再把英寸inch除以0.0254轉(zhuǎn)換為米。實(shí)地距離仍舊是:cos(latitude * pi/180) * 2 * pi * 6378137 meters; 因此比例尺的公式為:
    map scale = 256 * 2level / screen dpi / 0.0254 / (cos(latitude * pi/180) * 2 * pi * 6378137)
    比例尺= 1 : (cos(latitude * pi/180) * 2 * pi * 6378137 * screen dpi) / (256 * 2level * 0.0254)

    地面分辨率和地圖比例尺之間的關(guān)系:
    map scale = 1 : ground resolution * screen dpi / 0.0254 meters/inch
    縮放級(jí)別
    地圖寬度、高度(像素)
    地面分辨率(米/像素)
    地圖比例尺(以96dpi為例)
    1
    512
    78,271.5170
    1 : 295,829,355.45
    2
    1,024
    39,135.7585
    1 : 147,914,677.73
    3
    2,048
    19,567.8792
    1 : 73,957,338.86
    4
    4,096
    9,783.9396
    1 : 36,978,669.43
    5
    8,192
    4,891.9698
    1 : 18,489,334.72
    6
    16,384
    2,445.9849
    1 : 9,244,667.36
    7
    32,768
    1,222.9925
    1 : 4,622,333.68
    8
    65,536
    611.4962
    1 : 2,311,166.84
    9
    131,072
    305.7481
    1 : 1,155,583.42
    10
    262,144
    152.8741
    1 : 577,791.71
    11
    524,288
    76.4370
    1 : 288,895.85
    12
    1,048,576
    38.2185
    1 : 144,447.93
    13
    2,097,152
    19.1093
    1 : 72,223.96
    14
    4,194,304
    9.5546
    1 : 36,111.98
    15
    8,388,608
    4.7773
    1 : 18,055.99
    16
    16,777,216
    2.3887
    1 : 9,028.00
    17
    33,554,432
    1.1943
    1 : 4,514.00
    18
    67,108,864
    0.5972
    1 : 2,257.00
    19
    134,217,728
    0.2986
    1 : 1,128.50
    20
    268,435,456
    0.1493
    1 : 564.25
    21
    536,870,912
    0.0746
    1 : 282.12
    22
    1,073,741,824
    0.0373
    1 : 141.06
    23
    2,147,483,648
    0.0187
    1 : 70.53


    五、Bing Maps像素坐標(biāo)系和地圖圖片編碼
    為了優(yōu)化地圖系統(tǒng)性能,提高地圖下載和顯示速度,所有地圖都被分割成256 x 256像素大小的正方形小塊。由于在每個(gè)放大級(jí)別下的像素?cái)?shù)量都不一樣,因此地圖圖片(Tile)的數(shù)量也不一樣。每個(gè)tile都有一個(gè)XY坐標(biāo)值,從左 上角的(0, 0)至右下角的(2^level–1, 2^level–1)。例如在3級(jí)放大級(jí)別下,所有tile的坐標(biāo)值范圍為(0, 0)至(7, 7),如下圖:

    已知一個(gè)像素的XY坐標(biāo)值時(shí),我們很容易得到這個(gè)像素所在的Tile的XY坐標(biāo)值:
        tileX = floor(pixelX / 256)  tileY = floor(pixelY / 256)

    為了簡(jiǎn)化索引和存儲(chǔ)地圖圖片,每個(gè)tile的二維XY值被轉(zhuǎn)換成一維字串,即四叉樹(shù)鍵值(quardtree key,簡(jiǎn)稱quadkey)。每個(gè)quadkey獨(dú)立對(duì)應(yīng)某個(gè)放大級(jí)別下的一個(gè)tile,并且它可以被用作數(shù)據(jù)庫(kù)中B-tree索引值。為了將坐標(biāo)值轉(zhuǎn)換成 quadkey,需要將Y和X坐標(biāo)二進(jìn)制值交錯(cuò)組合,并轉(zhuǎn)換成4進(jìn)制值及對(duì)應(yīng)的字符串。例如,假設(shè)在放大級(jí)別為3時(shí),tile的XY坐標(biāo)值為 (3,5),quadkey計(jì)算如下:
      tileX = 3 = 011(二進(jìn)制)
      tileY = 5 = 101(二進(jìn)制)
      quadkey = 100111(二進(jìn)制) = 213(四進(jìn)制) = “213”
    Quadkey還有其他一些有意思的特性。第一,quadkey的長(zhǎng)度等于該tile所對(duì)應(yīng)的放大級(jí)別;第二,每個(gè)tile的quadkey的前幾位 和其父tile(上一放大級(jí)別所對(duì)應(yīng)的tile)的quadkey相同,下圖中,tile 2是tile 20至23的父tile,tile 13是tile 130至133的父級(jí):

    最后,quadkey提供的一維索引值通常顯示了兩個(gè)tile在XY坐標(biāo)系中的相似性。換句話說(shuō),兩個(gè)相鄰的tile對(duì)應(yīng)的quadkey非常接近。這對(duì) 于優(yōu)化數(shù)據(jù)庫(kù)的性能非常重要,因?yàn)橄噜彽膖ile通常被同時(shí)請(qǐng)求顯示,因此可以將這些tile存放在相同的磁盤區(qū)域中,以減少磁盤的讀取次數(shù)。

    下面是微軟Bing Maps的TileSystem相關(guān)算法:
    using System;
    using System.Text;

    namespace Microsoft.MapPoint
    {
    static class TileSystem
    {
    private const double EarthRadius = 6378137;
    private const double MinLatitude = -85.05112878;
    private const double MaxLatitude = 85.05112878;
    private const double MinLongitude = -180;
    private const double MaxLongitude = 180;


    /// <summary>
    /// Clips a number to the specified minimum and maximum values.
    /// </summary>
    /// <param name="n">The number to clip.</param>
    /// <param name="minValue">Minimum allowable value.</param>
    /// <param name="maxValue">Maximum allowable value.</param>
    /// <returns>The clipped value.</returns>
    private static double Clip(double n, double minValue, double maxValue)
    {
    return Math.Min(Math.Max(n, minValue), maxValue);
    }



    /// <summary>
    /// Determines the map width and height (in pixels) at a specified level
    /// of detail.
    /// </summary>
    /// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
    /// to 23 (highest detail).</param>
    /// <returns>The map width and height in pixels.</returns>
    public static uint MapSize(int levelOfDetail)
    {
    return (uint256 << levelOfDetail;
    }



    /// <summary>
    /// Determines the ground resolution (in meters per pixel) at a specified
    /// latitude and level of detail.
    /// </summary>
    /// <param name="latitude">Latitude (in degrees) at which to measure the
    /// ground resolution.</param>
    /// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
    /// to 23 (highest detail).</param>
    /// <returns>The ground resolution, in meters per pixel.</returns>
    public static double GroundResolution(double latitude, int levelOfDetail)
    {
    latitude 
    = Clip(latitude, MinLatitude, MaxLatitude);
    return Math.Cos(latitude * Math.PI / 180* 2 * Math.PI * EarthRadius / MapSize(levelOfDetail);
    }



    /// <summary>
    /// Determines the map scale at a specified latitude, level of detail,
    /// and screen resolution.
    /// </summary>
    /// <param name="latitude">Latitude (in degrees) at which to measure the
    /// map scale.</param>
    /// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
    /// to 23 (highest detail).</param>
    /// <param name="screenDpi">Resolution of the screen, in dots per inch.</param>
    /// <returns>The map scale, expressed as the denominator N of the ratio 1 : N.</returns>
    public static double MapScale(double latitude, int levelOfDetail, int screenDpi)
    {
    return GroundResolution(latitude, levelOfDetail) * screenDpi / 0.0254;
    }



    /// <summary>
    /// Converts a point from latitude/longitude WGS-84 coordinates (in degrees)
    /// into pixel XY coordinates at a specified level of detail.
    /// </summary>
    /// <param name="latitude">Latitude of the point, in degrees.</param>
    /// <param name="longitude">Longitude of the point, in degrees.</param>
    /// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
    /// to 23 (highest detail).</param>
    /// <param name="pixelX">Output parameter receiving the X coordinate in pixels.</param>
    /// <param name="pixelY">Output parameter receiving the Y coordinate in pixels.</param>
    public static void LatLongToPixelXY(double latitude, double longitude, int levelOfDetail, out int pixelX, out int pixelY)
    {
    latitude 
    = Clip(latitude, MinLatitude, MaxLatitude);
    longitude 
    = Clip(longitude, MinLongitude, MaxLongitude);

    double x = (longitude + 180/ 360;
    double sinLatitude = Math.Sin(latitude * Math.PI / 180);
    double y = 0.5 - Math.Log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);

    uint mapSize = MapSize(levelOfDetail);
    pixelX 
    = (int) Clip(x * mapSize + 0.50, mapSize - 1);
    pixelY 
    = (int) Clip(y * mapSize + 0.50, mapSize - 1);
    }



    /// <summary>
    /// Converts a pixel from pixel XY coordinates at a specified level of detail
    /// into latitude/longitude WGS-84 coordinates (in degrees).
    /// </summary>
    /// <param name="pixelX">X coordinate of the point, in pixels.</param>
    /// <param name="pixelY">Y coordinates of the point, in pixels.</param>
    /// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
    /// to 23 (highest detail).</param>
    /// <param name="latitude">Output parameter receiving the latitude in degrees.</param>
    /// <param name="longitude">Output parameter receiving the longitude in degrees.</param>
    public static void PixelXYToLatLong(int pixelX, int pixelY, int levelOfDetail, out double latitude, out double longitude)
    {
    double mapSize = MapSize(levelOfDetail);
    double x = (Clip(pixelX, 0, mapSize - 1/ mapSize) - 0.5;
    double y = 0.5 - (Clip(pixelY, 0, mapSize - 1/ mapSize);

    latitude 
    = 90 - 360 * Math.Atan(Math.Exp(-* 2 * Math.PI)) / Math.PI;
    longitude 
    = 360 * x;
    }



    /// <summary>
    /// Converts pixel XY coordinates into tile XY coordinates of the tile containing
    /// the specified pixel.
    /// </summary>
    /// <param name="pixelX">Pixel X coordinate.</param>
    /// <param name="pixelY">Pixel Y coordinate.</param>
    /// <param name="tileX">Output parameter receiving the tile X coordinate.</param>
    /// <param name="tileY">Output parameter receiving the tile Y coordinate.</param>
    public static void PixelXYToTileXY(int pixelX, int pixelY, out int tileX, out int tileY)
    {
    tileX 
    = pixelX / 256;
    tileY 
    = pixelY / 256;
    }



    /// <summary>
    /// Converts tile XY coordinates into pixel XY coordinates of the upper-left pixel
    /// of the specified tile.
    /// </summary>
    /// <param name="tileX">Tile X coordinate.</param>
    /// <param name="tileY">Tile Y coordinate.</param>
    /// <param name="pixelX">Output parameter receiving the pixel X coordinate.</param>
    /// <param name="pixelY">Output parameter receiving the pixel Y coordinate.</param>
    public static void TileXYToPixelXY(int tileX, int tileY, out int pixelX, out int pixelY)
    {
    pixelX 
    = tileX * 256;
    pixelY 
    = tileY * 256;
    }



    /// <summary>
    /// Converts tile XY coordinates into a QuadKey at a specified level of detail.
    /// </summary>
    /// <param name="tileX">Tile X coordinate.</param>
    /// <param name="tileY">Tile Y coordinate.</param>
    /// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
    /// to 23 (highest detail).</param>
    /// <returns>A string containing the QuadKey.</returns>
    public static string TileXYToQuadKey(int tileX, int tileY, int levelOfDetail)
    {
    StringBuilder quadKey 
    = new StringBuilder();
    for (int i = levelOfDetail; i > 0; i--)
    {
    char digit = '0';
    int mask = 1 << (i - 1);
    if ((tileX & mask) != 0)
    {
    digit
    ++;
    }
    if ((tileY & mask) != 0)
    {
    digit
    ++;
    digit
    ++;
    }
    quadKey.Append(digit);
    }
    return quadKey.ToString();
    }



    /// <summary>
    /// Converts a QuadKey into tile XY coordinates.
    /// </summary>
    /// <param name="quadKey">QuadKey of the tile.</param>
    /// <param name="tileX">Output parameter receiving the tile X coordinate.</param>
    /// <param name="tileY">Output parameter receiving the tile Y coordinate.</param>
    /// <param name="levelOfDetail">Output parameter receiving the level of detail.</param>
    public static void QuadKeyToTileXY(string quadKey, out int tileX, out int tileY, out int levelOfDetail)
    {
    tileX 
    = tileY = 0;
    levelOfDetail 
    = quadKey.Length;
    for (int i = levelOfDetail; i > 0; i--)
    {
    int mask = 1 << (i - 1);
    switch (quadKey[levelOfDetail - i])
    {
    case '0':
    break;

    case '1':
    tileX 
    |= mask;
    break;

    case '2':
    tileY 
    |= mask;
    break;

    case '3':
    tileX 
    |= mask;
    tileY 
    |= mask;
    break;

    default:
    throw new ArgumentException("Invalid QuadKey digit sequence.");
    }
    }
    }
    }
    }


    評(píng)論

    # re: GIS理論(墨卡托投影、地理坐標(biāo)系、地面分辨率、地圖比例尺、Bing Maps Tile System)(ZZ)  回復(fù)  更多評(píng)論   

    2010-09-24 22:27 by GIS
    博主:您好!我想自己生成一個(gè)矢量的Bing Maps Tile System 格網(wǎng)數(shù)據(jù),但不知道怎么做,請(qǐng)您指教!程序要求就是輸入左下、右上點(diǎn)的經(jīng)緯度和相對(duì)應(yīng)的級(jí)數(shù),可以生成SHP格網(wǎng)數(shù)據(jù)。請(qǐng)您指教!如果您有已經(jīng)做好的東西,能不能發(fā)一個(gè)給我haiocean@126.com十分感謝!
    主站蜘蛛池模板: 亚洲精品中文字幕无码A片老| 亚洲高清视频免费| 无人视频免费观看免费视频 | 亚洲国产精品无码专区影院| 亚洲avav天堂av在线不卡| 久久精品国产亚洲AV无码麻豆| 亚洲中文无码线在线观看| 在线观看亚洲av每日更新| 亚洲毛片αv无线播放一区| 67pao强力打造67194在线午夜亚洲| 亚洲av永久无码精品天堂久久| 亚洲av日韩综合一区久热| 一级一级一级毛片免费毛片| 免费国产黄网站在线观看 | 人成午夜免费视频在线观看| 永久中文字幕免费视频网站| 亚洲中文字幕无码中文字在线| 91亚洲导航深夜福利| 亚洲成AV人影片在线观看| 中文字幕永久免费视频| 4hu四虎最新免费地址| 69式国产真人免费视频 | 国产免费人成在线视频| 久久精品国产亚洲一区二区| 亚洲一区精品视频在线| 成人精品综合免费视频| 一级午夜免费视频| 真实国产乱子伦精品免费| 国产免费资源高清小视频在线观看| 亚洲AV无码一区二区乱孑伦AS | 成在人线av无码免费高潮水| 和日本免费不卡在线v| 久久精品国产精品亚洲人人 | 四虎1515hh永久久免费| 亚洲国产综合人成综合网站| 亚洲春色另类小说| 精品多毛少妇人妻AV免费久久| 久久久高清免费视频| 亚洲日韩精品无码专区网址| 亚洲熟妇无码AV不卡在线播放| 国产真人无码作爱视频免费|