地方分辨率88bifa必发娱乐

GIS答辩(墨卡托投影、地理坐标系、地面分辨率、地图比例尺、Bing
Maps Tile System)

  墨卡托投影(Mercator
Projection),又名“等角正轴圆柱投影”,荷兰王国地图学家墨卡托(Mercator)在1569年拟定,假如地球被围在四个空心的圆柱里,其赤道与圆柱相接触,然后再假想地

球基本有一盏灯,把球面上的图形投影到圆柱体上,再把圆柱体展开,这便是一幅标准纬线为零度(即赤道)的“墨卡托投影”绘制出的世界地图。

壹 、墨卡托投影坐标系(Mercator Projection)

  墨卡托投影以任何社会风气范围,赤道作为标准纬线,本初子午线作为核退热除蒸线,两者交点为坐标原点,往南向西为正,往南向东为负。南北极在地图的正下、上方,而东西方向处于地图的正右、左。

  由于Mercator
Projection在两极附近是趋于无限值得,由此它并没完全显示了上上下下世界,地图上最高洋度是85.05度。为了简化总括,大家应用球形映射,而不是椭球体形状。纵然采纳Mercator
Projection只是为了有利于展现地图,供给精通的是,那种映射会给Y轴方向带来0.33%的误差。

88bifa必发娱乐 1


88bifa必发娱乐 2

earthRadius =6378137

20037508.3427892 = earthRadius * (math.pi – 0)

85.05112877980659 = (math.atan(math.exp(aa / earthRadius))-math.pi/4)*2
* 180 / math.pi

image = 512 * 512

groundResolution(1 level)  = (20037508.3427892 * 2) / 512 =
78271.516964

screendpi = 96

mapScale = groundResolution * 96 / 0.0254 = 295829355.455


  由于赤道半径为6378137米,则赤道周长为2*PI*r =
二〇〇三7508.3427892,因而X轴的取值范围:[-20037508.3427892,20037508.3427892]。当纬度φ接近两极,即90°时,Y值趋向于无穷。因而普通把Y轴的取值范围也限制在[-20037508.3427892,20037508.3427892]时期。因而在墨卡托投影坐标系(米)下的坐标范围是:最小为(-二〇〇〇7508.3427892,
-贰零零壹7508.3427892 )到最大 坐标为(20007508.3427892, 贰零零叁7508.3427892)。

贰 、地理坐标系(Geographical coordinates)

  地理经度的取值范围是[-180,180],纬度不容许到达90°,通过纬度取值范围为[20037508.3427892,20037508.3427892]反总结可收获纬度值为85.05112877980659。由此纬度取值范围是[-85.05112877980659,85.05112877980659]。因此,地理坐标系(经纬度)对应的界定是:最小地理坐标(-180,-85.05112877980659),最大地理坐标(180,
85.05112877980659)。

③ 、地面分辨率(Ground Resolution)

  地面分辨率是以叁个像素(pixel)代表的当地尺寸(米)。以微软Bing
Maps为例,当Level为1时,图片大小为512*512(伍个Tile),那么赤道上空分辨率为:赤道周长/512。其余纬度的长空分辨率则为
纬度圈长度/512,极端的北极则为0。Level为2时,赤道的空中分辨率为
赤道周长/1024,别的纬度为 纬度圈长度1024。很明显,Ground
Resolution取决于八个参数,缩放级别Level和纬度latitude
,Level决定像素的有点,latitude决定地面距离的长度。

地面分辨率的公式为,单位:米/像素:

ground resolution = (cos(latitude * pi/180) * 2 * pi * 6378137
meters) / (256 * 2level pixels)

  最低地图放大级别(1级),地图是512 x
512像素。每下八个加大级别,地图的莫斯中国科学技术大学学和宽度分别乘于2:2级是1024 x
1024像素,3级是2048 x 2048像素,4级是4096 x
4096像素,等等。经常而言,地图的幅度和惊人能够由以下式子计算得到:map
width = map height = 256 * 2^level pixels

四 、地图比例尺(Map Scale)

  地图比例尺是指度量相同指标时,地图上偏离与实际距离的比例。通过地图分辨率在估测计算可见由Level可得到图片的像素大小,那么须求把其转移为以米为单位的离开,涉及到DPI(dot
per inch),一时半刻可通晓为接近的PPI(pixel per
inch),即每英寸代表有点个像素。256 * 2level / DPI
即拿到相应的英寸inch,再把英寸inch除以0.0254转换为米。实地距离还是是: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)

  地面分辨率和地图比例尺之间的关系:

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

缩放级别

地图宽度、高度(像素)

地面分辨率(米/像素)

