Re: Need some help with sorting
- From: Lew <lew@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 May 2007 16:46:34 -0400
jobo wrote:
I'm having some issues trying to figure out an efficient way to do
this.
So I query a database for a bunch of real estate properties that gives
me latitude/longitude coordinates. The maximum number of results that
will be returned is 100.
From those 100 properties I need to calculate a bounding box that willenclose all 100 properties. This might sound confusing, but just think
about a graph full of X/Y coordinates and you need to calculate an
appropiate view screen that will show all points.
The solution I have come up with is you have an array of latitude/
longitude and you have two for loops that would iterate and calculate
maximum distance between two points and keep track of the current
maximum distance between two points untl it reaches the end of the
loop. But this is a very inefficient solution.
How does distance help you determine a bounding box?
Given that there are 100 properties it would give me a Big-O of
100*100 = 10,000 iterations.
I was thinking of sorting the points somehow and indexing is (nlogn)
then iterate through it once to find the maximum distance which would
be at most 100*log(100) + 100 = 300.
Anyone have any ideas? Thanks!
Any simple closed curve that has all the returned properties on one side or the other (not some on one side and some on the other) will be a bounding box for all the properties.
Draw a box one mm on a side anywhere not crossing or within any of the properties. It'll be a bounding box.
--
Lew
.
- References:
- Need some help with sorting
- From: jobo
- Re: Need some help with sorting
- From: Lew
- Need some help with sorting
- Prev by Date: Re: Understanding class access
- Next by Date: Re: Need some help with sorting
- Previous by thread: Re: Need some help with sorting
- Next by thread: Re: Need some help with sorting
- Index(es):
Relevant Pages
|