问题
I am developing windows mobile application. I want to create geofence when storing the location to the sqlite database to generate SMS alerts when entering to the geofence. I am loading the location to the text boxes through map.
This is the code so far
private void Load_Location(object sender, RoutedEventArgs e)
{
LattxtBx.Text = String.Format("{0}", AddLocation.Center.Position.Latitude);
LongtxtBx.Text = String.Format("{0}", AddLocation.Center.Position.Longitude);
}
private async void AddContact_Click(object sender, RoutedEventArgs e)
{
DatabaseHelperClass Db_Helper = new DatabaseHelperClass();//Creating object for DatabaseHelperClass.cs from ViewModel/DatabaseHelperClass.cs
if (NametxtBx.Text != "" & AgetxtBx.Text != "" & AddresstxtBx.Text != "" & SchooltxtBx.Text != "" & GardienttxtBx.Text != "" & PhonetxtBx.Text != "" & LattxtBx.Text != "" & LongtxtBx.Text != "")
{
Db_Helper.Insert(new Contacts(NametxtBx.Text, AgetxtBx.Text, AddresstxtBx.Text, SchooltxtBx.Text, GardienttxtBx.Text, PhonetxtBx.Text, LattxtBx.Text, LongtxtBx.Text));
Frame.Navigate(typeof(ReadContactList));//after add contact redirect to contact listbox page
}
else
{
MessageDialog messageDialog = new MessageDialog("Please fill all fields");//Text should not be empty
await messageDialog.ShowAsync();
}
}
回答1:
Jan has written an algorithm to check if a lat/long is inside a fence (a list of lat/longs) See here
来源:https://stackoverflow.com/questions/34468690/create-geofence-while-storing-the-location-to-the-sqlite-database