apache / apache/lucene

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

Open
#9,767 5 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Major type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

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

For example:

```java
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](https://issues.apache.org/jira/browse/LUCENE-8721) by Nick Knize (@nknize), updated Mar 13 2019
Attachments: [LUCENE-8721.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-8721/LUCENE-8721.patch) (versions: 2)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.