當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。