<code id="smqwm"><abbr id="smqwm"></abbr></code>
<dfn id="smqwm"><source id="smqwm"></source></dfn>
<li id="smqwm"><code id="smqwm"></code></li>
<ul id="smqwm"><source id="smqwm"></source></ul>
<strike id="smqwm"></strike>
<center id="smqwm"></center>

GPS糾偏0.01精度工具/算法案例

2019-05-28 11:04:22 root

 

精度工具下載 :http://map.yanue.net/gps.html
 
該校正適用于 Google map China, Microsoft map china ,MapABC 等,因?yàn)檫@些地圖構(gòu)成方法是一樣的需要offset.dat文件,該文件為0.01精度校正數(shù)據(jù), 有需要者請(qǐng)聯(lián)系本網(wǎng)站人員, 非免費(fèi)版本。
 
算法演示:
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
   代碼功能:利用0.01精度校正庫(kù)文件修正中國(guó)地圖經(jīng)緯度偏移。
*/
header("Content-Type:text/html; charset=utf-8");
define('__dat_db__' 'offset.dat' );// DAT數(shù)據(jù)文件
define('datmax' , 9813675 );// 數(shù)據(jù)條數(shù)-結(jié)束記錄
 
// # offset.php?lat=39.914914&lon=116.460633
$lon=$_GET['lon'];
$lat=$_GET['lat'];
$tmplon=intval($lon * 100);
$tmplat=intval($lat * 100);
//經(jīng)度到像素X值
function lngToPixel($lng,$zoom) {
return ($lng+180)*(256<<$zoom)/360;
}
//像素X到經(jīng)度
function pixelToLng($pixelX,$zoom){
return $pixelX*360/(256<<$zoom)-180;
}
//緯度到像素Y
function latToPixel($lat$zoom) {
$siny = sin($lat * pi() / 180);
$y=log((1+$siny)/(1-$siny));
return (128<<$zoom)*(1-$y/(2*pi()));
}
//像素Y到緯度
function pixelToLat($pixelY$zoom) {
$y = 2*pi()*(1-$pixelY /(128 << $zoom));
$z = pow(M_E, $y);
$siny = ($z -1)/($z +1);
return asin($siny) * 180/pi();
}
 
function xy_fk( $number ){
        $fp fopen(__dat_db__,"rb"); //■1■.將 r 改為 rb
        $myxy=$number;//#"112262582";
        $left = 0;//開(kāi)始記錄
        $right = datmax;//結(jié)束記錄
 
        //采用用二分法來(lái)查找查數(shù)據(jù)
        while($left <= $right){
            $recordCount =(floor(($left+$right)/2))*8; //取半
            //echo "運(yùn)算:left=".$left." right=".$right." midde=".$recordCount."
";
            @fseek $fp$recordCount , SEEK_SET ); //設(shè)置游標(biāo)
            $c fread($fp,8); //讀8字節(jié)
            $lon = unpack('s',substr($c,0,2));
            $lat = unpack('s',substr($c,2,2));
            $x = unpack('s',substr($c,4,2));
            $y = unpack('s',substr($c,6,2));
            $jwd=$lon[1].$lat[1];
            //echo "找到的經(jīng)緯度:".$jwd;
            if ($jwd==$myxy){
               fclose($fp);
               return $x[1]."|".$y[1];
               break;
            }else if($jwd<$myxy){
               //echo " > ".$myxy."
";
               $left=($recordCount/8) +1;
            }else if($jwd>$myxy){
               //echo " < ".$myxy."
";
               $right=($recordCount/8) -1;
            }
 
        }
        fclose($fp);
}
 
$offset =xy_fk($tmplon.$tmplat);
$off=explode('|',$offset);
$lngPixel=lngToPixel($lon,18)+$off[0];
$latPixel=latToPixel($lat,18)+$off[1];
 
echo pixelToLat($latPixel,18).",".pixelToLng($lngPixel,18);
 
?>
c#算法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;   
 
namespace MapDigit.GIS
{
    public class GeoLatLng
    {   
 
