Re: [Lucene.Net] [jira] [Commented] (LUCENENET-431) Spatial.Net Cartesian won't find docs in radius in certain cases

2011-07-06 Thread Matt Warren
I've been looking at this with Olle over on the RavenDB mailing list.

Just to add that this patch
https://issues.apache.org/jira/secure/attachment/12420781/LUCENE-1930.patch
solves
the issue also. It's from this issue
https://issues.apache.org/jira/browse/LUCENE-1930

But it's more complicated than the fix you propose. As far as I can tell it
uses a completely different method of projecting locations, but I don't
really know much about how it works other than that.

On 6 July 2011 14:33, Digy (JIRA) j...@apache.org wrote:


[
 https://issues.apache.org/jira/browse/LUCENENET-431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13060571#comment-13060571]

 Digy commented on LUCENENET-431:
 

 Hi Olle,

 {code}
static double TransformLat(double lat)
{
var PI = 3.14159265358979323846;
return (Math.Atan(Math.Exp((lat * 180 / 20037508.34) / 180 *
 PI)) / PI * 360 - 90) * 10;
}


static double TransformLon(double lon)
{
return (lon * 180 / 20037508.34) * 10;
}

 

 private double _lat = TransformLat(55.6880508001);
 private double _lng = TransformLon(13.5871808352); // This passes:
 13.6271808352

 

 private void AddData(IndexWriter writer)
{
AddPoint(writer, Within radius, TransformLat(55.6880508001),
 TransformLon(13.5717346673));
AddPoint(writer, Within radius, TransformLat(55.6821978456),
 TransformLon(13.6076183965));
AddPoint(writer, Within radius, TransformLat(55.673251569),
 TransformLon(13.5946697607));
AddPoint(writer, Close but not in radius,
 TransformLat(55.8634157297), TransformLon(13.5497731987));
AddPoint(writer, Faar away, TransformLat(40.7137578228),
 TransformLon(-74.0126901936));

writer.Commit();
writer.Close();
}
 {code}

 When I change your code as above, it seems to work(According to above
 functions yours 4th point should be 11 miles away).

 If this works for all your cases, we can think of a patch for Spatial.Net.
 (Don't ask what these two functions do, since I found them somewhere in
 OpenLayers project :) )
 Maybe someone can explain these projection issues(if this really is the
 case).

 DIGY



  Spatial.Net Cartesian won't find docs in radius in certain cases
  
 
  Key: LUCENENET-431
  URL: https://issues.apache.org/jira/browse/LUCENENET-431
  Project: Lucene.Net
   Issue Type: Bug
   Components: Lucene.Net Contrib
 Affects Versions: Lucene.Net 2.9.4
  Environment: Windows 7 x64
 Reporter: Olle Jacobsen
   Labels: spatialsearch
 
  To replicate change Lucene.Net.Contrib.Spatial.Test.TestCartesian to the
 following witch should return 3 results.
  Line
  42: private double _lat = 55.6880508001;
  43: private double _lng = 13.5871808352; // This passes: 13.6271808352
  73: AddPoint(writer, Within radius, 55.6880508001, 13.5717346673);
  74: AddPoint(writer, Within radius, 55.6821978456, 13.6076183965);
  75: AddPoint(writer, Within radius, 55.673251569, 13.5946697607);
  76: AddPoint(writer, Close but not in radius, 55.8634157297,
 13.5497731987);
  77: AddPoint(writer, Faar away, 40.7137578228, -74.0126901936);
  130: const double miles = 5.0;
  156: Console.WriteLine(Distances should be 3  + distances.Count);
  157: Console.WriteLine(Results should be 3  + results);
  159: Assert.AreEqual(3, distances.Count); // fixed a store of only needed
 distances
  160: Assert.AreEqual(3, results);

 --
 This message is automatically generated by JIRA.
 For more information on JIRA, see: http://www.atlassian.com/software/jira





[Lucene.Net] Possible bug in Lucene with Prefix Search and Danish Locale

2011-06-30 Thread Matt Warren
I think that the code here shows a bug in Lucene.NET, see
http://gist.github.com/1056231.
This happens when using 2.9.2.

After some digging I think that it's due to the way it does a Prefix search.

The main problem is shown by this code http://gist.github.com/1056242.
If the Locale is Danish, this returns FALSE, weird eh!!
   daab.StartsWith(da) //false
But this works as expected
   daab.StartsWith(da, StringComparison.InvariantCulture) //true

The line of code that has this problem is the TermCompare(..) function in
PrefixTermEnum.cs,
see
http://svn.apache.org/repos/asf/incubator/lucene.net/trunk/src/core/Search/PrefixTermEnum.cs


Re: [Lucene.Net] Possible bug in Lucene with Prefix Search and Danish Locale

2011-06-30 Thread Matt Warren
Thanks for the info, after reading issue 420 it makes sense now

On 30 June 2011 15:38, Ben West bwsithspaw...@yahoo.com wrote:

 Hey Matt,

 This is issue 420: https://issues.apache.org/jira/browse/LUCENENET-420

 I think the theory so far has been that the user should manage the culture
 rather than Lucene. If you disagree could you post on that issue ticket?

 Thanks,
 -Ben


 - Original Message -
 From: Matt Warren mattd...@gmail.com
 To: lucene-net-...@lucene.apache.org
 Cc:
 Sent: Thursday, June 30, 2011 9:28 AM
 Subject: [Lucene.Net] Possible bug in Lucene with Prefix Search and Danish
 Locale

 I think that the code here shows a bug in Lucene.NET, see
 http://gist.github.com/1056231.
 This happens when using 2.9.2.

 After some digging I think that it's due to the way it does a Prefix
 search.

 The main problem is shown by this code http://gist.github.com/1056242.
 If the Locale is Danish, this returns FALSE, weird eh!!
daab.StartsWith(da) //false
 But this works as expected
daab.StartsWith(da, StringComparison.InvariantCulture) //true

 The line of code that has this problem is the TermCompare(..) function in
 PrefixTermEnum.cs,
 see

 http://svn.apache.org/repos/asf/incubator/lucene.net/trunk/src/core/Search/PrefixTermEnum.cs