To display data on google maps, I have >50k rows of data in SQL server 2005 with the following (simplified) structure
PointID
Latitude
Longitude
TypeID
I can select a small subset within a bounding box, ensuring a decent mix of Types like this:
.....
(
@NELat float,
@NELong float,
@SWLat float,
@SWLong float
)
as
select top 100 PointID, Latitude, Longitude,
rank() over (partition by PointTable.TypeID order by newid()) as NewRank
from PointTable
where
(
CONVERT(float, PointTable.Latitude) >= @SWLat and CONVERT(float, PointTable.Latitude) <= @NELat and
CONVERT(float, PointTable.Longitude) >= @SWLong and CONVERT(float, PointTable.Longitude) <= @NELong
)
order by NewRank
Unfortunately the initial data is biased towards one particular geographical location.
What's the most efficient/computationally quickest way to ensure that the retrieved data has a decent geographical spread?
I don't want to cluster the data, just to show a more even spread of data across the bounding box. Could I possibly create a subset of bounding box grids, and partition over them? Any suggestions would be a great help!
I had been looking into the geography datatype available to SQL sever 2008, but it doesn't look like it's available in 2005. Also I am aware float
is not the best datatype for storing coordinates, but that wasn't up to me.