You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2012/09/21 15:38:12 UTC
svn commit: r1388489 - in /lucene.net/trunk: src/contrib/Spatial/BBox/
src/contrib/Spatial/Prefix/ src/contrib/Spatial/Queries/
src/contrib/Spatial/Vector/ test-files/spatial/ test/contrib/Spatial/
test/contrib/Spatial/BBox/
Author: synhershko
Date: Fri Sep 21 13:38:11 2012
New Revision: 1388489
URL: http://svn.apache.org/viewvc?rev=1388489&view=rev
Log:
LUCENE-4375 Fix use of BBoxWithin BBoxIntersects and IsWithin
+ dotnetifying all getters/setters in SpatialArgs .NET
Added:
lucene.net/trunk/test-files/spatial/cities-Intersects-BBox.txt
Removed:
lucene.net/trunk/test-files/spatial/cities-IsWithin-BBox.txt
Modified:
lucene.net/trunk/src/contrib/Spatial/BBox/BBoxStrategy.cs
lucene.net/trunk/src/contrib/Spatial/Prefix/PrefixTreeStrategy.cs
lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs
lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs
lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgs.cs
lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs
lucene.net/trunk/src/contrib/Spatial/Queries/SpatialOperation.cs
lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs
lucene.net/trunk/test/contrib/Spatial/BBox/TestBBoxStrategy.cs
lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.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=1388489&r1=1388488&r2=1388489&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:38:11 2012
@@ -93,7 +93,7 @@ namespace Lucene.Net.Spatial.BBox
public override ValueSource MakeValueSource(SpatialArgs args)
{
- return new BBoxSimilarityValueSource(this, new AreaSimilarity(args.GetShape().GetBoundingBox(), queryPower, targetPower));
+ return new BBoxSimilarityValueSource(this, new AreaSimilarity(args.Shape.GetBoundingBox(), queryPower, targetPower));
}
public override Query MakeQuery(SpatialArgs args)
@@ -116,7 +116,7 @@ namespace Lucene.Net.Spatial.BBox
private Query MakeSpatialQuery(SpatialArgs args)
{
- Rectangle bbox = args.GetShape().GetBoundingBox();
+ Rectangle bbox = args.Shape.GetBoundingBox();
Query spatial = null;
// Useful for understanding Relations:
Modified: lucene.net/trunk/src/contrib/Spatial/Prefix/PrefixTreeStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Prefix/PrefixTreeStrategy.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Prefix/PrefixTreeStrategy.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Prefix/PrefixTreeStrategy.cs Fri Sep 21 13:38:11 2012
@@ -168,7 +168,7 @@ namespace Lucene.Net.Spatial.Prefix
public ValueSource MakeValueSource(SpatialArgs args, DistanceCalculator calc)
{
var p = (PointPrefixTreeFieldCacheProvider)GetCacheProvider();
- Point point = args.GetShape().GetCenter();
+ Point point = args.Shape.GetCenter();
return new ShapeFieldCacheDistanceValueSource(point, calc, p);
}
Modified: lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs Fri Sep 21 13:38:11 2012
@@ -44,10 +44,10 @@ namespace Lucene.Net.Spatial.Prefix
public override Filter MakeFilter(SpatialArgs args)
{
var op = args.Operation;
- if (!SpatialOperation.Is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin, SpatialOperation.BBoxIntersects))
+ if (op != SpatialOperation.Intersects)
throw new UnsupportedSpatialOperation(op);
- Shape shape = args.GetShape();
+ Shape shape = args.Shape;
int detailLevel = grid.GetLevelForDistance(args.ResolveDistErr(ctx, distErrPct));
Modified: lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs Fri Sep 21 13:38:11 2012
@@ -39,12 +39,10 @@ namespace Lucene.Net.Spatial.Prefix
public override Filter MakeFilter(SpatialArgs args)
{
SpatialOperation op = args.Operation;
- if (
- !SpatialOperation.Is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin,
- SpatialOperation.BBoxIntersects))
+ if (op != SpatialOperation.Intersects)
throw new UnsupportedSpatialOperation(op);
- Shape shape = args.GetShape();
+ Shape shape = args.Shape;
int detailLevel = grid.GetLevelForDistance(args.ResolveDistErr(ctx, distErrPct));
var cells = grid.GetNodes(shape, detailLevel, false);
var filter = new TermsFilter();
Modified: lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgs.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgs.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgs.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgs.cs Fri Sep 21 13:38:11 2012
@@ -40,14 +40,13 @@ namespace Lucene.Net.Spatial.Queries
public static readonly double DEFAULT_DISTERRPCT = 0.025d;
public SpatialOperation Operation { get; set; }
- private Shape shape;
- 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.Shape = shape;
}
/// <summary>
@@ -90,7 +89,7 @@ namespace Lucene.Net.Spatial.Queries
if (DistErr != null)
return DistErr.Value;
double? distErrPct = (this.distErrPct ?? defaultDistErrPct);
- return CalcDistanceFromErrPct(shape, distErrPct.Value, ctx);
+ return CalcDistanceFromErrPct(Shape, distErrPct.Value, ctx);
}
/// <summary>
@@ -98,7 +97,7 @@ namespace Lucene.Net.Spatial.Queries
/// </summary>
public void Validate()
{
- if (Operation.IsTargetNeedsArea() && !shape.HasArea())
+ if (Operation.IsTargetNeedsArea() && !Shape.HasArea())
{
throw new ArgumentException(Operation + " only supports geometry with area");
}
@@ -113,21 +112,7 @@ namespace Lucene.Net.Spatial.Queries
// Getters & Setters
//------------------------------------------------
- /// <summary>
- /// Considers {@link SpatialOperation#BBoxWithin} in returning the shape.
- /// </summary>
- /// <returns></returns>
- public Shape GetShape()
- {
- if (shape != null && (Operation == SpatialOperation.BBoxWithin || Operation == SpatialOperation.BBoxIntersects))
- return shape.GetBoundingBox();
- return shape;
- }
-
- public void SetShape(Shape shape)
- {
- this.shape = shape;
- }
+ public Shape Shape { get; set; }
/// <summary>
/// A measure of acceptable error of the shape as a fraction. This effectively
Modified: lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs Fri Sep 21 13:38:11 2012
@@ -37,7 +37,7 @@ namespace Lucene.Net.Spatial.Queries
var str = new StringBuilder();
str.Append(args.Operation.GetName());
str.Append('(');
- str.Append(args.GetShape());
+ str.Append(args.Shape);
if (args.DistErrPct != null)
str.Append(" distErrPct=").Append(String.Format("{0:0.00}%", args.DistErrPct*100d));
if (args.DistErr != null)
Modified: lucene.net/trunk/src/contrib/Spatial/Queries/SpatialOperation.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Queries/SpatialOperation.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Queries/SpatialOperation.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Queries/SpatialOperation.cs Fri Sep 21 13:38:11 2012
@@ -28,8 +28,17 @@ namespace Lucene.Net.Spatial.Queries
private static readonly IList<SpatialOperation> list = new List<SpatialOperation>();
// Geometry Operations
+
+ /// <summary>
+ /// Bounding box of the *indexed* shape.
+ /// </summary>
public static readonly SpatialOperation BBoxIntersects = new SpatialOperation("BBoxIntersects", true, false, false);
+
+ /// <summary>
+ /// Bounding box of the *indexed* shape.
+ /// </summary>
public static readonly SpatialOperation BBoxWithin = new SpatialOperation("BBoxWithin", true, false, false);
+
public static readonly SpatialOperation Contains = new SpatialOperation("Contains", true, true, false);
public static readonly SpatialOperation Intersects = new SpatialOperation("Intersects", true, false, false);
public static readonly SpatialOperation IsEqualTo = new SpatialOperation("IsEqualTo", false, false, false);
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=1388489&r1=1388488&r2=1388489&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:38:11 2012
@@ -89,14 +89,14 @@ namespace Lucene.Net.Spatial.Vector
public override ValueSource MakeValueSource(SpatialArgs args)
{
- Point p = args.GetShape().GetCenter();
+ Point p = args.Shape.GetCenter();
return new DistanceValueSource(this, p, ctx.GetDistCalc());
}
public override Query MakeQuery(SpatialArgs args)
{
// For starters, just limit the bbox
- var shape = args.GetShape();
+ var shape = args.Shape;
if (!(shape is Rectangle || shape is Circle))
throw new InvalidShapeException("Only Rectangles and Circles are currently supported, found ["
+ shape.GetType().Name + "]");//TODO
@@ -123,7 +123,7 @@ namespace Lucene.Net.Spatial.Vector
SpatialOperation.IsWithin))
{
spatial = MakeWithin(bbox);
- var circle = args.GetShape() as Circle;
+ var circle = args.Shape as Circle;
if (circle != null)
{
// Make the ValueSource
@@ -163,7 +163,7 @@ namespace Lucene.Net.Spatial.Vector
public override Filter MakeFilter(SpatialArgs args)
{
- var circle = args.GetShape() as Circle;
+ var circle = args.Shape as Circle;
if (circle != null)
{
if (SpatialOperation.Is(args.Operation,
Added: lucene.net/trunk/test-files/spatial/cities-Intersects-BBox.txt
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test-files/spatial/cities-Intersects-BBox.txt?rev=1388489&view=auto
==============================================================================
--- lucene.net/trunk/test-files/spatial/cities-Intersects-BBox.txt (added)
+++ lucene.net/trunk/test-files/spatial/cities-Intersects-BBox.txt Fri Sep 21 13:38:11 2012
@@ -0,0 +1,7 @@
+[San Francisco] G5391959 @ Intersects(-122.524918 37.674973 -122.360123 37.817108)
+[Wellington] G2179537 @ Intersects(174.711456 -41.360779 174.854279 -41.213837)
+[Barcelona] G6544100 G3128760 @ Intersects(2.127228 41.333313 2.226105 41.408844)
+
+
+
+
Modified: lucene.net/trunk/test/contrib/Spatial/BBox/TestBBoxStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/BBox/TestBBoxStrategy.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/BBox/TestBBoxStrategy.cs (original)
+++ lucene.net/trunk/test/contrib/Spatial/BBox/TestBBoxStrategy.cs Fri Sep 21 13:38:11 2012
@@ -44,7 +44,7 @@ namespace Lucene.Net.Contrib.Spatial.Tes
{
getAddAndVerifyIndexedDocuments(DATA_STATES_BBOX);
- executeQueries(SpatialMatchConcern.FILTER, QTEST_States_IsWithin_BBox);
+ executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_Intersects_BBox);
executeQueries(SpatialMatchConcern.FILTER, QTEST_States_Intersects_BBox);
}
Modified: lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs?rev=1388489&r1=1388488&r2=1388489&view=diff
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs (original)
+++ lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs Fri Sep 21 13:38:11 2012
@@ -38,7 +38,7 @@ namespace Lucene.Net.Contrib.Spatial.Tes
public static readonly String DATA_COUNTRIES_BBOX = "countries-bbox.txt";
public static readonly String DATA_WORLD_CITIES_POINTS = "world-cities-points.txt";
- public static readonly String QTEST_States_IsWithin_BBox = "states-IsWithin-BBox.txt";
+ public static readonly String QTEST_Cities_Intersects_BBox = "cities-Intersects-BBox.txt";
public static readonly String QTEST_States_Intersects_BBox = "states-Intersects-BBox.txt";
public static readonly String QTEST_Cities_IsWithin_BBox = "cities-IsWithin-BBox.txt";
public static readonly String QTEST_Simple_Queries_BBox = "simple-Queries-BBox.txt";