20 using System.Collections.Concurrent;
22 using Lucene.Net.Support.Compatibility;
24 using System.Collections.Generic;
25 using Lucene.Net.Analysis;
26 using Lucene.Net.Analysis.Tokenattributes;
27 using Lucene.Net.Documents;
28 using Lucene.Net.Search.Function;
29 using Lucene.Net.Spatial.Prefix.Tree;
30 using Lucene.Net.Spatial.Queries;
31 using Lucene.Net.Spatial.Util;
32 using Spatial4n.Core.Shapes;
34 namespace Lucene.Net.Spatial.Prefix
44 private readonly IDictionary<String, PointPrefixTreeFieldCacheProvider> provider =
45 new ConcurrentDictionary<string, PointPrefixTreeFieldCacheProvider>();
47 protected int defaultFieldValuesArrayLen = 2;
48 protected double distErrPct = SpatialArgs.DEFAULT_DISTERRPCT;
51 : base(grid.GetSpatialContext(), fieldName)
58 public void SetDefaultFieldValuesArrayLen(
int defaultFieldValuesArrayLen)
60 this.defaultFieldValuesArrayLen = defaultFieldValuesArrayLen;
68 public double DistErrPct {
get;
set; }
72 double distErr = SpatialArgs.CalcDistanceFromErrPct(shape, distErrPct, ctx);
73 return CreateIndexableFields(shape, distErr);
76 public AbstractField[] CreateIndexableFields(Shape shape,
double distErr)
78 int detailLevel = grid.GetLevelForDistance(distErr);
79 var cells = grid.GetNodes(shape, detailLevel,
true);
83 if (!(shape is Point))
85 Point ctr = shape.GetCenter();
87 cells.Add(grid.GetNodes(ctr, grid.GetMaxLevels(),
false)[0]);
96 {OmitNorms =
true, OmitTermFreqAndPositions =
true}
106 private readonly IEnumerator<Node> iter;
116 termAtt = AddAttribute<ITermAttribute>();
119 private string nextTokenStringNeedingLeaf;
121 public override bool IncrementToken()
124 if (nextTokenStringNeedingLeaf != null)
126 termAtt.Append(nextTokenStringNeedingLeaf);
128 nextTokenStringNeedingLeaf = null;
133 Node cell = iter.Current;
135 termAtt.Append(token);
137 nextTokenStringNeedingLeaf = token;
143 protected override void Dispose(
bool disposing)
148 public ShapeFieldCacheProvider<Point> GetCacheProvider()
151 if (!provider.TryGetValue(GetFieldName(), out p) || p == null)
155 if (!provider.ContainsKey(GetFieldName()))
158 provider[GetFieldName()] = p;
165 public override ValueSource MakeDistanceValueSource(Point queryPoint)