Lucene.Net
  1. Lucene.Net
  2. LUCENENET-431

Spatial.Net Cartesian won't find docs in radius in certain cases

    Details

      Description

      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);

        Activity

        Hide
        Prescott Nasser added a comment -

        Commited to trunk

        Show
        Prescott Nasser added a comment - Commited to trunk
        Hide
        Prescott Nasser added a comment -

        Updating affected builds

        Show
        Prescott Nasser added a comment - Updating affected builds
        Hide
        Prescott Nasser added a comment -

        Patch for the trunk

        Show
        Prescott Nasser added a comment - Patch for the trunk
        Hide
        Digy added a comment -

        Thanks Olle and Matt,

        I committed the LUCENE-1930 patch to the 2.9.4g branch (+ added Olle's test case).

        (Another divergence from lucene.java; since this patch is still waiting to be applied).

        DIGY

        Show
        Digy added a comment - Thanks Olle and Matt, I committed the LUCENE-1930 patch to the 2.9.4g branch (+ added Olle's test case). (Another divergence from lucene.java; since this patch is still waiting to be applied). DIGY
        Hide
        Digy added a comment -

        Hi Olle,

                static double TransformLat(double lat)
                {
                    var PI = 3.14159265358979323846;
                    return (Math.Atan(Math.Exp((lat * 180 / 20037508.34) / 180 * PI)) / PI * 360 - 90) * 100000;
                }
        
        
                static double TransformLon(double lon)
                {
                    return (lon * 180 / 20037508.34) * 100000;
                }
        
        ....
        
        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();
                }
        

        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

        Show
        Digy added a comment - Hi Olle, static double TransformLat( double lat) { var PI = 3.14159265358979323846; return ( Math .Atan( Math .Exp((lat * 180 / 20037508.34) / 180 * PI)) / PI * 360 - 90) * 100000; } static double TransformLon( double lon) { return (lon * 180 / 20037508.34) * 100000; } .... 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(); } 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

          People

          • Assignee:
            Prescott Nasser
            Reporter:
            Olle Jacobsen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development