        public GeoLatLng(double latitude, double longitude)
        {
            this.latitude = latitude;
            this.longitude = longitude;
        }
        public double latitude;
        public double longitude;
    }   
 
    public class GeoPoint
    {
        public GeoPoint(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public int x;
        public int y;
    }   
 
    public class OffsetInChina
    {
        //用于從GPS坐標(biāo)轉(zhuǎn)換為偏移后坐標(biāo)
        public static GeoLatLng fromEarthToMars(GeoLatLng earth)
        {
            GeoPoint ptOffset = getOffset(earth.latitude, earth.longitude);
            if (ptOffset.x != 0 || ptOffset.y != 0)
            {
                int pixelX, pixelY;
                TileSystem.LatLongToPixelXY(earth.latitude, earth.longitude, 18, out pixelX, out pixelY);
                GeoPoint pt = new GeoPoint(pixelX, pixelY);
                pt.x += ptOffset.x;
                pt.y += ptOffset.y;
                double latitude, longitude;
                TileSystem.PixelXYToLatLong(pt.x, pt.y, 18, out latitude, out longitude);
                return new GeoLatLng(latitude, longitude);   
 
            }
            else
            {
                return new GeoLatLng(earth.latitude, earth.longitude);
            }   
 
        }   
 
        //用于將偏移后坐標(biāo)轉(zhuǎn)成真實(shí)的坐標(biāo)
        public static GeoLatLng fromMarToEarth(GeoLatLng mars)
        {
            GeoPoint ptOffset = getOffset(mars.latitude, mars.longitude);
            if (ptOffset.x != 0 || ptOffset.y != 0)
            {
                int pixelX, pixelY;
                TileSystem.LatLongToPixelXY(mars.latitude, mars.longitude, 18, out pixelX, out pixelY);
                GeoPoint pt = new GeoPoint(pixelX, pixelY);
                pt.x -= ptOffset.x;
                pt.y -= ptOffset.y;
                double latitude, longitude;
                TileSystem.PixelXYToLatLong(pt.x, pt.y, 18, out latitude, out longitude);
                return new GeoLatLng(latitude, longitude);   
 
            }
            else
            {
                return new GeoLatLng(mars.latitude, mars.longitude);
            }
        }   
 
        //這個(gè)函數(shù)用于將需要查詢的經(jīng)緯度轉(zhuǎn)成最近的0.01分度值,無(wú)插值
        //也可以自行實(shí)現(xiàn)插值
        private static GeoPoint getQueryLocation(double latitude, double longitude)
        {
            int lat = (int)(latitude * 100);
            int lng = (int)(longitude * 100);
            double lat1 = ((int)(latitude * 1000 + 0.499999)) / 10.0;
            double lng1 = ((int)(longitude * 1000 + 0.499999)) / 10.0;
            for (double x = longitude; x < longitude + 1; x += 0.5)
            {
                for (double y = latitude; x < latitude + 1; y += 0.5)
                {
                    if (x <= lng1 && lng1 < (x + 0.5) && lat1 >= y && lat1 < (y + 0.5))
                    {
                        return new GeoPoint((int)(x + 0.5), (int)(y + 0.5));
                    }
                }
            }
            return new GeoPoint(lng, lat);
        }   
 
        private static GeoPoint getOffset(double longitude, double latitude)
        {
            //這個(gè)函數(shù)用于返回查詢結(jié)果,就是從校正數(shù)據(jù)中返回18級(jí)時(shí)x,y方偏移
            //可以自行實(shí)現(xiàn)
            return null;
        }   
 
    }
}
 

 


日本不打码在线免费观看,国产亚洲一区二区在线观看,国产成精品在线观看,无码人妻丰满熟妇区毛片 亚洲精选AⅤ在线观看 精品久久国产下药白嫩美女
<code id="smqwm"><abbr id="smqwm"></abbr></code>
<dfn id="smqwm"><source id="smqwm"></source></dfn>
<li id="smqwm"><code id="smqwm"></code></li>
<ul id="smqwm"><source id="smqwm"></source></ul>
<strike id="smqwm"></strike>
<center id="smqwm"></center>