public static string GetAreaFromGpsData(TrackPoint p, string preArea = null)
        {
            Telogis.GeoBase.LatLon loc = new Telogis.GeoBase.LatLon(p.Latitude, p.Longitude);
            string tableName           = "all";
            //if (type == AreaType.区域)
            //    tableName = "states";
            //else if (type == AreaType.重要地点)
            //    tableName = "islands";

            var ret = Telogis.GeoBase.DataQuery.QueryPolygonsAtPoint(loc, tableName);

            if (ret.Length == 0)
            {
                return(null);
            }
            else if (ret.Length == 1 || string.IsNullOrEmpty(preArea))
            {
                return(ret[0].Name);
            }
            else
            {
                foreach (var i in ret)
                {
                    if (i.Name == preArea)
                    {
                        return(i.Name);
                    }
                }
                return(ret[0].Name);
            }
        }
        public static string GetAreaFromGpsData(TrackPoint p, string preArea = null)
        {
            Telogis.GeoBase.LatLon loc = new Telogis.GeoBase.LatLon(p.Latitude, p.Longitude);
            string tableName = "all";
            //if (type == AreaType.区域)
            //    tableName = "states";
            //else if (type == AreaType.重要地点)
            //    tableName = "islands";

            var ret = Telogis.GeoBase.DataQuery.QueryPolygonsAtPoint(loc, tableName);
            if (ret.Length == 0)
                return null;
            else if (ret.Length == 1 || string.IsNullOrEmpty(preArea))
                return ret[0].Name;
            else
            {
                foreach (var i in ret)
                {
                    if (i.Name == preArea)
                    {
                        return i.Name;
                    }
                }
                return ret[0].Name;
            }
        }
        public static string GetRoadFromGpsData(TrackPoint gpsData, string preRoad = null)
        {
            Telogis.GeoBase.LatLon loc = new Telogis.GeoBase.LatLon(gpsData.Latitude, gpsData.Longitude);

            var arg = new Telogis.GeoBase.ReverseGeoCodeArgs(loc);

            arg.Heading = gpsData.Heading;
            if (!string.IsNullOrEmpty(preRoad))
            {
                arg.LastNames = new string[] { preRoad };
            }
            arg.Mode  = Telogis.GeoBase.ReverseGeoCodeMode.AllLinks;
            arg.Speed = gpsData.Speed;

            var streetFull = Telogis.GeoBase.GeoCoder.ReverseGeoCodeFull(arg);

            if (streetFull != null)
            {
                double distance = streetFull.Intersection.DistanceTo(loc, Telogis.GeoBase.DistanceUnit.METERS);
                if (distance > RoadWidth)
                {
                    return(null);
                }

                if (preRoad != null)
                {
                    if (streetFull.Address != null)
                    {
                        foreach (var i in streetFull.Address.Names)
                        {
                            if (i == preRoad)
                            {
                                return(i);
                            }
                        }
                    }

                    if (streetFull.CrossStreet != null)
                    {
                        foreach (var i in streetFull.CrossStreet.Name)
                        {
                            if (i == preRoad)
                            {
                                return(i);
                            }
                        }
                    }
                }

                if (string.IsNullOrEmpty(streetFull.Address.PrimaryName))
                {
                    return(preRoad);
                }

                return(streetFull.Address.PrimaryName);
            }
            return(null);
        }
        public static string GetRoadFromGpsData(TrackPoint gpsData, string preRoad = null)
        {
            Telogis.GeoBase.LatLon loc = new Telogis.GeoBase.LatLon(gpsData.Latitude, gpsData.Longitude);

            var arg = new Telogis.GeoBase.ReverseGeoCodeArgs(loc);
            arg.Heading = gpsData.Heading;
            if (!string.IsNullOrEmpty(preRoad))
            {
                arg.LastNames = new string[] { preRoad };
            }
            arg.Mode = Telogis.GeoBase.ReverseGeoCodeMode.AllLinks;
            arg.Speed = gpsData.Speed;

            var streetFull = Telogis.GeoBase.GeoCoder.ReverseGeoCodeFull(arg);
            if (streetFull != null)
            {
                double distance = streetFull.Intersection.DistanceTo(loc, Telogis.GeoBase.DistanceUnit.METERS);
                if (distance > RoadWidth)
                    return null;

                if (preRoad != null)
                {
                    if (streetFull.Address != null)
                    {
                        foreach (var i in streetFull.Address.Names)
                        {
                            if (i == preRoad)
                            {
                                return i;
                            }
                        }
                    }

                    if (streetFull.CrossStreet != null)
                    {
                        foreach (var i in streetFull.CrossStreet.Name)
                        {
                            if (i == preRoad)
                            {
                                return i;
                            }
                        }
                    }
                }

                if (string.IsNullOrEmpty(streetFull.Address.PrimaryName))
                    return preRoad;

                return streetFull.Address.PrimaryName;
            }
            return null;
        }