﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GPS软件平台开发技术博客 &#187; 百度地图纠偏加偏</title>
	<atom:link href="http://www.jt808.com/?feed=rss2&#038;tag=%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%E7%BA%A0%E5%81%8F%E5%8A%A0%E5%81%8F" rel="self" type="application/rss+xml" />
	<link>http://www.jt808.com</link>
	<description>帮助IT团队快速构建符合部标的GPS和视频平台(2379423771@qq.com)</description>
	<lastBuildDate>Sun, 03 Nov 2024 04:30:16 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>GPS部标平台的架构设计(五)-地图服务算法库</title>
		<link>http://www.jt808.com/?p=552</link>
		<comments>http://www.jt808.com/?p=552#comments</comments>
		<pubDate>Tue, 16 Sep 2014 03:16:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GPS系统]]></category>
		<category><![CDATA[部标监控平台]]></category>
		<category><![CDATA[GB35658过检与认证]]></category>
		<category><![CDATA[GPS偏移]]></category>
		<category><![CDATA[GPS纠偏]]></category>
		<category><![CDATA[电子围栏]]></category>
		<category><![CDATA[百度地图纠偏加偏]]></category>

		<guid isPermaLink="false">http://www.ltmonitor.com/blog/?p=552</guid>
		<description><![CDATA[&#160; GPS平台，需要和各种地图打交道，需要解决一下的问题： 1.坐标偏移，这个不用多说，需要将原始坐 [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>GPS平台，需要和各种地图打交道，需要解决一下的问题：</p>
<p>1.坐标偏移，这个不用多说，需要将原始坐标加偏，然后在地图上显示出来；</p>
<p>2.坐标解偏，或者纠偏，就是用户在地图上画出的各种区域，标注，发送到后台存储的坐标都是偏移的，这就面临一个严重的问题，因为在部标808协议中，对于区域报警，需要将区域的顶点坐标，下发给终端，终端在实际运行中，不断用GPS坐标和区域坐标进行比对，来判断是否是进入区域报警，还是离开区域报警。如果区域坐标是偏移的，那么判断出来必然是错误的。所以下发前，必须要将偏移的坐标逆向再还原成原始的基于wgs84坐标系的坐标出来。</p>
<p>3.区域报警，GPS部标平台也要求电子围栏的功能，就是要求平台支持区域报警，也就是说，如果终端没有这个功能，平台也是可以自己来分析GPS位置，来进行区域报警。那么部标平台就要提供圆形、多边形、矩形区域的判断算法。</p>
<p>4.路线偏移，部标规定部标平台在过检测的时候，必须要测试路线偏移报警，所以部标平台也要提供路线偏移的判断算法。</p>
<p>5.地理位置，用户需要知道车辆的地理位置的文字信息，需要知道报警时的具体地点，很多平台在报表中仅仅显示了个经纬度坐标，这个是很让人恼火的。所以在后台需要提供获取地理位置的接口，在报警的时候，记录下地理位置。保存到数据库中，再形成报表显示。</p>
<p>所以我们在设计的过程中，坚决屏弃掉掉远程调用百度地图SDK http接口之类的方法，因为无法容忍Http调用的次数限制、性能损失和网络问题带来的Timeout等不可预料的未知错误，所以坚决设计一个底层的算法服务库，提供给其他开发人员使用，<span style="color: rgb(51, 51, 51); font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px;">因为是纯算法，上本地可以无限次调用，也不用担心性能问题，在开发方法上由于是直接调用转换，对于程序员开发效率也是大大提升。</span></p>
<p style="margin: 0px 0px 10px; padding: 0px; color: rgb(51, 51, 51); font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px;">解决了最难解决的百度坐标加偏和反向纠偏的问题，纯算法代码，不调用百度地图的SDK API，而且提供了百度所没有的反向纠偏的算法，可以将手机百度地图的坐标直接反向解析成原始GPS坐标(wgs84坐标系）。</p>
<p style="margin: 0px 0px 10px; padding: 0px; color: rgb(51, 51, 51); font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px;">百度地图、谷歌地图、高德地图、四维地图、GPS终端设备坐标直接可以灵活互转，再也不用受限于远程调用http接口的性能损失和网络中断的麻烦。</p>
<p style="margin: 0px 0px 10px; padding: 0px; color: rgb(51, 51, 51); font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px;">&nbsp;</p>
<p>现在提供了一个在线的动态库，供大家试用，离线的动态库DLL和源码需要购买(<strong style="font-size: 16px;"><u><span style="color: rgb(0, 0, 0); font-family: 'lucida Grande', Verdana, 'Microsoft YaHei'; line-height: 18px;">2379423771@qq.com)</span></u></strong>，<a href="http://www.jt808.com/wp-content/plugins/download-monitor/download.php?id=20" style=""><img src="http://www.ltmonitor.com/blog/wp-content/uploads/2011/08/Download-17.png" alt="GPS算法服务库Demo" />GPS算法服务库Demo 已下载 2528 次</a></p>
<p>调用方法如下：</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MapServiceClient;
using MapServiceClient.MapFix;
using GpsNET.CoordService;
using GpsNET;
/**
 *@author: www.ltmonitor.com
 *@email: speed.zheng@gmail.com
 */
namespace MapServiceDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            MapServiceClient.MapFix.IMapService service = MapServiceFactory.getMapService();

            double lng1 = 121.111;
            double lat1 = 32.121;
            //获取地理位置
            String location = service.GetLocation(lng1, lat1);
            Console.WriteLine(location);

            //测试点是否在圆形区域中
            double centerLng = 120;
            double centerLat = 32;//圆心坐标
            double radiusByMeter = 100;//圆形半径，米为单位
            Boolean isInCircle = service.IsInCircle(lng1, lat1, centerLng, centerLat, radiusByMeter);

            //测试点是否在多边形中
            MyPointLatLng p = new MyPointLatLng(lat1, lng1);
            MyPointLatLng p1 = new MyPointLatLng(33.12,121.10);
            MyPointLatLng p2 = new MyPointLatLng(33.12, 121.10);
            MyPointLatLng p3 = new MyPointLatLng(33.12, 121.10);
            MyPointLatLng p4 = new MyPointLatLng(33.12, 121.10);
            MyPointLatLng[] points = new MyPointLatLng[]{p1,p2,p3};//多边形的顶点
            Boolean isInPolygon = service.IsInPolygon(p, points);

            //测试点是否在矩形中,矩形的左上角和右下角的坐标必须要输入正确，不能搞混
            //Boolean isInRect = service.IsInRect(lng1,lat1,lngLeft, latTop,lngRight,latBottom);

            int offset = 12;//路线偏移的最大距离
            Boolean isOnline = service.IsPointOnLine(p, p1, p2, offset);

            //测试坐标加偏和解偏
            for (int m = 0; m &lt; 50; m++)
            {
                double lng = 121.122 + m * 0.01;
                double lat = 33.222 + m * 0.01;


                //百度坐标加偏
                MyPointLatLng pt1 = service.Fix(lng, lat, &quot;baidu&quot;);

                /**
                 *反向还原成原始的GPS坐标
                 */
                MyPointLatLng pt2 = service.Reverse(pt1.Lng, pt1.Lat, &quot;baidu&quot;);

                /**
                 * 获得两点之间的误差距离,单位米
                 */
                double d = service.GetDistanceByMeter(lng, lat, pt2.Lng, pt2.Lat);

                Console.WriteLine(&quot;百度坐标还原后，两点之间的误差精度:&quot; + d + &quot;米&quot;);

                //火星坐标系(如谷歌，高德)坐标加偏
                pt1 = service.Fix(lng, lat, &quot;google&quot;);
                /**
                 *反向还原成原始的GPS坐标
                 */
                pt2 = service.Reverse(pt1.Lng, pt1.Lat, &quot;google&quot;);

                /**
                 * 获得两点之间的误差距离,单位米
                 */
                d = service.GetDistanceByMeter(lng, lat, pt2.Lng, pt2.Lat);

                Console.WriteLine(&quot;谷歌坐标还原后，两点之间的误差精度:&quot; + d + &quot;米&quot;);

            }


            Console.ReadLine();
        }
    }
}

