[Xastir] rtree speeds up shapefiles
Tom Russo
russo at bogodyn.org
Thu Feb 10 18:39:19 EST 2005
On Thu, Feb 10, 2005 at 05:19:30PM -0600, we recorded a bogon-computron collision of the <jdw at eng.uah.edu> flavor, containing:
>
> On Feb 10, 2005, at 5:09 PM, Tom Russo wrote:
>
> >>What is the reason for the index expiration?
> >
> >To free up memory that is being wasted by storing indices that aren't
> >being
> >used.
>
> So, for the case of my USA-wide shapefiles, the index would initially
> be built for the entire shapefile. As I view my little area of north
> Alabama, with occasional scrolls into TN, AL, GA, MS, the indices for
> the parts of the shapfile I'm _not_ viewing regularly will be freed,
> but the stuff I'm looking at remains indexed as long as I keep using it
> within that hour time limit ?
No. If you have a USA-wide shapefile and are only viewing pieces of it,
the index sticks around as long as you do a map redraw more than once an
hour.
Here's the way it works:
draw_shapefile_map is called on a map, and the map intersects the current
viewport.
if (entire map visible)
display entire map, don't even access an rtree
else // it's only partly visible
if (there's no rtree for this map)
build an rtree, start its timer
else
grab the existing rtree, reset its timer
use rtree to find all parts of the map that intersect this view
display them
If an hour passes and the timer isn't reset by having the tree accessed,
the tree is deleted. This is meant to make sure we don't fill up all available
memory with trees for maps that are hardly ever viewed, or for maps that
are always 100% visible (and therefore never benefit from spatial indexing).
--
Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/
Tijeras, NM QRPL#1592 K2#398 SOC#236 AHTB#1
"When life gives you lemons, find someone with a paper cut."
More information about the Xastir
mailing list