Breaking up shapefiles Re: [Xastir] ESRI shapefiles and dbfawk

Tom Russo russo at bogodyn.org
Fri Dec 17 16:03:53 EST 2004


On Fri, Dec 17, 2004 at 11:24:04AM -0800, we recorded a bogon-computron collision of the <archer at eskimo.com> flavor, containing:
> On Fri, 17 Dec 2004, Tom Russo wrote:
> 
> > BTW, one of the things I like about having these spatial indices set up is that
> > it opens up the possibility of querying shapefile maps with the mouse
> > (i.e. you use the spatial indices to determine what shapes of what files
> > are under the mouse pointer, and read in the DBF records).  That's a ways
> > off, though --- first order of business is to get that memory usage under
> > control.
> 
> That would enable us to click on a weather alert to fetch the full
> text of the alert from the WXSVR, instead of finding it in the list.

One of the main purposes I had in mind when I said that, and probably the
easiest to implement --- you'd just run through the small handful of 
county shapefiles and do an RTreeSearch of each file's tree with the 
mouse point as the "rectangle."  My testing in a toy code indicates that
the method works fine when using degenerate rectangles for the search.

In pseudocode:
  set mousepointrect to the Rect struct containing mouse X,Y as both
     xmin,ymin,xmax,ymax
  for i in (...Counties/*.shp)
     if (si=get_shp_from_hash(i))
       nhits=RTreeSearch(si->root,&mouse_point,callbackfunction,0)

and just have callbackfunction check to see if each shape found matches
any alert we have, and if so display the alert data.  There would be only
a few matching shapes in this case, one per file.

If only the trees weren't so bloody huge.

-- 
Tom Russo    KM5VY     SAR502  DM64ux         http://www.swcp.com/~russo/
Tijeras, NM  QRPL#1592 K2#398  SOC#236 AHTB#1 http://www.qsl.net/~km5vy/
 "When life gives you lemons, find someone with a paper cut."



More information about the Xastir mailing list