[prev in list] [next in list] [prev in thread] [next in thread]
List: lucene-dev
Subject: geographical searches
From: Guillermo Payet <gpayet () localharvest ! org>
Date: 2005-05-01 20:14:25
Message-ID: 20050501201425.GA16096 () localharvest ! org
[Download RAW message or body]
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: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic