lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject svn commit: r1405531 - in /lucene.net/trunk: src/contrib/Spatial/Queries/ test/contrib/Spatial/ test/contrib/Spatial/Prefix/
Date Sun, 04 Nov 2012 11:40:21 GMT
Author: synhershko
Date: Sun Nov  4 11:40:21 2012
New Revision: 1405531

URL: http://svn.apache.org/viewvc?rev=1405531&view=rev
Log:
Partial port of LUCENE-4444 , plus one passing test of using LineString

Added:
    lucene.net/trunk/test/contrib/Spatial/Prefix/NtsPolygonTest.cs
Modified:
    lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs
    lucene.net/trunk/test/contrib/Spatial/Contrib.Spatial.Tests.csproj
    lucene.net/trunk/test/contrib/Spatial/PortedSolr3Test.cs
    lucene.net/trunk/test/contrib/Spatial/Prefix/TestRecursivePrefixTreeStrategy.cs
    lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs

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=1405531&r1=1405530&r2=1405531&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Queries/SpatialArgsParser.cs Sun Nov  4 11:40:21
2012
@@ -74,7 +74,7 @@ namespace Lucene.Net.Spatial.Queries
 				throw new ArgumentException("missing body : " + v);
 			}
 
-            Shape shape = new ShapeReadWriter(ctx).ReadShape(body);
+            var shape = ctx.ReadShape(body);
 			var args = new SpatialArgs(op, shape);
 
 			if (v.Length > (edx + 1))

Modified: lucene.net/trunk/test/contrib/Spatial/Contrib.Spatial.Tests.csproj
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/Contrib.Spatial.Tests.csproj?rev=1405531&r1=1405530&r2=1405531&view=diff
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/Contrib.Spatial.Tests.csproj (original)
+++ lucene.net/trunk/test/contrib/Spatial/Contrib.Spatial.Tests.csproj Sun Nov  4 11:40:21
2012
@@ -123,6 +123,7 @@
     <Compile Include="Compatibility\TermsFilterTest.cs" />
     <Compile Include="DistanceStrategyTest.cs" />
     <Compile Include="PortedSolr3Test.cs" />
+    <Compile Include="Prefix\NtsPolygonTest.cs" />
     <Compile Include="Prefix\TestRecursivePrefixTreeStrategy.cs" />
     <Compile Include="Prefix\TestTermQueryPrefixGridStrategy.cs" />
     <Compile Include="Prefix\Tree\SpatialPrefixTreeTest.cs" />

