本文整理汇总了C#中GeoCoordinate.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinate.ToString方法的具体用法?C# GeoCoordinate.ToString怎么用?C# GeoCoordinate.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoCoordinate
的用法示例。
在下文中一共展示了GeoCoordinate.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTestSimple
/// <summary>
/// Tests adding some simple data.
/// </summary>
protected void DoTestSimple()
{
// create the index.
ILocatedObjectIndex<GeoCoordinate, LocatedObjectData> index = this.CreateIndex();
// add the data.
GeoCoordinate point1 = new GeoCoordinate(0, 0);
LocatedObjectData point1_data = new LocatedObjectData()
{
SomeData = point1.ToString()
};
GeoCoordinate point2 = new GeoCoordinate(1, 1);
LocatedObjectData point2_data = new LocatedObjectData()
{
SomeData = point2.ToString()
};
GeoCoordinateBox location_box = new GeoCoordinateBox(
new GeoCoordinate(point1.Latitude - 0.0001, point1.Longitude - 0.0001),
new GeoCoordinate(point1.Latitude + 0.0001, point1.Longitude + 0.0001));
// try and get data from empty index.
// regression test for issue: https://osmsharp.codeplex.com/workitem/1244
IEnumerable<LocatedObjectData> location_box_data = index.GetInside(location_box);
Assert.IsNotNull(location_box_data);
Assert.AreEqual(0, location_box_data.Count());
// try point1.
index.Add(point1, point1_data);
location_box_data = index.GetInside(
location_box);
Assert.IsNotNull(location_box_data);
bool found = false;
foreach (LocatedObjectData location_data in location_box_data)
{
if (location_data.SomeData == point1.ToString())
{
found = true;
}
}
Assert.IsTrue(found, string.Format("Data added at location {0} not found in box {1}!",
point1, location_box));
// try point2.
index.Add(point2, point2_data);
location_box = new GeoCoordinateBox(
new GeoCoordinate(point2.Latitude - 0.0001, point2.Longitude - 0.0001),
new GeoCoordinate(point2.Latitude + 0.0001, point2.Longitude + 0.0001));
location_box_data = index.GetInside(
location_box);
Assert.IsNotNull(location_box_data);
found = false;
foreach (LocatedObjectData location_data in location_box_data)
{
if (location_data.SomeData == point2.ToString())
{
found = true;
}
}
Assert.IsTrue(found, string.Format("Data added at location {0} not found in box {1}!",
point2, location_box));
}
示例2: UpdateCoordinate
void UpdateCoordinate(GeoCoordinate geo)
{
InfoText.Text = geo.ToString();
ICivicAddressResolver resolver = new CivicAddressResolver();
var address = resolver.ResolveAddress(geo);
InfoText.Text += address.City;
}
示例3: getSearchLocation
private void getSearchLocation(GeoCoordinate location)
{
_mygeocodequerylocation = new GeocodeQuery
{
SearchTerm = location.ToString(),
GeoCoordinate = new GeoCoordinate(_myLatitude, _myLongitude)
};
_mygeocodequerylocation.QueryCompleted += MygeocodequerylocationSearch_QueryCompleted;
_mygeocodequerylocation.QueryAsync();
}
示例4: LocationSearch
private void LocationSearch(GeoCoordinate coordinates)
{
GeoCoordinate g = new GeoCoordinate();
if (_externalSource)
g = _externalCoordinates;
else
{
g = new GeoCoordinate(_myLatitude, _myLongitude);
}
_myGeocodeQuery = new GeocodeQuery
{
SearchTerm = coordinates.ToString(),
GeoCoordinate = g
};
_myGeocodeQuery.QueryCompleted += SearchQueryCompleted;
_myGeocodeQuery.QueryAsync();
}
示例5: GetNavigationRoutesPoiToPoi
private async void GetNavigationRoutesPoiToPoi(string poi_from, string poi_to, GeoCoordinate floorPoiLocation)
{
try
{
var isNetwork = NetworkInterface.GetIsNetworkAvailable();
if (isNetwork)
{
if (!poi_from.Equals(poi_to))
_routePoi = await CustomPushpinWp8APIClient.GetPoiToPoiRoute(poi_from, poi_to);
}
else
{
MessageBox.Show("No internet connection found. Check your internet connection and try again!");
directions_grid.Visibility = Visibility.Collapsed;
stackpanelClose();
MoveViewWindow(30);
ApplicationBar.IsVisible = true;
return;
}
_getIndoornav = true;
_selectedFloor = _floorPoiFromNumber;
Dispatcher.BeginInvoke(() =>
{
txt_cur.Text = _selectedFloor;
});
ChangeFloor();
if (!poi_from.Equals(poi_to))
GetRouteOfTheCurrentFloor();
// clear route details
if (Mymap.Layers.Contains(routedetails_layer))
Mymap.Layers.Remove(routedetails_layer);
// clear directions
if (GetRoute.Count != 0)
{
GetRoute.Clear();
if (_myMapRoute != null)
Mymap.RemoveRoute(_myMapRoute);
}
var g = new GeoCoordinate();
// set phone current location
if (!_externalSource)
{
g.Latitude = _myLatitude;
g.Longitude = _myLongitude;
}
else
{
g.Latitude = _externalCoordinates.Latitude;
g.Longitude = _externalCoordinates.Longitude;
}
GetRoute.Add(g);
_mygeocodequery = new GeocodeQuery
{
SearchTerm = floorPoiLocation.ToString(),
GeoCoordinate = g
};
_mygeocodequery.QueryCompleted += MygeocodequeryPoiSearch_QueryCompleted;
_mygeocodequery.QueryAsync();
}
catch
{
directions_grid.Visibility = Visibility.Collapsed;
stackpanelClose();
MoveViewWindow(30);
if (directions_grid.Visibility != Visibility.Visible)
ApplicationBar.IsVisible = true;
if (_routePoi.message.Contains("same"))
MessageBox.Show(_routePoi.message);
else
MessageBox.Show("Can not get navigation route inside building. Please check your internet connection!");
}
}
示例6: GetNavigationRoute
private void GetNavigationRoute(GeoCoordinate location)
{
// clear route details
if (Mymap.Layers.Contains(routedetails_layer))
Mymap.Layers.Remove(routedetails_layer);
// clear directions
if (GetRoute.Count != 0)
{
GetRoute.Clear();
if (_myMapRoute != null)
Mymap.RemoveRoute(_myMapRoute);
}
GeoCoordinate g = new GeoCoordinate();
if (_externalSource)
g = _externalCoordinates;
else
{
g = new GeoCoordinate(_myLatitude, _myLongitude);
}
// set phone current location
GetRoute.Add(g);
_mygeocodequery = new GeocodeQuery
{
SearchTerm = location.ToString(),
GeoCoordinate = g
};
_mygeocodequery.QueryCompleted += Mygeocodequery_QueryCompleted;
_mygeocodequery.QueryAsync();
}
示例7: GeoCoordinate_Unit_ToString4_ProviderIsNull
public void GeoCoordinate_Unit_ToString4_ProviderIsNull()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
String format = GeoCoordinate.SetFormat;
IFormatProvider provider = null;
String actual = target.ToString(format, provider);
Assert.IsNotNull(actual);
Assert.AreNotEqual(typeof(GeoCoordinate).ToString(), actual);
}
示例8: GetRouteTime
/// <summary>
/// Gets the estimated route time in minutes
/// </summary>
/// <param name="from"></param>
/// <param name="to"></param>
/// <returns>Route time in minutes</returns>
public static int GetRouteTime(GeoCoordinate from, GeoCoordinate to)
{
string requestStr = string.Format("http://www.waze.co.il/RoutingManager/routingRequest?from=x%3A{0}+y%3A{1}&to=x%3A{2}+y%3A{3}&returnJSON=false&returnGeometries=false&returnInstructions=false&timeout=60000&nPaths=1",
from.Longitude, from.Latitude, to.Longitude, to.Latitude);
try
{
HttpWebResponse resp = null;
ManualResetEvent mre = new ManualResetEvent(false);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(requestStr);
req.BeginGetResponse(delegate(IAsyncResult result)
{
try
{
resp = (HttpWebResponse)req.EndGetResponse(result);
mre.Set();
}
catch (Exception we)
{
System.Diagnostics.Debug.WriteLine(we.ToString());
WriteLog(we.ToString());
resp = null;
mre.Set();
}
}, null);
// we can't wait more then 6 seconds or else the OS will kill us.
if (!mre.WaitOne(6000))
{
WriteLog(to.ToString() + " : Reset event timed out.");
return -4;
}
// The server request failed.
if (resp == null)
{
WriteLog(to.ToString() + " : Server Response Null.");
return -3;
}
StreamReader sr = new StreamReader(resp.GetResponseStream());
string respString = sr.ReadToEnd();
System.Diagnostics.Debug.WriteLine("Response String:" + Environment.NewLine + respString);
int arrivingTime = 0;
Regex regex = new Regex("\"crossTime\":([0-9]+)");
MatchCollection matchCol = regex.Matches(respString);
foreach (Match match in matchCol)
{
int crossTime = int.Parse(match.Groups[1].Value);
arrivingTime += crossTime;
}
sr.Dispose();
return arrivingTime / 60;
}
catch (Exception exc)
{
WriteLog(exc.ToString());
System.Diagnostics.Debug.WriteLine(exc.ToString());
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
// ErrorToast(exc);
return -2;
}
}
示例9: GeoCoordinate_Unit_ToString4_FormatIsNull
public void GeoCoordinate_Unit_ToString4_FormatIsNull()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
String format = null;
IFormatProvider provider = CultureInfo.GetCultureInfo("en-US");
String actual = target.ToString(format, provider);
Assert.IsNotNull(actual);
Assert.AreNotEqual(typeof(GeoCoordinate).ToString(), actual);
}
示例10: GeoCoordinate_Unit_ToString4_Optimal
public void GeoCoordinate_Unit_ToString4_Optimal()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
IFormatProvider provider = CultureInfo.GetCultureInfo("en-US");
String[] validForms = new String[] {
};
foreach (String format in GeoCoordinateTests.GetValidStringFormats()) {
String actual = target.ToString(format, provider);
Assert.IsNotNull(actual);
Assert.AreNotEqual(typeof(GeoCoordinate).ToString(), actual);
}
}
示例11: GeoCoordinate_Unit_ToString4_FormatIsInvalid
public void GeoCoordinate_Unit_ToString4_FormatIsInvalid()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
String format = " \r \n \t ";
IFormatProvider provider = CultureInfo.GetCultureInfo("en-US");
target.ToString(format, provider);
}
示例12: GeoCoordinate_Unit_ToString2_Optimal
public void GeoCoordinate_Unit_ToString2_Optimal()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
foreach (String format in GeoCoordinateTests.GetValidStringFormats()) {
String actual = target.ToString(format);
Assert.IsNotNull(actual);
Assert.AreNotEqual(typeof(GeoCoordinate).ToString(), actual);
}
}
示例13: GeoCoordinate_Unit_ToString2_FormatIsNull
public void GeoCoordinate_Unit_ToString2_FormatIsNull()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
String format = null;
String actual = target.ToString(format);
Assert.IsNotNull(actual);
Assert.AreNotEqual(typeof(GeoCoordinate).ToString(), actual);
}
示例14: GeoCoordinate_Unit_ToString2_FormatIsInvalid
public void GeoCoordinate_Unit_ToString2_FormatIsInvalid()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
String format = " \r \n \t ";
target.ToString(format);
}
示例15: ConvertLocation
public void ConvertLocation(GeoCoordinate location)
{
Debug.WriteLine("ConvertLocation");
// converts a point to an address
Debug.WriteLine("ConvertLocation" );
Debug.WriteLine("GeoCoordinate:" + location.ToString());
CivicAddressResolver resolver = new CivicAddressResolver();
CivicAddress d = new CivicAddress();
if (location.IsUnknown == false)
{
CivicAddress address = resolver.ResolveAddress(location);
Debug.WriteLine("CivicAddress:" + address.ToString());
if (!address.IsUnknown)
{
Debug.WriteLine("Country: {0}, Zip: {1}",
address.CountryRegion,
address.PostalCode);
}
else
{
Debug.WriteLine("Address unknown.");
}
}
}