Let’s say I get the user to pick long and lat on map. I have database with following columns:
zip
state
latitude
longitude
city
full_state
How do I retrieve the closest match for long and lat with hibernate HQL query?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One simple thing that you could do, is write your query so that you search for anything within a set range of from a given latitude and longitude. For example you could search for anything where:
latitude<(latitude+<your boundary>)
and latitude>(latitude-<your boundary>)
and longitude<(longitude+<your boundary>)
and longitude>(longitude-<your boundary>)
I think 1 degree of latitude or longitude is about about 69.11 miles. so to find anything within 50 miles set your boundary to be around 0.8