Modified: lucene.net/trunk/test/contrib/Spatial/PortedSolr3Test.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/PortedSolr3Test.cs?rev=1405531&r1=1405530&r2=1405531&view=diff
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/PortedSolr3Test.cs (original)
+++ lucene.net/trunk/test/contrib/Spatial/PortedSolr3Test.cs Sun Nov  4 11:40:21 2012
@@ -158,7 +158,7 @@ namespace Lucene.Net.Contrib.Spatial.Tes
         private void _checkHits(bool bbox, String ptStr, double distKM, int assertNumFound,
params int[] assertIds)
         {
             SpatialOperation op = SpatialOperation.Intersects;
-            Point pt = (Point) new ShapeReadWriter(ctx).ReadShape(ptStr);
+            var pt = (Point) ctx.ReadShape(ptStr);
             double distDEG = DistanceUtils.Dist2Degrees(distKM, DistanceUtils.EARTH_MEAN_RADIUS_KM);
             Shape shape = ctx.MakeCircle(pt, distDEG);
             if (bbox)

Added: lucene.net/trunk/test/contrib/Spatial/Prefix/NtsPolygonTest.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/Prefix/NtsPolygonTest.cs?rev=1405531&view=auto
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/Prefix/NtsPolygonTest.cs (added)
+++ lucene.net/trunk/test/contrib/Spatial/Prefix/NtsPolygonTest.cs Sun Nov  4 11:40:21 2012
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Lucene.Net.Documents;
+using Lucene.Net.Spatial.Prefix;
+using Lucene.Net.Spatial.Prefix.Tree;
+using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Support;
+using NUnit.Framework;
+using Spatial4n.Core.Context;
+using Spatial4n.Core.Context.Nts;
+using Spatial4n.Core.Io.Samples;
+using Spatial4n.Core.Shapes;
+
+namespace Lucene.Net.Contrib.Spatial.Test.Prefix
+{
+	public class NtsPolygonTest : StrategyTestCase
+	{
+		private static readonly double LUCENE_4464_distErrPct = SpatialArgs.DEFAULT_DISTERRPCT;//DEFAULT
2.5%
+
+		public NtsPolygonTest()
+		{
+			//var args = new HashMap<String, String> {{"spatialContextFactory", "com.spatial4j.core.context.jts.JtsSpatialContextFactory"}};
+			//SpatialContextFactory.MakeSpatialContext(args, getClass().getClassLoader());
+			ctx = new NtsSpatialContext(true);
+
+			var grid = new GeohashPrefixTree(ctx, 11);//< 1 meter == 11 maxLevels
+			this.strategy = new RecursivePrefixTreeStrategy(grid, GetType().Name);
+			((RecursivePrefixTreeStrategy)this.strategy).DistErrPct = LUCENE_4464_distErrPct;//1%
radius (small!)
+		}
+
+		[Test]
+		public void testLineStrings()
+		{
+			var sdIterator = new List<SampleData>
+                                              {
+                                                  new SampleData("LineB\tLineB\tLINESTRING
(0 1, 1 1, 2 1)"),
+                                                  new SampleData("LineC\tLineC\tLINESTRING
(0 1, 0.8 0.8, 2 1)"),
+                                                  new SampleData("LineD\tLineD\tLINESTRING
(0 1, 0.5 1, 2 1)")
+                                              };
+
+			ctx = NtsSpatialContext.GEO;
+			List<Document> testDocuments = getDocumentsNts(sdIterator.GetEnumerator());
+			addDocumentsAndCommit(testDocuments);
+			verifyDocumentsIndexed(testDocuments.Count);
+
+			var lineA = ctx.ReadShape("LINESTRING (0 0, 1 1, 1 2)");
+			var args = new SpatialArgs(SpatialOperation.Intersects, lineA);
+			var got = executeQuery(strategy.MakeQuery(args), 100);
+			assertEquals(3, got.numFound); //found all 3
+		}
+	}
+}

Modified: lucene.net/trunk/test/contrib/Spatial/Prefix/TestRecursivePrefixTreeStrategy.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/Prefix/TestRecursivePrefixTreeStrategy.cs?rev=1405531&r1=1405530&r2=1405531&view=diff
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/Prefix/TestRecursivePrefixTreeStrategy.cs (original)
+++ lucene.net/trunk/test/contrib/Spatial/Prefix/TestRecursivePrefixTreeStrategy.cs Sun Nov
 4 11:40:21 2012
@@ -17,7 +17,6 @@
 
 using System;
 using System.Collections.Generic;
-using Lucene.Net.Documents;
 using Lucene.Net.Spatial.Prefix;
 using Lucene.Net.Spatial.Prefix.Tree;
 using Lucene.Net.Spatial.Queries;
@@ -25,7 +24,6 @@ using NUnit.Framework;
 using Spatial4n.Core.Context;
 using Spatial4n.Core.Distance;
 using Spatial4n.Core.Shapes;
-using Spatial4n.Core.Shapes.Impl;
 using Spatial4n.Core.Util;
 
 namespace Lucene.Net.Contrib.Spatial.Test.Prefix

Modified: lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs?rev=1405531&r1=1405530&r2=1405531&view=diff
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs (original)
+++ lucene.net/trunk/test/contrib/Spatial/StrategyTestCase.cs Sun Nov  4 11:40:21 2012
@@ -28,6 +28,7 @@ using Lucene.Net.Spatial.Util;
 using Lucene.Net.Util;
 using NUnit.Framework;
 using Spatial4n.Core.Context;
+using Spatial4n.Core.Context.Nts;
 using Spatial4n.Core.Io;
 using Spatial4n.Core.Io.Samples;
 using Spatial4n.Core.Shapes;
@@ -84,7 +85,11 @@ namespace Lucene.Net.Contrib.Spatial.Tes
 
         protected List<Document> getDocuments(String testDataFile)
         {
-            IEnumerator<SampleData> sampleData = getSampleData(testDataFile);
+            return getDocuments(getSampleData(testDataFile));
+        }
+
+        protected List<Document> getDocuments(IEnumerator<SampleData> sampleData)
+        {
             var documents = new List<Document>();
             while (sampleData.MoveNext())
             {
@@ -110,7 +115,12 @@ namespace Lucene.Net.Contrib.Spatial.Tes
             return documents;
         }
 
-        /* Subclasses may override to transform or remove a shape for indexing */
+
+                documents.Add(document);
+            }
+            return documents;
+        }
+
 
         protected virtual Shape convertShapeFromGetDocuments(Shape shape)
         {
@@ -146,8 +156,7 @@ namespace Lucene.Net.Contrib.Spatial.Tes
                 if (storeShape && got.numFound > 0)
                 {
                     //check stored value is there & parses
-                    assertNotNull(
-                        new ShapeReadWriter(ctx).ReadShape(got.results[0].document.Get(strategy.GetFieldName())));
+                    assertNotNull(ctx.ReadShape(got.results[0].document.Get(strategy.GetFieldName())));
                 }
                 if (concern.orderIsImportant)
                 {
@@ -206,7 +215,7 @@ namespace Lucene.Net.Contrib.Spatial.Tes
 
         protected void adoc(String id, String shapeStr)
         {
-            Shape shape = shapeStr == null ? null : new ShapeReadWriter(ctx).ReadShape(shapeStr);
+            Shape shape = shapeStr == null ? null : ctx.ReadShape(shapeStr);
             addDocument(newDoc(id, shape));
         }
 



Mime
View raw message