{"id":111,"date":"2014-02-18T07:13:59","date_gmt":"2014-02-18T07:13:59","guid":{"rendered":"http:\/\/www.sunyuping.cn\/wordpress\/?p=111"},"modified":"2014-02-18T07:13:59","modified_gmt":"2014-02-18T07:13:59","slug":"%e9%80%9a%e8%bf%87%e8%ae%a1%e7%ae%97%e8%bf%9b%e8%a1%8cgps%e5%9d%90%e6%a0%87%e3%80%81%e7%81%ab%e6%98%9f%e5%9d%90%e6%a0%87%e4%b8%8e%e7%99%be%e5%ba%a6%e5%9d%90%e6%a0%87%e9%97%b4%e7%9a%84%e8%bd%ac","status":"publish","type":"post","link":"https:\/\/www.sunyuping.com\/index.php\/2014\/02\/18\/%e9%80%9a%e8%bf%87%e8%ae%a1%e7%ae%97%e8%bf%9b%e8%a1%8cgps%e5%9d%90%e6%a0%87%e3%80%81%e7%81%ab%e6%98%9f%e5%9d%90%e6%a0%87%e4%b8%8e%e7%99%be%e5%ba%a6%e5%9d%90%e6%a0%87%e9%97%b4%e7%9a%84%e8%bd%ac\/","title":{"rendered":"\u901a\u8fc7\u8ba1\u7b97\u8fdb\u884cGPS\u5750\u6807\u3001\u706b\u661f\u5750\u6807\u4e0e\u767e\u5ea6\u5750\u6807\u95f4\u7684\u8f6c\u6362\u3002\u4e0d\u9700\u6570\u636e\u5e93\u548c\u8054\u7f51\u3002"},"content":{"rendered":"<p>\t\t\t\t\u901a\u8fc7\u8ba1\u7b97\u8fdb\u884cGPS\u5750\u6807\u3001\u706b\u661f\u5750\u6807\u4e0e\u767e\u5ea6\u5750\u6807\u95f4\u7684\u8f6c\u6362\u3002<br \/>\n\u4e0d\u9700\u6570\u636e\u5e93\u548c\u8054\u7f51\u3002<br \/>\n\u6ce8\uff1a\u8f6c\u6362\u7b97\u6cd5\u4f1a\u5b9a\u671f\u6539\u53d8\uff0c\u4f46\u5468\u671f\u5e94\u8be5\u6bd4\u8f83\u957f\u3002\uff08\u76ee\u524d\u7684\u4f7f\u7528\u770b\u6765\u4ecd\u7136\u53ef\u7528\uff09<br \/>\n\u5728\u7f51\u4e0a\u770b\u5230\u7684\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5177\u4f53\u662f\u4fee\u6539\u81ea\u8fd9\u4efd\u4ee3\u7801\uff1a<br \/>\n<a href=\"https:\/\/on4wp7.codeplex.com\/SourceControl\/changeset\/view\/21483#353936\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/on4wp7.codeplex.com\/SourceControl\/changeset\/view\/21483#353936<\/a><\/p>\n<pre class=\"brush:objc\">  \n\/\/ \u767e\u5ea6\u5750\u6807\u8f6c\u8c37\u6b4c\u5750\u6807\n\nconst CGFloat x_pi = 3.14159265358979324 * 3000.0 \/ 180.0;\n\n+ (void)transformatBDLat:(CGFloat)fBDLat BDLng:(CGFloat)fBDLng toGoogleLat:(CGFloat *)pfGoogleLat googleLng:(CGFloat *)pfGoogleLng\n{\n\n    CGFloat x = fBDLng - 0.0065f, y = fBDLat - 0.006f;\n\n    CGFloat z = sqrt(x * x + y * y) - 0.00002f * sin(y * x_pi);\n\n    CGFloat theta = atan2(y, x) - 0.000003f * cos(x * x_pi);\n\n    *pfGoogleLng = z * cos(theta);\n\n    *pfGoogleLat = z * sin(theta);\n\n}\n\n+ (CLLocationCoordinate2D)getGoogleLocFromBaiduLocLat:(CGFloat)fBaiduLat lng:(CGFloat)fBaiduLng\n\n{\n\n    CGFloat fLat;\n\n    CGFloat fLng;\n\n    [[self class] transformatBDLat:fBaiduLat BDLng:fBaiduLng toGoogleLat:&amp;fLat; googleLng:&amp;fLng;];\n\n    CLLocationCoordinate2D objLoc;\n\n    objLoc.latitude = fLat;\n\n    objLoc.longitude = fLng;\n\n    return objLoc;\n\n}\n\n\/\/ \u8c37\u6b4c\u5750\u6807\u8f6c\u767e\u5ea6\u5750\u6807\n\n+ (CLLocationCoordinate2D)getBaiduLocFromGoogleLocLat:(CGFloat)fGoogleLat lng:(CGFloat)fGoogleLng\n\n{\n\n    CLLocationCoordinate2D objLoc;\n\n    CGFloat x = fGoogleLng, y = fGoogleLat;\n\n    CGFloat z = sqrt(x * x + y * y) + 0.00002f * sin(y * x_pi);\n\n    CGFloat theta = atan2(y, x) + 0.000003f * cos(x * x_pi);\n\n    objLoc.longitude = z * cos(theta) + 0.0065;\n\n    objLoc.latitude = z * sin(theta) + 0.006;\n\n    return objLoc;\n\n}\n\n\/*******************       === GPS-Google  BEGIN  ===    *******************\/\n\n\/*               \u5728\u7f51\u4e0a\u770b\u5230\u7684\u6839\u636e\u8fd9\u4e2a c# \u4ee3\u7801\u6539\u7684 GPS\u5750\u6807\u8f6c\u706b\u661f\u5750\u6807               *\/\n\n\/*  https:\/\/on4wp7.codeplex.com\/SourceControl\/changeset\/view\/21483#353936  *\/\n\n\/***************************************************************************\/\n\nconst double pi = 3.14159265358979324;\n\n\/\/\n\n\/\/ Krasovsky 1940\n\n\/\/\n\n\/\/ a = 6378245.0, 1\/f = 298.3\n\n\/\/ b = a * (1 - f)\n\n\/\/ ee = (a^2 - b^2) \/ a^2;\n\nconst double a = 6378245.0;\n\nconst double ee = 0.00669342162296594323;\n\nbool outOfChina(double lat, double lon);\n\nstatic double transformLat(double x, double y);\n\nstatic double transformLon(double x, double y);\n\n\/\/ World Geodetic System ==&gt; Mars Geodetic System\n\nCLLocationCoordinate2D transformFromWGSCoord2MarsCoord(CLLocationCoordinate2D wgsCoordinate)\n\n{\n\n    double wgLat = wgsCoordinate.latitude;\n\n    double wgLon = wgsCoordinate.longitude;\n\n    if (outOfChina(wgLat, wgLon))\n\n    {\n\n        return wgsCoordinate;\n\n    }\n\n    double dLat = transformLat(wgLon - 105.0, wgLat - 35.0);\n\n    double dLon = transformLon(wgLon - 105.0, wgLat - 35.0);\n\n    double radLat = wgLat \/ 180.0 * pi;\n\n    double magic = sin(radLat);\n\n    magic = 1 - ee * magic * magic;\n\n    double sqrtMagic = sqrt(magic);\n\n    dLat = (dLat * 180.0) \/ ((a * (1 - ee)) \/ (magic * sqrtMagic) * pi);\n\n    dLon = (dLon * 180.0) \/ (a \/ sqrtMagic * cos(radLat) * pi);\n\n    CLLocationCoordinate2D marsCoordinate = {wgLat + dLat, wgLon + dLon};\n\n    return marsCoordinate;\n\n}\n\nbool outOfChina(double lat, double lon)\n{\n    if (lon &lt; 72.004 || lon &gt; 137.8347)\n        return true;\n    if (lat &lt; 0.8293 || lat &gt; 55.8271)\n        return true;\n    return false;\n}\n\ndouble transformLat(double x, double y)\n{\n    double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * sqrt(abs(x));\n    ret += (20.0 * sin(6.0 * x * pi) + 20.0 * sin(2.0 * x * pi)) * 2.0 \/ 3.0;\n    ret += (20.0 * sin(y * pi) + 40.0 * sin(y \/ 3.0 * pi)) * 2.0 \/ 3.0;\n    ret += (160.0 * sin(y \/ 12.0 * pi) + 320 * sin(y * pi \/ 30.0)) * 2.0 \/ 3.0;\n    return ret;\n}\n\ndouble transformLon(double x, double y)\n{\n    double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt(abs(x));\n    ret += (20.0 * sin(6.0 * x * pi) + 20.0 * sin(2.0 * x * pi)) * 2.0 \/ 3.0;\n    ret += (20.0 * sin(x * pi) + 40.0 * sin(x \/ 3.0 * pi)) * 2.0 \/ 3.0;\n    ret += (150.0 * sin(x \/ 12.0 * pi) + 300.0 * sin(x \/ 30.0 * pi)) * 2.0 \/ 3.0;\n    return ret;\n}\n\/*******************       === GPS-Google  END  ===    *******************\/\n\/\/ GPS\u5750\u6807\u8f6c\u8c37\u6b4c\u5750\u6807\n+ (CLLocationCoordinate2D)GPSLocToGoogleLoc:(CLLocationCoordinate2D)objGPSLoc\n{\n    return transformFromWGSCoord2MarsCoord(objGPSLoc);\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7\u8ba1\u7b97\u8fdb\u884cGPS\u5750\u6807\u3001\u706b\u661f\u5750\u6807\u4e0e\u767e\u5ea6\u5750\u6807\u95f4\u7684\u8f6c\u6362\u3002 \u4e0d\u9700\u6570\u636e\u5e93\u548c\u8054\u7f51\u3002 \u6ce8\uff1a\u8f6c\u6362\u7b97\u6cd5\u4f1a\u5b9a\u671f\u6539\u53d8\uff0c\u4f46\u5468\u671f\u5e94\u8be5\u6bd4 &#8230; <a title=\"\u901a\u8fc7\u8ba1\u7b97\u8fdb\u884cGPS\u5750\u6807\u3001\u706b\u661f\u5750\u6807\u4e0e\u767e\u5ea6\u5750\u6807\u95f4\u7684\u8f6c\u6362\u3002\u4e0d\u9700\u6570\u636e\u5e93\u548c\u8054\u7f51\u3002\" class=\"read-more\" href=\"https:\/\/www.sunyuping.com\/index.php\/2014\/02\/18\/%e9%80%9a%e8%bf%87%e8%ae%a1%e7%ae%97%e8%bf%9b%e8%a1%8cgps%e5%9d%90%e6%a0%87%e3%80%81%e7%81%ab%e6%98%9f%e5%9d%90%e6%a0%87%e4%b8%8e%e7%99%be%e5%ba%a6%e5%9d%90%e6%a0%87%e9%97%b4%e7%9a%84%e8%bd%ac\/\" aria-label=\"\u9605\u8bfb \u901a\u8fc7\u8ba1\u7b97\u8fdb\u884cGPS\u5750\u6807\u3001\u706b\u661f\u5750\u6807\u4e0e\u767e\u5ea6\u5750\u6807\u95f4\u7684\u8f6c\u6362\u3002\u4e0d\u9700\u6570\u636e\u5e93\u548c\u8054\u7f51\u3002\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":0,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/111\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/media?parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/categories?post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/tags?post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}