Beispiel #1
0
 public static IEnumerable <GeoLatLonAlt> GetAltitudeForCoords(double lat, double lng, double distance)
 {
     distance = distance / 1000;
     using (var db = new BotContext())
     {
         return
             (db.MapzenAlt.Where(
                  x =>
                  12742 *
                  SqlCeFunctions.Asin(
                      SqlCeFunctions.SquareRoot(SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lat - lat) / 2) *
                                                SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 *
                                                                   (x.Lat - lat) / 2) +
                                                SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * lat) *
                                                SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * x.Lat) *
                                                SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lon - lng) / 2) *
                                                SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lon - lng) / 2))) <
                  distance).OrderBy(x =>
                                    12742 *
                                    SqlCeFunctions.Asin(
                                        SqlCeFunctions.SquareRoot(SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lat - lat) / 2) *
                                                                  SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 *
                                                                                     (x.Lat - lat) / 2) +
                                                                  SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * lat) *
                                                                  SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * x.Lat) *
                                                                  SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lon - lng) / 2) *
                                                                  SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lon - lng) / 2)))).ToList());
     }
 }
Beispiel #2
0
 public static bool ElevationDataExists(double lat, double lng, double distance)
 {
     distance = distance / 1000;
     using (var db = new BotContext())
     {
         var res = false;
         try
         {
             res =
                 db.MapzenAlt.Any(
                     x =>
                     12742 *
                     SqlCeFunctions.Asin(
                         SqlCeFunctions.SquareRoot(
                             SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lat - lat) / 2) *
                             SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 *
                                                (x.Lat - lat) / 2) +
                             SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * lat) *
                             SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * x.Lat) *
                             SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lon - lng) / 2) *
                             SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Lon - lng) / 2))) <
                     distance);
         }
         catch (Exception)
         {
             //ignore
         }
         return(res);
     }
 }
Beispiel #3
0
 public static IEnumerable <PokemonSeen> GetPokemonSeenForCoords(double lat, double lng, double distance)
 {
     distance = distance / 1000;
     using (var db = new BotContext())
     {
         return
             (db.PokemonSeen.Where(
                  x =>
                  12742 *
                  SqlCeFunctions.Asin(
                      SqlCeFunctions.SquareRoot(SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Latitude - lat) / 2) *
                                                SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 *
                                                                   (x.Latitude - lat) / 2) +
                                                SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * lat) *
                                                SqlCeFunctions.Cos(SqlCeFunctions.Pi() / 180 * x.Latitude) *
                                                SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Longitude - lng) / 2) *
                                                SqlCeFunctions.Sin(SqlCeFunctions.Pi() / 180 * (x.Longitude - lng) / 2))) <
                  distance).ToList());
     }
 }