0

in this example i need to limit search for seraching just places in arround of 10000 meters for example , this method is dosen't work for me . this is my code :

  using (GeolocationTestEntities context = new GeolocationTestEntities ())
        {


            var distance = 10000;
            var distanceInMeters = distance * 0.6214;

            var CurrentLocation = DbGeography.FromText("POINT(" + CurrentLat + " " + CurrentLng + ")");
                var places = (from u in context.schoolinfo
                              where u.Location.Distance(CurrentLocation) < distanceInMeters
                              select u).Take(10).Select(x => new schoollinfo() { Name = x.name, Lat = x.Location.Latitude, Lng = x.Location.Longitude, Distance = x.Location.Distance(CurrentLocation) });
                var nearschools = places.ToList();
                HttpCookie cookie = new HttpCookie("Cookie");
                cookie["CurrentLat"] = CurrentLat;
                cookie["CurrentLng"] = CurrentLng;
                this.ControllerContext.HttpContext.Response.Cookies.Add(cookie);

                return Json(nearschools, JsonRequestBehavior.AllowGet);


        }

thanks,

oussama_tr
  • 61
  • 7
  • Try different co-ordinates. What records are in DBGeography? Are there lat / long within the current location? Without this info we can only guess... Also you actually forgot to ask a question. Did it work before? What guide are you following? – Jeremy Thompson Oct 20 '17 at 22:27
  • hi, i records a list of a lat/long , my question it s how can i search just places in a round of 10 Km for example , start position it's current location – oussama_tr Oct 21 '17 at 12:02
  • Please [edit] your question with additional information. Thanks. – Jeremy Thompson Oct 21 '17 at 12:04

1 Answers1

0

You should not use (distance * 0.6214). Because Distance() metod is already use meter.

Nurullah
  • 1
  • 1
  • 1