lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [08/26] lucenenet git commit: Added missing Spatial classes, ported Spatial tests, and fixed several bugs
Date Fri, 25 Nov 2016 11:07:13 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d8c73530/src/Lucene.Net.Tests.Spatial/Test-Files/cities-Intersects-BBox.txt
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/Test-Files/cities-Intersects-BBox.txt b/src/Lucene.Net.Tests.Spatial/Test-Files/cities-Intersects-BBox.txt
new file mode 100644
index 0000000..e85748c
--- /dev/null
+++ b/src/Lucene.Net.Tests.Spatial/Test-Files/cities-Intersects-BBox.txt
@@ -0,0 +1,3 @@
+[San Francisco] G5391959 @ Intersects(ENVELOPE(-122.524918, -122.360123, 37.817108, 37.674973))
+[Wellington] G2179537 @ Intersects(ENVELOPE(174.711456, 174.854279, -41.213837, -41.360779))
+[Barcelona] G6544100 G3128760  @  Intersects(ENVELOPE(2.127228, 2.226105, 41.408844, 41.333313))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d8c73530/src/Lucene.Net.Tests.Spatial/Test-Files/simple-Queries-BBox.txt
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/Test-Files/simple-Queries-BBox.txt b/src/Lucene.Net.Tests.Spatial/Test-Files/simple-Queries-BBox.txt
new file mode 100644
index 0000000..7aacc9b
--- /dev/null
+++ b/src/Lucene.Net.Tests.Spatial/Test-Files/simple-Queries-BBox.txt
@@ -0,0 +1,8 @@
+C5 @ IsWithin(ENVELOPE(-6, 6, 6, -6))
+C5 @ BBoxWithin(ENVELOPE(-6, 6, 6, -6))
+C10 @ Contains(ENVELOPE(-6, 6, 6, -6))
+C10 @ IsEqualTo(ENVELOPE(-10, 10, 10, -10))
+C5 C10 @ Intersects(ENVELOPE(-2, 2, 2, -2))
+C5 C10 @ Overlaps(ENVELOPE(-2, 2, 2, -2))
+C5 C10 @ BBoxIntersects(ENVELOPE(-2, 2, 2, -2))
+NW15 @ IsDisjointTo(ENVELOPE(-10, 10, 10, -10))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d8c73530/src/Lucene.Net.Tests.Spatial/Test-Files/states-Intersects-BBox.txt
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/Test-Files/states-Intersects-BBox.txt b/src/Lucene.Net.Tests.Spatial/Test-Files/states-Intersects-BBox.txt
new file mode 100644
index 0000000..a45df7b
--- /dev/null
+++ b/src/Lucene.Net.Tests.Spatial/Test-Files/states-Intersects-BBox.txt
@@ -0,0 +1,3 @@
+WY CO	@ Intersects(ENVELOPE(-106.964844, -105.734375, 42.800781, 39.460938))
+TX @ Intersects(ENVELOPE(-99.669922, -98.439453, 32.253906, 30.583984))
+MS TX LA @ Intersects(ENVELOPE(-95.363281, -90.133789, 32.473633, 29.792969))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d8c73530/src/Lucene.Net.Tests.Spatial/Test-Files/states-IsWithin-BBox.txt
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/Test-Files/states-IsWithin-BBox.txt b/src/Lucene.Net.Tests.Spatial/Test-Files/states-IsWithin-BBox.txt
new file mode 100644
index 0000000..6a504da
--- /dev/null
+++ b/src/Lucene.Net.Tests.Spatial/Test-Files/states-IsWithin-BBox.txt
@@ -0,0 +1,4 @@
+KS	@ IsWithin(ENVELOPE(-103.493164, -93.825195, 41.086914, 36.208984))
+WA @ IsWithin(ENVELOPE(-126.916016, -115.314453, 50.688965, 44.36084))
+MA CT RI @ IsWithin(ENVELOPE(-73.894043, -69.521484, 43.198242, 40.825195))
+AL GA @ IsWithin(ENVELOPE(-89.472656, -80.244141, 35.90332, 29.311523))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d8c73530/src/Lucene.Net.Tests.Spatial/TestTestFramework.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/TestTestFramework.cs b/src/Lucene.Net.Tests.Spatial/TestTestFramework.cs
new file mode 100644
index 0000000..72f99c1
--- /dev/null
+++ b/src/Lucene.Net.Tests.Spatial/TestTestFramework.cs
@@ -0,0 +1,63 @@
+using Lucene.Net.Spatial.Queries;
+using Lucene.Net.Util;
+using NUnit.Framework;
+using Spatial4n.Core.Context;
+using Spatial4n.Core.Shapes;
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace Lucene.Net.Spatial
+{
+    /*
+     * Licensed to the Apache Software Foundation (ASF) under one or more
+     * contributor license agreements.  See the NOTICE file distributed with
+     * this work for additional information regarding copyright ownership.
+     * The ASF licenses this file to You under the Apache License, Version 2.0
+     * (the "License"); you may not use this file except in compliance with
+     * the License.  You may obtain a copy of the License at
+     *
+     *     http://www.apache.org/licenses/LICENSE-2.0
+     *
+     * Unless required by applicable law or agreed to in writing, software
+     * distributed under the License is distributed on an "AS IS" BASIS,
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     * See the License for the specific language governing permissions and
+     * limitations under the License.
+     */
+
+    public class TestTestFramework : LuceneTestCase
+    {
+        [Test]
+        public virtual void TestQueries()
+        {
+            String name = StrategyTestCase.RESOURCE_PATH + StrategyTestCase.QTEST_Cities_Intersects_BBox;
+
+            Stream @in = GetType().Assembly.GetManifestResourceStream(name);
+            SpatialContext ctx = SpatialContext.GEO;
+            IEnumerator<SpatialTestQuery> iter = SpatialTestQuery.GetTestQueries(
+                new SpatialArgsParser(), ctx, name, @in);//closes the InputStream
+            List<SpatialTestQuery> tests = new List<SpatialTestQuery>();
+            while (iter.MoveNext())
+            {
+                tests.Add(iter.Current);
+            }
+            assertEquals(3, tests.size());
+
+            SpatialTestQuery sf = tests[0];
+            // assert
+            assertEquals(1, sf.ids.size());
+            assertTrue(sf.ids[0].equals("G5391959"));
+            assertTrue(sf.args.Shape is IRectangle);
+            assertEquals(SpatialOperation.Intersects, sf.args.Operation);
+        }
+
+        [Test]
+        public virtual void SpatialExample_Mem()
+        {
+            //kind of a hack so that SpatialExample is tested despite
+            // it not starting or ending with "Test".
+            SpatialExample.Main(null);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d8c73530/src/Lucene.Net.Tests.Spatial/Vector/TestPointVectorStrategy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/Vector/TestPointVectorStrategy.cs b/src/Lucene.Net.Tests.Spatial/Vector/TestPointVectorStrategy.cs
new file mode 100644
index 0000000..a43faf0
--- /dev/null
+++ b/src/Lucene.Net.Tests.Spatial/Vector/TestPointVectorStrategy.cs
@@ -0,0 +1,61 @@
+using Lucene.Net.Search;
+using Lucene.Net.Spatial.Queries;
+using NUnit.Framework;
+using Spatial4n.Core.Context;
+using Spatial4n.Core.Shapes;
+using System;
+
+namespace Lucene.Net.Spatial.Vector
+{
+    /*
+     * Licensed to the Apache Software Foundation (ASF) under one or more
+     * contributor license agreements.  See the NOTICE file distributed with
+     * this work for additional information regarding copyright ownership.
+     * The ASF licenses this file to You under the Apache License, Version 2.0
+     * (the "License"); you may not use this file except in compliance with
+     * the License.  You may obtain a copy of the License at
+     *
+     *     http://www.apache.org/licenses/LICENSE-2.0
+     *
+     * Unless required by applicable law or agreed to in writing, software
+     * distributed under the License is distributed on an "AS IS" BASIS,
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     * See the License for the specific language governing permissions and
+     * limitations under the License.
+     */
+
+    public class TestPointVectorStrategy : StrategyTestCase
+    {
+        public override void SetUp()
+        {
+            base.SetUp();
+            this.ctx = SpatialContext.GEO;
+            this.strategy = new PointVectorStrategy(ctx, GetType().Name);
+        }
+
+        [Test]
+        public virtual void TestCircleShapeSupport()
+        {
+            ICircle circle = ctx.MakeCircle(ctx.MakePoint(0, 0), 10);
+            SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);
+            Query query = this.strategy.MakeQuery(args);
+
+            assertNotNull(query);
+        }
+
+        [Test]
+        public virtual void TestInvalidQueryShape()
+        {
+            IPoint point = ctx.MakePoint(0, 0);
+            SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, point);
+            Assert.Throws<NotSupportedException>(() => this.strategy.MakeQuery(args));
+        }
+
+        [Test]
+        public virtual void TestCitiesIntersectsBBox()
+        {
+            getAddAndVerifyIndexedDocuments(DATA_WORLD_CITIES_POINTS);
+            executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_Intersects_BBox);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d8c73530/src/Lucene.Net.Tests.Spatial/packages.config
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/packages.config b/src/Lucene.Net.Tests.Spatial/packages.config
new file mode 100644
index 0000000..139d513
--- /dev/null
+++ b/src/Lucene.Net.Tests.Spatial/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="NUnit" version="2.6.3" targetFramework="net451" />
+</packages>
\ No newline at end of file


Mime
View raw message