Skip to content

LatLonShapePolygon and LineQuery fail on shared dateline queries [LUCENE-8721] #9767

@asfimport

Description

@asfimport

Indexed shapes should be returned with search geometries that share the dateline on the opposite hemisphere.

For example:

  public void testSharedDateline() throws Exception {
    //// index /////
    Directory dir = newDirectory();
    RandomIndexWriter w = new RandomIndexWriter(random(), dir);
    Document doc = new Document();
    // index western hemisphere geometry
    Polygon indexPoly = new Polygon(
        new double[] {-7.5d, 15d, 15d, 0d, -7.5d},
        new double[] {-180d, -180d, -176d, -176d, -180d}
    );
    Field[] fields = LatLonShape.createIndexableFields("test", indexPoly);
    for (Field f : fields) {
      doc.add(f);
    }
    w.addDocument(doc);
    w.forceMerge(1);

    ///// search //////
    IndexReader reader = w.getReader();
    w.close();
    IndexSearcher searcher = newSearcher(reader);
    // search w/ eastern hemisphere geometry that shares the dateline
    Polygon searchPoly = new Polygon(new double[] {-7.5d, 15d, 15d, 0d, -7.5d},
        new double[] {180d, 180d, 170d, 170d, 180d});
    Query q = LatLonShape.newPolygonQuery("test", QueryRelation.INTERSECTS, searchPoly);
    assertEquals(1, searcher.count(q));
    IOUtils.close(w, reader, dir);
  }

Migrated from LUCENE-8721 by Nick Knize (@nknize), updated Mar 13 2019
Attachments: LUCENE-8721.patch (versions: 2)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions