Coordinate interchange between Web mocato coordinates and WGS84 coordinates

Source: Internet
Author: User
Original article address:
Http://bbs.esrichina-bj.cn/ESRI/thread-78245-1-1.html

Commonly used map projection in WebGIS development is Web mocato and WGS84. Therefore, Song maps, bingmaps, Baidu maps, mapabc, mapbar, most of the maps on ArcGIS online are Web mocato maps, and the map projection launched on ArcGIS online is WGS84.
During the development process, the interaction between different coordinate systems is often encountered, especially when the basemap uses the Web mocato, positioning (GPS, WiFi, and so on) signal coordinates are WGS84 coordinates, the general solution is to write a conversion database for the Coordinate Reference System, which is similar to proj4. However, in general, there are few interchange between reference systems, in addition, implementing or calling proj4 on the client is a very difficult or troublesome task. In most cases, we can convert the coordinates of Web mocato and WGS84.
The following figure shows the interaction between the Web mocato coordinate and the WGS84 coordinate implemented by objective-C. Program Of course, it can also be implemented in other languages, which is relatively simple and convenient to use.
// Convert the longitude and latitude to the Mercator
-(Cgpoint) lonlat2mercator :( cgpoint) lonlat
{
Cgpoint Mercator;
Double X = lonlat. x * 20037508.34/180;
Double Y = Log (TAN (90 + lonlat. Y) * m_pi/360)/(m_pi/180 );
Y = y * 20037508.34/180;
Mercator. x = X;
Mercator. Y = y;
Return Mercator;
}
// Mercato turn longitude and latitude
-(Cgpoint) mercator2lonlat :( cgpoint) Mercator
{
Cgpoint lonlat;
Double X = Mercator. X/20037508.34*180;
Double Y = Mercator. Y/20037508.34*180;
Y = 180/m_pi * (2 * atan (exp (y * m_pi/180)-m_pi/2 );
Lonlat. x = X;
Lonlat. Y = y;
Return lonlat;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.