You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mv...@apache.org on 2018/01/11 14:13:11 UTC
lucene-solr:branch_7x: LUCENE-8120: Fix LatLonBoundingBox's
toString() method
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x af54154a6 -> 5e428cd29
LUCENE-8120: Fix LatLonBoundingBox's toString() method
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/5e428cd2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5e428cd2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5e428cd2
Branch: refs/heads/branch_7x
Commit: 5e428cd29887b7a7532f8fe666796538d83f04bb
Parents: af54154
Author: Martijn van Groningen <ma...@gmail.com>
Authored: Thu Jan 11 15:08:05 2018 +0100
Committer: Martijn van Groningen <mv...@apache.org>
Committed: Thu Jan 11 15:12:50 2018 +0100
----------------------------------------------------------------------
lucene/CHANGES.txt | 6 ++++--
.../lucene/document/LatLonBoundingBox.java | 21 ++++++++++----------
.../search/TestLatLonBoundingBoxQueries.java | 6 ++++++
3 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5e428cd2/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index cc4a6c2..f65ccb8 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -59,6 +59,8 @@ Bug Fixes
problem (LUCENE-2287, LUCENE-5455, LUCENE-6796). Some public but internal parts of
the UH were refactored. (David Smiley, Steve Davids)
+* LUCENE-8120: Fix LatLonBoundingBox's toString() method (Martijn van Groningen, Adrien Grand)
+
Other
* LUCENE-8111: IndexOrDocValuesQuery Javadoc references outdated method name.
@@ -177,8 +179,8 @@ Optimizations
* LUCENE-8058: Large instances of TermInSetQuery are no longer eligible for
caching as they could break memory accounting of the query cache.
(Adrien Grand)
-
-* LUCENE-8055: MemoryIndex.MemoryDocValuesIterator returns 2 documents
+
+* LUCENE-8055: MemoryIndex.MemoryDocValuesIterator returns 2 documents
instead of 1. (Simon Willnauer)
* LUCENE-8043: Fix document accounting in IndexWriter to prevent writing too many
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5e428cd2/lucene/sandbox/src/java/org/apache/lucene/document/LatLonBoundingBox.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonBoundingBox.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonBoundingBox.java
index c6d8b55..3a2264c 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonBoundingBox.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonBoundingBox.java
@@ -203,29 +203,30 @@ public class LatLonBoundingBox extends Field {
sb.append(" <");
sb.append(name);
sb.append(':');
+ sb.append('[');
byte[] b = ((BytesRef)fieldsData).bytes;
- toString(b, 0);
+ sb.append(toString(b, 0));
+ sb.append(',');
+ sb.append(toString(b, 1));
+ sb.append(']');
sb.append('>');
-
return sb.toString();
}
private static String toString(byte[] ranges, int dimension) {
- double min, max;
- int minOfs = 0;
- int maxOfs = ranges.length/2;
+ double lat, lon;
switch (dimension) {
case 0:
- min = decodeLatitude(ranges, minOfs);
- max = decodeLatitude(ranges, maxOfs);
+ lat = decodeLatitude(ranges, 0);
+ lon = decodeLongitude(ranges, 4);
break;
case 1:
- min = decodeLongitude(ranges, minOfs);
- max = decodeLongitude(ranges, maxOfs);
+ lat = decodeLatitude(ranges, 8);
+ lon = decodeLongitude(ranges, 12);
break;
default:
throw new IllegalArgumentException("invalid dimension [" + dimension + "] in toString");
}
- return "[" + min + " : " + max + "]";
+ return lat + "," + lon;
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5e428cd2/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonBoundingBoxQueries.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonBoundingBoxQueries.java b/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonBoundingBoxQueries.java
index 39d32a1..7506fb8 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonBoundingBoxQueries.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonBoundingBoxQueries.java
@@ -97,6 +97,12 @@ public class TestLatLonBoundingBoxQueries extends BaseRangeFieldQueryTestCase {
dir.close();
}
+ public void testToString() {
+ LatLonBoundingBox field = new LatLonBoundingBox(FIELD_NAME, -20d, -180d, 20d, -100d);
+ String expected = "LatLonBoundingBox <geoBoundingBoxField:[-20.000000023283064,-180.0,19.99999998137355,-100.0000000745058]>";
+ assertEquals(expected, field.toString());
+ }
+
@Override
protected int dimension() {
return 2;