-
地图坐标系转换
2018-04-24 15:36:47* 谷歌中国地图和搜搜中国地图采用的是GCJ02地理坐标系; BD09坐标系:即百度坐标系,GCJ02坐标系经加密后的坐标系; * 搜狗坐标系、图吧坐标系等,估计也是在GCJ02基础上加密而成的。 chenhua */ -
地图坐标系转换工具类Java版
2020-01-21 11:22:58本工具类为java版地图坐标系转换工具类,适用于SuperMap、ArcGIS、MapInfo等主流的地图引擎 -
地图坐标系转换工具类JS版
2020-01-21 11:24:27本工具类为Javascript版地图坐标系转换工具类,适用于SuperMap、ArcGIS、MapInfo等主流的地图引擎。 -
地图坐标系转换简介
2020-08-28 17:09:03地图坐标系转换简介及问题分享 背景介绍 从android系统定位获取到的经纬度,到谷歌地图查询,发现定位偏移很大,以为是定位误差或者定位策略问题导致,实际上并非如此,详情以下分解。 各坐标系简介 WGS84...- 地图坐标系转换简介及问题分享
- 背景介绍
从android系统定位获取到的经纬度,到谷歌地图查询,发现定位偏移很大,以为是定位误差或者定位策略问题导致,实际上并非如此,详情以下分解。
-
- 各坐标系简介
- WGS84坐标系 即地球坐标系,国际上通用的坐标系。 设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系。谷歌地图采用的是WGS84地理坐标系(中国范围内谷歌中国地图采用的是GCJ02地理坐标系),android手机定位使用
- GCJ02坐标系 即火星坐标系,WGS84坐标系经加密后的坐标系。 出于国家安全考虑,国内所有导航电子地图必须使用国家测绘局制定的加密坐标系统,即将一个真实的经纬度坐标加密成一个不正确的经纬度坐标。高德地图使用。
- BD09坐标系 即百度坐标系,GCJ02坐标系经加密后的坐标系。百度地图使用。
- 各坐标系转换
- 百度地图,官方API支持WGS84、GCJ02转换成BD09,反向不支持
- 高德地图,官方API支持WGS84、BD09转换成GCJ02,反向不支持
- WGS84,无官方API支持BD09、GCJ02转WGS84,网上有各种非官方的转换方法,但准确度有待考究,并且已知的很多也是有误的。
- 经验总结:
- 手机上定位获取到的经纬度,不能直接在地图上定位位置,而应该转换成对应坐标系,再用对应到地图才能正确定位
- 手机上定位获取到的经纬度,可以直接使用系统API逆地理编码得到对应地址名,逆地理编码能力也来源于百度或高德
-
- 为什么会发生偏移
1.坐标系不兼容
由于坐标系之间不兼容,如在百度地图上定位的经纬度拿到高德地图上直接描点就肯定会发生偏移;只考虑国内的情况,高德地图和Google地图是可以不经过转换也能够准确显示的(在国内用的都是GCJ-02坐标系);下面是收录了网上的WGS-84,GCJ-02,百度坐标系(bd-09)之间的相互转换的方法,经测试,是转换后相对准确可用的。
2.国内外不同
谷歌地图采用的是WGS84地理坐标系(中国范围除外),谷歌中国地图和搜搜中国地图采用的是GCJ02地理坐标系,百度采用的是BD09坐标系,而设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系。
在国内定位的经纬度,然后在国外网络下显示也会发生偏移(谷歌和高德会依据网络的情况选择使用WGS-84坐标还是GCJ-02坐标,百度地图则一直使用bd-02坐标系)。
参考链接:
实测转换精确度比较高的可用网站: https://atool.vip/lnglat/
WGS84、BD09、GCJ02互转,共6个函数(转载版)
# -*- coding: utf-8 -*- import math x_pi = 3.14159265358979324 * 3000.0 / 180.0 pi = 3.1415926535897932384626 # π a = 6378245.0 # 长半轴 ee = 0.00669342162296594323 # 偏心率平方 def gcj02_to_bd09(lng, lat): """ 火星坐标系(GCJ-02)转百度坐标系(BD-09) 谷歌、高德——>百度 :param lng:火星坐标经度 :param lat:火星坐标纬度 :return: """ z = math.sqrt(lng * lng + lat * lat) + 0.00002 * math.sin(lat * x_pi) theta = math.atan2(lat, lng) + 0.000003 * math.cos(lng * x_pi) bd_lng = z * math.cos(theta) + 0.0065 bd_lat = z * math.sin(theta) + 0.006 return [bd_lng, bd_lat] def bd09_to_gcj02(bd_lon, bd_lat): """ 百度坐标系(BD-09)转火星坐标系(GCJ-02) 百度——>谷歌、高德 :param bd_lat:百度坐标纬度 :param bd_lon:百度坐标经度 :return:转换后的坐标列表形式 """ x = bd_lon - 0.0065 y = bd_lat - 0.006 z = math.sqrt(x * x + y * y) - 0.00002 * math.sin(y * x_pi) theta = math.atan2(y, x) - 0.000003 * math.cos(x * x_pi) gg_lng = z * math.cos(theta) gg_lat = z * math.sin(theta) return [gg_lng, gg_lat] def wgs84_to_gcj02(lng, lat): """ WGS84转GCJ02(火星坐标系) :param lng:WGS84坐标系的经度 :param lat:WGS84坐标系的纬度 :return: """ dlat = _transformlat(lng - 105.0, lat - 35.0) dlng = _transformlng(lng - 105.0, lat - 35.0) radlat = lat / 180.0 * pi magic = math.sin(radlat) magic = 1 - ee * magic * magic sqrtmagic = math.sqrt(magic) dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * pi) dlng = (dlng * 180.0) / (a / sqrtmagic * math.cos(radlat) * pi) mglat = lat + dlat mglng = lng + dlng return [mglng, mglat] def gcj02_to_wgs84(lng, lat): """ GCJ02(火星坐标系)转GPS84 :param lng:火星坐标系的经度 :param lat:火星坐标系纬度 :return: """ dlat = _transformlat(lng - 105.0, lat - 35.0) dlng = _transformlng(lng - 105.0, lat - 35.0) radlat = lat / 180.0 * pi magic = math.sin(radlat) magic = 1 - ee * magic * magic sqrtmagic = math.sqrt(magic) dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * pi) dlng = (dlng * 180.0) / (a / sqrtmagic * math.cos(radlat) * pi) mglat = lat + dlat mglng = lng + dlng return [lng * 2 - mglng, lat * 2 - mglat] def bd09_to_wgs84(bd_lon, bd_lat): lon, lat = bd09_to_gcj02(bd_lon, bd_lat) return gcj02_to_wgs84(lon, lat) def wgs84_to_bd09(lon, lat): lon, lat = wgs84_to_gcj02(lon, lat) return gcj02_to_bd09(lon, lat) def _transformlat(lng, lat): ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + \ 0.1 * lng * lat + 0.2 * math.sqrt(math.fabs(lng)) ret += (20.0 * math.sin(6.0 * lng * pi) + 20.0 * math.sin(2.0 * lng * pi)) * 2.0 / 3.0 ret += (20.0 * math.sin(lat * pi) + 40.0 * math.sin(lat / 3.0 * pi)) * 2.0 / 3.0 ret += (160.0 * math.sin(lat / 12.0 * pi) + 320 * math.sin(lat * pi / 30.0)) * 2.0 / 3.0 return ret def _transformlng(lng, lat): ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + \ 0.1 * lng * lat + 0.1 * math.sqrt(math.fabs(lng)) ret += (20.0 * math.sin(6.0 * lng * pi) + 20.0 * math.sin(2.0 * lng * pi)) * 2.0 / 3.0 ret += (20.0 * math.sin(lng * pi) + 40.0 * math.sin(lng / 3.0 * pi)) * 2.0 / 3.0 ret += (150.0 * math.sin(lng / 12.0 * pi) + 300.0 * math.sin(lng / 30.0 * pi)) * 2.0 / 3.0 return ret
- 地图坐标系转换简介及问题分享
-
neu坐标系和xyz坐标系转换_Python地图坐标系转换库MapDatumTrans发布
2021-01-06 09:40:39MapDatumTrans · PyPIpypi.org这个项目是的主要目的是自用,因为以前不懂,把个人图片里的...做这些用的是我以前搞得一个开源Python程序GPX-in-China,可以自动把WSG84坐标系的GPX文件转换为GCJ02。算法来自:sc...MapDatumTrans · PyPIpypi.org这个项目是的主要目的是自用,因为以前不懂,把个人图片里的图片地理位置坐标都搞成了GCJ02坐标系,但实际上MacOS照片、小米的相册应用都可以正确处理WGS84坐标系,使用GCJ02坐标系反倒会偏移。
做这些用的是我以前搞得一个开源Python程序GPX-in-China,可以自动把WSG84坐标系的GPX文件转换为GCJ02。算法来自:scateu/PyWGS84ToGCJ02但是其只提供了WGS84 to GCJ02的转换。我最近想搞一个更通用的工具,也需要GCJ02转换为WGS84。
提供了这个功能的库是wandergis/coordTransform_py。但是其pypi的库不能使用,我这边重新稍作修改,重新封装了一下。主要修改了两个部分:
- 删除一个坐标是否是中国的判断,这个判断是用矩形法判断的,即把中国看成一个矩形,好处就是算法简单,坏处是会把大片中国以外的坐标判断为中国。以后再想更好的办法。
- 删除了高德API的使用,这个目的是保持一个简单库只做一件事情,做的事情多,疏于维护反而不好。
最后项目链接:
bluicezhen/MapDatumTrans: MapDatumTranss is a transformer for map datum,include WGS84, GCJ-02 and BD-09.github.com欢迎批判。
-
各地图坐标系转换(WGS84坐标系,GCJ02坐标系,BD09坐标系)
2014-09-16 16:59:24各地图坐标系转换; WGS84坐标系:即地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系,谷歌地图采用的是WGS84地理坐标系(中国范围除外); GCJ02坐标系:即火星坐标...package position; import org.junit.Test; /** * 各地图API坐标系统比较与转换; * * WGS84坐标系:即地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系,谷歌地图采用的是WGS84地理坐标系(中国范围除外); * * GCJ02坐标系:即火星坐标系,是由中国国家测绘局制订的地理信息系统的坐标系统。由WGS84坐标系经加密后的坐标系。谷歌中国地图和搜搜中国地图采用的是GCJ02地理坐标系; * * BD09坐标系:即百度坐标系,GCJ02坐标系经加密后的坐标系; * * 搜狗坐标系、图吧坐标系等,估计也是在GCJ02基础上加密而成的。 * * @author chenhua * */ public class PositionUtil { private static double pi = 3.1415926535897932384626; private static double a = 6378245.0; private static double ee = 0.00669342162296594323; @Test public void t1() { // 北斗芯片获取的经纬度为WGS84地理坐标 31.426896,119.496145 Gps gps = new Gps(31.426896, 119.496145); System.out.println("gps :" + gps); Gps gcj = gps84_To_Gcj02(gps.getWgLat(), gps.getWgLon()); System.out.println("gcj :" + gcj); Gps star = gcj_To_Gps84(gcj.getWgLat(), gcj.getWgLon()); System.out.println("star:" + star); Gps bd = gcj02_To_Bd09(gcj.getWgLat(), gcj.getWgLon()); System.out.println("bd :" + bd); Gps gcj2 = bd09_To_Gcj02(bd.getWgLat(), bd.getWgLon()); System.out.println("gcj :" + gcj2); } /** * 84 to 火星坐标系 (GCJ-02) * * World Geodetic System ==> Mars Geodetic System * * @param lat * @param lon * @return */ public static Gps gps84_To_Gcj02(double lat, double lon) { if (outOfChina(lat, lon)) { return null; } double dLat = transformLat(lon - 105.0, lat - 35.0); double dLon = transformLon(lon - 105.0, lat - 35.0); double radLat = lat / 180.0 * pi; double magic = Math.sin(radLat); magic = 1 - ee * magic * magic; double sqrtMagic = Math.sqrt(magic); dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); double mgLat = lat + dLat; double mgLon = lon + dLon; return new Gps(mgLat, mgLon); } /** * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return */ public Gps gcj_To_Gps84(double lat, double lon) { Gps gps = transform(lat, lon); double lontitude = lon * 2 - gps.getWgLon(); double latitude = lat * 2 - gps.getWgLat(); return new Gps(latitude, lontitude); } /** * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 GCJ-02 坐标转换成 BD-09 坐标 * * @param gg_lat * @param gg_lon */ public static Gps gcj02_To_Bd09(double gg_lat, double gg_lon) { double x = gg_lon, y = gg_lat; double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi); double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi); double bd_lon = z * Math.cos(theta) + 0.0065; double bd_lat = z * Math.sin(theta) + 0.006; return new Gps(bd_lat, bd_lon); } /** * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 BD-09 坐标转换成GCJ-02 坐标 * * @param bd_lat * @param bd_lon * @return */ public static Gps bd09_To_Gcj02(double bd_lat, double bd_lon) { double x = bd_lon - 0.0065, y = bd_lat - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi); double gg_lon = z * Math.cos(theta); double gg_lat = z * Math.sin(theta); return new Gps(gg_lat, gg_lon); } private static boolean outOfChina(double lat, double lon) { if (lon < 72.004 || lon > 137.8347) return true; if (lat < 0.8293 || lat > 55.8271) return true; return false; } private Gps transform(double lat, double lon) { if (outOfChina(lat, lon)) { return new Gps(lat, lon); } double dLat = transformLat(lon - 105.0, lat - 35.0); double dLon = transformLon(lon - 105.0, lat - 35.0); double radLat = lat / 180.0 * pi; double magic = Math.sin(radLat); magic = 1 - ee * magic * magic; double sqrtMagic = Math.sqrt(magic); dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); double mgLat = lat + dLat; double mgLon = lon + dLon; return new Gps(mgLat, mgLon); } private static double transformLat(double x, double y) { double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0; ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0; return ret; } private static double transformLon(double x, double y) { double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0; ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0; return ret; } }
package position; public class Gps { private double wgLat; private double wgLon; public Gps(double wgLat, double wgLon) { setWgLat(wgLat); setWgLon(wgLon); } public double getWgLat() { return wgLat; } public void setWgLat(double wgLat) { this.wgLat = wgLat; } public double getWgLon() { return wgLon; } public void setWgLon(double wgLon) { this.wgLon = wgLon; } @Override public String toString() { return wgLat + "," + wgLon; } }
-
iOS地图坐标系转换
2015-11-25 16:10:451,iOS百度地图坐标系转换----百度To谷歌 UIKIT_EXTERN NSDictionary* BMKBaiduCoorForWgs84(CLLocationCoordinate2D coorWgs84); UIKIT_EXTERN NSDictionary* BMKBaiduCoorForGcj(CLLocationCoordinate2D coorGcj);...1,iOS百度地图坐标系转换----百度To谷歌
<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(122, 72, 47);">UIKIT_EXTERN</span> <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">NSDictionary</span>* BMKBaiduCoorForWgs84(<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">CLLocationCoordinate2D</span> coorWgs84); <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(122, 72, 47);">UIKIT_EXTERN</span><span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(0, 0, 0);"> </span>NSDictionary<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(0, 0, 0);">* BMKBaiduCoorForGcj(</span>CLLocationCoordinate2D<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(0, 0, 0);"> coorGcj);</span> <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(122, 72, 47);">UIKIT_EXTERN</span> <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">CLLocationCoordinate2D</span> BMKCoorDictionaryDecode(<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">NSDictionary</span>* dictionary);
<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(126, 72, 48);">#import </span>"GTMBase64.h"
- (CLLocationCoordinate2D )getBaiduFromGoogle:(CLLocationCoordinate2D )locationCoord { NSDictionary *baidudict =BMKBaiduCoorForGcj(CLLocationCoordinate2DMa<wbr>ke(locationCoord.latitude, locationCoord.longitude)); NSLog(@"google坐标是:%f,%f",locationCoord.latitude,locationCoord.longitude); NSString *xbase64 =[baidudict objectForKey:@"x"]; NSString *ybase64 = [baidudict objectForKey:@"y"]; NSData *xdata = [GTMBase64 decodeString:xbase64]; NSData *ydata = [GTMBase64 decodeString:ybase64]; NSString *xstr = [[NSString alloc] initWithData:xdata encoding:NSUTF8StringEncoding]; NSString *ystr = [[NSString alloc] initWithData:ydata encoding:NSUTF8StringEncoding]; CLLocationCoordinate2D result; result.latitude =[ystr floatValue]; result.longitude = [xstr floatValue]; NSLog(@"百度坐标是:%f,%f",result.latitude,result.longitude); return result; } </wbr>
百度坐标和GPS坐标转换在很近的距离时偏差非常接近。
假设你有百度坐标:x1=116.397428,y1=39.90923
把这个坐标当成GPS坐标,通过接口获得他的百度坐标:x2=116.41004950566,y2=39.916979519873
通过计算就可以得到GPS的坐标:
x = 2*x1-x2,y = 2*y1-y2
x=116.38480649434001
y=39.9014804801272,在WebGIS的开发中经常用到的地图投影为Web墨卡托和WGS84,谷歌地图,bingmaps,百度地图,mapabc,mapbar,以及 ArcGIS online上的大部分地图为Web墨卡托地图,ArcGIS online上最开始发布的地图投影为WGS84。在开发过程中很多时候会遇到不同坐标系之间互转的问题,特别是底图使用Web墨卡托,定位(GPS,wifi等)信号坐标为WGS84坐标的时候,那么通 用解决方案就是写一个坐标参考系的转换库,类似于proj4,但一般情况下很少用到那么多的参考系之间的互转,并且在客户端实现或者调用proj4都是一 件很困难或者麻烦的事情,大多数情况下我们实现Web墨卡托坐标与WGS84坐标互转就可以了。
下面是使用objective-c实现的Web墨卡托坐标与WGS84坐标互转程序,当然也可以使用其他语言来实现,使用起来比较简单和方便。
//经纬度转墨卡托
-(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 ;
}
//墨卡托转经纬度
-(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;
}3,WGS 84 - SRID 4326 WGS 84 标准提供地球的球体参照面。这是全球定位系统(Global Positioning System,简称 GPS)使用的空间参照系。WGS 84 的坐标原点是地球的质心,精度可达到 ±1 米。WGS 表示世界坐标系 (World Geodetic System)。WGS 84 坐标单位是度,其中,第一个坐标是经度,范围是 -180 到 180;第二个坐标是纬度,范围是 -90 到 90。
WGS 84 的缺省测量单位是米,是球形地球类型的空间参照系。
4,GPS to ArgGIS实例(ArcGIS for iOS)
// 定位
@property (nonatomic, retain) CLLocationManager *LocationMan;
@property (nonatomic, retain) AGSGraphic *LocationPin;
- (IBAction)MapLocationBtnTouched:(id)sender
{
UIButton *btn = (UIButton *)sender;
if (LocationMan == nil) {
LocationMan = [[CLLocationManager alloc] init];
LocationMan.delegate = self;
}
if (!btn.isSelected) {
[LocationMan startUpdatingLocation];
[btn setSelected:YES];
}else{
[LocationMan stopUpdatingLocation];
[self.graphicsLayer removeGraphic:self.LocationPin];
self.LocationMan = nil;
self.LocationPin = nil;
[btn setSelected:NO];
[self.graphicsLayer dataChanged];
}
}
#pragma mark - CLLocationDelegate Methods
// (__MAC_10_6, __MAC_NA, __IPHONE_2_0, __IPHONE_6_0)
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
[self createLocationPin:newLocation];
}
// __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
[self createLocationPin:[locations lastObject]];
}
- (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;
}
- (void)createLocationPin:(CLLocation *)location
{
AGSGeometryEngine *GeometryEngine = [AGSGeometryEngine defaultGeometryEngine];
// 经纬度对应xy
CGPoint point = CGPointMake(location.coordinate.longitude, location.coordinate.latitude);
point = [self lonLat2Mercator:point];
// 102100是墨卡托空间参考系 WKID可以参照此网址:http://gis.jl.gov.cn/Portal/api/JS/help/jsapi/spatialreference.htm
AGSSpatialReference *sPrf = [AGSSpatialReferencespatialReferenceWithWKID:102100];
AGSPoint *mappoint = [AGSPoint pointWithX:point.x y:point.y spatialReference:sPrf];
// 3857就是GIS服务的空间参考系, 可以在网页中打开GIS服务查看此参考系
AGSPoint *mappoint2 = (AGSPoint *)[GeometryEngine projectGeometry:mappointtoSpatialReference:[AGSSpatialReference spatialReferenceWithWKID:3857]];
if (LocationPin == nil) {
AGSPictureMarkerSymbol *pt = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"POIRedPin_small.png"];
self.LocationPin = [[AGSGraphic alloc] initWithGeometry:mappoint2 symbol:ptattributes:nil infoTemplateDelegate:nil];
[self.graphicsLayer addGraphic:LocationPin];
}else{
self.LocationPin.geometry = mappoint2;
}
[self.graphicsLayer dataChanged];
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSString *errMsg = [error localizedDescription];
}
GIS服务为:NSString *TStr =@"http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer";
// 如果TStr中有汉字的话, 要执行下面代码, 下面这个服务只是测试, 无此服务.
// NSString *TStr = @"http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/中国/MapServer";
// TStr = [TStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *mapUrl = [NSURL URLWithString:TStr];
AGSTiledMapServiceLayer *tiledLyr = [AGSTiledMapServiceLayertiledMapServiceLayerWithURL:mapUrl];
[self.BaseMapView addMapLayer:tiledLyr withName:@"TiledLayer"];
-
FreeJTS部标视频平台:车载坐标系与地图坐标系转换
2020-11-23 10:48:07经了解,需要进行车载坐标系和地图坐标系进行转换。 常见坐标系 WGS84坐标系 地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系。 GCJ02坐标系 火星坐标系,是由中国... -
gps各种地图坐标系转换
2018-04-23 16:28:00在之前开发地图应用的时候发现从WGS84坐标系(GPS)转换成某个地图坐标系都比较困难。然后只能使用地图供应商提供的webservice接口转换。百度也提供了免费的webservice接口(限制并发量)。对于少数点的转换性能还... -
Kotlin地图坐标系转换
2019-12-30 18:06:301.效果图: 2.运行结果: E/TAG: 最初始的高德选点坐标: 113.402847,23.164699 E/TAG: g84坐标点: 113.39732255710973,23.167184411566584 E/TAG: g02的坐标点: ... E/TAG: 最终的坐标点: 113.40284698937... -
iOS 地图坐标系转换
2018-08-12 23:52:50很可惜,在中国,任何一个地图产品都不允许使用GPS坐标, 据说是为了保密。GPS坐标形式如图,度分秒形式的经纬度。 2、 GCJ-02,国测局02年发布的坐标体系。又称“火星坐标”。 在中国,必须至少... -
对.gpx文件进行地图坐标系转换
2020-10-02 13:11:07关于地图坐标系,可以参考这篇文章,下表列出了几种常用的坐标系: 坐标系 解释 使用地图 WGS84 地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系,最基础的... -
真实GPS转腾讯/高德地图坐标系,百度地图与腾讯/高德地图坐标系转换
2019-11-26 11:21:411.获取真实坐标GPS wgs84转为gcj编码方式 positiontransform(array,manual){ //定义常量 var GPS = { PI : 3.14159265358979324, x_pi : 3.141592... -
GPS各种地图坐标系转换(转载)
2016-08-17 09:58:00在之前开发地图应用的时候发现从WGS84坐标系(GPS)转换成某个地图坐标系都比较困难。然后只能使用地图供应商提供的webservice接口转换。百度也提供了免费的webservice接口(限制并发量)。对于少数点的转换性能还可... -
wgs84坐标系拾取工具_各种地图坐标系转换工具
2021-02-11 15:40:58} }/*** 各种坐标系转换工具类 *@authorchenfangbo *@returndouble **/ public classPositionUtil {public static final String BAIDU_LBS_TYPE = "bd09ll";public static double pi = 3.1415926535897932384626 * ... -
iOS Swift 应用内跳转第三方地图导航路线 及地图坐标系转换
2019-08-27 15:52:28支持百度 谷歌 高德 苹果 腾讯地图 一键打开及 地图之间的坐标系的转换 ... 注意: 百度用的自己的坐标系(在火星坐标系上...在传递经纬度的时候请确定是什么坐标系 然后使用坐标系转换代码 进行坐标转换。 在iOS开... -
ios 地图坐标系转换
2015-07-27 00:49:45一、坐标体系 首先我们要明白,开发者能接触到哪些坐标体系呢?...很可惜,在中国,任何一个地图产品都不允许使用GPS坐标, 据说是为了保密。GPS坐标形式如图,度分秒形式的经纬度。 2、 GCJ-02,国测局02年... -
百度高德地图 坐标系转换
2016-09-26 08:49:27可以访问http://www.gpsspg.com/maps.htm 来参考坐标变化 API可以使用:http://api.zdoz.net/interfaces.aspx -
python地图坐标系转换(bd09,gcj02,wgs84三种投影坐标系相互转化)
2021-04-14 08:39:40坐标系是GIS的重中之重,一般来说,工作底图平面坐标系应采用国家大地坐标系CGCS2000(或相当于精度WGS84坐标系),投影方式采用高斯-克吕格投影,高程基准采用1985国家高程基准。 1.2 地理坐标系(GCS,Geographic ... -
主流地图 坐标系转换,百度、腾讯、高德等
2014-12-02 09:38:45在我国,为了国家安全,电子地图不可以使用地球坐标系WGS84,必须经过偏转。面前主流的几款地图都...那么这3个常用坐标系直接如何转换呢。 参照这个连接我总结了一下。http://blog.csdn.net/meegomeego/article/detail