GPS Correction 0.01 Precision Tool / Algorithm Case

2019-09-17 11:40:39 root 390

Precision tool download: http://map.yanue.net/gps.html

 

This correction applies to Google map China, Microsoft map china, MapABC, etc., because these maps are the same as the offset.dat file, which is 0.01 precision correction data. If you need it, please contact the website, non-free version.

 

Algorithm demonstration:

 

 

?

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

/*

   Code function: Correct the Chinese map latitude and longitude offset with the 0.01 precision correction library file.

*/

header("Content-Type:text/html; charset=utf-8");

define('__dat_db__' 'offset.dat' );// DAT the file of data

define('datmax' , 9813675 );// Number of data - end record

 

// # offset.php?lat=39.914914&lon=116.460633

$lon=$_GET['lon'];

$lat=$_GET['lat'];

$tmplon=intval($lon * 100);

$tmplat=intval($lat * 100);

//Longitude to pixel X value

function lngToPixel($lng,$zoom) {

return ($lng+180)*(256<<$zoom)/360;

}

//Pixel X to longitude

function pixelToLng($pixelX,$zoom){

return $pixelX*360/(256<<$zoom)-180;

}

//Latitude to pixel Y

function latToPixel($lat$zoom) {

$siny = sin($lat * pi() / 180);

$y=log((1+$siny)/(1-$siny));

return (128<<$zoom)*(1-$y/(2*pi()));

}

//Pixel Y to latitudefunction 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;//Start recording        $right = datmax;//end the record

 

        //Use dichotomy to find data

        while($left <= $right){

            $recordCount =(floor(($left+$right)/2))*8; //Take half

            //echo "Operation:left=".$left." right=".$right." midde=".$recordCount."
";

            @fseek $fp$recordCount , SEEK_SET ); //Set cursor

            $c fread($fp,8); //Read 8 bytes

            $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 "Latitude and longitude found:".$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#algorithm

?

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

    {

        //Used to convert from GPS coordinates to post-offset coordinates        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);

            }   

 

        }   

 

        //Used to convert the post-offset coordinates to true coordinates

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

            }

        }   

 

        //This function is used to convert the latitude and longitude that needs to be queried into the nearest 0.01 division value, without interpolation.

        //You can also implement interpolation by yourself.

        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)

        {

            //This function is used to return the result of the query, which is to return the level 18, x, y offset from the corrected data.

            //Can be implemented by itself

            return null;

        }   

 

    }

}

主站蜘蛛池模板: 国内精品久久久久影院日本| 狠狠色噜噜狠狠狠狠69| 欧美激情二区三区| 国产成人精品视频一区二区不卡 | 18精品久久久无码午夜福利| 小小视频日本高清完整版| 久久亚洲国产精品五月天婷| 欧美aaaaaaaaaa| 亚洲精品456在线播放| 精品久久人人做人人爽综合| 国产乱子伦视频大全| 日日夜夜嗷嗷叫| 国内揄拍国内精品视频| xxxxx性bbbbb欧美| 成人综合激情另类小说| 妓女嫖客叫床粗话对白| 乱子伦一级在线观看高清| 欧美视频亚洲色图| 免费在线观看污网站| www.亚洲日本| 男人j放进女人p全黄午夜视频| 国产h肉在线视频免费观看| 黄色三级在线播放| 国产精品91视频| 84pao国产成视频免费播放| 天堂а√在线地址中文在线| 一本大道一卡二大卡三卡免费| 2018国产大陆天天弄| 性生活大片免费看| 久久伊人久久亚洲综合| 欧美人与动牲交a欧美精品| 亚洲激情成人网| 特黄特色大片免费| 免费又黄又爽1000禁片| 精品国产三级a∨在线欧美| 国产AV一区二区三区无码野战| 青青青手机视频| 国产在视频线精品视频2021| 国产精品20p| 日韩在线电影网| 亚洲一二区视频|