mercredi 27 avril 2016

Something wrong with these Sqlite queries

I am writing an android application to show wifi locations around, it query Latitude and Longitude from sqlite database. I got this problem when I put current Latitude and Longitude variable LAT,LON in the query, it's query result show wrong and very far wifi locations from my current location. It's working fine when I put an example location like 10.029269, 105.766794. I have check the LAT,LON value, it's Double variable and show the right Latitude and Longitude. So I am sure 100% that the problem are these queries!

Cursor cursor = database.rawQuery("SELECT lat AS distance FROM wifi ORDER BY (("+LAT+"-lat)*("+LAT+"-lat)) + (("+LON+"-lon)*("+LON+"-lon)) ASC LIMIT 5", null);
Cursor cursor = database.rawQuery("SELECT lon AS distance FROM wifi ORDER BY (("+LAT+"-lat)*("+LAT+"-lat)) + (("+LON+"-lon)*("+LON+"-lon)) ASC LIMIT 5", null);

Aucun commentaire:

Enregistrer un commentaire