lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject svn commit: r1388490 - in /lucene.net/trunk/src/contrib/Spatial: BBox/BBoxStrategy.cs SpatialStrategy.cs Vector/TwoDoublesStrategy.cs
Date Fri, 21 Sep 2012 13:39:02 GMT
Author: synhershko
Date: Fri Sep 21 13:39:02 2012
New Revision: 1388490

URL: http://svn.apache.org/viewvc?rev=1388490&view=rev
Log:
LUCENE-4173 remove ignoreIncompatibleGeometry, fail unless given the exact shape needed

Modified:
    lucene.net/trunk/src/contrib/Spatial/BBox/BBoxStrategy.cs
    lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs
    lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs

Modified: lucene.net/trunk/src/contrib/Spatial/BBox/BBoxStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/BBox/BBoxStrategy.cs?rev=1388490&r1=1388489&r2=1388490&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/BBox/BBoxStrategy.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/BBox/BBoxStrategy.cs Fri Sep 21 13:39:02 2012
@@ -72,9 +72,16 @@ namespace Lucene.Net.Spatial.BBox
 		// Indexing
 		//---------------------------------
 
-		public override AbstractField[] CreateIndexableFields(Shape shape)
-		{
-			Rectangle bbox = shape.GetBoundingBox();
+        public override AbstractField[] CreateIndexableFields(Shape shape)
+        {
+            var rect = shape as Rectangle;
+            if (rect != null)
+                return CreateIndexableFields(rect);
+            throw new ArgumentException("Can only index Rectangle, not " + shape, "shape");
+        }
+
+	    public AbstractField[] CreateIndexableFields(Rectangle bbox)
+        {
 			var fields = new AbstractField[5];
 			fields[0] = DoubleField(field_minX, bbox.GetMinX());
 			fields[1] = DoubleField(field_maxX, bbox.GetMaxX());
@@ -93,7 +100,10 @@ namespace Lucene.Net.Spatial.BBox
 
 		public override ValueSource MakeValueSource(SpatialArgs args)
 		{
-			return new BBoxSimilarityValueSource(this, new AreaSimilarity(args.Shape.GetBoundingBox(),
queryPower, targetPower));
+            var rect = args.Shape as Rectangle;
+            if (rect == null)
+                throw new ArgumentException("Can only get valueSource by Rectangle, not "
+ args.Shape);
+            return new BBoxSimilarityValueSource(this, new AreaSimilarity(rect, queryPower,
targetPower));
 		}
 
 		public override Query MakeQuery(SpatialArgs args)
@@ -116,7 +126,10 @@ namespace Lucene.Net.Spatial.BBox
 
 		private Query MakeSpatialQuery(SpatialArgs args)
 		{
-			Rectangle bbox = args.Shape.GetBoundingBox();
+            var bbox = args.Shape as Rectangle;
+            if (bbox == null)
+                throw new ArgumentException("Can only query by Rectangle, not " + args.Shape);
+
 			Query spatial = null;
 
 			// Useful for understanding Relations:

Modified: lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs?rev=1388490&r1=1388489&r2=1388490&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs Fri Sep 21 13:39:02 2012
@@ -36,7 +36,6 @@ namespace Lucene.Net.Spatial
 	/// </summary>
 	public abstract class SpatialStrategy
 	{
-		protected bool ignoreIncompatibleGeometry;
 		protected readonly SpatialContext ctx;
 		protected readonly string fieldName;
 
@@ -117,20 +116,9 @@ namespace Lucene.Net.Spatial
 		/// Make a Filter
 		/// </summary>
 		/// <param name="args"></param>
-		/// <param name="fieldInfo"></param>
 		/// <returns></returns>
 		public abstract Filter MakeFilter(SpatialArgs args);
 
-		public bool IsIgnoreIncompatibleGeometry()
-		{
-			return ignoreIncompatibleGeometry;
-		}
-
-		public void SetIgnoreIncompatibleGeometry(bool ignoreIncompatibleGeometry)
-		{
-			this.ignoreIncompatibleGeometry = ignoreIncompatibleGeometry;
-		}
-
 		public override string ToString()
 		{
 			return GetType().Name + " field:" + fieldName + " ctx=" + ctx;

Modified: lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs?rev=1388490&r1=1388489&r2=1388490&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs Fri Sep 21 13:39:02
2012
@@ -63,9 +63,15 @@ namespace Lucene.Net.Spatial.Vector
 
 		public override AbstractField[] CreateIndexableFields(Shape shape)
 		{
-			var point = shape as Point;
-			if (point != null)
-			{
+		    var point = shape as Point;
+		    if (point != null)
+		        return CreateIndexableFields(point);
+
+		    throw new ArgumentException("Can only index Point, not " + shape);
+		}
+
+        public AbstractField[] CreateIndexableFields(Point point)
+        {
 				var f = new AbstractField[2];
 
 				var f0 = new NumericField(fieldNameX, precisionStep, Field.Store.NO, true)
@@ -79,12 +85,6 @@ namespace Lucene.Net.Spatial.Vector
 				f[1] = f1;
 
 				return f;
-			}
-			if (!ignoreIncompatibleGeometry)
-			{
-				throw new ArgumentException("TwoDoublesStrategy can not index: " + shape);
-			}
-			return new AbstractField[0]; // nothing (solr does not support null) 
 		}
 
 		public override ValueSource MakeValueSource(SpatialArgs args)



Mime
View raw message