A thought....
I don't really need any geographical scoring. I just need to be able
to show all items within a region. Since a lot of the complexity of
"Query" has to do with scoring, would it be better to just use the
GeoFilter, and to search for *? Are there any performance issues
with this?
--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]