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