Sorting results on a mysql table along longitude and then latitude, NOT a circular radius
Hey all... I've been tasked with a global search project. They want to search a database of pictures, all with long/lat references storied per image in a mysql DB.
However, their search criteria is a little specific.
A simplified table structure is:
id
INT auto inc primary
imagePath
varchar 255
long
DECIMAL 12,7
lat
DECIMAL 12,7
I need to provide the SQL statement with a start long/lat position. They then want to receive 34 images, going south from their initial long reference.. once they get to -90 (the bottom of the earth) to pop over 1 degree to the right/East and search up to the north to 90 and repeat until 34 images are found.
What's confusing me is开发者_开发百科 how to calculate the minus to plus changes.. ensuring that we loop up and down along the earths 'long' reference.
Has anyone done this before..? I'd LOVE to do it in a single query... (I've seen how one can fetch results based on a circle radius, but my client.. bless em.. doesn't want to do that)
Ok, back to google!!
Thoughts...
Tris...
Inputs are $the_lat and $the_long
SELECT *
FROM table
WHERE long > $the_long
OR ( long = $the_long AND lat >= $the_lat)
ORDER BY long ASC, lat ASC
LIMIT 34
As is, it's a uni-directional search -- it won't wrap around to longs < $the_long.
精彩评论