本文整理汇总了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");
}
}