I guess the solution is to forget about using IndexSearcher and Query at all and to write a simple "GeoSearcher" that opens the regular index, plus the QuadTree, and uses the same approach I used in GeoFilter to generate a group of hits. Like this:
GeoQuery geoSearcher = new GeoSearcher("path_to_index_file", quadTree); hits = geoQuery.search(rect,filter); Would that be right? --G On Sun, May 01, 2005 at 01:14:25PM -0700, Guillermo Payet wrote: > Hi, > > I started implementing geographical searches yesterday, using BBN's QuadTree > implementaion as the spacial index. I first implemented a new "GeoFilter" > class to filter queries to "all items within a rectangle". That was pretty > easy and it's now working beautifuly, and very fast too. See below force > source code. > > BTW: I'm creating the QuadTree in memory right now during Lucene index > creation, but not storing it in the disk yet. I'll add something like > a couple of "GeoIndexReader" and "GeoIndexWriter" classes later. > > I'm now having a hell of a time figuring out how to implement a "GeoQuery" > class though. Just figuring out how the whole Query mechanism works > by reading the source code is proving to be quite a challenge. > > Question: Is there any article or document that explains this? Also: > Any tips as to what the right approach would be here? > > --G > > > ---------------------------------------------------------------------------- > package com.oceangroup.projects.localharvest.search; > > import java.util.BitSet; > import java.util.Vector; > import java.io.IOException; > > import org.apache.lucene.search.*; > import org.apache.lucene.index.IndexReader; > > import com.oceangroup.servlets.gis.LatLonRect; > > import com.bbn.openmap.util.quadtree.QuadTree; > > /** > * A Filter that restricts search results to a geographical area > * > */ > public class GeoFilter extends Filter { > > QuadTree qTree; > LatLonRect rect; > > public GeoFilter(QuadTree quadTree, LatLonRect rect) { > this.qTree = quadTree; > this.rect = rect; > } > > public BitSet bits(IndexReader reader) throws IOException { > BitSet bits = new BitSet(reader.maxDoc()); > Vector<Integer> results = > qTree.get((float)rect.urLat,(float)rect.llLon,(float)rect.llLat,(float)rect.urLon); > > if (results == null || results.size()==0) { > return bits; > } > > for (Integer item: results) { > bits.set(item.intValue()); > } > > return bits; > } > } > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- Guillermo Payet L O C A L H A R V E S T http://www.localharvest.org Every Morning I awake torn between a desire to save the world and an inclination to savor it. This makes it hard to plan the day. -E.B.White --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]