You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2013/04/03 19:40:15 UTC

[32/51] [partial] Mass convert mixed tabs to spaces

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Prefix/Tree/QuadPrefixTree.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Prefix/Tree/QuadPrefixTree.cs b/src/contrib/Spatial/Prefix/Tree/QuadPrefixTree.cs
index d038fde..230fd4a 100644
--- a/src/contrib/Spatial/Prefix/Tree/QuadPrefixTree.cs
+++ b/src/contrib/Spatial/Prefix/Tree/QuadPrefixTree.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -28,296 +28,296 @@ namespace Lucene.Net.Spatial.Prefix.Tree
     /// Implementation of {@link SpatialPrefixTree} which uses a quad tree
     /// (http://en.wikipedia.org/wiki/Quadtree)
     /// </summary>
-	public class QuadPrefixTree : SpatialPrefixTree
-	{
+    public class QuadPrefixTree : SpatialPrefixTree
+    {
         /// <summary>
         /// Factory for creating {@link QuadPrefixTree} instances with useful defaults
         /// </summary>
-		public class Factory : SpatialPrefixTreeFactory
-		{
-			protected override int GetLevelForDistance(double degrees)
-			{
-				var grid = new QuadPrefixTree(ctx, MAX_LEVELS_POSSIBLE);
-				return grid.GetLevelForDistance(degrees);
-			}
-
-			protected override SpatialPrefixTree NewSPT()
-			{
-				return new QuadPrefixTree(ctx, maxLevels != null ? maxLevels.Value : MAX_LEVELS_POSSIBLE);
-			}
-		}
-
-		public static readonly int MAX_LEVELS_POSSIBLE = 50;//not really sure how big this should be
-
-		public static readonly int DEFAULT_MAX_LEVELS = 12;
-		private double xmin;
-		private double xmax;
-		private double ymin;
-		private double ymax;
-		private double xmid;
-		private double ymid;
-
-		private double gridW;
-		private double gridH;
-
-		double[] levelW;
-		double[] levelH;
-		int[] levelS; // side
-		int[] levelN; // number
-
-		public QuadPrefixTree(SpatialContext ctx, Rectangle bounds, int maxLevels)
-			: base(ctx, maxLevels)
-		{
-			Init(ctx, bounds, maxLevels);
-		}
-
-		public QuadPrefixTree(SpatialContext ctx)
-			: base(ctx, DEFAULT_MAX_LEVELS)
-		{
-			Init(ctx, ctx.GetWorldBounds(), DEFAULT_MAX_LEVELS);
-		}
-
-		public QuadPrefixTree(SpatialContext ctx, int maxLevels)
-			: base(ctx, maxLevels)
-		{
-			Init(ctx, ctx.GetWorldBounds(), maxLevels);
-		}
-
-		protected void Init(SpatialContext ctx, Rectangle bounds, int maxLevels)
-		{
-			this.xmin = bounds.GetMinX();
-			this.xmax = bounds.GetMaxX();
-			this.ymin = bounds.GetMinY();
-			this.ymax = bounds.GetMaxY();
-
-			levelW = new double[maxLevels];
-			levelH = new double[maxLevels];
-			levelS = new int[maxLevels];
-			levelN = new int[maxLevels];
-
-			gridW = xmax - xmin;
-			gridH = ymax - ymin;
-			xmid = xmin + gridW / 2.0;
-			ymid = ymin + gridH / 2.0;
-			levelW[0] = gridW / 2.0;
-			levelH[0] = gridH / 2.0;
-			levelS[0] = 2;
-			levelN[0] = 4;
-
-			for (int i = 1; i < levelW.Length; i++)
-			{
-				levelW[i] = levelW[i - 1] / 2.0;
-				levelH[i] = levelH[i - 1] / 2.0;
-				levelS[i] = levelS[i - 1] * 2;
-				levelN[i] = levelN[i - 1] * 4;
-			}
-
-		}
-
-		public override int GetLevelForDistance(double dist)
-		{
+        public class Factory : SpatialPrefixTreeFactory
+        {
+            protected override int GetLevelForDistance(double degrees)
+            {
+                var grid = new QuadPrefixTree(ctx, MAX_LEVELS_POSSIBLE);
+                return grid.GetLevelForDistance(degrees);
+            }
+
+            protected override SpatialPrefixTree NewSPT()
+            {
+                return new QuadPrefixTree(ctx, maxLevels != null ? maxLevels.Value : MAX_LEVELS_POSSIBLE);
+            }
+        }
+
+        public static readonly int MAX_LEVELS_POSSIBLE = 50;//not really sure how big this should be
+
+        public static readonly int DEFAULT_MAX_LEVELS = 12;
+        private double xmin;
+        private double xmax;
+        private double ymin;
+        private double ymax;
+        private double xmid;
+        private double ymid;
+
+        private double gridW;
+        private double gridH;
+
+        double[] levelW;
+        double[] levelH;
+        int[] levelS; // side
+        int[] levelN; // number
+
+        public QuadPrefixTree(SpatialContext ctx, Rectangle bounds, int maxLevels)
+            : base(ctx, maxLevels)
+        {
+            Init(ctx, bounds, maxLevels);
+        }
+
+        public QuadPrefixTree(SpatialContext ctx)
+            : base(ctx, DEFAULT_MAX_LEVELS)
+        {
+            Init(ctx, ctx.GetWorldBounds(), DEFAULT_MAX_LEVELS);
+        }
+
+        public QuadPrefixTree(SpatialContext ctx, int maxLevels)
+            : base(ctx, maxLevels)
+        {
+            Init(ctx, ctx.GetWorldBounds(), maxLevels);
+        }
+
+        protected void Init(SpatialContext ctx, Rectangle bounds, int maxLevels)
+        {
+            this.xmin = bounds.GetMinX();
+            this.xmax = bounds.GetMaxX();
+            this.ymin = bounds.GetMinY();
+            this.ymax = bounds.GetMaxY();
+
+            levelW = new double[maxLevels];
+            levelH = new double[maxLevels];
+            levelS = new int[maxLevels];
+            levelN = new int[maxLevels];
+
+            gridW = xmax - xmin;
+            gridH = ymax - ymin;
+            xmid = xmin + gridW / 2.0;
+            ymid = ymin + gridH / 2.0;
+            levelW[0] = gridW / 2.0;
+            levelH[0] = gridH / 2.0;
+            levelS[0] = 2;
+            levelN[0] = 4;
+
+            for (int i = 1; i < levelW.Length; i++)
+            {
+                levelW[i] = levelW[i - 1] / 2.0;
+                levelH[i] = levelH[i - 1] / 2.0;
+                levelS[i] = levelS[i - 1] * 2;
+                levelN[i] = levelN[i - 1] * 4;
+            }
+
+        }
+
+        public override int GetLevelForDistance(double dist)
+        {
             if (dist == 0)//short circuit
                 return maxLevels;
             for (int i = 0; i < maxLevels - 1; i++)
-			{
-				//note: level[i] is actually a lookup for level i+1
+            {
+                //note: level[i] is actually a lookup for level i+1
                 if (dist > levelW[i] && dist > levelH[i])
-				{
-					return i + 1;
-				}
-			}
-			return maxLevels;
-		}
-
-		protected override Node GetNode(Point p, int level)
-		{
-			var cells = new List<Node>(1);
+                {
+                    return i + 1;
+                }
+            }
+            return maxLevels;
+        }
+
+        protected override Node GetNode(Point p, int level)
+        {
+            var cells = new List<Node>(1);
             Build(xmid, ymid, 0, cells, new StringBuilder(), ctx.MakePoint(p.GetX(), p.GetY()), level);
-			return cells[0];//note cells could be longer if p on edge
-		}
-
-		public override Node GetNode(string token)
-		{
-			return new QuadCell(token, this);
-		}
-
-		public override Node GetNode(byte[] bytes, int offset, int len)
-		{
-			throw new System.NotImplementedException();
-		}
-
-		public override IList<Node> GetNodes(Shape shape, int detailLevel, bool inclParents)
-		{
-			var point = shape as Point;
-			if (point != null)
-				return base.GetNodesAltPoint(point, detailLevel, inclParents);
-			else
-				return base.GetNodes(shape, detailLevel, inclParents);
-		}
-
-		private void Build(double x, double y, int level, List<Node> matches, StringBuilder str, Shape shape, int maxLevel)
-		{
-			Debug.Assert(str.Length == level);
-			double w = levelW[level] / 2;
-			double h = levelH[level] / 2;
-
-			// Z-Order
-			// http://en.wikipedia.org/wiki/Z-order_%28curve%29
-			CheckBattenberg('A', x - w, y + h, level, matches, str, shape, maxLevel);
-			CheckBattenberg('B', x + w, y + h, level, matches, str, shape, maxLevel);
-			CheckBattenberg('C', x - w, y - h, level, matches, str, shape, maxLevel);
-			CheckBattenberg('D', x + w, y - h, level, matches, str, shape, maxLevel);
-
-			// possibly consider hilbert curve
-			// http://en.wikipedia.org/wiki/Hilbert_curve
-			// http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves
-			// if we actually use the range property in the query, this could be useful
-		}
-
-		private void CheckBattenberg(
-			char c,
-			double cx,
-			double cy,
-			int level,
-			List<Node> matches,
-			StringBuilder str,
-			Shape shape,
-			int maxLevel)
-		{
-			Debug.Assert(str.Length == level);
-			double w = levelW[level] / 2;
-			double h = levelH[level] / 2;
-
-			int strlen = str.Length;
+            return cells[0];//note cells could be longer if p on edge
+        }
+
+        public override Node GetNode(string token)
+        {
+            return new QuadCell(token, this);
+        }
+
+        public override Node GetNode(byte[] bytes, int offset, int len)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public override IList<Node> GetNodes(Shape shape, int detailLevel, bool inclParents)
+        {
+            var point = shape as Point;
+            if (point != null)
+                return base.GetNodesAltPoint(point, detailLevel, inclParents);
+            else
+                return base.GetNodes(shape, detailLevel, inclParents);
+        }
+
+        private void Build(double x, double y, int level, List<Node> matches, StringBuilder str, Shape shape, int maxLevel)
+        {
+            Debug.Assert(str.Length == level);
+            double w = levelW[level] / 2;
+            double h = levelH[level] / 2;
+
+            // Z-Order
+            // http://en.wikipedia.org/wiki/Z-order_%28curve%29
+            CheckBattenberg('A', x - w, y + h, level, matches, str, shape, maxLevel);
+            CheckBattenberg('B', x + w, y + h, level, matches, str, shape, maxLevel);
+            CheckBattenberg('C', x - w, y - h, level, matches, str, shape, maxLevel);
+            CheckBattenberg('D', x + w, y - h, level, matches, str, shape, maxLevel);
+
+            // possibly consider hilbert curve
+            // http://en.wikipedia.org/wiki/Hilbert_curve
+            // http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves
+            // if we actually use the range property in the query, this could be useful
+        }
+
+        private void CheckBattenberg(
+            char c,
+            double cx,
+            double cy,
+            int level,
+            List<Node> matches,
+            StringBuilder str,
+            Shape shape,
+            int maxLevel)
+        {
+            Debug.Assert(str.Length == level);
+            double w = levelW[level] / 2;
+            double h = levelH[level] / 2;
+
+            int strlen = str.Length;
             Rectangle rectangle = ctx.MakeRectangle(cx - w, cx + w, cy - h, cy + h);
             SpatialRelation v = shape.Relate(rectangle);
-			if (SpatialRelation.CONTAINS == v)
-			{
-				str.Append(c);
-				//str.append(SpatialPrefixGrid.COVER);
-				matches.Add(new QuadCell(str.ToString(), v.Transpose(), this));
-			}
-			else if (SpatialRelation.DISJOINT == v)
-			{
-				// nothing
-			}
-			else
-			{ // SpatialRelation.WITHIN, SpatialRelation.INTERSECTS
-				str.Append(c);
-
-				int nextLevel = level + 1;
-				if (nextLevel >= maxLevel)
-				{
-					//str.append(SpatialPrefixGrid.INTERSECTS);
-					matches.Add(new QuadCell(str.ToString(), v.Transpose(), this));
-				}
-				else
-				{
-					Build(cx, cy, nextLevel, matches, str, shape, maxLevel);
-				}
-			}
-			str.Length = strlen;
-		}
-
-		public class QuadCell : Node
-		{
-
-			public QuadCell(String token, QuadPrefixTree enclosingInstance)
-				: base(enclosingInstance, token)
-			{
-			}
-
-			public QuadCell(String token, SpatialRelation shapeRel, QuadPrefixTree enclosingInstance)
-				: base(enclosingInstance, token)
-			{
-				this.shapeRel = shapeRel;
-			}
-
-			public override void Reset(string newToken)
-			{
-				base.Reset(newToken);
-				shape = null;
-			}
-
-			public override IList<Node> GetSubCells()
-			{
-				var tree = (QuadPrefixTree)spatialPrefixTree;
-				var cells = new List<Node>(4)
-                  	{
-                  		new QuadCell(GetTokenString() + "A", tree),
-                  		new QuadCell(GetTokenString() + "B", tree),
-                  		new QuadCell(GetTokenString() + "C", tree),
-                  		new QuadCell(GetTokenString() + "D", tree)
-                  	};
-				return cells;
-			}
-
-			public override int GetSubCellsSize()
-			{
-				return 4;
-			}
-
-			public override Node GetSubCell(Point p)
-			{
-				return ((QuadPrefixTree)spatialPrefixTree).GetNode(p, GetLevel() + 1); //not performant!
-			}
-
-			private Shape shape;//cache
-
-			public override Shape GetShape()
-			{
-				if (shape == null)
-					shape = MakeShape();
-				return shape;
-			}
-
-			private Rectangle MakeShape()
-			{
-				String token = GetTokenString();
-				var tree = ((QuadPrefixTree)spatialPrefixTree);
-				double xmin = tree.xmin;
-				double ymin = tree.ymin;
-
-				for (int i = 0; i < token.Length; i++)
-				{
-					char c = token[i];
-					if ('A' == c || 'a' == c)
-					{
-						ymin += tree.levelH[i];
-					}
-					else if ('B' == c || 'b' == c)
-					{
-						xmin += tree.levelW[i];
-						ymin += tree.levelH[i];
-					}
-					else if ('C' == c || 'c' == c)
-					{
-						// nothing really
-					}
-					else if ('D' == c || 'd' == c)
-					{
-						xmin += tree.levelW[i];
-					}
-					else
-					{
-						throw new Exception("unexpected char: " + c);
-					}
-				}
-				int len = token.Length;
-				double width, height;
-				if (len > 0)
-				{
-					width = tree.levelW[len - 1];
-					height = tree.levelH[len - 1];
-				}
-				else
-				{
-					width = tree.gridW;
-					height = tree.gridH;
-				}
+            if (SpatialRelation.CONTAINS == v)
+            {
+                str.Append(c);
+                //str.append(SpatialPrefixGrid.COVER);
+                matches.Add(new QuadCell(str.ToString(), v.Transpose(), this));
+            }
+            else if (SpatialRelation.DISJOINT == v)
+            {
+                // nothing
+            }
+            else
+            { // SpatialRelation.WITHIN, SpatialRelation.INTERSECTS
+                str.Append(c);
+
+                int nextLevel = level + 1;
+                if (nextLevel >= maxLevel)
+                {
+                    //str.append(SpatialPrefixGrid.INTERSECTS);
+                    matches.Add(new QuadCell(str.ToString(), v.Transpose(), this));
+                }
+                else
+                {
+                    Build(cx, cy, nextLevel, matches, str, shape, maxLevel);
+                }
+            }
+            str.Length = strlen;
+        }
+
+        public class QuadCell : Node
+        {
+
+            public QuadCell(String token, QuadPrefixTree enclosingInstance)
+                : base(enclosingInstance, token)
+            {
+            }
+
+            public QuadCell(String token, SpatialRelation shapeRel, QuadPrefixTree enclosingInstance)
+                : base(enclosingInstance, token)
+            {
+                this.shapeRel = shapeRel;
+            }
+
+            public override void Reset(string newToken)
+            {
+                base.Reset(newToken);
+                shape = null;
+            }
+
+            public override IList<Node> GetSubCells()
+            {
+                var tree = (QuadPrefixTree)spatialPrefixTree;
+                var cells = new List<Node>(4)
+                      {
+                          new QuadCell(GetTokenString() + "A", tree),
+                          new QuadCell(GetTokenString() + "B", tree),
+                          new QuadCell(GetTokenString() + "C", tree),
+                          new QuadCell(GetTokenString() + "D", tree)
+                      };
+                return cells;
+            }
+
+            public override int GetSubCellsSize()
+            {
+                return 4;
+            }
+
+            public override Node GetSubCell(Point p)
+            {
+                return ((QuadPrefixTree)spatialPrefixTree).GetNode(p, GetLevel() + 1); //not performant!
+            }
+
+            private Shape shape;//cache
+
+            public override Shape GetShape()
+            {
+                if (shape == null)
+                    shape = MakeShape();
+                return shape;
+            }
+
+            private Rectangle MakeShape()
+            {
+                String token = GetTokenString();
+                var tree = ((QuadPrefixTree)spatialPrefixTree);
+                double xmin = tree.xmin;
+                double ymin = tree.ymin;
+
+                for (int i = 0; i < token.Length; i++)
+                {
+                    char c = token[i];
+                    if ('A' == c || 'a' == c)
+                    {
+                        ymin += tree.levelH[i];
+                    }
+                    else if ('B' == c || 'b' == c)
+                    {
+                        xmin += tree.levelW[i];
+                        ymin += tree.levelH[i];
+                    }
+                    else if ('C' == c || 'c' == c)
+                    {
+                        // nothing really
+                    }
+                    else if ('D' == c || 'd' == c)
+                    {
+                        xmin += tree.levelW[i];
+                    }
+                    else
+                    {
+                        throw new Exception("unexpected char: " + c);
+                    }
+                }
+                int len = token.Length;
+                double width, height;
+                if (len > 0)
+                {
+                    width = tree.levelW[len - 1];
+                    height = tree.levelH[len - 1];
+                }
+                else
+                {
+                    width = tree.gridW;
+                    height = tree.gridH;
+                }
                 return spatialPrefixTree.ctx.MakeRectangle(xmin, xmin + width, ymin, ymin + height);
-			}
-		}//QuadCell
+            }
+        }//QuadCell
 
-	}
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTree.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTree.cs b/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTree.cs
index d539b1a..908fded 100644
--- a/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTree.cs
+++ b/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTree.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -26,251 +26,251 @@ using Spatial4n.Core.Shapes;
 
 namespace Lucene.Net.Spatial.Prefix.Tree
 {
-	/// <summary>
+    /// <summary>
     /// A spatial Prefix Tree, or Trie, which decomposes shapes into prefixed strings at variable lengths corresponding to
-	/// variable precision.  Each string corresponds to a spatial region.
-	/// 
-	/// Implementations of this class should be thread-safe and immutable once initialized. 
-	/// </summary>
-	public abstract class SpatialPrefixTree
-	{
-		protected readonly int maxLevels;
-		internal readonly SpatialContext ctx;// it's internal to allow Node to access it
+    /// variable precision.  Each string corresponds to a spatial region.
+    /// 
+    /// Implementations of this class should be thread-safe and immutable once initialized. 
+    /// </summary>
+    public abstract class SpatialPrefixTree
+    {
+        protected readonly int maxLevels;
+        internal readonly SpatialContext ctx;// it's internal to allow Node to access it
 
-		protected SpatialPrefixTree(SpatialContext ctx, int maxLevels)
-		{
-			Debug.Assert(maxLevels > 0);
-			this.ctx = ctx;
-			this.maxLevels = maxLevels;
-		}
+        protected SpatialPrefixTree(SpatialContext ctx, int maxLevels)
+        {
+            Debug.Assert(maxLevels > 0);
+            this.ctx = ctx;
+            this.maxLevels = maxLevels;
+        }
 
-		public SpatialContext GetSpatialContext()
-		{
-			return ctx;
-		}
+        public SpatialContext GetSpatialContext()
+        {
+            return ctx;
+        }
 
-		public int GetMaxLevels()
-		{
-			return maxLevels;
-		}
+        public int GetMaxLevels()
+        {
+            return maxLevels;
+        }
 
-		public override String ToString()
-		{
-			return GetType().Name + "(maxLevels:" + maxLevels + ",ctx:" + ctx + ")";
-		}
+        public override String ToString()
+        {
+            return GetType().Name + "(maxLevels:" + maxLevels + ",ctx:" + ctx + ")";
+        }
 
-	    /// <summary>
-	    /// Returns the level of the largest grid in which its longest side is less
-	    /// than or equal to the provided distance (in degrees). Consequently {@link
-	    /// dist} acts as an error epsilon declaring the amount of detail needed in the
-	    /// grid, such that you can get a grid with just the right amount of
-	    /// precision.
-	    /// </summary>
+        /// <summary>
+        /// Returns the level of the largest grid in which its longest side is less
+        /// than or equal to the provided distance (in degrees). Consequently {@link
+        /// dist} acts as an error epsilon declaring the amount of detail needed in the
+        /// grid, such that you can get a grid with just the right amount of
+        /// precision.
+        /// </summary>
         /// <param name="dist">>= 0</param>
         /// <returns>level [1 to maxLevels]</returns>
-		public abstract int GetLevelForDistance(double dist);
+        public abstract int GetLevelForDistance(double dist);
 
-		//TODO double getDistanceForLevel(int level)
+        //TODO double getDistanceForLevel(int level)
 
-		//[NotSerialized]
-		private Node worldNode;//cached
+        //[NotSerialized]
+        private Node worldNode;//cached
 
-		/*
-		 * Returns the level 0 cell which encompasses all spatial data. Equivalent to {@link #getNode(String)} with "".
-		 * This cell is threadsafe, just like a spatial prefix grid is, although cells aren't
-		 * generally threadsafe.
-		 * TODO rename to getTopCell or is this fine?
-		 */
-		public Node GetWorldNode()
-		{
-			if (worldNode == null)
-			{
-				worldNode = GetNode("");
-			}
-			return worldNode;
-		}
+        /*
+         * Returns the level 0 cell which encompasses all spatial data. Equivalent to {@link #getNode(String)} with "".
+         * This cell is threadsafe, just like a spatial prefix grid is, although cells aren't
+         * generally threadsafe.
+         * TODO rename to getTopCell or is this fine?
+         */
+        public Node GetWorldNode()
+        {
+            if (worldNode == null)
+            {
+                worldNode = GetNode("");
+            }
+            return worldNode;
+        }
 
-		/*
-		 * The cell for the specified token. The empty string should be equal to {@link #getWorldNode()}.
-		 * Precondition: Never called when token length > maxLevel.
-		 */
-		public abstract Node GetNode(String token);
+        /*
+         * The cell for the specified token. The empty string should be equal to {@link #getWorldNode()}.
+         * Precondition: Never called when token length > maxLevel.
+         */
+        public abstract Node GetNode(String token);
 
-		public abstract Node GetNode(byte[] bytes, int offset, int len);
+        public abstract Node GetNode(byte[] bytes, int offset, int len);
 
-		//public Node GetNode(byte[] bytes, int offset, int len, Node target)
-		//{
-		//    if (target == null)
-		//    {
-		//        return GetNode(bytes, offset, len);
-		//    }
+        //public Node GetNode(byte[] bytes, int offset, int len, Node target)
+        //{
+        //    if (target == null)
+        //    {
+        //        return GetNode(bytes, offset, len);
+        //    }
 
-		//    target.Reset(bytes, offset, len);
-		//    return target;
-		//}
+        //    target.Reset(bytes, offset, len);
+        //    return target;
+        //}
 
-		public Node GetNode(string token, Node target)
-		{
-			if (target == null)
-			{
-				return GetNode(token);
-			}
+        public Node GetNode(string token, Node target)
+        {
+            if (target == null)
+            {
+                return GetNode(token);
+            }
 
-			target.Reset(token);
-			return target;
-		}
+            target.Reset(token);
+            return target;
+        }
 
-		protected virtual Node GetNode(Point p, int level)
-		{
-			return GetNodes(p, level, false).ElementAt(0);
-		}
+        protected virtual Node GetNode(Point p, int level)
+        {
+            return GetNodes(p, level, false).ElementAt(0);
+        }
 
-		/*
-		 * Gets the intersecting & including cells for the specified shape, without exceeding detail level.
-		 * The result is a set of cells (no dups), sorted. Unmodifiable.
-		 * <p/>
-		 * This implementation checks if shape is a Point and if so uses an implementation that
-		 * recursively calls {@link Node#getSubCell(com.spatial4j.core.shape.Point)}. Cell subclasses
-		 * ideally implement that method with a quick implementation, otherwise, subclasses should
-		 * override this method to invoke {@link #getNodesAltPoint(com.spatial4j.core.shape.Point, int, boolean)}.
-		 * TODO consider another approach returning an iterator -- won't build up all cells in memory.
-		 */
-		public virtual IList<Node> GetNodes(Shape shape, int detailLevel, bool inclParents)
-		{
-			if (detailLevel > maxLevels)
-			{
-				throw new ArgumentException("detailLevel > maxLevels", "detailLevel");
-			}
+        /*
+         * Gets the intersecting & including cells for the specified shape, without exceeding detail level.
+         * The result is a set of cells (no dups), sorted. Unmodifiable.
+         * <p/>
+         * This implementation checks if shape is a Point and if so uses an implementation that
+         * recursively calls {@link Node#getSubCell(com.spatial4j.core.shape.Point)}. Cell subclasses
+         * ideally implement that method with a quick implementation, otherwise, subclasses should
+         * override this method to invoke {@link #getNodesAltPoint(com.spatial4j.core.shape.Point, int, boolean)}.
+         * TODO consider another approach returning an iterator -- won't build up all cells in memory.
+         */
+        public virtual IList<Node> GetNodes(Shape shape, int detailLevel, bool inclParents)
+        {
+            if (detailLevel > maxLevels)
+            {
+                throw new ArgumentException("detailLevel > maxLevels", "detailLevel");
+            }
 
-			List<Node> cells;
-			if (shape is Point)
-			{
-				//optimized point algorithm
-				int initialCapacity = inclParents ? 1 + detailLevel : 1;
-				cells = new List<Node>(initialCapacity);
-				RecursiveGetNodes(GetWorldNode(), (Point)shape, detailLevel, true, cells);
-				Debug.Assert(cells.Count == initialCapacity);
-			}
-			else
-			{
-				cells = new List<Node>(inclParents ? 1024 : 512);
-				RecursiveGetNodes(GetWorldNode(), shape, detailLevel, inclParents, cells);
-			}
-			if (inclParents)
-			{
-				Debug.Assert(cells[0].GetLevel() == 0);
-				cells.RemoveAt(0);//remove getWorldNode()
-			}
-			return cells;
-		}
+            List<Node> cells;
+            if (shape is Point)
+            {
+                //optimized point algorithm
+                int initialCapacity = inclParents ? 1 + detailLevel : 1;
+                cells = new List<Node>(initialCapacity);
+                RecursiveGetNodes(GetWorldNode(), (Point)shape, detailLevel, true, cells);
+                Debug.Assert(cells.Count == initialCapacity);
+            }
+            else
+            {
+                cells = new List<Node>(inclParents ? 1024 : 512);
+                RecursiveGetNodes(GetWorldNode(), shape, detailLevel, inclParents, cells);
+            }
+            if (inclParents)
+            {
+                Debug.Assert(cells[0].GetLevel() == 0);
+                cells.RemoveAt(0);//remove getWorldNode()
+            }
+            return cells;
+        }
 
-		private void RecursiveGetNodes(Node node, Shape shape, int detailLevel, bool inclParents, IList<Node> result)
-		{
-			if (node.IsLeaf())
-			{//cell is within shape
-				result.Add(node);
-				return;
-			}
+        private void RecursiveGetNodes(Node node, Shape shape, int detailLevel, bool inclParents, IList<Node> result)
+        {
+            if (node.IsLeaf())
+            {//cell is within shape
+                result.Add(node);
+                return;
+            }
 
-			var subCells = node.GetSubCells(shape);
-			if (node.GetLevel() == detailLevel - 1)
-			{
-				if (subCells.Count < node.GetSubCellsSize())
-				{
-					if (inclParents)
-						result.Add(node);
-					foreach (var subCell in subCells)
-					{
-						subCell.SetLeaf();
-						result.Add(subCell);
-					}
-				}
-				else
-				{//a bottom level (i.e. detail level) optimization where all boxes intersect, so use parent cell.
-					node.SetLeaf();
-					result.Add(node);
-				}
-			}
-			else
-			{
-				if (inclParents)
-				{
-					result.Add(node);
-				}
-				foreach (var subCell in subCells)
-				{
-					RecursiveGetNodes(subCell, shape, detailLevel, inclParents, result);//tail call
-				}
-			}
-		}
+            var subCells = node.GetSubCells(shape);
+            if (node.GetLevel() == detailLevel - 1)
+            {
+                if (subCells.Count < node.GetSubCellsSize())
+                {
+                    if (inclParents)
+                        result.Add(node);
+                    foreach (var subCell in subCells)
+                    {
+                        subCell.SetLeaf();
+                        result.Add(subCell);
+                    }
+                }
+                else
+                {//a bottom level (i.e. detail level) optimization where all boxes intersect, so use parent cell.
+                    node.SetLeaf();
+                    result.Add(node);
+                }
+            }
+            else
+            {
+                if (inclParents)
+                {
+                    result.Add(node);
+                }
+                foreach (var subCell in subCells)
+                {
+                    RecursiveGetNodes(subCell, shape, detailLevel, inclParents, result);//tail call
+                }
+            }
+        }
 
-		private void RecursiveGetNodes(Node node, Point point, int detailLevel, bool inclParents, IList<Node> result)
-		{
-			if (inclParents)
-			{
-				result.Add(node);
-			}
-			Node pCell = node.GetSubCell(point);
-			if (node.GetLevel() == detailLevel - 1)
-			{
-				pCell.SetLeaf();
-				result.Add(pCell);
-			}
-			else
-			{
-				RecursiveGetNodes(pCell, point, detailLevel, inclParents, result);//tail call
-			}
-		}
+        private void RecursiveGetNodes(Node node, Point point, int detailLevel, bool inclParents, IList<Node> result)
+        {
+            if (inclParents)
+            {
+                result.Add(node);
+            }
+            Node pCell = node.GetSubCell(point);
+            if (node.GetLevel() == detailLevel - 1)
+            {
+                pCell.SetLeaf();
+                result.Add(pCell);
+            }
+            else
+            {
+                RecursiveGetNodes(pCell, point, detailLevel, inclParents, result);//tail call
+            }
+        }
 
-		/*
-		 * Subclasses might override {@link #getNodes(com.spatial4j.core.shape.Shape, int, boolean)}
-		 * and check if the argument is a shape and if so, delegate
-		 * to this implementation, which calls {@link #getNode(com.spatial4j.core.shape.Point, int)} and
-		 * then calls {@link #getNode(String)} repeatedly if inclParents is true.
-		 */
-		protected virtual IList<Node> GetNodesAltPoint(Point p, int detailLevel, bool inclParents)
-		{
-			Node cell = GetNode(p, detailLevel);
-			if (!inclParents)
-			{
+        /*
+         * Subclasses might override {@link #getNodes(com.spatial4j.core.shape.Shape, int, boolean)}
+         * and check if the argument is a shape and if so, delegate
+         * to this implementation, which calls {@link #getNode(com.spatial4j.core.shape.Point, int)} and
+         * then calls {@link #getNode(String)} repeatedly if inclParents is true.
+         */
+        protected virtual IList<Node> GetNodesAltPoint(Point p, int detailLevel, bool inclParents)
+        {
+            Node cell = GetNode(p, detailLevel);
+            if (!inclParents)
+            {
 #if !NET35
-				return new ReadOnlyCollectionBuilder<Node>(new[] { cell }).ToReadOnlyCollection();
+                return new ReadOnlyCollectionBuilder<Node>(new[] { cell }).ToReadOnlyCollection();
 #else
                 return new List<Node>(new[] { cell }).AsReadOnly();
 #endif
-			}
+            }
 
-			String endToken = cell.GetTokenString();
-			Debug.Assert(endToken.Length == detailLevel);
-			var cells = new List<Node>(detailLevel);
-			for (int i = 1; i < detailLevel; i++)
-			{
-				cells.Add(GetNode(endToken.Substring(0, i)));
-			}
-			cells.Add(cell);
-			return cells;
-		}
+            String endToken = cell.GetTokenString();
+            Debug.Assert(endToken.Length == detailLevel);
+            var cells = new List<Node>(detailLevel);
+            for (int i = 1; i < detailLevel; i++)
+            {
+                cells.Add(GetNode(endToken.Substring(0, i)));
+            }
+            cells.Add(cell);
+            return cells;
+        }
 
-		/*
-		 * Will add the trailing leaf byte for leaves. This isn't particularly efficient.
-		 */
-		public static List<String> NodesToTokenStrings(Collection<Node> nodes)
-		{
-			var tokens = new List<String>((nodes.Count));
-			foreach (Node node in nodes)
-			{
-				String token = node.GetTokenString();
-				if (node.IsLeaf())
-				{
-					tokens.Add(token + (char)Node.LEAF_BYTE);
-				}
-				else
-				{
-					tokens.Add(token);
-				}
-			}
-			return tokens;
-		}
+        /*
+         * Will add the trailing leaf byte for leaves. This isn't particularly efficient.
+         */
+        public static List<String> NodesToTokenStrings(Collection<Node> nodes)
+        {
+            var tokens = new List<String>((nodes.Count));
+            foreach (Node node in nodes)
+            {
+                String token = node.GetTokenString();
+                if (node.IsLeaf())
+                {
+                    tokens.Add(token + (char)Node.LEAF_BYTE);
+                }
+                else
+                {
+                    tokens.Add(token);
+                }
+            }
+            return tokens;
+        }
 
-	}
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTreeFactory.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTreeFactory.cs b/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTreeFactory.cs
index 1d26f3a..e4e73c6 100644
--- a/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTreeFactory.cs
+++ b/src/contrib/Spatial/Prefix/Tree/SpatialPrefixTreeFactory.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -26,49 +26,49 @@ namespace Lucene.Net.Spatial.Prefix.Tree
     /// Abstract Factory for creating {@link SpatialPrefixTree} instances with useful
     /// defaults and passed on configurations defined in a Map.
     /// </summary>
-	public abstract class SpatialPrefixTreeFactory
-	{
-		private const double DEFAULT_GEO_MAX_DETAIL_KM = 0.001; //1m
+    public abstract class SpatialPrefixTreeFactory
+    {
+        private const double DEFAULT_GEO_MAX_DETAIL_KM = 0.001; //1m
         public static readonly String PREFIX_TREE = "prefixTree";
         public static readonly String MAX_LEVELS = "maxLevels";
         public static readonly String MAX_DIST_ERR = "maxDistErr";
 
-		protected Dictionary<String, String> args;
-		protected SpatialContext ctx;
-		protected int? maxLevels;
+        protected Dictionary<String, String> args;
+        protected SpatialContext ctx;
+        protected int? maxLevels;
 
-		/// <summary>
-		/// The factory  is looked up via "prefixTree" in args, expecting "geohash" or "quad".
-		/// If its neither of these, then "geohash" is chosen for a geo context, otherwise "quad" is chosen.
-		/// </summary>
-		/// <param name="args"></param>
-		/// <param name="ctx"></param>
-		/// <returns></returns>
-		public static SpatialPrefixTree MakeSPT(Dictionary<String, String> args, SpatialContext ctx)
-		{
-			SpatialPrefixTreeFactory instance;
-			String cname;
+        /// <summary>
+        /// The factory  is looked up via "prefixTree" in args, expecting "geohash" or "quad".
+        /// If its neither of these, then "geohash" is chosen for a geo context, otherwise "quad" is chosen.
+        /// </summary>
+        /// <param name="args"></param>
+        /// <param name="ctx"></param>
+        /// <returns></returns>
+        public static SpatialPrefixTree MakeSPT(Dictionary<String, String> args, SpatialContext ctx)
+        {
+            SpatialPrefixTreeFactory instance;
+            String cname;
             if (!args.TryGetValue(PREFIX_TREE, out cname) || cname == null)
-				cname = ctx.IsGeo() ? "geohash" : "quad";
-			if ("geohash".Equals(cname, StringComparison.InvariantCultureIgnoreCase))
-				instance = new GeohashPrefixTree.Factory();
-			else if ("quad".Equals(cname, StringComparison.InvariantCultureIgnoreCase))
-				instance = new QuadPrefixTree.Factory();
-			else
-			{
-				Type t = Type.GetType(cname);
-				instance = (SpatialPrefixTreeFactory)Activator.CreateInstance(t);
-			}
-			instance.Init(args, ctx);
-			return instance.NewSPT();
-		}
+                cname = ctx.IsGeo() ? "geohash" : "quad";
+            if ("geohash".Equals(cname, StringComparison.InvariantCultureIgnoreCase))
+                instance = new GeohashPrefixTree.Factory();
+            else if ("quad".Equals(cname, StringComparison.InvariantCultureIgnoreCase))
+                instance = new QuadPrefixTree.Factory();
+            else
+            {
+                Type t = Type.GetType(cname);
+                instance = (SpatialPrefixTreeFactory)Activator.CreateInstance(t);
+            }
+            instance.Init(args, ctx);
+            return instance.NewSPT();
+        }
 
-		protected void Init(Dictionary<String, String> args, SpatialContext ctx)
-		{
-			this.args = args;
-			this.ctx = ctx;
-			InitMaxLevels();
-		}
+        protected void Init(Dictionary<String, String> args, SpatialContext ctx)
+        {
+            this.args = args;
+            this.ctx = ctx;
+            InitMaxLevels();
+        }
 
         protected void InitMaxLevels()
         {
@@ -93,10 +93,10 @@ namespace Lucene.Net.Spatial.Prefix.Tree
             maxLevels = GetLevelForDistance(degrees);
         }
 
-	    /* Calls {@link SpatialPrefixTree#getLevelForDistance(double)}. */
-		protected abstract int GetLevelForDistance(double degrees);
+        /* Calls {@link SpatialPrefixTree#getLevelForDistance(double)}. */
+        protected abstract int GetLevelForDistance(double degrees);
 
-		protected abstract SpatialPrefixTree NewSPT();
+        protected abstract SpatialPrefixTree NewSPT();
 
-	}
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Properties/AssemblyInfo.cs b/src/contrib/Spatial/Properties/AssemblyInfo.cs
index dd324bd..a5b4d0a 100644
--- a/src/contrib/Spatial/Properties/AssemblyInfo.cs
+++ b/src/contrib/Spatial/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Queries/SpatialArgs.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Queries/SpatialArgs.cs b/src/contrib/Spatial/Queries/SpatialArgs.cs
index 796e55a..9af4c7f 100644
--- a/src/contrib/Spatial/Queries/SpatialArgs.cs
+++ b/src/contrib/Spatial/Queries/SpatialArgs.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -23,31 +23,31 @@ using Spatial4n.Core.Shapes;
 
 namespace Spatial4n.Core.Exceptions
 {
-	[Serializable]
-	public class InvalidSpatialArgument : ArgumentException
-	{
-		public InvalidSpatialArgument(String reason)
-			: base(reason)
-		{
-		}
-	}
+    [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 class SpatialArgs
+    {
+        public static readonly double DEFAULT_DISTERRPCT = 0.025d;
 
-		public SpatialOperation Operation { get; set; }
+        public SpatialOperation Operation { get; set; }
 
-	    public SpatialArgs(SpatialOperation operation, Shape shape)
-		{
+        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;
-		}
+            this.Operation = operation;
+            this.Shape = shape;
+        }
 
         /// <summary>
         /// Computes the distance given a shape and the {@code distErrPct}.  The
@@ -92,51 +92,51 @@ namespace Lucene.Net.Spatial.Queries
             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())
-			{
+        /// <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()
-		{
+        public override String ToString()
+        {
             return SpatialArgsParser.WriteSpatialArgs(this);
-		}
+        }
 
-		//------------------------------------------------
-		// Getters & Setters
-		//------------------------------------------------
+        //------------------------------------------------
+        // Getters & Setters
+        //------------------------------------------------
 
-	    public Shape Shape { get; set; }
+        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;
-	        }
-	    }
+        /// <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>
+        /// <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; }
-	}
+        public double? DistErr { get; set; }
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Queries/SpatialArgsParser.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Queries/SpatialArgsParser.cs b/src/contrib/Spatial/Queries/SpatialArgsParser.cs
index 78c1b5d..6335780 100644
--- a/src/contrib/Spatial/Queries/SpatialArgsParser.cs
+++ b/src/contrib/Spatial/Queries/SpatialArgsParser.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -24,8 +24,8 @@ using Spatial4n.Core.Shapes;
 
 namespace Lucene.Net.Spatial.Queries
 {
-	public class SpatialArgsParser
-	{
+    public class SpatialArgsParser
+    {
         public const String DIST_ERR_PCT = "distErrPct";
         public const String DIST_ERR = "distErr";
 
@@ -54,58 +54,58 @@ namespace Lucene.Net.Spatial.Queries
         /// <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(')');
+        public SpatialArgs Parse(String v, SpatialContext ctx)
+        {
+            int idx = v.IndexOf('(');
+            int edx = v.LastIndexOf(')');
 
-			if (idx < 0 || idx > edx)
-			{
+            if (idx < 0 || idx > edx)
+            {
                 throw new ArgumentException("missing parens: " + v);
-			}
+            }
 
-			SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx).Trim());
+            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);
-			}
+            //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);
+            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);
+            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);
-					}
-				}
-			}
+                    if (aa.Count != 0)
+                    {
+                        throw new ArgumentException("unused parameters: " + aa);
+                    }
+                }
+            }
             args.Validate();
