当前位置: 首页>>代码示例>>C#>>正文


C# Location.getID方法代码示例

本文整理汇总了C#中TripThruCore.Location.getID方法的典型用法代码示例。如果您正苦于以下问题:C# Location.getID方法的具体用法?C# Location.getID怎么用?C# Location.getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TripThruCore.Location的用法示例。


在下文中一共展示了Location.getID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReverseGeoLoc

 // http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
 public static string GetReverseGeoLoc(Location location)
 {
     lock (locationNames)
     {
         string key = location.getID();
         if (locationNames.ContainsKey(key))
             return locationNames[key];
         return GetReverseGeoLocationNameFromMapService(location);
     }
 }
开发者ID:TripThru,项目名称:Gateway,代码行数:11,代码来源:1397817436$MapTools.cs

示例2: GetReverseGeoLocAddress

 public static Pair<string, string> GetReverseGeoLocAddress(Location location)
 {
     lock (locationAddresses)
     {
         string key = location.getID();
         if (locationAddresses.ContainsKey(key))
             return locationAddresses[key];
         return GetReverseGeoAddressFromMapService(location);
     }
 }
开发者ID:TripThru,项目名称:Gateway,代码行数:10,代码来源:1397889938$MapTools.cs

示例3: GetReverseGeoLocationNameFromMapService

        private static string GetReverseGeoLocationNameFromMapService(Location location)
        {
            //return "Google -- Over query limit";

            XmlDocument doc = new XmlDocument();
            {
                doc.Load("http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + location.Lat + "," + location.Lng + "&sensor=false");
                XmlNode element = doc.SelectSingleNode("//GeocodeResponse/status");
                /*if (element.InnerText == "OVER_QUERY_LIMIT")
                {

                    System.Threading.Thread.Sleep(new TimeSpan(0, 1, 10));
                    doc.Load("http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + location.Lat + "," + location.Lng + "&sensor=false");
                    element = doc.SelectSingleNode("//GeocodeResponse/status");

                }*/
                if (element.InnerText == "ZERO_RESULTS" || element.InnerText == "OVER_QUERY_LIMIT")
                    return "Google -- Over query limit";
                else
                {

                    element = doc.SelectSingleNode("//GeocodeResponse/result/formatted_address");
                    locationNames.Add(location.getID(), element.InnerText);
                    WriteGeoLocationNames();
                    return element.InnerText;
                }
            }
        }
开发者ID:TripThru,项目名称:Gateway,代码行数:28,代码来源:1397817436$MapTools.cs

示例4: GetReverseGeoAddressFromMapService

        private static Pair<string, string> GetReverseGeoAddressFromMapService(Location location)
        {
            Pair<string, string> address = new Pair<string, string>();
            XmlDocument doc = new XmlDocument();
            doc.Load("http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + location.Lat + "," + location.Lng + "&sensor=false");
            XmlNode element = doc.SelectSingleNode("//GeocodeResponse/status");
            /*if (element.InnerText == "OVER_QUERY_LIMIT")
            {
                System.Threading.Thread.Sleep(new TimeSpan(0, 1, 10));
                doc.Load("http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + location.Lat + "," + location.Lng + "&sensor=false");
                element = doc.SelectSingleNode("//GeocodeResponse/status");

            }*/
            if (!(element.InnerText == "ZERO_RESULTS" || element.InnerText == "OVER_QUERY_LIMIT"))
            {
                var streetNumberNode =
                    doc.SelectSingleNode(
                        "//GeocodeResponse/result/address_component[type=\"street_number\"]/short_name");
                string street_number = streetNumberNode != null ? streetNumberNode.InnerText : "";

                var routeNode =
                    doc.SelectSingleNode("//GeocodeResponse/result/address_component[type=\"route\"]/short_name");
                string route = routeNode != null ? routeNode.InnerText : "";

                var postalCodeNode =
                    doc.SelectSingleNode(
                        "//GeocodeResponse/result/address_component[type=\"postal_code\"]/short_name");
                string postal_code = postalCodeNode != null ? postalCodeNode.InnerText : "";

                address = new Pair<string, string>(street_number + " " + route, postal_code);
                locationAddresses.Add(location.getID(), address);
                WriteGeoLocationAddresses();
                return address;

            }
            else
            {
                return new Pair<string, string>("reached query limit", "reached query limit");
            }
        }
开发者ID:TripThru,项目名称:Gateway,代码行数:40,代码来源:1397817436$MapTools.cs


注:本文中的TripThruCore.Location.getID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。