public class BBoxOverlapRatioValueSource extends BBoxSimilarityValueSource
Spatial relevance scoring algorithm:
minSideLength
may be used whenever an
area is calculated (queryArea, targetArea, intersectionArea). This allows for points or horizontal/vertical lines
to be used as the query shape and in such case the descending order should have smallest boxes up front. Without
this, a point or line query shape typically scores everything with the same value since there is 0 area.
Note: The actual computation of queryRatio and targetRatio is more complicated so that it considers points and lines. Lines have the ratio of overlap, and points are either 1.0 or 0.0 depending on whether it intersects or not.
Originally based on Geoportal's SpatialRankingValueSource but modified quite a bit. GeoPortal's algorithm will yield a score of 0 if either a line or point is compared, and it doesn't output a 0-1 normalized score (it multiplies the factors), and it doesn't support minSideLength, and it had dateline bugs.
Constructor and Description |
---|
BBoxOverlapRatioValueSource(ValueSource rectValueSource,
boolean isGeo,
org.locationtech.spatial4j.shape.Rectangle queryExtent,
double queryTargetProportion,
double minSideLength) |
BBoxOverlapRatioValueSource(ValueSource rectValueSource,
org.locationtech.spatial4j.shape.Rectangle queryExtent)
Construct with 75% weighting towards target (roughly GeoPortal's default), geo degrees assumed, no
minimum side length.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
hashCode() |
protected double |
score(org.locationtech.spatial4j.shape.Rectangle target,
AtomicReference<Explanation> exp)
Return a relevancy score.
|
protected String |
similarityDescription()
A comma-separated list of configurable items of the subclass to put into
BBoxSimilarityValueSource.description() . |
createWeight, description, getValues
asDoubleValuesSource, asLongValuesSource, getSortField, newContext, toString
public BBoxOverlapRatioValueSource(ValueSource rectValueSource, boolean isGeo, org.locationtech.spatial4j.shape.Rectangle queryExtent, double queryTargetProportion, double minSideLength)
rectValueSource
- mandatory; source of rectanglesisGeo
- True if ctx.isGeo() and thus dateline issues should be attended toqueryExtent
- mandatory; the query rectanglequeryTargetProportion
- see class javadocs. Between 0 and 1.minSideLength
- see class javadocs. 0.0 will effectively disable.public BBoxOverlapRatioValueSource(ValueSource rectValueSource, org.locationtech.spatial4j.shape.Rectangle queryExtent)
public boolean equals(Object o)
equals
in class BBoxSimilarityValueSource
public int hashCode()
hashCode
in class BBoxSimilarityValueSource
protected String similarityDescription()
BBoxSimilarityValueSource
BBoxSimilarityValueSource.description()
.similarityDescription
in class BBoxSimilarityValueSource
protected double score(org.locationtech.spatial4j.shape.Rectangle target, AtomicReference<Explanation> exp)
BBoxSimilarityValueSource
exp
is provided then diagnostic information is added.score
in class BBoxSimilarityValueSource
target
- The indexed rectangle; not null.exp
- Optional diagnostic holder.Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.