原始坐标，和经过加偏再解偏后的坐标比较，误差精度在1米左右，非常精确。运行结果如下：

</pre>
<p><img alt="" height="887" src="http://www.ltmonitor.com/blog/wp-content/uploads/testmapfix.JPG" width="639" /></p>
<p> (10005)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jt808.com/?feed=rss2&#038;p=552</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPS部标平台的架构设计(四)-百度地图设计</title>
		<link>http://www.jt808.com/?p=534</link>
		<comments>http://www.jt808.com/?p=534#comments</comments>
		<pubDate>Wed, 16 Jul 2014 10:05:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GPS系统]]></category>
		<category><![CDATA[部标监控平台]]></category>
		<category><![CDATA[gps部标]]></category>
		<category><![CDATA[JT/T 808]]></category>
		<category><![CDATA[百度地图]]></category>
		<category><![CDATA[百度地图纠偏加偏]]></category>
		<category><![CDATA[部标平台]]></category>

		<guid isPermaLink="false">http://www.ltmonitor.com/blog/?p=534</guid>
		<description><![CDATA[部标GPS软件平台之百度地图设计(www.jt808.com) 地图是客户端中不可缺少的一个模块，很多人在设计 [...]]]></description>
			<content:encoded><![CDATA[<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">部标GPS软件平台之百度地图设计(www.jt808.com)</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">地图是客户端中不可缺少的一个模块，很多人在设计和画图时候，喜欢加上地图引擎这样高大上的字眼，显得自己的平台有内涵，说白了就是用第三方的SDK来开发，早期的GPS监 控软件用的都是mapx、mapxtrem、acrgis之类的，使用的都是本地地图。不仅要购买正版地图，还要购买价格不菲的地图引擎license，服务器版的部署的时候，还要绑定到服务器ID上，现在这种开发方式已被抛弃。现在的百度地图、谷歌地图提供的SDK接口丰富，开发方便，系统稳定，大家都用的很爽。</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">在部标GPS软件平台中，由于部标过检的时候，指定要求在四维地图和高德地图中任选一家，必须要有审图号，也就是说必要购买，不能用免费的地图，年费三万起，这个无疑加大了运营成本，加重了企业负担，现在物流运输企业挣钱都是从车轱辘里蹦出来的，那些地图厂商坐地收费，因为是年费，要年年交，真是黑。</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">但是虽说是部标平台，过检是第一步，第二步要给客户用，很多客户由于在实际上网的过程中，对于百度地图已经很接受了，所以经常会指定要求用百度地图。所以我们在设计平 台的时候，考虑多个地图切换和兼容是顺理成章的事情。</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">百度地图的主要优势如下：<br />
	1) 卫星地图，百度的卫星地图虽然远不如谷歌的卫星地图，但是比国内这些四维之类的垃圾要强大多了，谷歌的服务经常被搞，所以忍痛放弃；<br />
	2) 百度的javascript SDK和手机SDK较其他地图要完善的多，升级较多;<br />
	3) API上要比其他厂商的API要丰富，出来Javascript API,也提供了web service API(高德地图目前不提供), 可以在后台使用C#或Java语言调用web服务接口进行坐标转换和位置解析服务。<br />
	5) 地图美观。这个美观主要是在地图图层优化上，不同的zoom下，显示不同的图层，这样地图加载的速度会比较流畅，显示也比较美观。我们自己在开发时，较少考虑这一点，比如车辆图标，当地图缩小到国家级的时候，车辆密密麻麻的显示在一起，实际上要根据不同的zoom进行优化。</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">
	因为地图SDK都是基于Javascript的SDK，所以设计主要集中在前端的Javascript的设计上。</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">主要设计模块分为:<br />
	1)地图主界面页面(jsp);<br />
	2)后台ajax数据调用接口;<br />
	3)地图接口js;<br />
	4)工具栏;</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">地图页面主要控制地图界面UI的布局和显示方式，主要的UI部分包括:&nbsp;<br />
	1) 地图操作工具条；<br />
	2）中心地图DIV;<br />
	3) 历史轨迹查询工具条;<br />
	4) 实时数据显示栏;<br />
	5) 历史轨迹数据显示栏</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;"><img alt="" src="http://images.cnitblog.com/i/304499/201407/161754367242697.jpg" style="border: 0px; width: 758px;" /></p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">地图接口js设计<br />
	首先根据部标要求的地图功能，我们来设计地图操作的放大、缩小、围栏、线路、标注、图层等接口等。</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">地图接口的核心就是对较复杂的围栏和线路操作进行一个封装，因为部标808不仅要求围栏和线路指令下发给终端，终端支持报警，还需要平台也能支持围栏报警和路线偏移报警，主要的操作如下：</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">1）地图上画出多边形、矩形和圆形围栏及线路，并持久化;</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">2) &nbsp;绑定给车辆；</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">3) 下发绑定指令给终端；</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">4) 车辆进入围栏，触发报警; (这里可能是终端报警，平台也要支持报警)</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">5）报警后，显示车辆在地图中心;</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">&nbsp;<img alt="" src="http://images.cnitblog.com/i/304499/201407/161801512715874.jpg" style="border: 0px; width: 758px;" /></p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">ajax调用接口<br />
	1) 当初始化地图的时候，获取用户的权限，根据权限显示不同的地图操作工具;<br />
	2) 获取用户录入的各种图元并加载到地图上显示，如自定义标注、各种类型的围栏、线路等；<br />
	3) 实时监控时，不断获取实时数据，并刷新地图车辆位置，画出实时轨迹;<br />
	4) 历史轨迹回放时，获取历史数据，并刷新地图车辆位置，画出历史轨迹;<br />
	5) 持久化接口，将用户在地图上的标注、画出的围栏、线路等保存到后台数据库；</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">地图服务模块<br />
	1.位置解析模块，不断的解析车辆的坐标，转为地理位置描述，更新到系统中，并在前台显示；<br />
	2.加偏服务模块，根据前台的调用request,调用百度地图的加偏地址，转换坐标在前台地图上显示；</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">3.实时加偏，采用加偏算法和逆向纠偏算法，可以实时的进行百度地图的坐标系统转换，不需要百度自带的webservice服务，避免了百度调用接口的限制及性能的损失，因为每次远程调用http，都要耗费不固定的远程调用时间及调用超时的时间。</p>