地图比例尺(以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像素坐标系和地图图片编码

  为了优化地图系统脾气,进步地图下载和展现速度,全部地图都被划分成256
x
256像素大小的椭圆形小块。由于在每种放大级别下的像素数量都不一致,由此地图图片(Tile)的多寡也不雷同。每一种tile都有叁个XY坐标值,从左上角的(0,
0)至右下角的(2^level–1,
2^level–1)。例如在3级放大级别下,全数tile的坐标值范围为(0, 0)至(7,
7),如下图:

88bifa必发娱乐 3

  已知3个像素的XY坐标值时,大家很简单取得那个像素所在的Tile的XY坐标值:

tileX = floor(pixelX / 256) tileY = floor(pixelY / 256)

  为了简化索引和储存地图图片,每一个tile的二维XY值被转换来一维字串,即四叉树键值(quardtree
key,简称quadkey)。种种quadkey独立对应有个别放大级别下的二个tile,并且它可以被当做数据库中B-tree索引值。为了将坐标值转换到quadkey,要求将Y和X坐标二进制值交错组合,并转换来4进制值及相应的字符串。例如,如若在加大级别为3时,tile的XY坐标值为(3,5),quadkey总计如下:

tileX = 3 = 011(二进制)

tileY = 5 = 101(二进制)

quadkey = 100111(二进制) = 213(四进制) = “213”

Quadkey还有别的一些好玩的性状。第1,quadkey的尺寸等于该tile所对应的推广级别;第叁,每一个tile的quadkey的前4人和其父tile(上一放大级别所对应的tile)的quadkey相同,下图中,tile
2是tile 20至23的父tile,tile 13是tile 130至133的父级:

88bifa必发娱乐 4

  最后,quadkey提供的一维索引值平时突显了八个tile在XY坐标系中的相似性。换句话说,多个相邻的tile对应的quadkey相当接近。那对于优化数据库的属性尤其关键,因为隔壁的tile通常被同时呼吁展现,由此得以将那几个tile存放在同等的磁盘区域中,以减少磁盘的读取次数。

  上面是微软Bing Maps的TileSystem相关算法:

 

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(intlevelOfDetail)

        {

            return (uint) 256 << 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, intscreenDpi)

        {

            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, intlevelOfDetail, 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.5, 0, mapSize - 1);

            pixelY = (int) Clip(y * mapSize + 0.5, 0, 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, intlevelOfDetail, 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(-y * 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, intlevelOfDetail)

        {

            StringBuilder quadKey = newStringBuilder();

            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 intlevelOfDetail)

        {

            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.");

                }

            }

        }

    }

}

 


当大家在用arcgis server
塑造切片时,大家会发以往缓存生成的conf.xml中有如此的一部分:

88bifa必发娱乐 5

在上述部分中<LODInfo>代表了每一级切片的音讯,<LevelID>代表切片的级数。

在此处,<Scale>代表比例尺。比例尺是表示图上距离比实地离开裁减的程度,也叫缩尺。公式为:比例尺=图上距离/实地距离。用数字的比例式或分数式表示比例尺的大大小小。例如地图上1毫米代表实地距离500公里,可写成:1∶50,000,000或写成:二成0,000,000。

  <Resolution>,代表分辨率。Resolution
的实际意义代表当前地图范围内,1像素代表有个别地图单位(X地图单位/像素),地图单位取决于数量小编的长空参考。

当大家在展开Web
API的费用时,平日会碰着依据Resolution来缩放地图的图景。可是事实上须求中我们更要求依据Scale来缩放,因而就涉嫌到Scale和Resolution的转换。

Resolution和Scale的转移算法:

Resolution跟dpi有关,跟地图的单位关于。(dpi代表每英寸的像素数)

  Resolution和Scale的转移算法

举例:

案例一:如若地图的坐标单位是米, dpi为96

           1英寸= 2.54厘米;

           1英寸=96像素;

88bifa必发娱乐,末段换算的单位是米;

比方当前地图比例尺为1: 12伍仟000,则表示图上1米实地12陆仟000米;

米和像素间的折算公式:

           1英寸=0.0254米=96像素

           1像素=0.0254/96 米

则遵照1:125000000比例尺,图上1像素代表实地距离是125000000*0.0254/96 =
33072.9166666667米。大家以此换算结果和切片的结果略微有0.07米的误差。这几个误差发生的来头是英寸换算分米的参数决定的,server使用的折算参数1英寸相当于0.0255000508米。

案例二:假设地理坐标系是wgs84,地图的单位是度,dpi为96

           Server低度和米之内的折算参数:

             1度相当于 111194.872221777米

接下去就要求实行度和像素间的折算:

当比例尺为1:65000000米时,约等于1像素 = 6四千000*0.0254000508/96 =
16933.3672米

再将米转换为度 16933.3672/111194.872221777 = 0.1522855043731385度

因此地方图单位为度时,近似总计在1:65000000
对应的Resolution为0.1522855043731385度

表明结果:

88bifa必发娱乐 6


double resolution = scale * 0.0254000508/96/111194.872221777;

相关文章