|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--edu.ucsb.adl.middleware.SpatialRanker
Ranks query results by spatial similarity to the query region. Results having spatial footprints that are more similar to the query region are ranked higher.
The query must contain a spatial constraint against bucket
adl:geographic-locations; if not, an exception is
raised. Limitation: if the query region is a polygon, the
polygon's bounding box is used for ranking purposes.
A result's spatial footprint is obtained from the result's mapping
to the adl:geographic-locations bucket in its ADL
bucket view. If the result has more than one such mapping, the
mapping that results in the highest rank is used; if the result has
no such mappings, it is assigned a minimal rank. Limitation: as
with the query region, if the spatial footprint is a polygon or
polyline, the polygon's or polyline's bounding box is used for
ranking purposes.
This class supports two algorithms for computing spatial similarity. In both algorithms, "spatial similarity" means similarity in terms of size, shape, and location.
In the "hausdorff-distance" algorithm, a result's rank
is determined by the Hausdorff distance between its spatial
footprint and the query region; the smaller the distance, the
higher the rank. The so-called "directed Hausdorff distance" from
a region A to a region B is the distance between the
point p in A that is farthest from any point in
B and the point q in B that is closest to
p. The Hausdorff distance between A and B is
then the maximum of the directed distance from A to B
and the directed distance from B to A. Intuitively,
the Hausdorff distance is a measure of the mismatch between
A and B: if the Hausdorff distance is d, then
every point of A is within distance d of some point
of B and vice versa.
In the "intersection-union-ratio" algorithm, a
result's rank is determined by the ratio of 1) the area of the
intersection of its spatial footprint and the query region
to 2) the area of the union of its spatial footprint and
the query region; the greater the ratio, the higher the rank. If
the query region has zero area, all results are assigned a minimal
rank.
This class computes spatial similarity using a truncated cylinder manifold as the underlying topology. That is, the distance is computed in an equirectangular projection, but there is no discontinuity at the +/-180 meridian (or any other meridian).
For more information, see Spatial Similarity Functions.
$Log: SpatialRanker.java,v $ Revision 1.1 2004/09/05 21:43:21 gjanee Initial revision
| Method Summary | |
void |
characters(char[] string,
int start,
int length)
For use by ValidatingXmlParser only. |
static edu.ucsb.adl.middleware.SpatialRanker |
createRanker(java.lang.String algorithm)
Creates a SpatialRanker. |
void |
endElement(int elementCode)
For use by ValidatingXmlParser only. |
static void |
main(java.lang.String[] args)
Test driver. |
double |
rank(edu.ucsb.adl.middleware.Result result,
edu.ucsb.adl.middleware.Query query)
Ranks a query result. |
void |
startElement(int elementCode,
java.lang.String[] attributes)
For use by ValidatingXmlParser only. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static edu.ucsb.adl.middleware.SpatialRanker createRanker(java.lang.String algorithm)
throws InternalErrorException
SpatialRanker. The ranker may be
invoked multiple times, but is not multithread-safe.
algorithm - The algorithm to use. Must be either
"hausdorff-distance" or
"intersection-union-ratio".
SpatialRanker.
InternalErrorException - If algorithm is invalid.
public double rank(edu.ucsb.adl.middleware.Result result,
edu.ucsb.adl.middleware.Query query)
throws InternalErrorException
rank in interface Rankerresult - The result.query - The query that produced the result, which must contain a
spatial constraint against bucket
adl:geographic-locations.
InternalErrorException - If any error occurs.
public void startElement(int elementCode,
java.lang.String[] attributes)
ValidatingXmlParser only.
startElement in interface XmlHandlerelementCode - The element's code.attributes - Element attribute values, indexed by attribute code. All of
the element's declared attributes are represented in the array;
attributes for which a value is specified in the document or
for which there is a DTD-specified default have
non-null values. The handler should reference the
array for the duration of the call only, as it is reused by the
parser. Also, the array may be longer than necessary.
public void endElement(int elementCode)
throws XmlException
ValidatingXmlParser only.
endElement in interface XmlHandlerelementCode - The element's code.
XmlException - If any error occurs.
public void characters(char[] string,
int start,
int length)
ValidatingXmlParser only.
characters in interface XmlHandlerstring - The textual content.start - The index in string at which the textual content
starts.length - The length of the content.
public static void main(java.lang.String[] args)
throws java.io.IOException,
InternalErrorException
java.io.IOException
InternalErrorException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||