yes - use tiles, but I'd rather use quadtiles, as they have nicer properties (particularly you can fetch the super-tile of 4 child tiles incredibly easily. Calculating which tile a point is in is not very hard; I've got a bit of java lying around, but it's easy enough to understand.
<br><br>Incidentally, though I didn't mention it at the time, this scheme is particularly good for databases that support data file partitioning.<br><br>Here's the post I sent a while ago:<br><br>> [sniiip]<br>> I'd be interested to hear from computer scientists about fancy algorithms for
<br>> spacially-sorting the data, doing indexes, etc. First person to mention<br>> Hilbert space gets a nerd of the month award.<br>><br><br>Quadtrees. We need to be doing this in OSM in general, and it would<br>
make things much simpler.<br><br>To illustrate - divide the world into 4 quadrants. Call the top-left<br>A, top-right B, bottom-left C, bottom-right D. Then for each quadrant,<br>do the same. thus the grid is now<br><br>AA AB BA BB
<br>AC AD BC BD<br>CA CB DA DB<br>CC CD DC DD<br><br>each time you repeat this process (and you can do this as much as you<br>like), you halve the area in each addressable tile. For around 13<br>characters, you get (IIRC) 100m of resolution if you started with the
<br>entire globe (may be wrong, memory is hazy).<br><br>So, just thinking about nodes, we store along with each (long, lat)<br>coordinate the quadtree address. Instead of querying, say,<br><br>select * from nodes where lat>? and lat<? and lon>? and lon<?
<br><br>we just do (say)<br>select * from nodes where quadtree='AAABDBA'<br><br>rather neatly, if you wanted to zoom out to the next level of detail, you can do<br><br>select  * from nodes where quadtree like 'AAABDB%'<br>
<br>Which will get any node in AAABDBA, AAABDBB, AAABDBC and AAABDBD. This<br>is a single index lookup, and is very fast.<br><br>This also solves another sticky problem. Consider segments (ways are<br>just the same on a larger scale). You have a segment going from AB to
<br>BC. Using the current 'get nodes in area, get missing nodes in<br>segments' method, if you fetch the area AD, you'll miss the fact that<br>there is this segment going through it. By storing for each<br>way/segment the list of tiles it intersects, the segments query is
<br>also simplified to 'select * from segments where quadtree like 'xyz%'.<br><br>This is particularly important for areas - for example, you could be<br>viewing a tile in the middle of a forest whose edge does not actually
<br>intersect with your tile at all.<br><br>This makes the map query somewhat easy, just a sequence of<br>select * from nodes where <span id="st" name="st" class="st">quadtile</span> like ?<br>select * from segments join segment_quadtile on
<br>segment.id=segment_quadtile<div style="direction: ltr;">.<span id="st" name="st" class="st">quadtile</span> where segment_quadtile like ?<br>etc., etc.<br><br>Using quadtree addresses is also useful for external applications. Say
<br>OSM had an RSS feed of changes that listed which quadtiles have been<br>changed. Map renderers can thus use this information to invalidate<br>their cache for just that tile, and re-render, without having to check<br>for changes each time. I could 'register' for information if anything
<br>changed in a list of <span id="st" name="st" class="st">quadtile</span> addresess (say, those covring oxford),<br>and it would be very easy to calculate when something I would be<br>interested in had happened.<br><br>
This isn't very complicated and could be done relatively quickly. I<br>have most of a java implementation buried on my harddrive somewhere...</div><br><br>