Surface Pro 7 deal! Save big at Amazon right now
- I have the Lat/Lng of locations in an SQLite table. I also generated the SQLite DataContext class through SQLMetal.
I need SQLite to SORT BY whichever location is closer to a given Lat/Long coordinate. I'm using LINQ, and it doesn't seem to support ExecuteQuery* or whatever the WP7 equivalent could be.
Is it possible to run calculations via LINQ?
I've found this equation that should calculate the distance quickly. I simply have no idea how to use this in my existing DataContext.
[CODE]((<lat> - LATITUDE_COLUMN) * (<lat> - LATITUDE_COLUMN) +
(<lng> - LONGITUDE_COLUM) * (<lng> - LONGITUDE_COLUM))[/CODE]12-31-2011 08:31 PMLike 0 -
Code:var result = (from dblot in dc.Parkinglots orderby ((x - dblot.Lat) * (x - dblot.Lat) + (y - dblot.Lng) * (y - dblot.Lng)) select dblot).Take(30);
Finally, although it's not useful in this example, a nice syntax is something like this:
Code:var result = from meep in myList select new { a = meep.Something - meep.SomethingElse, b = meep.AnotherThing - 20 };
01-01-2012 04:09 PMLike 0
- Forum
- Developers
- Developers Corner
Latitude and Longitude in SQLite DB
LINK TO POST COPIED TO CLIPBOARD