19 using Lucene.Net.Documents;
20 using Lucene.Net.Search;
21 using Lucene.Net.Search.Function;
22 using Lucene.Net.Spatial.Queries;
23 using Lucene.Net.Spatial.Util;
24 using Spatial4n.Core.Context;
25 using Spatial4n.Core.Shapes;
27 namespace Lucene.Net.Spatial
37 public abstract class SpatialStrategy
39 protected readonly SpatialContext ctx;
40 protected readonly
string fieldName;
47 protected SpatialStrategy(SpatialContext ctx,
string fieldName)
50 throw new ArgumentException(
"ctx is required",
"ctx");
52 if (
string.IsNullOrEmpty(fieldName))
53 throw new ArgumentException(
"fieldName is required",
"fieldName");
54 this.fieldName = fieldName;
57 public SpatialContext GetSpatialContext()
67 public String GetFieldName()
85 public abstract AbstractField[] CreateIndexableFields(Shape shape);
97 public abstract ValueSource MakeDistanceValueSource(Point queryPoint);
123 public abstract Filter MakeFilter(SpatialArgs args);
135 public ValueSource MakeRecipDistanceValueSource(Shape queryShape)
137 Rectangle bbox = queryShape.GetBoundingBox();
138 double diagonalDist = ctx.GetDistCalc().Distance(
139 ctx.MakePoint(bbox.GetMinX(), bbox.GetMinY()), bbox.GetMaxX(), bbox.GetMaxY());
140 double distToEdge = diagonalDist*0.5;
141 float c = (float) distToEdge*0.1f;
145 public override string ToString()
147 return GetType().Name +
" field:" + fieldName +
" ctx=" + ctx;