From lucene-net-commits-return-2070-apmail-lucene-lucene-net-commits-archive=lucene.apache.org@lucene.apache.org Mon Aug 20 21:40:52 2012 Return-Path: X-Original-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Delivered-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C49F3656 for ; Mon, 20 Aug 2012 21:40:52 +0000 (UTC) Received: (qmail 97549 invoked by uid 500); 20 Aug 2012 21:40:52 -0000 Delivered-To: apmail-lucene-lucene-net-commits-archive@lucene.apache.org Received: (qmail 97517 invoked by uid 500); 20 Aug 2012 21:40:52 -0000 Mailing-List: contact lucene-net-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucene.apache.org Delivered-To: mailing list lucene-net-commits@lucene.apache.org Received: (qmail 97510 invoked by uid 99); 20 Aug 2012 21:40:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Aug 2012 21:40:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Aug 2012 21:40:49 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 968C323889E3; Mon, 20 Aug 2012 21:40:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1375236 - in /incubator/lucene.net/trunk: build/vs2010/contrib/ src/contrib/Spatial/ src/contrib/Spatial/Prefix/ src/contrib/Spatial/Vector/ Date: Mon, 20 Aug 2012 21:40:04 -0000 To: lucene-net-commits@lucene.apache.org From: synhershko@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120820214004.968C323889E3@eris.apache.org> Author: synhershko Date: Mon Aug 20 21:40:03 2012 New Revision: 1375236 URL: http://svn.apache.org/viewvc?rev=1375236&view=rev Log: Catching up the spatial module (core, not tests yet) LUCENE-4166, LUCENE-4157. Still need to port TermsFilter. Modified: incubator/lucene.net/trunk/build/vs2010/contrib/Contrib.Spatial.sln incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs incubator/lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs incubator/lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs Modified: incubator/lucene.net/trunk/build/vs2010/contrib/Contrib.Spatial.sln URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/build/vs2010/contrib/Contrib.Spatial.sln?rev=1375236&r1=1375235&r2=1375236&view=diff ============================================================================== --- incubator/lucene.net/trunk/build/vs2010/contrib/Contrib.Spatial.sln (original) +++ incubator/lucene.net/trunk/build/vs2010/contrib/Contrib.Spatial.sln Mon Aug 20 21:40:03 2012 @@ -1,34 +1,34 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "..\..\..\src\core\Lucene.Net.csproj", "{5D4AD9BE-1FFB-41AB-9943-25737971BF57}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Spatial", "..\..\..\src\contrib\Spatial\Contrib.Spatial.csproj", "{35C347F4-24B2-4BE5-8117-A0E3001551CE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug35|Any CPU = Debug35|Any CPU Debug|Any CPU = Debug|Any CPU - Release35|Any CPU = Release35|Any CPU + Debug35|Any CPU = Debug35|Any CPU Release|Any CPU = Release|Any CPU + Release35|Any CPU = Release35|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug35|Any CPU.Build.0 = Debug35|Any CPU - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release35|Any CPU.ActiveCfg = Release35|Any CPU - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release35|Any CPU.Build.0 = Release35|Any CPU - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release|Any CPU.Build.0 = Release|Any CPU - {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU - {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug35|Any CPU.Build.0 = Debug35|Any CPU {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release35|Any CPU.ActiveCfg = Release35|Any CPU - {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release35|Any CPU.Build.0 = Release35|Any CPU + {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU + {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug35|Any CPU.Build.0 = Debug35|Any CPU {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.ActiveCfg = Release|Any CPU {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.Build.0 = Release|Any CPU + {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release35|Any CPU.ActiveCfg = Release35|Any CPU + {5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release35|Any CPU.Build.0 = Release35|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Debug35|Any CPU.Build.0 = Debug35|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release|Any CPU.Build.0 = Release|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release35|Any CPU.ActiveCfg = Release35|Any CPU + {35C347F4-24B2-4BE5-8117-A0E3001551CE}.Release35|Any CPU.Build.0 = Release35|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs?rev=1375236&r1=1375235&r2=1375236&view=diff ============================================================================== --- incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs (original) +++ incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/RecursivePrefixTreeStrategy.cs Mon Aug 20 21:40:03 2012 @@ -25,6 +25,9 @@ using Spatial4n.Core.Shapes; namespace Lucene.Net.Spatial.Prefix { + /// + /// Based on {@link RecursivePrefixTreeFilter}. + /// public class RecursivePrefixTreeStrategy : PrefixTreeStrategy { private int prefixGridScanLevel;//TODO how is this customized? @@ -40,25 +43,17 @@ namespace Lucene.Net.Spatial.Prefix this.prefixGridScanLevel = prefixGridScanLevel; } - public override Query MakeQuery(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) - { - Filter f = MakeFilter(args, fieldInfo); - - ValueSource vs = MakeValueSource(args, fieldInfo); - return new FilteredQuery(new FunctionQuery(vs), f); - } - public override Filter MakeFilter(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) { var op = args.Operation; - if (!SpatialOperation.Is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin)) + if (!SpatialOperation.Is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin, SpatialOperation.BBoxIntersects)) throw new UnsupportedSpatialOperation(op); - Shape qshape = args.GetShape(); + Shape shape = args.GetShape(); - int detailLevel = grid.GetMaxLevelForPrecision(qshape, args.GetDistPrecision()); + int detailLevel = grid.GetMaxLevelForPrecision(shape, args.GetDistPrecision()); - return new RecursivePrefixTreeFilter(fieldInfo.GetFieldName(), grid, qshape, prefixGridScanLevel, detailLevel); + return new RecursivePrefixTreeFilter(fieldInfo.GetFieldName(), grid, shape, prefixGridScanLevel, detailLevel); } public override string ToString() Modified: incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs?rev=1375236&r1=1375235&r2=1375236&view=diff ============================================================================== --- incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs (original) +++ incubator/lucene.net/trunk/src/contrib/Spatial/Prefix/TermQueryPrefixTreeStrategy.cs Mon Aug 20 21:40:03 2012 @@ -20,9 +20,14 @@ using Lucene.Net.Search; using Lucene.Net.Spatial.Prefix.Tree; using Spatial4n.Core.Exceptions; using Spatial4n.Core.Query; +using Spatial4n.Core.Shapes; namespace Lucene.Net.Spatial.Prefix { + /// + /// A basic implementation using a large {@link TermsFilter} of all the nodes from + /// {@link SpatialPrefixTree#getNodes(com.spatial4j.core.shape.Shape, int, boolean)}. + /// public class TermQueryPrefixTreeStrategy : PrefixTreeStrategy { public TermQueryPrefixTreeStrategy(SpatialPrefixTree grid) @@ -30,30 +35,23 @@ namespace Lucene.Net.Spatial.Prefix { } - public override Query MakeQuery(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) + public override Filter MakeFilter(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) { - if (args.Operation != SpatialOperation.Intersects && - args.Operation != SpatialOperation.IsWithin && - args.Operation != SpatialOperation.Overlaps) - { - // TODO -- can translate these other query types - throw new UnsupportedSpatialOperation(args.Operation); - } - var qshape = args.GetShape(); - int detailLevel = grid.GetMaxLevelForPrecision(qshape, args.GetDistPrecision()); - var cells = grid.GetNodes(qshape, detailLevel, false); + SpatialOperation op = args.Operation; + if ( + !SpatialOperation.Is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin, + SpatialOperation.BBoxIntersects)) + throw new UnsupportedSpatialOperation(op); - var booleanQuery = new BooleanQuery(); - foreach (var cell in cells) + Shape shape = args.GetShape(); + int detailLevel = grid.GetMaxLevelForPrecision(shape, args.GetDistPrecision()); + var cells = grid.GetNodes(shape, detailLevel, false); + var filter = new TermsFilter(); + foreach (Node cell in cells) { - booleanQuery.Add(new TermQuery(new Term(fieldInfo.GetFieldName(), cell.GetTokenString())), Occur.SHOULD); + filter.AddTerm(new Term(fieldInfo.GetFieldName(), cell.GetTokenString())); } - return booleanQuery; - } - - public override Filter MakeFilter(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) - { - return new QueryWrapperFilter(MakeQuery(args, fieldInfo)); + return filter; } } } Modified: incubator/lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs?rev=1375236&r1=1375235&r2=1375236&view=diff ============================================================================== --- incubator/lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs (original) +++ incubator/lucene.net/trunk/src/contrib/Spatial/SpatialStrategy.cs Mon Aug 20 21:40:03 2012 @@ -18,6 +18,7 @@ using Lucene.Net.Documents; using Lucene.Net.Search; using Lucene.Net.Search.Function; +using Lucene.Net.Spatial.Util; using Spatial4n.Core.Context; using Spatial4n.Core.Query; using Spatial4n.Core.Shapes; @@ -61,15 +62,29 @@ namespace Lucene.Net.Spatial return new AbstractField[] { CreateField(fieldInfo, shape, index, store) }; } + /// + /// The value source yields a number that is proportional to the distance between the query shape and indexed data. + /// + /// + /// + /// public abstract ValueSource MakeValueSource(SpatialArgs args, T fieldInfo); /// - /// Make a query + /// Make a query which has a score based on the distance from the data to the query shape. + /// The default implementation constructs a {@link FilteredQuery} based on + /// {@link #makeFilter(com.spatial4j.core.query.SpatialArgs, SpatialFieldInfo)} and + /// {@link #makeValueSource(com.spatial4j.core.query.SpatialArgs, SpatialFieldInfo)}. /// /// /// /// - public abstract Query MakeQuery(SpatialArgs args, T fieldInfo); + public virtual Query MakeQuery(SpatialArgs args, T fieldInfo) + { + Filter filter = MakeFilter(args, fieldInfo); + ValueSource vs = MakeValueSource(args, fieldInfo); + return new FilteredQuery(new FunctionQuery(vs), filter); + } /// /// Make a Filter Modified: incubator/lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs?rev=1375236&r1=1375235&r2=1375236&view=diff ============================================================================== --- incubator/lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs (original) +++ incubator/lucene.net/trunk/src/contrib/Spatial/Vector/TwoDoublesStrategy.cs Mon Aug 20 21:40:03 2012 @@ -83,12 +83,11 @@ namespace Lucene.Net.Spatial.Vector { // For starters, just limit the bbox var shape = args.GetShape(); - var bbox = shape as Rectangle; - if (bbox == null) - { - throw new InvalidShapeException("A rectangle is the only supported shape (so far), not " + shape.GetType().Name);//TODO - } + if (!(shape is Rectangle || shape is Circle)) + throw new InvalidShapeException("Only Rectangles and Circles are currently supported, found [" + + shape.GetType().Name + "]");//TODO + Rectangle bbox = shape.GetBoundingBox(); if (bbox.GetCrossesDateLine()) { throw new InvalidOperationException("Crossing dateline not yet supported");