<p style="line-height: 25.200000762939453px; margin: 10px auto; color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', Times, sans-serif; font-size: 14px;">另外存在一个问题是，无论是那个地图，在地图上画的区域存储在数据库的都是自己地图坐标系统的经纬度节点，如果要进行电子围栏报警，下发给终端的时候，终端是百分百误报的，因为终端的坐标和地图坐标系统不符，需要在下发给终端前，还原成原始坐标再下发给终端。所以就需要逆向还原的纠偏算法。我们提供正向和反向的算法库。算法库代码参见：<a href="http://www.jt808.com/?p=552" style="font-family: Arial, Verdana, sans-serif; font-size: 12px;">http://www.jt808.com/?p=552</a></p>
<h3 style="margin: 0px; padding: 0px; font-size: 14px; font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px; color: blue;"><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 128);"><strong style="margin: 0px; padding: 0px;"><u style="margin: 0px; padding: 0px;">需要购买C# .netframework2.0 离线版 DLL 的300元 算法源码600元，包含原始坐标加偏和逆向纠偏还原成原始坐标。提供火星坐标和百度坐标两种接口，不是数据库，提供的是算法源码，实时解析，需要的可以直接联系我(<strong style="color: rgb(34, 34, 34); font-family: Arial, Verdana, sans-serif; font-size: 16px; line-height: normal;"><u><span style="color: rgb(0, 0, 0); font-family: 'lucida Grande', Verdana, 'Microsoft YaHei'; line-height: 18px;">2379423771@qq.com</span></u></strong>)购买。</u></strong></span></h3>
<p> (14483)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jt808.com/?feed=rss2&#038;p=534</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GMap.NET开发技巧（十一）-使用百度地图</title>
		<link>http://www.jt808.com/?p=289</link>
		<comments>http://www.jt808.com/?p=289#comments</comments>
		<pubDate>Sun, 27 Jan 2013 16:25:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GPS系统]]></category>
		<category><![CDATA[百度地图]]></category>
		<category><![CDATA[百度地图纠偏加偏]]></category>

		<guid isPermaLink="false">http://www.ltmonitor.com/blog/?p=289</guid>
		<description><![CDATA[本章介绍一下，是如何在GMap.NET 使用百度地图的具体方法和代码介绍等。 当然使用百度地图，面临的难题不仅 [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" height="129" src="http://www.ltmonitor.com/blog/wp-content/uploads/baidu.gif" width="270" />本章介绍一下，是如何在GMap.NET 使用百度地图的具体方法和代码介绍等。</p>
<p>当然使用百度地图，面临的难题不仅与此，还需要解决百度地图的偏移问题，我们当然不希望去调用百度地图SDK提供的HTTP接口，那是很愚蠢的，因为</p>
<p>要面临远程HTTP调用的不确定性，客户需要的是确定的结果，程序也是如此。</p>
<p>所以我们提供了百度地图的纠偏和加偏的算法源码库，参见文章：<span style="font-size:18px;"><a href="http://www.jt808.com/?p=552">-百度谷歌地图服务算法库</a></span></p>
<p>如果要使用百度地图，必须将初始化代码改成下面的这样：</p>
<pre class="brush:other">this.MainMap.Position = new PointLatLng(double.Parse(ConfigurationManager.AppSettings[&quot;defaultLat&quot;]), 
                                                        double.Parse(ConfigurationManager.AppSettings[&quot;defaultLng&quot;]));

                this.MainMap.MapProvider.Area = new RectLatLng(30.981178, 105.351914, 2.765142, 4.120995);
                this.MainMap.BoundsOfMap = new RectLatLng(30.981178, 105.351914,  2.765142, 4.120995);
                this.MainMap.Manager.Mode = AccessMode.CacheOnly;
                this.MainMap.MapProvider = GMapProviders.BaiduMapProvider;//或BaiduSateliteMapProvider
                this.MainMap.DragButton = MouseButton.Left;
                this.MainMap.Zoom = 13;
                this.MainMap.MinZoom = 8;
                this.MainMap.MaxZoom = 24;</pre>
<p>GMapProvider 是地图数据源的接口。</p>
<p>当初始化调用this.MainMap.MapProvider = GMapProviders.BaiduMapProvider的时候，</p>
<p>就会根据不同地图的不同规则进行加载数据，下面就以百度地图为例说明如何扩展一个地图数据源的接口等。</p>
<p><strong>1).BaiduMapProviderBase</strong></p>
<p>BaiduMapProviderBase继承GMapProvider类。</p>
<p>地图分为卫星和普通地图两种模式，所以需要定义一些公用方法来调用。</p>
<p>&nbsp;</p>
<pre class="brush:other">public abstract class BaiduMapProviderBase : GMapProvider
    {
        public BaiduMapProviderBase()
        {
            MaxZoom = null;
            RefererUrl = &quot;http://map.baidu.com&quot;;
            Copyright = string.Format(&quot;&copy;{0} Baidu Corporation, &copy;{0} NAVTEQ, &copy;{0} Image courtesy of NASA&quot;, DateTime.Today.Year);    
        }

        public override PureProjection Projection
        {
            get { return MercatorProjection.Instance; }
        }

        GMapProvider[] overlays;
        public override GMapProvider[] Overlays
        {
            get
            {
                if (overlays == null)
                {
                    overlays = new GMapProvider[] { this };
                }
                return overlays;
            }
        }
    }</pre>
<p><strong>2).<strong>BaiduMapProvider</strong></strong></p>
<p>BaiduMapProvider 是继承于BaiduMapProviderBase，并实现GetTileImage方法。</p>
<p>GetTileImage 的用途是根据当前的鼠标信息pos和缩放比zoom获取图片的方法。</p>
<pre class="brush:other">public class BaiduMapProvider : BaiduMapProviderBase
    {
        ....public override PureImage GetTileImage(GPoint pos, int zoom)
        {
            string url = MakeTileImageUrl(pos, zoom, LanguageStr);

            return GetTileImageUsingHttp(url);
        }

        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            zoom = zoom - 1;
            var offsetX = Math.Pow(2, zoom);
            var offsetY = offsetX - 1;

            var numX = pos.X - offsetX;
            var numY = -pos.Y + offsetY;

            zoom = zoom + 1;
            var num = (pos.X + pos.Y)%8 + 1;
            var x = numX.ToString().Replace(&quot;-&quot;, &quot;M&quot;);
            var y = numY.ToString().Replace(&quot;-&quot;, &quot;M&quot;);

            //http://q3.baidu.com/it/u=x=721;y=209;z=12;v=014;type=web&amp;fm=44
            string url = string.Format(UrlFormat, num, x, y, zoom, &quot;014&quot;, &quot;web&quot;, &quot;44&quot;);
            Console.WriteLine(&quot;url:&quot; + url);
            return url;
        }

        static readonly string UrlFormat = &quot;http://q{0}.baidu.com/it/u=x={1};y={2};z={3};v={4};type={5}&amp;fm={6}&quot;;
        
    }


