You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2016/11/25 11:07:08 UTC

[03/26] lucenenet git commit: Some tidy up

Some tidy up


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/9e566a89
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/9e566a89
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/9e566a89

Branch: refs/heads/master
Commit: 9e566a89279be1897772c4fbee9dbb3e86e1331a
Parents: 4a485ee
Author: Naz Junaid <na...@gmail.com>
Authored: Wed Jul 27 23:05:18 2016 +0100
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Tue Nov 15 19:17:54 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Spatial/DisjointSpatialFilter.cs |   2 +-
 .../Lucene.Net.Spatial.csproj                   |   9 +-
 .../Prefix/AbstractPrefixTreeFilter.cs          |  52 +++----
 .../Prefix/AbstractVisitingPrefixTreeFilter.cs  |  70 ++++-----
 .../Prefix/ContainsPrefixTreeFilter.cs          |  82 ++++-------
 .../Prefix/IntersectsPrefixTreeFilter.cs        |  29 +---
 .../Prefix/PointPrefixTreeFieldCacheProvider.cs |   1 -
 .../Prefix/PrefixTreeStrategy.cs                |   6 +-
 .../Prefix/RecursivePrefixTreeStrategy.cs       |   6 +-
 .../Prefix/TermQueryPrefixTreeStrategy.cs       |   4 +-
 .../Prefix/WithinPrefixTreeFilter.cs            |  73 +++++-----
 src/Lucene.Net.Spatial/Queries/SpatialArgs.cs   | 142 ------------------
 .../Queries/SpatialArgsParser.cs                | 140 ------------------
 .../Queries/SpatialOperation.cs                 | 116 ---------------
 .../Queries/UnsupportedSpatialOperation.cs      |  30 ----
 src/Lucene.Net.Spatial/Query/SpatialArgs.cs     | 136 ++++++++++++++++++
 .../Query/SpatialArgsParser.cs                  | 144 +++++++++++++++++++
 .../Query/SpatialOperation.cs                   | 114 +++++++++++++++
 .../Query/UnsupportedSpatialOperation.cs        |  30 ++++
 .../Serialized/SerializedDVStrategy.cs          |  69 +++++++++
 src/Lucene.Net.Spatial/SpatialStrategy.cs       |   2 +-
 .../Vector/PointVectorStrategy.cs               |   2 +-
 22 files changed, 627 insertions(+), 632 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/DisjointSpatialFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/DisjointSpatialFilter.cs b/src/Lucene.Net.Spatial/DisjointSpatialFilter.cs
index e36a97b..3ad309e 100644
--- a/src/Lucene.Net.Spatial/DisjointSpatialFilter.cs
+++ b/src/Lucene.Net.Spatial/DisjointSpatialFilter.cs
@@ -18,7 +18,7 @@ using System;
 using Lucene.Net.Index;
 using Lucene.Net.Queries;
 using Lucene.Net.Search;
-using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Spatial.Query;
 using Lucene.Net.Util;
 
 namespace Lucene.Net.Spatial

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Lucene.Net.Spatial.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Lucene.Net.Spatial.csproj b/src/Lucene.Net.Spatial/Lucene.Net.Spatial.csproj
index fabf96c..f6669e6 100644
--- a/src/Lucene.Net.Spatial/Lucene.Net.Spatial.csproj
+++ b/src/Lucene.Net.Spatial/Lucene.Net.Spatial.csproj
@@ -82,10 +82,11 @@
     <Compile Include="Prefix\Tree\SpatialPrefixTreeFactory.cs" />
     <Compile Include="Prefix\WithinPrefixTreeFilter.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Queries\SpatialArgs.cs" />
-    <Compile Include="Queries\SpatialArgsParser.cs" />
-    <Compile Include="Queries\SpatialOperation.cs" />
-    <Compile Include="Queries\UnsupportedSpatialOperation.cs" />
+    <Compile Include="Query\SpatialArgs.cs" />
+    <Compile Include="Query\SpatialArgsParser.cs" />
+    <Compile Include="Query\SpatialOperation.cs" />
+    <Compile Include="Query\UnsupportedSpatialOperation.cs" />
+    <Compile Include="Serialized\SerializedDVStrategy.cs" />
     <Compile Include="SpatialStrategy.cs" />
     <Compile Include="Util\ShapeFieldCacheDistanceValueSource.cs" />
     <Compile Include="Util\CachingDoubleValueSource.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/AbstractPrefixTreeFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/AbstractPrefixTreeFilter.cs b/src/Lucene.Net.Spatial/Prefix/AbstractPrefixTreeFilter.cs