-			return args;
-		}
+            return args;
+        }
 
-		protected static double? ReadDouble(String v)
-		{
-			double val;
-			return double.TryParse(v, out val) ? val : (double?)null;
-		}
+        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;
-		}
+        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
@@ -113,28 +113,28 @@ namespace Lucene.Net.Spatial.Queries
         /// </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;
-		}
+        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/62f018ab/src/contrib/Spatial/Queries/SpatialOperation.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Queries/SpatialOperation.cs b/src/contrib/Spatial/Queries/SpatialOperation.cs
index 60a26d9..af82b7d 100644
--- a/src/contrib/Spatial/Queries/SpatialOperation.cs
+++ b/src/contrib/Spatial/Queries/SpatialOperation.cs
@@ -1,4 +1,4 @@
-/* See the NOTICE file distributed with
+/* 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
@@ -21,96 +21,96 @@ 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>();
+    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
+        // Geometry Operations
 
         /// <summary>
         /// Bounding box of the *indexed* shape.
         /// </summary>
-		public static readonly SpatialOperation BBoxIntersects = new SpatialOperation("BBoxIntersects", true, false, false);
+        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 GetName()
-		{
-			return name;
-		}
-
-		public override String ToString()
-		{
-			return name;
-		}
-
-	}
+        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 GetName()
+        {
+            return name;
+        }
+
+        public override String ToString()
+        {
+            return name;
+        }
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Queries/UnsupportedSpatialOperation.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Queries/UnsupportedSpatialOperation.cs b/src/contrib/Spatial/Queries/UnsupportedSpatialOperation.cs
index b542f3a..ad93734 100644
--- a/src/contrib/Spatial/Queries/UnsupportedSpatialOperation.cs
+++ b/src/contrib/Spatial/Queries/UnsupportedSpatialOperation.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -19,11 +19,11 @@ using System;
 
 namespace Lucene.Net.Spatial.Queries
 {
-	[Serializable]
-	public class UnsupportedSpatialOperation : InvalidOperationException
-	{
-		public UnsupportedSpatialOperation(SpatialOperation op) : base(op.GetName())
-		{
-		}
-	}
+    [Serializable]
+    public class UnsupportedSpatialOperation : InvalidOperationException
+    {
+        public UnsupportedSpatialOperation(SpatialOperation op) : base(op.GetName())
+        {
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/SpatialStrategy.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/SpatialStrategy.cs b/src/contrib/Spatial/SpatialStrategy.cs
index c4bcc10..f47deca 100644
--- a/src/contrib/Spatial/SpatialStrategy.cs
+++ b/src/contrib/Spatial/SpatialStrategy.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -26,101 +26,101 @@ using Spatial4n.Core.Shapes;
 
 namespace Lucene.Net.Spatial
 {
-	/// <summary>
-	/// The SpatialStrategy encapsulates an approach to indexing and searching based on shapes.
-	/// <p/>
-	/// Note that a SpatialStrategy is not involved with the Lucene stored field values of shapes, which is
-	/// immaterial to indexing and search.
-	/// <p/>
-	/// Thread-safe.
-	/// </summary>
-	public abstract class SpatialStrategy
-	{
-		protected readonly SpatialContext ctx;
-		protected readonly string fieldName;
+    /// <summary>
+    /// The SpatialStrategy encapsulates an approach to indexing and searching based on shapes.
+    /// <p/>
+    /// Note that a SpatialStrategy is not involved with the Lucene stored field values of shapes, which is
+    /// immaterial to indexing and search.
+    /// <p/>
+    /// Thread-safe.
+    /// </summary>
+    public abstract class SpatialStrategy
+    {
+        protected readonly SpatialContext ctx;
+        protected readonly string fieldName;
 
-	    /// <summary>
-	    /// Constructs the spatial strategy with its mandatory arguments.
-	    /// </summary>
-	    /// <param name="ctx"></param>
-	    /// <param name="fieldName"> </param>
-	    protected SpatialStrategy(SpatialContext ctx, string fieldName)
-		{
-			if (ctx == null)
-				throw new ArgumentException("ctx is required", "ctx");
-			this.ctx = ctx;
-			if (string.IsNullOrEmpty(fieldName))
-				throw new ArgumentException("fieldName is required", "fieldName");
-			this.fieldName = fieldName;
-		}
+        /// <summary>
+        /// Constructs the spatial strategy with its mandatory arguments.
+        /// </summary>
+        /// <param name="ctx"></param>
+        /// <param name="fieldName"> </param>
+        protected SpatialStrategy(SpatialContext ctx, string fieldName)
+        {
+            if (ctx == null)
+                throw new ArgumentException("ctx is required", "ctx");
+            this.ctx = ctx;
+            if (string.IsNullOrEmpty(fieldName))
+                throw new ArgumentException("fieldName is required", "fieldName");
+            this.fieldName = fieldName;
+        }
 
-		public SpatialContext GetSpatialContext()
-		{
-			return ctx;
-		}
+        public SpatialContext GetSpatialContext()
+        {
+            return ctx;
+        }
 
-		/// <summary>
-		/// The name of the field or the prefix of them if there are multiple
-		/// fields needed internally.
-		/// </summary>
-		/// <returns></returns>
-		public String GetFieldName()
-		{
-			return fieldName;
-		}
+        /// <summary>
+        /// The name of the field or the prefix of them if there are multiple
+        /// fields needed internally.
+        /// </summary>
+        /// <returns></returns>
+        public String GetFieldName()
+        {
+            return fieldName;
+        }
 
-		/// <summary>
-		/// Returns the IndexableField(s) from the <c>shape</c> that are to be
-		/// added to the {@link org.apache.lucene.document.Document}.  These fields
-		/// are expected to be marked as indexed and not stored.
-		/// <p/>
-		/// Note: If you want to <i>store</i> the shape as a string for retrieval in search
-		/// results, you could add it like this:
-		/// <pre>document.add(new StoredField(fieldName,ctx.toString(shape)));</pre>
-		/// The particular string representation used doesn't matter to the Strategy since it
-		/// doesn't use it.
-		/// </summary>
-		/// <param name="shape"></param>
-		/// <returns>Not null nor will it have null elements.</returns>
-		public abstract AbstractField[] CreateIndexableFields(Shape shape);
+        /// <summary>
+        /// Returns the IndexableField(s) from the <c>shape</c> that are to be
+        /// added to the {@link org.apache.lucene.document.Document}.  These fields
+        /// are expected to be marked as indexed and not stored.
+        /// <p/>
+        /// Note: If you want to <i>store</i> the shape as a string for retrieval in search
+        /// results, you could add it like this:
+        /// <pre>document.add(new StoredField(fieldName,ctx.toString(shape)));</pre>
+        /// The particular string representation used doesn't matter to the Strategy since it
+        /// doesn't use it.
+        /// </summary>
+        /// <param name="shape"></param>
+        /// <returns>Not null nor will it have null elements.</returns>
+        public abstract AbstractField[] CreateIndexableFields(Shape shape);
 
-		public AbstractField CreateStoredField(Shape shape)
-		{
-			return new Field(GetFieldName(), ctx.ToString(shape), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO);
-		}
+        public AbstractField CreateStoredField(Shape shape)
+        {
+            return new Field(GetFieldName(), ctx.ToString(shape), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO);
+        }
 
-		/// <summary>
-		/// Make a ValueSource returning the distance between the center of the
-		/// indexed shape and {@code queryPoint}.  If there are multiple indexed shapes
-		/// then the closest one is chosen.
-		/// </summary>
-		public abstract ValueSource MakeDistanceValueSource(Point queryPoint);
+        /// <summary>
+        /// Make a ValueSource returning the distance between the center of the
+        /// indexed shape and {@code queryPoint}.  If there are multiple indexed shapes
+        /// then the closest one is chosen.
+        /// </summary>
+        public abstract ValueSource MakeDistanceValueSource(Point queryPoint);
 
-	    /// <summary>
-	    /// Make a (ConstantScore) Query based principally on {@link org.apache.lucene.spatial.query.SpatialOperation}
-	    /// and {@link Shape} from the supplied {@code args}.
-	    /// The default implementation is
-	    /// <pre>return new ConstantScoreQuery(makeFilter(args));</pre>
-	    /// </summary>
-	    /// <param name="args"></param>
-	    /// <returns></returns>
-	    public virtual ConstantScoreQuery MakeQuery(SpatialArgs args)
-		{
+        /// <summary>
+        /// Make a (ConstantScore) Query based principally on {@link org.apache.lucene.spatial.query.SpatialOperation}
+        /// and {@link Shape} from the supplied {@code args}.
+        /// The default implementation is
+        /// <pre>return new ConstantScoreQuery(makeFilter(args));</pre>
+        /// </summary>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        public virtual ConstantScoreQuery MakeQuery(SpatialArgs args)
+        {
             return new ConstantScoreQuery(MakeFilter(args));
-		}
+        }
 
-		/// <summary>
-		/// Make a Filter based principally on {@link org.apache.lucene.spatial.query.SpatialOperation}
-		/// and {@link Shape} from the supplied {@code args}.
-		/// <p />
-		/// If a subclasses implements
-		/// {@link #makeQuery(org.apache.lucene.spatial.query.SpatialArgs)}
-		/// then this method could be simply:
-		/// <pre>return new QueryWrapperFilter(makeQuery(args).getQuery());</pre>
-		/// </summary>
-		/// <param name="args"></param>
-		/// <returns></returns>
-		public abstract Filter MakeFilter(SpatialArgs args);
+        /// <summary>
+        /// Make a Filter based principally on {@link org.apache.lucene.spatial.query.SpatialOperation}
+        /// and {@link Shape} from the supplied {@code args}.
+        /// <p />
+        /// If a subclasses implements
+        /// {@link #makeQuery(org.apache.lucene.spatial.query.SpatialArgs)}
+        /// then this method could be simply:
+        /// <pre>return new QueryWrapperFilter(makeQuery(args).getQuery());</pre>
+        /// </summary>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        public abstract Filter MakeFilter(SpatialArgs args);
 
         /// <summary>
         /// Returns a ValueSource with values ranging from 1 to 0, depending inversely
@@ -142,9 +142,9 @@ namespace Lucene.Net.Spatial
             return new ReciprocalFloatFunction(MakeDistanceValueSource(queryShape.GetCenter()), 1f, c, c);
         }
 
-	    public override string ToString()
-		{
-			return GetType().Name + " field:" + fieldName + " ctx=" + ctx;
-		}
-	}
+        public override string ToString()
+        {
+            return GetType().Name + " field:" + fieldName + " ctx=" + ctx;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Util/Bits.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Util/Bits.cs b/src/contrib/Spatial/Util/Bits.cs
index d6c7bfa..f0040ee 100644
--- a/src/contrib/Spatial/Util/Bits.cs
+++ b/src/contrib/Spatial/Util/Bits.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -17,76 +17,76 @@
 
 namespace Lucene.Net.Spatial.Util
 {
-	/// <summary>
-	/// Interface for Bitset-like structures.
-	/// </summary>
-	public interface IBits
-	{
-		bool Get(int index);
-		int Length();
-	}
+    /// <summary>
+    /// Interface for Bitset-like structures.
+    /// </summary>
+    public interface IBits
+    {
+        bool Get(int index);
+        int Length();
+    }
 
-	/// <summary>
-	/// Empty implementation, basically just so we can provide EMPTY_ARRAY
-	/// </summary>
-	public abstract class Bits : IBits
-	{
-		public static readonly Bits[] EMPTY_ARRAY = new Bits[0];
+    /// <summary>
+    /// Empty implementation, basically just so we can provide EMPTY_ARRAY
+    /// </summary>
+    public abstract class Bits : IBits
+    {
+        public static readonly Bits[] EMPTY_ARRAY = new Bits[0];
 
-		public virtual bool Get(int index)
-		{
-			throw new System.NotImplementedException();
-		}
+        public virtual bool Get(int index)
+        {
+            throw new System.NotImplementedException();
+        }
 
-		public virtual int Length()
-		{
-			throw new System.NotImplementedException();
-		}
-	}
+        public virtual int Length()
+        {
+            throw new System.NotImplementedException();
+        }
+    }
 
-	/// <summary>
-	/// Bits impl of the specified length with all bits set.
-	/// </summary>
-	public class MatchAllBits : Bits
-	{
-		private readonly int len;
+    /// <summary>
+    /// Bits impl of the specified length with all bits set.
+    /// </summary>
+    public class MatchAllBits : Bits
+    {
+        private readonly int len;
 
-		public MatchAllBits(int len)
-		{
-			this.len = len;
-		}
+        public MatchAllBits(int len)
+        {
+            this.len = len;
+        }
 
-		public override bool Get(int index)
-		{
-			return true;
-		}
+        public override bool Get(int index)
+        {
+            return true;
+        }
 
-		public override int Length()
-		{
-			return len;
-		}
-	}
+        public override int Length()
+        {
+            return len;
+        }
+    }
 
-	/// <summary>
-	/// Bits impl of the specified length with no bits set. 
-	/// </summary>
-	public class MatchNoBits : Bits
-	{
-		private readonly int len;
+    /// <summary>
+    /// Bits impl of the specified length with no bits set. 
+    /// </summary>
+    public class MatchNoBits : Bits
+    {
+        private readonly int len;
 
-		public MatchNoBits(int len)
-		{
-			this.len = len;
-		}
+        public MatchNoBits(int len)
+        {
+            this.len = len;
+        }
 
-		public override bool Get(int index)
-		{
-			return false;
-		}
+        public override bool Get(int index)
+        {
+            return false;
+        }
 
-		public override int Length()
-		{
-			return len;
-		}
-	}
+        public override int Length()
+        {
+            return len;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Util/CachingDoubleValueSource.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Util/CachingDoubleValueSource.cs b/src/contrib/Spatial/Util/CachingDoubleValueSource.cs
index 0a52b66..ef7a174 100644
--- a/src/contrib/Spatial/Util/CachingDoubleValueSource.cs
+++ b/src/contrib/Spatial/Util/CachingDoubleValueSource.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -21,81 +21,81 @@ using Lucene.Net.Search.Function;
 
 namespace Lucene.Net.Spatial.Util
 {
-	public class CachingDoubleValueSource : ValueSource
-	{
-		protected readonly ValueSource source;
-		protected readonly Dictionary<int, double> cache;
-
-		public CachingDoubleValueSource(ValueSource source)
-		{
-			this.source = source;
-			cache = new Dictionary<int, double>();
-		}
-
-		public class CachingDoubleDocValue : DocValues
-		{
-			private readonly int docBase;
-			private readonly DocValues values;
-			private readonly Dictionary<int, double> cache;
-
-			public CachingDoubleDocValue(int docBase, DocValues vals, Dictionary<int, double> cache)
-			{
-				this.docBase = docBase;
-				this.values = vals;
-				this.cache = cache;
-			}
-
-			public override double DoubleVal(int doc)
-			{
-				var key = docBase + doc;
-				double v;
-				if (!cache.TryGetValue(key, out v))
-				{
-					v = values.DoubleVal(doc);
-					cache[key] = v;
-				}
-				return v;
-			}
-
-			public override float FloatVal(int doc)
-			{
-				return (float)DoubleVal(doc);
-			}
-
-			public override string ToString(int doc)
-			{
-				return DoubleVal(doc) + string.Empty;
-			}
-		}
-
-		public override DocValues GetValues(IndexReader reader)
-		{
-			var @base = 0; //reader.DocBase;
-			var vals = source.GetValues(reader);
-			return new CachingDoubleDocValue(@base, vals, cache);
-
-		}
-
-		public override string Description()
-		{
-			return "Cached[" + source.Description() + "]";
-		}
-
-		public override bool Equals(object o)
-		{
-			if (this == o) return true;
-
-			var that = o as CachingDoubleValueSource;
-
-			if (that == null) return false;
-			if (source != null ? !source.Equals(that.source) : that.source != null) return false;
-
-			return true;
-		}
-
-		public override int GetHashCode()
-		{
-			return source != null ? source.GetHashCode() : 0;
-		}
-	}
+    public class CachingDoubleValueSource : ValueSource
+    {
+        protected readonly ValueSource source;
+        protected readonly Dictionary<int, double> cache;
+
+        public CachingDoubleValueSource(ValueSource source)
+        {
+            this.source = source;
+            cache = new Dictionary<int, double>();
+        }
+
+        public class CachingDoubleDocValue : DocValues
+        {
+            private readonly int docBase;
+            private readonly DocValues values;
+            private readonly Dictionary<int, double> cache;
+
+            public CachingDoubleDocValue(int docBase, DocValues vals, Dictionary<int, double> cache)
+            {
+                this.docBase = docBase;
+                this.values = vals;
+                this.cache = cache;
+            }
+
+            public override double DoubleVal(int doc)
+            {
+                var key = docBase + doc;
+                double v;
+                if (!cache.TryGetValue(key, out v))
+                {
+                    v = values.DoubleVal(doc);
+                    cache[key] = v;
+                }
+                return v;
+            }
+
+            public override float FloatVal(int doc)
+            {
+                return (float)DoubleVal(doc);
+            }
+
+            public override string ToString(int doc)
+            {
+                return DoubleVal(doc) + string.Empty;
+            }
+        }
+
+        public override DocValues GetValues(IndexReader reader)
+        {
+            var @base = 0; //reader.DocBase;
+            var vals = source.GetValues(reader);
+            return new CachingDoubleDocValue(@base, vals, cache);
+
+        }
+
+        public override string Description()
+        {
+            return "Cached[" + source.Description() + "]";
+        }
+
+        public override bool Equals(object o)
+        {
+            if (this == o) return true;
+
+            var that = o as CachingDoubleValueSource;
+
+            if (that == null) return false;
+            if (source != null ? !source.Equals(that.source) : that.source != null) return false;
+
+            return true;
+        }
+
+        public override int GetHashCode()
+        {
+            return source != null ? source.GetHashCode() : 0;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Spatial/Util/CompatibilityExtensions.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Spatial/Util/CompatibilityExtensions.cs b/src/contrib/Spatial/Util/CompatibilityExtensions.cs
index 1a1bebd..e802662 100644
--- a/src/contrib/Spatial/Util/CompatibilityExtensions.cs
+++ b/src/contrib/Spatial/Util/CompatibilityExtensions.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.
@@ -28,24 +28,24 @@ using Lucene.Net.Search;
 
 namespace Lucene.Net.Spatial.Util
 {
-	public static class CompatibilityExtensions
-	{
-		public static void Append(this ITermAttribute termAtt, string str)
-		{
-			termAtt.SetTermBuffer(termAtt.Term + str); // TODO: Not optimal, but works
-		}
+    public static class CompatibilityExtensions
+    {
+        public static void Append(this ITermAttribute termAtt, string str)
+        {
+            termAtt.SetTermBuffer(termAtt.Term + str); // TODO: Not optimal, but works
+        }
 
-		public static void Append(this ITermAttribute termAtt, char ch)
-		{
-			termAtt.SetTermBuffer(termAtt.Term + new string(new[] { ch })); // TODO: Not optimal, but works
-		}
+        public static void Append(this ITermAttribute termAtt, char ch)
+        {
+            termAtt.SetTermBuffer(termAtt.Term + new string(new[] { ch })); // TODO: Not optimal, but works
+        }
 
-		private static readonly ConcurrentDictionary<string, IBits> _docsWithFieldCache = new ConcurrentDictionary<string, IBits>();
+        private static readonly ConcurrentDictionary<string, IBits> _docsWithFieldCache = new ConcurrentDictionary<string, IBits>();
 
-		internal static IBits GetDocsWithField(this FieldCache fc, IndexReader reader, String field)
-		{
-			return _docsWithFieldCache.GetOrAdd(field, f => DocsWithFieldCacheEntry_CreateValue(reader, new Entry(field, null), false));
-		}
+        internal static IBits GetDocsWithField(this FieldCache fc, IndexReader reader, String field)
+        {
+            return _docsWithFieldCache.GetOrAdd(field, f => DocsWithFieldCacheEntry_CreateValue(reader, new Entry(field, null), false));
+        }
 
         /// <summary> <p/>
         /// EXPERT: Instructs the FieldCache to forcibly expunge all entries 
@@ -67,149 +67,149 @@ namespace Lucene.Net.Spatial.Util
             _docsWithFieldCache.Clear();
         }
 
-		private static IBits DocsWithFieldCacheEntry_CreateValue(IndexReader reader, Entry entryKey, bool setDocsWithField /* ignored */)
-		{
-			var field = entryKey.field;
-			FixedBitSet res = null;
-			var terms = new TermsEnumCompatibility(reader, field);
-			var maxDoc = reader.MaxDoc;
-
-			var term = terms.Next();
-			if (term != null)
-			{
-				int termsDocCount = terms.GetDocCount();
-				Debug.Assert(termsDocCount <= maxDoc);
-				if (termsDocCount == maxDoc)
-				{
-					// Fast case: all docs have this field:
-					return new MatchAllBits(maxDoc);
-				}
-
-				while (true)
-				{
-					if (res == null)
-					{
-						// lazy init
-						res = new FixedBitSet(maxDoc);
-					}
-
-					var termDocs = reader.TermDocs(term);
-					while (termDocs.Next())
-					{
-						res.Set(termDocs.Doc);
-					}
-		
-					term = terms.Next();
-					if (term == null)
-					{
-						break;
-					}
-				}
-			}
-			if (res == null)
-			{
-				return new MatchNoBits(maxDoc);
-			}
-			int numSet = res.Cardinality();
-			if (numSet >= maxDoc)
-			{
-				// The cardinality of the BitSet is maxDoc if all documents have a value.
-				Debug.Assert(numSet == maxDoc);
-				return new MatchAllBits(maxDoc);
-			}
-			return res;
-		}
-
-		/* table of number of leading zeros in a byte */
-		public static readonly byte[] nlzTable = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-		/// <summary>
-		/// Returns the number of leading zero bits.
-		/// </summary>
-		/// <param name="x"></param>
-		/// <returns></returns>
-		public static int BitUtilNlz(long x)
-		{
-			int n = 0;
-			// do the first step as a long
-			var y = (int)((ulong)x >> 32);
-			if (y == 0) { n += 32; y = (int)(x); }
-			if ((y & 0xFFFF0000) == 0) { n += 16; y <<= 16; }
-			if ((y & 0xFF000000) == 0) { n += 8; y <<= 8; }
-			return n + nlzTable[(uint)y >> 24];
-			/* implementation without table:
-			  if ((y & 0xF0000000) == 0) { n+=4; y<<=4; }
-			  if ((y & 0xC0000000) == 0) { n+=2; y<<=2; }
-			  if ((y & 0x80000000) == 0) { n+=1; y<<=1; }
-			  if ((y & 0x80000000) == 0) { n+=1;}
-			  return n;
-			 */
-		}
-	}
-
-	public static class Arrays
-	{
-		public static void Fill<T>(T[] array, int fromIndex, int toIndex, T value)
-		{
-			if (array == null)
-			{
-				throw new ArgumentNullException("array");
-			}
-			if (fromIndex < 0 || fromIndex > toIndex)
-			{
-				throw new ArgumentOutOfRangeException("fromIndex");
-			}
-			if (toIndex > array.Length)
-			{
-				throw new ArgumentOutOfRangeException("toIndex");
-			}
-			for (var i = fromIndex; i < toIndex; i++)
-			{
-				array[i] = value;
-			}
-		}
-	}
-
-	/// <summary>
-	/// Expert: Every composite-key in the internal cache is of this type.
-	/// </summary>
-	internal class Entry
-	{
-		internal readonly String field;        // which Fieldable
-		internal readonly Object custom;       // which custom comparator or parser
-
-		/* Creates one of these objects for a custom comparator/parser. */
-		public Entry(String field, Object custom)
-		{
-			this.field = field;
-			this.custom = custom;
-		}
-
-		/* Two of these are equal iff they reference the same field and type. */
-		public override bool Equals(Object o)
-		{
-			var other = o as Entry;
-			if (other != null)
-			{
-				if (other.field.Equals(field))
-				{
-					if (other.custom == null)
-					{
-						if (custom == null) return true;
-					}
-					else if (other.custom.Equals(custom))
-					{
-						return true;
-					}
-				}
-			}
-			return false;
-		}
-
-		/* Composes a hashcode based on the field and type. */
-		public override int GetHashCode()
-		{
-			return field.GetHashCode() ^ (custom == null ? 0 : custom.GetHashCode());
-		}
-	}
+        private static IBits DocsWithFieldCacheEntry_CreateValue(IndexReader reader, Entry entryKey, bool setDocsWithField /* ignored */)
+        {
+            var field = entryKey.field;
+            FixedBitSet res = null;
+            var terms = new TermsEnumCompatibility(reader, field);
+            var maxDoc = reader.MaxDoc;
+
+            var term = terms.Next();
+            if (term != null)
+            {
+                int termsDocCount = terms.GetDocCount();
+                Debug.Assert(termsDocCount <= maxDoc);
+                if (termsDocCount == maxDoc)
+                {
+                    // Fast case: all docs have this field:
+                    return new MatchAllBits(maxDoc);
+                }
+
+                while (true)
+                {
+                    if (res == null)
+                    {
+                        // lazy init
+                        res = new FixedBitSet(maxDoc);
+                    }
+
+                    var termDocs = reader.TermDocs(term);
+                    while (termDocs.Next())
+                    {
+                        res.Set(termDocs.Doc);
+                    }
+        
+                    term = terms.Next();
+                    if (term == null)
+                    {
+                        break;
+                    }
+                }
+            }
+            if (res == null)
+            {
+                return new MatchNoBits(maxDoc);
+            }
+            int numSet = res.Cardinality();
+            if (numSet >= maxDoc)
+            {
+                // The cardinality of the BitSet is maxDoc if all documents have a value.
+                Debug.Assert(numSet == maxDoc);
+                return new MatchAllBits(maxDoc);
+            }
+            return res;
+        }
+
+        /* table of number of leading zeros in a byte */
+        public static readonly byte[] nlzTable = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+        /// <summary>
+        /// Returns the number of leading zero bits.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <returns></returns>
+        public static int BitUtilNlz(long x)
+        {
+            int n = 0;
+            // do the first step as a long
+            var y = (int)((ulong)x >> 32);
+            if (y == 0) { n += 32; y = (int)(x); }
+            if ((y & 0xFFFF0000) == 0) { n += 16; y <<= 16; }
+            if ((y & 0xFF000000) == 0) { n += 8; y <<= 8; }
+            return n + nlzTable[(uint)y >> 24];
+            /* implementation without table:
+              if ((y & 0xF0000000) == 0) { n+=4; y<<=4; }
+              if ((y & 0xC0000000) == 0) { n+=2; y<<=2; }
+              if ((y & 0x80000000) == 0) { n+=1; y<<=1; }
+              if ((y & 0x80000000) == 0) { n+=1;}
+              return n;
+             */
+        }
+    }
+
+    public static class Arrays
+    {
+        public static void Fill<T>(T[] array, int fromIndex, int toIndex, T value)
+        {
+            if (array == null)
+            {
+                throw new ArgumentNullException("array");
+            }
+            if (fromIndex < 0 || fromIndex > toIndex)
+            {
+                throw new ArgumentOutOfRangeException("fromIndex");
+            }
+            if (toIndex > array.Length)
+            {
+                throw new ArgumentOutOfRangeException("toIndex");
+            }
+            for (var i = fromIndex; i < toIndex; i++)
+            {
+                array[i] = value;
+            }
+        }
+    }
+
+    /// <summary>
+    /// Expert: Every composite-key in the internal cache is of this type.
+    /// </summary>
+    internal class Entry
+    {
+        internal readonly String field;        // which Fieldable
+        internal readonly Object custom;       // which custom comparator or parser
+
+        /* Creates one of these objects for a custom comparator/parser. */
+        public Entry(String field, Object custom)
+        {
+            this.field = field;
+            this.custom = custom;
+        }
+
+        /* Two of these are equal iff they reference the same field and type. */
+        public override bool Equals(Object o)
+        {
+            var other = o as Entry;
+            if (other != null)
+            {
+                if (other.field.Equals(field))
+                {
+                    if (other.custom == null)
+                    {
+                        if (custom == null) return true;
+                    }
+                    else if (other.custom.Equals(custom))
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
+        /* Composes a hashcode based on the field and type. */
+        public override int GetHashCode()
+        {
+            return field.GetHashCode() ^ (custom == null ? 0 : custom.GetHashCode());
+        }
+    }
 }