</pre>
<p> (25274)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jt808.com/?feed=rss2&#038;p=289</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GMap.NET开发技巧(四)-GPS百度地图坐标偏移及地图加偏和逆向纠偏解决方法和代码</title>
		<link>http://www.jt808.com/?p=153</link>
		<comments>http://www.jt808.com/?p=153#comments</comments>
		<pubDate>Tue, 09 Oct 2012 06:01:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GPS系统]]></category>
		<category><![CDATA[GMap.NET]]></category>
		<category><![CDATA[百度地图]]></category>
		<category><![CDATA[百度地图纠偏加偏]]></category>
		<category><![CDATA[谷歌地图]]></category>

		<guid isPermaLink="false">http://www.ltmonitor.com/blog/?p=153</guid>
		<description><![CDATA[很多国内开发者使用GMap.NET开发地图应用程序，非常方便，可是在实际应用中傻眼了，因为GPS坐标的位置在谷 [...]]]></description>
			<content:encoded><![CDATA[<p>很多国内开发者使用GMap.NET开发地图应用程序，非常方便，可是在实际应用中傻眼了，因为GPS坐标的位置在谷歌和百度地图上出现了严重的便宜，这个是要了命的，地图应用就是要给别人一个精确的Location，解决不了偏差，前面的开发都是白费。但是GMap.NET只是一个对瓦片操作和客户端GDI输出的操作进行了较好的封装，对于有中国特色的国情，跟人家八竿子打不着。所以在有人给GMap.NET的作者提过，但是没有解决。</p>
<p>这和GMap.NET没有关系， 在中国商业地图数据提供和服务提供商，都必须要到国家测绘管理部门，进行评审通过后才能在大陆发布，谷歌地图也也一样。地图服务器商都需将<span style="color: rgb(17, 17, 17); font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px; white-space: pre-wrap; ">真实坐标的电子地图，加密成火星地图和火星坐标。</span>GPS导航设备生产制造商也需要这样做。<span style="color: rgb(17, 17, 17); font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px; white-space: pre-wrap; ">所以就出现了</span>GPS坐标在基于<span style="color: rgb(17, 17, 17); font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px; white-space: pre-wrap; ">WGS84坐标系统的</span>地图上显示出现坐标偏移，误差很大很严重，而且不是线性的，网上有人给出算法公式，都是胡说八道，根本不好用，更离谱的还要根据不同的城市，进行不同的加偏，还有的提供了一个加偏数据库，瞎扯淡。</p>
<p>所以偏移其实给地图一点关系都没有，管你是谷歌、百度还是搜狐地图，只要对GPS坐标进行加偏和纠偏处理就能够解决这个问题。</p>
<p>为了解决GMap.NET的谷歌和百度地图坐标偏移的问题，我就开发了一个纠偏和加偏的算法和动态库给开发者来使用，直接在.NET的工程项目中调用转换方法即可，绝对好用，在谷歌和百度地图上，车辆行驶的轨迹和地图的道路是严丝合缝的吻合的。<span style="color: rgb(51, 51, 51); font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px;">百度地图、谷歌地图、高德地图、四维地图、GPS终端设备坐标直接可以灵活互转，再也不用受限于远程调用http接口的性能损失和网络中断的麻烦。</span></p>
<h3 style="color:blue;"><a href="http://www.jt808.com/?p=552"><span style="color:#000080;"><strong><u>需要购买C# .netframework2.0 离线版 DLL 的300元 算法源码600元(Java或者C#语言可选），包含原始坐标加偏和逆向纠偏还原成原始坐标。提供火星坐标和百度坐标两种接口，不是数据库，提供的是算法源码，实时解析，需要的可以直接联系我(</u></strong></span><strong style="color: rgb(34, 34, 34); font-size: 16px;"><u><span style="color: rgb(0, 0, 0); font-family: 'lucida Grande', Verdana, 'Microsoft YaHei'; line-height: 18px;">2379423771@qq.com</span></u></strong><span style="color:#000080;"><strong><u>)购买。</u></strong></span></a></h3>
<p>直接转换，不需要数据库，更不用拆半和二分查询等影响性能的东西。算法库描述参我的文章:<span style="color:#f00;"><a href="http://www.jt808.com/?p=552"><span style="font-family: Georgia, Arial, Helvetica, sans-serif; font-size: 2em; text-transform: capitalize;">地图服务算法库</span></a></span></p>
<p><a href="http://www.jt808.com/?p=552" style="margin: 0px; padding: 0px; color: rgb(0, 94, 172); text-decoration: none; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: rgb(223, 223, 223); font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px;"><img alt="GPS算法服务库Demo" src="http://www.ltmonitor.com/blog/wp-content/uploads/2011/08/Download-17.png" style="margin: 0px; padding: 0px; border: none;" />GPS算法服务库Demo 已下载 91 次</a></p>
<p>开发说明（开发环境是.NET 4 C#)&nbsp;</p>
<pre class="brush:csharp">   double latitude = 38.123;
   double longitude = 124.5;
  //单个坐标转换
  GpsPoint gp = MapFix.Fix(latitude, longitude);   
  //批量转换
  List&lt;GpsPoint&gt; needTransformGpsPoints;
  List&lt;GpsPoint&gt; gpsPoints = MapFix.Fix(needTransformGpsPoints);

</pre>
<p><img alt="" height="165" src="http://www.ltmonitor.com/blog/wp-content/uploads/gmapfix.JPG" width="587" /></p>
<pre class="brush:csharp"></pre>
<pre class="brush:csharp"></pre>
<p>运行效果图如下图所示，在GPS监控平台上，运行轨迹和谷歌地图道路非常吻合，精确度非常高。如需购买完整的交通部部标GPS车辆监控平台,可以联系我2379423771@qq.com。</p>
<h3 style="margin: 0px; padding: 0px; font-size: 14px; font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px; white-space: normal; color: red;">Java平台，参见：<a href="http://www.jt808.com/?p=522" style="margin: 0px; padding: 0px; color: rgb(0, 94, 172); text-decoration: none;"><span style="margin: 0px; padding: 0px;">基于<span style="margin: 0px; padding: 0px; color: rgb(92, 121, 144); font-family: Georgia, Arial, Helvetica, sans-serif; text-transform: capitalize;">Struts+Spring+Hibernate+Ibatis+Quartz+Mina框架构建部标监控平台</span></span></a></h3>
<p style="margin: 0px 0px 10px; padding: 0px; color: rgb(51, 51, 51); font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; line-height: 24px; white-space: normal;">.NET平台，参见：<a href="http://www.jt808.com/?p=665" rel="bookmark" style="margin: 0px; padding: 0px; color: rgb(38, 38, 38); text-decoration: none; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: rgb(223, 223, 223); font-family: Georgia, Arial, Helvetica, sans-serif; font-size: 2em; text-transform: capitalize;">基于Asp.NET MVC构建GPS部标平台 </a></p>
<p><img alt="" height="347" src="http://www.ltmonitor.com/blog/wp-content/uploads/hisroute2d.JPG" width="594" /></p>
<p><img alt="" height="647" src="http://www.ltmonitor.com/blog/wp-content/uploads/hisroute.JPG" width="883" /></p>
<p> (73936)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jt808.com/?feed=rss2&#038;p=153</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>