index c70a7c5..fadab36 100644
--- a/src/Lucene.Net.Spatial/Prefix/AbstractPrefixTreeFilter.cs
+++ b/src/Lucene.Net.Spatial/Prefix/AbstractPrefixTreeFilter.cs
@@ -23,21 +23,19 @@ using Spatial4n.Core.Shapes;
 
 namespace Lucene.Net.Spatial.Prefix
 {
-    /// <summary>Base class for Lucene Filters on SpatialPrefixTree fields.</summary>
-    /// <remarks>Base class for Lucene Filters on SpatialPrefixTree fields.</remarks>
-    /// <lucene.experimental></lucene.experimental>
+    /// <summary>
+    /// Base class for Lucene Filters on SpatialPrefixTree fields.
+    /// @lucene.experimental
+    /// </summary>
     public abstract class AbstractPrefixTreeFilter : Filter
     {
-        protected internal readonly int detailLevel;
-        protected internal readonly string fieldName;
-
-        protected internal readonly SpatialPrefixTree grid;
         protected internal readonly Shape queryShape;
-
-        public AbstractPrefixTreeFilter(Shape queryShape, string
-                                                              fieldName, SpatialPrefixTree grid, int detailLevel)
+        protected internal readonly string fieldName;
+        protected internal readonly SpatialPrefixTree grid;//not in equals/hashCode since it's implied for a specific field
+        protected internal readonly int detailLevel;
+        
+        public AbstractPrefixTreeFilter(Shape queryShape, string fieldName, SpatialPrefixTree grid, int detailLevel)
         {
-            //not in equals/hashCode since it's implied for a specific field
             this.queryShape = queryShape;
             this.fieldName = fieldName;
             this.grid = grid;
@@ -82,32 +80,29 @@ namespace Lucene.Net.Spatial.Prefix
 
         /// <summary>
         /// Holds transient state and docid collecting utility methods as part of
-        /// traversing a
-        /// <see cref="TermsEnum">Lucene.Net.Index.TermsEnum</see>
-        /// .
+        /// traversing a <see cref="TermsEnum">Lucene.Net.Index.TermsEnum</see>.
         /// </summary>
         public abstract class BaseTermsEnumTraverser
         {
-            private readonly AbstractPrefixTreeFilter _enclosing;
-            protected internal readonly AtomicReaderContext context;
-
-            protected internal readonly int maxDoc;
-            protected internal Bits acceptDocs;
+            private readonly AbstractPrefixTreeFilter outerInstance;
+            protected readonly AtomicReaderContext context;
+            protected Bits acceptDocs;
+            protected readonly int maxDoc;
 
-            protected internal DocsEnum docsEnum;
-            protected internal TermsEnum termsEnum;
+            protected TermsEnum termsEnum;//remember to check for null in getDocIdSet
+            protected DocsEnum docsEnum;
+            
 
             /// <exception cref="System.IO.IOException"></exception>
-            public BaseTermsEnumTraverser(AbstractPrefixTreeFilter _enclosing, AtomicReaderContext
-                                                                                   context, Bits acceptDocs)
+            public BaseTermsEnumTraverser(AbstractPrefixTreeFilter outerInstance, AtomicReaderContext context, Bits acceptDocs)
             {
-                this._enclosing = _enclosing;
-                //remember to check for null in getDocIdSet
+                this.outerInstance = outerInstance;
+                
                 this.context = context;
                 AtomicReader reader = context.AtomicReader;
                 this.acceptDocs = acceptDocs;
                 maxDoc = reader.MaxDoc;
-                Terms terms = reader.Terms(this._enclosing.fieldName);
+                Terms terms = reader.Terms(this.outerInstance.fieldName);
                 if (terms != null)
                 {
                     termsEnum = terms.Iterator(null);
@@ -115,12 +110,11 @@ namespace Lucene.Net.Spatial.Prefix
             }
 
             /// <exception cref="System.IO.IOException"></exception>
-            protected internal virtual void CollectDocs(FixedBitSet bitSet)
+            protected virtual void CollectDocs(FixedBitSet bitSet)
             {
                 //WARN: keep this specialization in sync
                 Debug.Assert(termsEnum != null);
-                docsEnum = termsEnum.Docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE
-                    );
+                docsEnum = termsEnum.Docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
                 int docid;
                 while ((docid = docsEnum.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/AbstractVisitingPrefixTreeFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/AbstractVisitingPrefixTreeFilter.cs b/src/Lucene.Net.Spatial/Prefix/AbstractVisitingPrefixTreeFilter.cs
index 980f4cc..861c0de 100644
--- a/src/Lucene.Net.Spatial/Prefix/AbstractVisitingPrefixTreeFilter.cs
+++ b/src/Lucene.Net.Spatial/Prefix/AbstractVisitingPrefixTreeFilter.cs
@@ -28,36 +28,27 @@ using Spatial4n.Core.Shapes;
 namespace Lucene.Net.Spatial.Prefix
 {
     /// <summary>
-    /// Traverses a
-    /// <see cref="Lucene.Net.Spatial.Prefix.Tree.SpatialPrefixTree">Lucene.Net.Spatial.Prefix.Tree.SpatialPrefixTree
-    /// 	</see>
-    /// indexed field, using the template &
+    /// Traverses a <see cref="SpatialPrefixTree">SpatialPrefixTree</see> indexed field, using the template &
     /// visitor design patterns for subclasses to guide the traversal and collect
     /// matching documents.
     /// <p/>
-    /// Subclasses implement
-    /// <see cref="Lucene.Net.Search.Filter.GetDocIdSet(AtomicReaderContext, Bits)
-    /// 	">Lucene.Search.Filter.GetDocIdSet(AtomicReaderContext, Bits)
-    /// 	</see>
-    /// by instantiating a custom
-    /// <see cref="VisitorTemplate">VisitorTemplate</see>
+    /// Subclasses implement <see cref="Filter.GetDocIdSet(AtomicReaderContext, Bits)">Lucene.Search.Filter.GetDocIdSet(AtomicReaderContext, Bits)</see>
+    /// by instantiating a custom <see cref="VisitorTemplate">VisitorTemplate</see>
     /// subclass (i.e. an anonymous inner class) and implement the
     /// required methods.
+    /// @lucene.internal
     /// </summary>
-    /// <lucene.internal></lucene.internal>
     public abstract class AbstractVisitingPrefixTreeFilter : AbstractPrefixTreeFilter
     {
+        // Historical note: this code resulted from a refactoring of RecursivePrefixTreeFilter,
+        // which in turn came out of SOLR-2155
+
         protected internal readonly int prefixGridScanLevel;
 
-        public AbstractVisitingPrefixTreeFilter(Shape queryShape
-                                                , string fieldName, SpatialPrefixTree grid, int detailLevel,
-                                                int prefixGridScanLevel
-            )
+        public AbstractVisitingPrefixTreeFilter(Shape queryShape, string fieldName, SpatialPrefixTree grid, 
+                                                int detailLevel, int prefixGridScanLevel)
             : base(queryShape, fieldName, grid, detailLevel)
         {
-            //Historical note: this code resulted from a refactoring of RecursivePrefixTreeFilter,
-            // which in turn came out of SOLR-2155
-            //at least one less than grid.getMaxLevels()
             this.prefixGridScanLevel = Math.Max(0, Math.Min(prefixGridScanLevel, grid.MaxLevels - 1));
             Debug.Assert(detailLevel <= grid.MaxLevels);
         }
@@ -66,9 +57,9 @@ namespace Lucene.Net.Spatial.Prefix
         {
             if (!base.Equals(o))
             {
-                return false;
+                return false;//checks getClass == o.getClass & instanceof
             }
-            //checks getClass == o.getClass & instanceof
+            
             var that = (AbstractVisitingPrefixTreeFilter)o;
             if (prefixGridScanLevel != that.prefixGridScanLevel)
             {
@@ -168,27 +159,20 @@ namespace Lucene.Net.Spatial.Prefix
         /// <lucene.internal></lucene.internal>
         public abstract class VisitorTemplate : BaseTermsEnumTraverser
         {
-            private readonly AbstractVisitingPrefixTreeFilter _enclosing;
+            private readonly AbstractVisitingPrefixTreeFilter outerInstance;
             private readonly BytesRef curVNodeTerm = new BytesRef();
-            protected internal readonly bool hasIndexedLeaves;
-
-            private VNode curVNode;
-
-            private Cell scanCell;
+            protected internal readonly bool hasIndexedLeaves;//if false then we can skip looking for them
 
-            private BytesRef thisTerm;
+            private VNode curVNode;//current pointer, derived from query shape
+            private BytesRef thisTerm; //the result of termsEnum.term()
+            private Cell scanCell;//curVNode.cell's term.
 
             /// <exception cref="System.IO.IOException"></exception>
-            public VisitorTemplate(AbstractVisitingPrefixTreeFilter _enclosing, AtomicReaderContext
-                                                                                    context, Bits acceptDocs,
+            public VisitorTemplate(AbstractVisitingPrefixTreeFilter outerInstance, AtomicReaderContext context, Bits acceptDocs,
                                    bool hasIndexedLeaves)
-                : base(_enclosing, context, acceptDocs)
+                : base(outerInstance, context, acceptDocs)
             {
-                this._enclosing = _enclosing;
-                //if false then we can skip looking for them
-                //current pointer, derived from query shape
-                //curVNode.cell's term.
-                //the result of termsEnum.term()
+                this.outerInstance = outerInstance;
                 this.hasIndexedLeaves = hasIndexedLeaves;
             }
 
@@ -207,7 +191,7 @@ namespace Lucene.Net.Spatial.Prefix
                 }
                 // all done
                 curVNode = new VNode(null);
-                curVNode.Reset(_enclosing.grid.WorldCell);
+                curVNode.Reset(outerInstance.grid.WorldCell);
                 Start();
                 AddIntersectingChildren();
                 while (thisTerm != null)
@@ -257,7 +241,7 @@ namespace Lucene.Net.Spatial.Prefix
                     if (compare > 0)
                     {
                         // leap frog (termsEnum is beyond where we would otherwise seek)
-                        Debug.Assert(!((AtomicReader)context.Reader).Terms(_enclosing.fieldName).Iterator(null).SeekExact(curVNodeTerm), "should be absent");
+                        Debug.Assert(!((AtomicReader)context.Reader).Terms(outerInstance.fieldName).Iterator(null).SeekExact(curVNodeTerm), "should be absent");
                     }
                     else
                     {
@@ -309,7 +293,7 @@ namespace Lucene.Net.Spatial.Prefix
             {
                 Debug.Assert(thisTerm != null);
                 Cell cell = curVNode.cell;
-                if (cell.Level >= _enclosing.detailLevel)
+                if (cell.Level >= outerInstance.detailLevel)
                 {
                     throw new InvalidOperationException("Spatial logic error");
                 }
@@ -320,7 +304,7 @@ namespace Lucene.Net.Spatial.Prefix
                     // then add all of those docs
                     Debug.Assert(StringHelper.StartsWith(thisTerm, curVNodeTerm
                                      ));
-                    scanCell = _enclosing.grid.GetCell(thisTerm.Bytes, thisTerm.Offset
+                    scanCell = outerInstance.grid.GetCell(thisTerm.Bytes, thisTerm.Offset
                                                        , thisTerm.Length, scanCell);
                     if (scanCell.Level == cell.Level && scanCell.IsLeaf())
                     {
@@ -337,7 +321,7 @@ namespace Lucene.Net.Spatial.Prefix
                 // scan through terms beneath this cell.
                 // Scanning is a performance optimization trade-off.
                 //TODO use termsEnum.docFreq() as heuristic
-                bool scan = cell.Level >= _enclosing.prefixGridScanLevel;
+                bool scan = cell.Level >= outerInstance.prefixGridScanLevel;
                 //simple heuristic
                 if (!scan)
                 {
@@ -354,7 +338,7 @@ namespace Lucene.Net.Spatial.Prefix
                 else
                 {
                     //Scan (loop of termsEnum.next())
-                    Scan(_enclosing.detailLevel);
+                    Scan(outerInstance.detailLevel);
                 }
             }
 
@@ -370,7 +354,7 @@ namespace Lucene.Net.Spatial.Prefix
             /// </summary>
             protected internal virtual IEnumerator<Cell> FindSubCellsToVisit(Cell cell)
             {
-                return cell.GetSubCells(_enclosing.queryShape).GetEnumerator();
+                return cell.GetSubCells(outerInstance.queryShape).GetEnumerator();
             }
 
             /// <summary>
@@ -393,7 +377,7 @@ namespace Lucene.Net.Spatial.Prefix
                                             );
                     thisTerm = termsEnum.Next())
                 {
-                    scanCell = _enclosing.grid.GetCell(thisTerm.Bytes, thisTerm.Offset
+                    scanCell = outerInstance.grid.GetCell(thisTerm.Bytes, thisTerm.Offset
                                                        , thisTerm.Length, scanCell);
                     int termLevel = scanCell.Level;
                     if (termLevel > scanDetailLevel)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/ContainsPrefixTreeFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/ContainsPrefixTreeFilter.cs b/src/Lucene.Net.Spatial/Prefix/ContainsPrefixTreeFilter.cs
index 23fb602..c6c448f 100644
--- a/src/Lucene.Net.Spatial/Prefix/ContainsPrefixTreeFilter.cs
+++ b/src/Lucene.Net.Spatial/Prefix/ContainsPrefixTreeFilter.cs
@@ -16,13 +16,13 @@
  */
 using System;
 using System.Collections.Generic;
-using Lucene.Net.Spatial.Queries;
 using Lucene.Net.Spatial.Util;
 using Spatial4n.Core.Shapes;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
 using Lucene.Net.Spatial.Prefix;
 using Lucene.Net.Spatial.Prefix.Tree;
+using Lucene.Net.Spatial.Query;
 using Lucene.Net.Util;
 
 namespace Lucene.Net.Spatial.Prefix
@@ -59,14 +59,13 @@ namespace Lucene.Net.Spatial.Prefix
             private SpatialPrefixTree grid;
 
             /// <exception cref="System.IO.IOException"></exception>
-            public ContainsVisitor(ContainsPrefixTreeFilter enclosing, AtomicReaderContext context
-                , Bits acceptDocs)
-                : base(enclosing, context, acceptDocs)
+            public ContainsVisitor(ContainsPrefixTreeFilter outerInstance, AtomicReaderContext context, Bits acceptDocs)
+                : base(outerInstance, context, acceptDocs)
             {
-                this.queryShape = enclosing.queryShape;
-                this.detailLevel = enclosing.detailLevel;
-                this.grid = enclosing.grid;
-                this.multiOverlappingIndexedShapes = enclosing.multiOverlappingIndexedShapes;
+                this.queryShape = outerInstance.queryShape;
+                this.detailLevel = outerInstance.detailLevel;
+                this.grid = outerInstance.grid;
+                this.multiOverlappingIndexedShapes = outerInstance.multiOverlappingIndexedShapes;
             }
 
             internal BytesRef termBytes = new BytesRef();
@@ -221,6 +220,11 @@ namespace Lucene.Net.Spatial.Prefix
                 intSet = new SentinelIntSet(size, -1);
             }
 
+            public bool Get(int index)
+            {
+                return intSet.Exists(index);
+            }
+
             public virtual void Set(int index)
             {
                 intSet.Put(index);
@@ -230,14 +234,9 @@ namespace Lucene.Net.Spatial.Prefix
                 }
             }
 
-            /// <summary>Largest docid.</summary>
-            /// <remarks>Largest docid.</remarks>
-            public int Length
+            int Bits.Length()
             {
-                get
-                {
-                    return maxInt;
-                }
+                return maxInt;
             }
 
             /// <summary>Number of docids.</summary>
@@ -248,11 +247,10 @@ namespace Lucene.Net.Spatial.Prefix
             }
 
             /// <summary>NOTE: modifies and returns either "this" or "other"</summary>
-            public virtual ContainsPrefixTreeFilter.SmallDocSet Union(ContainsPrefixTreeFilter.SmallDocSet
-                 other)
+            public virtual SmallDocSet Union(SmallDocSet other)
             {
-                ContainsPrefixTreeFilter.SmallDocSet bigger;
-                ContainsPrefixTreeFilter.SmallDocSet smaller;
+                SmallDocSet bigger;
+                SmallDocSet smaller;
                 if (other.intSet.Size() > this.intSet.Size())
                 {
                     bigger = other;
@@ -275,19 +273,18 @@ namespace Lucene.Net.Spatial.Prefix
                 return bigger;
             }
 
-            /// <exception cref="System.IO.IOException"></exception>
-            public Lucene.Net.Util.Bits Bits
+            public override Bits GetBits()
             {
-                get
-                {
-                    //if the # of docids is super small, return null since iteration is going
-                    // to be faster
-                    return Size() > 4 ? this : null;
-                }
+                //if the # of docids is super small, return null since iteration is going
+                // to be faster
+                return Size() > 4 ? this : null;
             }
 
             private sealed class _DocIdSetIterator_225 : DocIdSetIterator
             {
+                private readonly int size;
+                private readonly int[] docs;
+
                 public _DocIdSetIterator_225(int size, int[] docs)
                 {
                     this.size = size;
@@ -299,9 +296,9 @@ namespace Lucene.Net.Spatial.Prefix
 
                 public override int DocID()
                 {
-                    if (this.idx >= 0 && this.idx < size)
+                    if (idx >= 0 && idx < size)
                     {
-                        return docs[this.idx];
+                        return docs[idx];
                     }
                     else
                     {
@@ -312,11 +309,11 @@ namespace Lucene.Net.Spatial.Prefix
                 /// <exception cref="System.IO.IOException"></exception>
                 public override int NextDoc()
                 {
-                    if (++this.idx < size)
+                    if (++idx < size)
                     {
-                        return docs[this.idx];
+                        return docs[idx];
                     }
-                    return DocIdSetIterator.NO_MORE_DOCS;
+                    return NO_MORE_DOCS;
                 }
 
                 /// <exception cref="System.IO.IOException"></exception>
@@ -324,22 +321,13 @@ namespace Lucene.Net.Spatial.Prefix
                 {
                     //for this small set this is likely faster vs. a binary search
                     // into the sorted array
-                    return this.SlowAdvance(target);
+                    return SlowAdvance(target);
                 }
 
                 public override long Cost()
                 {
                     return size;
                 }
-
-                private readonly int size;
-
-                private readonly int[] docs;
-            }
-            //class SmallDocSet
-            public bool this[int index]
-            {
-                get { return intSet.Exists(index); }
             }
 
             public override DocIdSetIterator GetIterator()
@@ -365,16 +353,6 @@ namespace Lucene.Net.Spatial.Prefix
                 Array.Sort(docs, 0, size);
                 return new _DocIdSetIterator_225(size, docs);
             }
-
-            public bool Get(int index)
-            {
-                throw new NotImplementedException();
-            }
-
-            int Bits.Length()
-            {
-                throw new NotImplementedException();
-            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/IntersectsPrefixTreeFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/IntersectsPrefixTreeFilter.cs b/src/Lucene.Net.Spatial/Prefix/IntersectsPrefixTreeFilter.cs
index f5d8713..4b8f25b 100644
--- a/src/Lucene.Net.Spatial/Prefix/IntersectsPrefixTreeFilter.cs
+++ b/src/Lucene.Net.Spatial/Prefix/IntersectsPrefixTreeFilter.cs
@@ -49,22 +49,20 @@ namespace Lucene.Net.Spatial.Prefix
         /// <exception cref="System.IO.IOException"></exception>
         public override DocIdSet GetDocIdSet(AtomicReaderContext context, Bits acceptDocs)
         {
-            return new _VisitorTemplate_55(this, context, acceptDocs, hasIndexedLeaves).GetDocIdSet
-                ();
+            return new _VisitorTemplate_55(this, context, acceptDocs, hasIndexedLeaves).GetDocIdSet();
         }
 
         #region Nested type: _VisitorTemplate_55
 
         private sealed class _VisitorTemplate_55 : VisitorTemplate
         {
-            private readonly IntersectsPrefixTreeFilter _enclosing;
+            private readonly IntersectsPrefixTreeFilter outerInstance;
             private FixedBitSet results;
 
-            public _VisitorTemplate_55(IntersectsPrefixTreeFilter _enclosing, AtomicReaderContext baseArg1, 
-                Bits baseArg2, bool baseArg3)
-                : base(_enclosing, baseArg1, baseArg2, baseArg3)
+            public _VisitorTemplate_55(IntersectsPrefixTreeFilter outerInstance, AtomicReaderContext context, Bits acceptDocs, bool hasIndexedLeaves)
+                : base(outerInstance, context, acceptDocs, hasIndexedLeaves)
             {
-                this._enclosing = _enclosing;
+                this.outerInstance = outerInstance;
             }
 
             protected internal override void Start()
@@ -80,8 +78,7 @@ namespace Lucene.Net.Spatial.Prefix
             /// <exception cref="System.IO.IOException"></exception>
             protected internal override bool Visit(Cell cell)
             {
-                if (cell.GetShapeRel() == SpatialRelation.WITHIN || cell.Level == _enclosing
-                                                                                      .detailLevel)
+                if (cell.GetShapeRel() == SpatialRelation.WITHIN || cell.Level == outerInstance.detailLevel)
                 {
                     CollectDocs(results);
                     return false;
@@ -98,19 +95,7 @@ namespace Lucene.Net.Spatial.Prefix
             /// <exception cref="System.IO.IOException"></exception>
             protected internal override void VisitScanned(Cell cell)
             {
-                Shape cShape;
-                //if this cell represents a point, use the cell center vs the box
-                // TODO this behavior is debatable; might want to be configurable
-                // (points never have isLeaf())
-                if (cell.Level == _enclosing.grid.MaxLevels && !cell.IsLeaf())
-                {
-                    cShape = cell.GetCenter();
-                }
-                else
-                {
-                    cShape = cell.GetShape();
-                }
-                if (_enclosing.queryShape.Relate(cShape).Intersects())
+                if (outerInstance.queryShape.Relate(cell.GetShape()).Intersects())
                 {
                     CollectDocs(results);
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/PointPrefixTreeFieldCacheProvider.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/PointPrefixTreeFieldCacheProvider.cs b/src/Lucene.Net.Spatial/Prefix/PointPrefixTreeFieldCacheProvider.cs
index 73c57f9..3459cb7 100644
--- a/src/Lucene.Net.Spatial/Prefix/PointPrefixTreeFieldCacheProvider.cs
+++ b/src/Lucene.Net.Spatial/Prefix/PointPrefixTreeFieldCacheProvider.cs
@@ -45,7 +45,6 @@ namespace Lucene.Net.Spatial.Prefix
 
         private Cell scanCell = null;//re-used in readShape to save GC
 
-        //re-used in readShape to save GC
         protected internal override Point ReadShape(BytesRef term)
         {
             scanCell = grid.GetCell(term.Bytes, term.Offset, term.Length, scanCell);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/PrefixTreeStrategy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/PrefixTreeStrategy.cs b/src/Lucene.Net.Spatial/Prefix/PrefixTreeStrategy.cs
index ff83b83..5f7c406 100644
--- a/src/Lucene.Net.Spatial/Prefix/PrefixTreeStrategy.cs
+++ b/src/Lucene.Net.Spatial/Prefix/PrefixTreeStrategy.cs
@@ -26,8 +26,8 @@ using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Documents;
 using Lucene.Net.Index;
 using Lucene.Net.Spatial.Prefix.Tree;
-using Lucene.Net.Spatial.Queries;
 using Lucene.Net.Queries.Function;
+using Lucene.Net.Spatial.Query;
 using Lucene.Net.Spatial.Util;
 using Lucene.Net.Support;
 using Spatial4n.Core.Shapes;
@@ -96,9 +96,7 @@ namespace Lucene.Net.Spatial.Prefix
             new ConcurrentDictionary<string, PointPrefixTreeFieldCacheProvider>();
 
         protected internal readonly bool simplifyIndexedCells;
-
         protected internal int defaultFieldValuesArrayLen = 2;
-
         protected internal double distErrPct = SpatialArgs.DEFAULT_DISTERRPCT;
 
         public PrefixTreeStrategy(SpatialPrefixTree grid, string fieldName, bool simplifyIndexedCells)
@@ -158,8 +156,10 @@ namespace Lucene.Net.Spatial.Prefix
         {
             int detailLevel = grid.GetLevelForDistance(distErr);
             IList<Cell> cells = grid.GetCells(shape, detailLevel, true, simplifyIndexedCells);
+
             //TODO is CellTokenStream supposed to be re-used somehow? see Uwe's comments:
             //  http://code.google.com/p/lucene-spatial-playground/issues/detail?id=4
+
             Field field = new Field(FieldName, new CellTokenStream(cells.GetEnumerator()), FieldType);
             return new Field[] { field };
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/RecursivePrefixTreeStrategy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/RecursivePrefixTreeStrategy.cs b/src/Lucene.Net.Spatial/Prefix/RecursivePrefixTreeStrategy.cs
index 2fcfe01..8740476 100644
--- a/src/Lucene.Net.Spatial/Prefix/RecursivePrefixTreeStrategy.cs
+++ b/src/Lucene.Net.Spatial/Prefix/RecursivePrefixTreeStrategy.cs
@@ -18,7 +18,7 @@
 using Lucene.Net.Queries.Function;
 using Lucene.Net.Search;
 using Lucene.Net.Spatial.Prefix.Tree;
-using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Spatial.Query;
 using Spatial4n.Core.Shapes;
 
 namespace Lucene.Net.Spatial.Prefix
@@ -37,9 +37,8 @@ namespace Lucene.Net.Spatial.Prefix
     /// <lucene.experimental></lucene.experimental>
     public class RecursivePrefixTreeStrategy : PrefixTreeStrategy
     {
-        protected readonly SpatialPrefixTree grid;
         private int prefixGridScanLevel;
-
+        
         /** True if only indexed points shall be supported.  See
         *  {@link IntersectsPrefixTreeFilter#hasIndexedLeaves}. */
         protected bool pointsOnly = false;
@@ -50,7 +49,6 @@ namespace Lucene.Net.Spatial.Prefix
         public RecursivePrefixTreeStrategy(SpatialPrefixTree grid, string fieldName)
             : base(grid, fieldName, true) //simplify indexed cells
         {
-            this.grid = grid;
             prefixGridScanLevel = grid.MaxLevels - 4;//TODO this default constant is dependent on the prefix grid size
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/TermQueryPrefixTreeStrategy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/TermQueryPrefixTreeStrategy.cs b/src/Lucene.Net.Spatial/Prefix/TermQueryPrefixTreeStrategy.cs
index b8753e3..aa67eeb 100644
--- a/src/Lucene.Net.Spatial/Prefix/TermQueryPrefixTreeStrategy.cs
+++ b/src/Lucene.Net.Spatial/Prefix/TermQueryPrefixTreeStrategy.cs
@@ -18,7 +18,7 @@ using System.Collections.Generic;
 using Lucene.Net.Queries;
 using Lucene.Net.Search;
 using Lucene.Net.Spatial.Prefix.Tree;
-using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Spatial.Query;
 using Lucene.Net.Util;
 using Spatial4n.Core.Shapes;
 
@@ -65,7 +65,7 @@ namespace Lucene.Net.Spatial.Prefix
             int i = 0;
             foreach (Cell cell in cells)
             {
-                terms[i++] = new BytesRef(cell.TokenString);
+                terms[i++] = new BytesRef(cell.TokenString);//TODO use cell.getTokenBytes()
             }
             return new TermsFilter(FieldName, terms);
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Prefix/WithinPrefixTreeFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Prefix/WithinPrefixTreeFilter.cs b/src/Lucene.Net.Spatial/Prefix/WithinPrefixTreeFilter.cs
index 07f8f9e..62d5104 100644
--- a/src/Lucene.Net.Spatial/Prefix/WithinPrefixTreeFilter.cs
+++ b/src/Lucene.Net.Spatial/Prefix/WithinPrefixTreeFilter.cs
@@ -20,7 +20,7 @@ using System.Diagnostics;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
 using Lucene.Net.Spatial.Prefix.Tree;
-using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Spatial.Query;
 using Lucene.Net.Util;
 using Spatial4n.Core.Context;
 using Spatial4n.Core.Distance;
@@ -48,7 +48,11 @@ namespace Lucene.Net.Spatial.Prefix
     /// <lucene.experimental></lucene.experimental>
     public class WithinPrefixTreeFilter : AbstractVisitingPrefixTreeFilter
     {
-        private readonly Shape bufferedQueryShape;
+        /// TODO LUCENE-4869: implement faster algorithm based on filtering out false-positives of a
+        //  minimal query buffer by looking in a DocValues cache holding a representative
+        //  point of each disjoint component of a document's shape(s).
+
+        private readonly Shape bufferedQueryShape;//if null then the whole world
 
         /// <summary>
         /// See
@@ -60,16 +64,10 @@ namespace Lucene.Net.Spatial.Prefix
         /// where non-matching documents are looked for so they can be excluded. If
         /// -1 is used then the whole world is examined (a good default for correctness).
         /// </summary>
-        public WithinPrefixTreeFilter(Shape queryShape, string fieldName
-                                      , SpatialPrefixTree grid, int detailLevel, int prefixGridScanLevel,
-                                      double queryBuffer
-            )
+        public WithinPrefixTreeFilter(Shape queryShape, string fieldName, SpatialPrefixTree grid, 
+                                      int detailLevel, int prefixGridScanLevel, double queryBuffer)
             : base(queryShape, fieldName, grid, detailLevel, prefixGridScanLevel)
         {
-            //TODO LUCENE-4869: implement faster algorithm based on filtering out false-positives of a
-            //  minimal query buffer by looking in a DocValues cache holding a representative
-            //  point of each disjoint component of a document's shape(s).
-            //if null then the whole world
             if (queryBuffer == -1)
             {
                 bufferedQueryShape = null;
@@ -80,10 +78,10 @@ namespace Lucene.Net.Spatial.Prefix
             }
         }
 
-        /// <summary>Returns a new shape that is larger than shape by at distErr.</summary>
-        /// <remarks>Returns a new shape that is larger than shape by at distErr.</remarks>
-        protected internal virtual Shape BufferShape(Shape
-                                                         shape, double distErr)
+        /// <summary>
+        /// Returns a new shape that is larger than shape by at distErr
+        /// </summary>
+        protected virtual Shape BufferShape(Shape shape, double distErr)
         {
             //TODO move this generic code elsewhere?  Spatial4j?
             if (distErr <= 0)
@@ -149,8 +147,7 @@ namespace Lucene.Net.Spatial.Prefix
         }
 
         /// <exception cref="System.IO.IOException"></exception>
-        public override DocIdSet GetDocIdSet(AtomicReaderContext context, Bits acceptDocs
-            )
+        public override DocIdSet GetDocIdSet(AtomicReaderContext context, Bits acceptDocs)
         {
             return new _VisitorTemplate_121(this, context, acceptDocs, true).GetDocIdSet();
         }
@@ -159,18 +156,18 @@ namespace Lucene.Net.Spatial.Prefix
 
         private sealed class _VisitorTemplate_121 : VisitorTemplate
         {
-            private readonly WithinPrefixTreeFilter _enclosing;
+            private readonly WithinPrefixTreeFilter outerInstance;
             private FixedBitSet inside;
 
             private FixedBitSet outside;
 
             private SpatialRelation visitRelation;
 
-            public _VisitorTemplate_121(WithinPrefixTreeFilter _enclosing, AtomicReaderContext
-                                                                               baseArg1, Bits baseArg2, bool baseArg3)
-                : base(_enclosing, baseArg1, baseArg2, baseArg3)
+            public _VisitorTemplate_121(WithinPrefixTreeFilter outerInstance, AtomicReaderContext context, 
+                Bits acceptDocs, bool hasIndexedLeaves)
+                : base(outerInstance, context, acceptDocs, hasIndexedLeaves)
             {
-                this._enclosing = _enclosing;
+                this.outerInstance = outerInstance;
             }
 
             protected internal override void Start()
@@ -188,7 +185,7 @@ namespace Lucene.Net.Spatial.Prefix
             protected internal override IEnumerator<Cell> FindSubCellsToVisit(Cell cell)
             {
                 //use buffered query shape instead of orig.  Works with null too.
-                return cell.GetSubCells(_enclosing.bufferedQueryShape).GetEnumerator();
+                return cell.GetSubCells(outerInstance.bufferedQueryShape).GetEnumerator();
             }
 
             /// <exception cref="System.IO.IOException"></exception>
@@ -196,27 +193,21 @@ namespace Lucene.Net.Spatial.Prefix
             {
                 //cell.relate is based on the bufferedQueryShape; we need to examine what
                 // the relation is against the queryShape
-                visitRelation = cell.GetShape().Relate(_enclosing.queryShape);
+                visitRelation = cell.GetShape().Relate(outerInstance.queryShape);
                 if (visitRelation == SpatialRelation.WITHIN)
                 {
                     CollectDocs(inside);
                     return false;
                 }
-                else
+                else if (visitRelation == SpatialRelation.DISJOINT)
                 {
-                    if (visitRelation == SpatialRelation.DISJOINT)
-                    {
-                        CollectDocs(outside);
-                        return false;
-                    }
-                    else
-                    {
-                        if (cell.Level == _enclosing.detailLevel)
-                        {
-                            CollectDocs(inside);
-                            return false;
-                        }
-                    }
+                    CollectDocs(outside);
+                    return false;
+                }
+                else if (cell.Level == outerInstance.detailLevel)
+                {
+                    CollectDocs(inside);
+                    return false;
                 }
                 return true;
             }
@@ -225,8 +216,8 @@ namespace Lucene.Net.Spatial.Prefix
             protected internal override void VisitLeaf(Cell cell)
             {
                 //visitRelation is declared as a field, populated by visit() so we don't recompute it
-                Debug.Assert(_enclosing.detailLevel != cell.Level);
-                Debug.Assert(visitRelation == cell.GetShape().Relate(_enclosing.queryShape));
+                Debug.Assert(outerInstance.detailLevel != cell.Level);
+                Debug.Assert(visitRelation == cell.GetShape().Relate(outerInstance.queryShape));
                 if (AllCellsIntersectQuery(cell, visitRelation))
                 {
                     CollectDocs(inside);
@@ -249,9 +240,9 @@ namespace Lucene.Net.Spatial.Prefix
             {
                 if (relate == SpatialRelation.NULL_VALUE)
                 {
-                    relate = cell.GetShape().Relate(_enclosing.queryShape);
+                    relate = cell.GetShape().Relate(outerInstance.queryShape);
                 }
-                if (cell.Level == _enclosing.detailLevel)
+                if (cell.Level == outerInstance.detailLevel)
                 {
                     return relate.Intersects();
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Queries/SpatialArgs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Queries/SpatialArgs.cs b/src/Lucene.Net.Spatial/Queries/SpatialArgs.cs
deleted file mode 100644
index 0383508..0000000
--- a/src/Lucene.Net.Spatial/Queries/SpatialArgs.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Text;
-using Spatial4n.Core.Context;
-using Spatial4n.Core.Exceptions;
-using Spatial4n.Core.Shapes;
-
-namespace Spatial4n.Core.Exceptions
-{
-    [Serializable]
-    public class InvalidSpatialArgument : ArgumentException
-    {
-        public InvalidSpatialArgument(String reason)
-            : base(reason)
-        {
-        }
-    }
-}
-
-namespace Lucene.Net.Spatial.Queries
-{
-    public class SpatialArgs
-    {
-        public static readonly double DEFAULT_DISTERRPCT = 0.025d;
-
-        public SpatialOperation Operation { get; set; }
-
-        public SpatialArgs(SpatialOperation operation, Shape shape)
-        {
-            if (operation == null || shape == null)
-                throw new ArgumentException("operation and shape are required");
-            this.Operation = operation;
-            this.Shape = shape;
-        }
-
-        /// <summary>
-        /// Computes the distance given a shape and the {@code distErrPct}.  The
-        /// algorithm is the fraction of the distance from the center of the query
-        /// shape to its furthest bounding box corner.
-        /// </summary>
-        /// <param name="shape">Mandatory.</param>
-        /// <param name="distErrPct">0 to 0.5</param>
-        /// <param name="ctx">Mandatory</param>
-        /// <returns>A distance (in degrees).</returns>
-        public static double CalcDistanceFromErrPct(Shape shape, double distErrPct, SpatialContext ctx)
-        {
-            if (distErrPct < 0 || distErrPct > 0.5)
-            {
-                throw new ArgumentException("distErrPct " + distErrPct + " must be between [0 to 0.5]", "distErrPct");
-            }
-            if (distErrPct == 0 || shape is Point)
-            {
-                return 0;
-            }
-            Rectangle bbox = shape.GetBoundingBox();
-            //The diagonal distance should be the same computed from any opposite corner,
-            // and this is the longest distance that might be occurring within the shape.
-            double diagonalDist = ctx.GetDistCalc().Distance(
-                ctx.MakePoint(bbox.GetMinX(), bbox.GetMinY()), bbox.GetMaxX(), bbox.GetMaxY());
-            return diagonalDist * 0.5 * distErrPct;
-        }
-
-        /// <summary>
-        /// Gets the error distance that specifies how precise the query shape is. This
-        /// looks at {@link #getDistErr()}, {@link #getDistErrPct()}, and {@code
-        /// defaultDistErrPct}.
-        /// </summary>
-        /// <param name="ctx"></param>
-        /// <param name="defaultDistErrPct">0 to 0.5</param>
-        /// <returns>>= 0</returns>
-        public double ResolveDistErr(SpatialContext ctx, double defaultDistErrPct)
-        {
-            if (DistErr != null)
-                return DistErr.Value;
-            double? distErrPct = (this.distErrPct ?? defaultDistErrPct);
-            return CalcDistanceFromErrPct(Shape, distErrPct.Value, ctx);
-        }
-
-        /// <summary>
-        /// Check if the arguments make sense -- throw an exception if not
-        /// </summary>
-        public void Validate()
-        {
-            if (Operation.IsTargetNeedsArea() && !Shape.HasArea())
-            {
-                throw new ArgumentException(Operation + " only supports geometry with area");
-            }
-        }
-
-        public override String ToString()
-        {
-            return SpatialArgsParser.WriteSpatialArgs(this);
-        }
-
-        //------------------------------------------------
-        // Getters & Setters
-        //------------------------------------------------
-
-        public Shape Shape { get; set; }
-
-        /// <summary>
-        /// A measure of acceptable error of the shape as a fraction. This effectively
-        /// inflates the size of the shape but should not shrink it.
-        /// <p/>
-        /// The default is {@link #DEFAULT_DIST_PRECISION}
-        /// </summary>
-        /// <returns>0 to 0.5</returns>
-        public double? DistErrPct
-        {
-            get { return distErrPct; }
-            set
-            {
-                if (value != null)
-                    distErrPct = value.Value;
-            }
-        }
-        private double? distErrPct;
-
-        /// <summary>
-        /// The acceptable error of the shape.  This effectively inflates the
-        /// size of the shape but should not shrink it.
-        /// </summary>
-        /// <returns>>= 0</returns>
-        public double? DistErr { get; set; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Queries/SpatialArgsParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Queries/SpatialArgsParser.cs b/src/Lucene.Net.Spatial/Queries/SpatialArgsParser.cs
deleted file mode 100644
index b6faa9f..0000000
--- a/src/Lucene.Net.Spatial/Queries/SpatialArgsParser.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Spatial4n.Core.Context;
-using Spatial4n.Core.Io;
-using Spatial4n.Core.Shapes;
-
-namespace Lucene.Net.Spatial.Queries
-{
-    public class SpatialArgsParser
-    {
-        public const String DIST_ERR_PCT = "distErrPct";
-        public const String DIST_ERR = "distErr";
-
-        /// <summary>
-        /// Writes a close approximation to the parsed input format.
-        /// </summary>
-        /// <param name="args"></param>
-        /// <returns></returns>
-        public static String WriteSpatialArgs(SpatialArgs args)
-        {
-            var str = new StringBuilder();
-            str.Append(args.Operation.Name);
-            str.Append('(');
-            str.Append(args.Shape);
-            if (args.DistErrPct != null)
-                str.Append(" distErrPct=").Append(String.Format("{0:0.00}%", args.DistErrPct * 100d));
-            if (args.DistErr != null)
-                str.Append(" distErr=").Append(args.DistErr);
-            str.Append(')');
-            return str.ToString();
-        }
-
-        /// <summary>
-        /// Parses a string such as "Intersects(-10,20,-8,22) distErrPct=0.025".
-        /// </summary>
-        /// <param name="v"></param>
-        /// <param name="ctx"></param>
-        /// <returns></returns>
-        public SpatialArgs Parse(String v, SpatialContext ctx)
-        {
-            int idx = v.IndexOf('(');
-            int edx = v.LastIndexOf(')');
-
-            if (idx < 0 || idx > edx)
-            {
-                throw new ArgumentException("missing parens: " + v);
-            }
-
-            SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx).Trim());
-
-            //Substring in .NET is (startPosn, length), But in Java it's (startPosn, endPosn)
-            //see http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#substring(int, int)
-            String body = v.Substring(idx + 1, edx - (idx + 1)).Trim();
-            if (body.Length < 1)
-            {
-                throw new ArgumentException("missing body : " + v);
-            }
-
-            var shape = ctx.ReadShape(body);
-            var args = new SpatialArgs(op, shape);
-
-            if (v.Length > (edx + 1))
-            {
-                body = v.Substring(edx + 1).Trim();
-                if (body.Length > 0)
-                {
-                    Dictionary<String, String> aa = ParseMap(body);
-                    args.DistErrPct = ReadDouble(aa["distErrPct"]); aa.Remove(DIST_ERR_PCT);
-                    args.DistErr = ReadDouble(aa["distErr"]); aa.Remove(DIST_ERR);
-                    if (aa.Count != 0)
-                    {
-                        throw new ArgumentException("unused parameters: " + aa);
-                    }
-                }
-            }
-            args.Validate();
-            return args;
-        }
-
-        protected static double? ReadDouble(String v)
-        {
-            double val;
-            return double.TryParse(v, out val) ? val : (double?)null;
-        }
-
-        protected static bool ReadBool(String v, bool defaultValue)
-        {
-            bool ret;
-            return bool.TryParse(v, out ret) ? ret : defaultValue;
-        }
-
-        /// <summary>
-        /// Parses "a=b c=d f" (whitespace separated) into name-value pairs. If there
-        /// is no '=' as in 'f' above then it's short for f=f.
-        /// </summary>
-        /// <param name="body"></param>
-        /// <returns></returns>
-        protected static Dictionary<String, String> ParseMap(String body)
-        {
-            var map = new Dictionary<String, String>();
-            int tokenPos = 0;
-            var st = body.Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
-            while (tokenPos < st.Length)
-            {
-                String a = st[tokenPos++];
-                int idx = a.IndexOf('=');
-                if (idx > 0)
-                {
-                    String k = a.Substring(0, idx);
-                    String v = a.Substring(idx + 1);
-                    map[k] = v;
-                }
-                else
-                {
-                    map[a] = a;
-                }
-            }
-            return map;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Queries/SpatialOperation.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Queries/SpatialOperation.cs b/src/Lucene.Net.Spatial/Queries/SpatialOperation.cs
deleted file mode 100644
index 26f57d3..0000000
--- a/src/Lucene.Net.Spatial/Queries/SpatialOperation.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-\ufeff/* See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * Esri Inc. licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using Spatial4n.Core.Exceptions;
-
-namespace Lucene.Net.Spatial.Queries
-{
-    public class SpatialOperation
-    {
-        // Private registry
-        private static readonly Dictionary<String, SpatialOperation> registry = new Dictionary<string, SpatialOperation>();
-        private static readonly IList<SpatialOperation> list = new List<SpatialOperation>();
-
-        // Geometry Operations
-
-        /// <summary>
-        /// Bounding box of the *indexed* shape.
-        /// </summary>
-        public static readonly SpatialOperation BBoxIntersects = new SpatialOperation("BBoxIntersects", true, false, false);
-
-        /// <summary>
-        /// Bounding box of the *indexed* shape.
-        /// </summary>
-        public static readonly SpatialOperation BBoxWithin = new SpatialOperation("BBoxWithin", true, false, false);
-
-        public static readonly SpatialOperation Contains = new SpatialOperation("Contains", true, true, false);
-        public static readonly SpatialOperation Intersects = new SpatialOperation("Intersects", true, false, false);
-        public static readonly SpatialOperation IsEqualTo = new SpatialOperation("IsEqualTo", false, false, false);
-        public static readonly SpatialOperation IsDisjointTo = new SpatialOperation("IsDisjointTo", false, false, false);
-        public static readonly SpatialOperation IsWithin = new SpatialOperation("IsWithin", true, false, true);
-        public static readonly SpatialOperation Overlaps = new SpatialOperation("Overlaps", true, false, true);
-
-        // Member variables
-        private readonly bool scoreIsMeaningful;
-        private readonly bool sourceNeedsArea;
-        private readonly bool targetNeedsArea;
-        private readonly String name;
-
-        protected SpatialOperation(String name, bool scoreIsMeaningful, bool sourceNeedsArea, bool targetNeedsArea)
-        {
-            this.name = name;
-            this.scoreIsMeaningful = scoreIsMeaningful;
-            this.sourceNeedsArea = sourceNeedsArea;
-            this.targetNeedsArea = targetNeedsArea;
-            registry[name] = this;
-            registry[name.ToUpper(CultureInfo.CreateSpecificCulture("en-US"))] = this;
-            list.Add(this);
-        }
-
-        public static SpatialOperation Get(String v)
-        {
-            SpatialOperation op;
-            if (!registry.TryGetValue(v, out op) || op == null)
-            {
-                if (!registry.TryGetValue(v.ToUpper(CultureInfo.CreateSpecificCulture("en-US")), out op) || op == null)
-                    throw new ArgumentException("Unknown Operation: " + v, "v");
-            }
-            return op;
-        }
-
-        public static IList<SpatialOperation> Values()
-        {
-            return list;
-        }
-
-        public static bool Is(SpatialOperation op, params SpatialOperation[] tst)
-        {
-            return tst.Any(t => op == t);
-        }
-
-
-        // ================================================= Getters / Setters =============================================
-
-        public bool IsScoreIsMeaningful()
-        {
-            return scoreIsMeaningful;
-        }
-
-        public bool IsSourceNeedsArea()
-        {
-            return sourceNeedsArea;
-        }
-
-        public bool IsTargetNeedsArea()
-        {
-            return targetNeedsArea;
-        }
-
-        public String Name
-        {
-            get { return name; }
-        }
-
-        public override String ToString()
-        {
-            return name;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Queries/UnsupportedSpatialOperation.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Queries/UnsupportedSpatialOperation.cs b/src/Lucene.Net.Spatial/Queries/UnsupportedSpatialOperation.cs
deleted file mode 100644
index 35949bc..0000000
--- a/src/Lucene.Net.Spatial/Queries/UnsupportedSpatialOperation.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Lucene.Net.Spatial.Queries
-{
-    [Serializable]
-    public class UnsupportedSpatialOperation : InvalidOperationException
-    {
-        public UnsupportedSpatialOperation(SpatialOperation op)
-            : base(op.Name)
-        {
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Query/SpatialArgs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Query/SpatialArgs.cs b/src/Lucene.Net.Spatial/Query/SpatialArgs.cs
new file mode 100644
index 0000000..11a3114
--- /dev/null
+++ b/src/Lucene.Net.Spatial/Query/SpatialArgs.cs
@@ -0,0 +1,136 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Spatial4n.Core.Context;
+using Spatial4n.Core.Shapes;
+
+namespace Lucene.Net.Spatial.Query
+{
+    public class SpatialArgs
+    {
+        public static readonly double DEFAULT_DISTERRPCT = 0.025d;
+
+        public SpatialOperation Operation { get; set; }
+
+        public SpatialArgs(SpatialOperation operation, Shape shape)
+        {
+            if (operation == null || shape == null)
+                throw new ArgumentException("operation and shape are required");
+            this.Operation = operation;
+            this.Shape = shape;
+        }
+
+        /// <summary>
+        /// Computes the distance given a shape and the {@code distErrPct}.  The
+        /// algorithm is the fraction of the distance from the center of the query
+        /// shape to its furthest bounding box corner.
+        /// </summary>
+        /// <param name="shape">Mandatory.</param>
+        /// <param name="distErrPct">0 to 0.5</param>
+        /// <param name="ctx">Mandatory</param>
+        /// <returns>A distance (in degrees).</returns>
+        public static double CalcDistanceFromErrPct(Shape shape, double distErrPct, SpatialContext ctx)
+        {
+            if (distErrPct < 0 || distErrPct > 0.5)
+            {
+                throw new ArgumentException("distErrPct " + distErrPct + " must be between [0 to 0.5]", "distErrPct");
+            }
+            if (distErrPct == 0 || shape is Point)
+            {
+                return 0;
+            }
+            Rectangle bbox = shape.GetBoundingBox();
+
+            //Compute the distance from the center to a corner.  Because the distance
+            // to a bottom corner vs a top corner can vary in a geospatial scenario,
+            // take the closest one (greater precision).
+            Point ctr = bbox.GetCenter();
+            double y = (ctr.GetY() >= 0 ? bbox.GetMaxY() : bbox.GetMinY());
+            double diagonalDist = ctx.GetDistCalc().Distance(ctr, bbox.GetMaxX(), y);
+            return diagonalDist * distErrPct;
+        }
+
+        /// <summary>
+        /// Gets the error distance that specifies how precise the query shape is. This
+        /// looks at {@link #getDistErr()}, {@link #getDistErrPct()}, and {@code
+        /// defaultDistErrPct}.
+        /// </summary>
+        /// <param name="ctx"></param>
+        /// <param name="defaultDistErrPct">0 to 0.5</param>
+        /// <returns>>= 0</returns>
+        public double ResolveDistErr(SpatialContext ctx, double defaultDistErrPct)
+        {
+            if (DistErr != null)
+                return DistErr.Value;
+            double distErrPct = (this.distErrPct ?? defaultDistErrPct);
+            return CalcDistanceFromErrPct(Shape, distErrPct, ctx);
+        }
+
+        /// <summary>
+        /// Check if the arguments make sense -- throw an exception if not
+        /// </summary>
+        public void Validate()
+        {
+            if (Operation.IsTargetNeedsArea() && !Shape.HasArea())
+            {
+                throw new ArgumentException(Operation + " only supports geometry with area");
+            }
+
+            if (DistErr != null && DistErrPct != null)
+            {
+                throw new ArgumentException("Only DistErr or DistErrPct can be specified.");
+            }
+        }
+
+        public override String ToString()
+        {
+            return SpatialArgsParser.WriteSpatialArgs(this);
+        }
+
+        //------------------------------------------------
+        // Getters & Setters
+        //------------------------------------------------
+
+        public Shape Shape { get; set; }
+
+        /// <summary>
+        /// A measure of acceptable error of the shape as a fraction. This effectively
+        /// inflates the size of the shape but should not shrink it.
+        /// <p/>
+        /// The default is {@link #DEFAULT_DIST_PRECISION}
+        /// </summary>
+        /// <returns>0 to 0.5</returns>
+        public double? DistErrPct
+        {
+            get { return distErrPct; }
+            set
+            {
+                if (value != null)
+                    distErrPct = value.Value;
+            }
+        }
+        private double? distErrPct;
+
+        /// <summary>
+        /// The acceptable error of the shape.  This effectively inflates the
+        /// size of the shape but should not shrink it.
+        /// </summary>
+        /// <returns>>= 0</returns>
+        public double? DistErr { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Query/SpatialArgsParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Query/SpatialArgsParser.cs b/src/Lucene.Net.Spatial/Query/SpatialArgsParser.cs
new file mode 100644
index 0000000..6f0b433
--- /dev/null
+++ b/src/Lucene.Net.Spatial/Query/SpatialArgsParser.cs
@@ -0,0 +1,144 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Lucene.Net.Support;
+using Spatial4n.Core.Context;
+
+namespace Lucene.Net.Spatial.Query
+{
+    public class SpatialArgsParser
+    {
+        public const String DIST_ERR_PCT = "distErrPct";
+        public const String DIST_ERR = "distErr";
+
+        /// <summary>
+        /// Writes a close approximation to the parsed input format.
+        /// </summary>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        public static String WriteSpatialArgs(SpatialArgs args)
+        {
+            var str = new StringBuilder();
+            str.Append(args.Operation.Name);
+            str.Append('(');
+            str.Append(args.Shape);
+            if (args.DistErrPct != null)
+                str.Append(" distErrPct=").Append(String.Format("{0:0.00}%", args.DistErrPct * 100d));
+            if (args.DistErr != null)
+                str.Append(" distErr=").Append(args.DistErr);
+            str.Append(')');
+            return str.ToString();
+        }
+
+        /// <summary>
+        /// Parses a string such as "Intersects(-10,20,-8,22) distErrPct=0.025".
+        /// </summary>
+        /// <param name="v"></param>
+        /// <param name="ctx"></param>
+        /// <returns></returns>
+        public SpatialArgs Parse(String v, SpatialContext ctx)
+        {
+            int idx = v.IndexOf('(');
+            int edx = v.LastIndexOf(')');
+
+            if (idx < 0 || idx > edx)
+            {
+                throw new ArgumentException("missing parens: " + v);
+            }
+
+            SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx).Trim());
+
+            //Substring in .NET is (startPosn, length), But in Java it's (startPosn, endPosn)
+            //see http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#substring(int, int)
+            String body = v.Substring(idx + 1, edx - (idx + 1)).Trim();
+            if (body.Length < 1)
+            {
+                throw new ArgumentException("missing body : " + v);
+            }
+
+            var shape = ctx.ReadShape(body);
+            var args = new SpatialArgs(op, shape);
+
+            if (v.Length > (edx + 1))
+            {
+                body = v.Substring(edx + 1).Trim();
+                if (body.Length > 0)
+                {
+                    Dictionary<String, String> aa = ParseMap(body);
+                    args.DistErrPct = ReadDouble(aa[DIST_ERR_PCT]);
+                    aa.Remove(DIST_ERR_PCT);
+
+                    args.DistErr = ReadDouble(aa[DIST_ERR]);
+                    aa.Remove(DIST_ERR);
+
+                    if (aa.Count != 0)
+                    {
+                        throw new ArgumentException("unused parameters: " + aa);
+                    }
+                }
+            }
+            args.Validate();
+            return args;
+        }
+
+        protected static double? ReadDouble(String v)
+        {
+            double val;
+            return double.TryParse(v, out val) ? val : (double?)null;
+        }
+
+        protected static bool ReadBool(String v, bool defaultValue)
+        {
+            bool ret;
+            return bool.TryParse(v, out ret) ? ret : defaultValue;
+        }
+
+        /// <summary>
+        /// Parses "a=b c=d f" (whitespace separated) into name-value pairs. If there
+        /// is no '=' as in 'f' above then it's short for f=f.
+        /// </summary>
+        /// <param name="body"></param>
+        /// <returns></returns>
+        protected static Dictionary<String, String> ParseMap(String body)
+        {
+            var map = new Dictionary<String, String>();
+            StringTokenizer st = new StringTokenizer(body, " \n\t");
+
+            while (st.HasMoreTokens())
+            {
+                String a = st.NextToken();
+                int idx = a.IndexOf('=');
+                if (idx > 0)
+                {
+                    String k = a.Substring(0, idx);
+                    String v = a.Substring(idx + 1);
+                    map[k] = v;
+                }
+                else
+                {
+                    map[a] = a;
+                }
+            }
+
+            return map;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Query/SpatialOperation.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Query/SpatialOperation.cs b/src/Lucene.Net.Spatial/Query/SpatialOperation.cs
new file mode 100644
index 0000000..16c28a4
--- /dev/null
+++ b/src/Lucene.Net.Spatial/Query/SpatialOperation.cs
@@ -0,0 +1,114 @@
+\ufeff/* See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * Esri Inc. licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+
+namespace Lucene.Net.Spatial.Query
+{
+    public class SpatialOperation
+    {
+        // Private registry
+        private static readonly Dictionary<String, SpatialOperation> registry = new Dictionary<string, SpatialOperation>();
+        private static readonly IList<SpatialOperation> list = new List<SpatialOperation>();
+
+        // Geometry Operations
+
+        /// <summary>
+        /// Bounding box of the *indexed* shape.
+        /// </summary>
+        public static readonly SpatialOperation BBoxIntersects = new SpatialOperation("BBoxIntersects", true, false, false);
+
+        /// <summary>
+        /// Bounding box of the *indexed* shape.
+        /// </summary>
+        public static readonly SpatialOperation BBoxWithin = new SpatialOperation("BBoxWithin", true, false, false);
+
+        public static readonly SpatialOperation Contains = new SpatialOperation("Contains", true, true, false);
+        public static readonly SpatialOperation Intersects = new SpatialOperation("Intersects", true, false, false);
+        public static readonly SpatialOperation IsEqualTo = new SpatialOperation("IsEqualTo", false, false, false);
+        public static readonly SpatialOperation IsDisjointTo = new SpatialOperation("IsDisjointTo", false, false, false);
+        public static readonly SpatialOperation IsWithin = new SpatialOperation("IsWithin", true, false, true);
+        public static readonly SpatialOperation Overlaps = new SpatialOperation("Overlaps", true, false, true);
+
+        // Member variables
+        private readonly bool scoreIsMeaningful;
+        private readonly bool sourceNeedsArea;
+        private readonly bool targetNeedsArea;
+        private readonly String name;
+
+        protected SpatialOperation(String name, bool scoreIsMeaningful, bool sourceNeedsArea, bool targetNeedsArea)
+        {
+            this.name = name;
+            this.scoreIsMeaningful = scoreIsMeaningful;
+            this.sourceNeedsArea = sourceNeedsArea;
+            this.targetNeedsArea = targetNeedsArea;
+            registry[name] = this;
+            registry[name.ToUpper(CultureInfo.CreateSpecificCulture("en-US"))] = this;
+            list.Add(this);
+        }
+
+        public static SpatialOperation Get(String v)
+        {
+            SpatialOperation op;
+            if (!registry.TryGetValue(v, out op) || op == null)
+            {
+                if (!registry.TryGetValue(v.ToUpper(CultureInfo.CreateSpecificCulture("en-US")), out op) || op == null)
+                    throw new ArgumentException("Unknown Operation: " + v, "v");
+            }
+            return op;
+        }
+
+        public static IList<SpatialOperation> Values()
+        {
+            return list;
+        }
+
+        public static bool Is(SpatialOperation op, params SpatialOperation[] tst)
+        {
+            return tst.Any(t => op == t);
+        }
+
+        // ================================================= Getters / Setters =============================================
+
+        public bool IsScoreIsMeaningful()
+        {
+            return scoreIsMeaningful;
+        }
+
+        public bool IsSourceNeedsArea()
+        {
+            return sourceNeedsArea;
+        }
+
+        public bool IsTargetNeedsArea()
+        {
+            return targetNeedsArea;
+        }
+
+        public String Name
+        {
+            get { return name; }
+        }
+
+        public override String ToString()
+        {
+            return name;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Query/UnsupportedSpatialOperation.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Query/UnsupportedSpatialOperation.cs b/src/Lucene.Net.Spatial/Query/UnsupportedSpatialOperation.cs
new file mode 100644
index 0000000..92ae852
--- /dev/null
+++ b/src/Lucene.Net.Spatial/Query/UnsupportedSpatialOperation.cs
@@ -0,0 +1,30 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Spatial.Query
+{
+    [Serializable]
+    public class UnsupportedSpatialOperation : InvalidOperationException
+    {
+        public UnsupportedSpatialOperation(SpatialOperation op)
+            : base(op.Name)
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Serialized/SerializedDVStrategy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Serialized/SerializedDVStrategy.cs b/src/Lucene.Net.Spatial/Serialized/SerializedDVStrategy.cs
new file mode 100644
index 0000000..d79c02c
--- /dev/null
+++ b/src/Lucene.Net.Spatial/Serialized/SerializedDVStrategy.cs
@@ -0,0 +1,69 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Lucene.Net.Documents;
+using Lucene.Net.Queries.Function;
+using Lucene.Net.Search;
+using Lucene.Net.Spatial;
+using Lucene.Net.Spatial.Query;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using Spatial4n.Core.Context;
+using Spatial4n.Core.Shapes;
+
+namespace Lucene.Net.Spatial.Serialized
+{
+    /// <summary>
+    /// A SpatialStrategy based on serializing a Shape stored into BinaryDocValues.
+    /// This is not at all fast; it's designed to be used in conjuction with another index based
+    /// SpatialStrategy that is approximated(like { @link org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy})
+    /// to add precision or eventually make more specific / advanced calculations on the per-document
+    /// geometry.
+    /// The serialization uses Spatial4j's {@link com.spatial4j.core.io.BinaryCodec}.
+    ///
+    /// @lucene.experimental
+    /// </summary>
+    public class SerializedDVStrategy : SpatialStrategy
+    {
+        public SerializedDVStrategy(SpatialContext ctx, string fieldName) : base(ctx, fieldName)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override Field[] CreateIndexableFields(Shape shape)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override ValueSource MakeDistanceValueSource(Point queryPoint, double multiplier)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override Filter MakeFilter(SpatialArgs args)
+        {
+            throw new NotImplementedException();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/SpatialStrategy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/SpatialStrategy.cs b/src/Lucene.Net.Spatial/SpatialStrategy.cs
index 2fb8689..76f827f 100644
--- a/src/Lucene.Net.Spatial/SpatialStrategy.cs
+++ b/src/Lucene.Net.Spatial/SpatialStrategy.cs
@@ -20,7 +20,7 @@ using Lucene.Net.Documents;
 using Lucene.Net.Queries.Function;
 using Lucene.Net.Queries.Function.ValueSources;
 using Lucene.Net.Search;
-using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Spatial.Query;
 using Spatial4n.Core.Context;
 using Spatial4n.Core.Shapes;
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e566a89/src/Lucene.Net.Spatial/Vector/PointVectorStrategy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Spatial/Vector/PointVectorStrategy.cs b/src/Lucene.Net.Spatial/Vector/PointVectorStrategy.cs
index aec23a0..213e95c 100644
--- a/src/Lucene.Net.Spatial/Vector/PointVectorStrategy.cs
+++ b/src/Lucene.Net.Spatial/Vector/PointVectorStrategy.cs
@@ -19,7 +19,7 @@ using System;
 using Lucene.Net.Documents;
 using Lucene.Net.Queries.Function;
 using Lucene.Net.Search;
-using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Spatial.Query;
 using Lucene.Net.Spatial.Util;
 using Spatial4n.Core.Context;
 using Spatial4n.Core.Shapes;