Converting Longitude & Latitude to X Y on a map with Calibration points

后端 未结 7 1022
既然无缘
既然无缘 2020-11-29 01:25

If i have a jpeg map with size sizeX, sizeY

and some calibration points on the map (X, Y, Lon, Lat)

What would be the algorithm for calculating the correspon

相关标签:
7条回答
  • 2020-11-29 02:01

    This is fairly straight forward and simple.. let me explain how its possible.

    Latitude and Longitude are imaginary lines drawn on earth so that you can accurately pinpoint any location on the world . simply put they are the X and Y coords of a plane. Latitude is a vertical line running from north to south with its 90 deg at the north pole and -90deg at the south pole.

    Longitude on the other hand is a horizontal line running east to south with -180deg in the west and 180deg in the east.

    you can convert the latLng into pixel coords as by assuming that the width of the html container is the width of the world and the same applies to the the height.

    Formula - Longitude - pixel

    (givenLng*widthOfContainerElement)/360
    

    where 360 is the total longitude in degrees

    Formula -Latitude - pixel

    (givenLat*heightOfContainerElement)/180
    

    where 180 is the total latitude in degree

    //Height is calculated from the bottom
    

    you can find a working implementation of this formula here, on my website (it uses JavaScript only)

    http://www.learntby.me/javascript/latLngconversion.php

    let me know if you still need any clarifications.

    0 讨论(0)
提交回复
热议问题