本文整理匯總了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);
}
}
示例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);
}
}
示例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;
}
}
}
示例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");
}
}