Added the `DistanceUnit.NAUTICALMILES` enumeration
label with the corresponding *NM* and *nmi* unit suffixes. Update the docs to match. Closes #5085
This commit is contained in:
parent
ac9e2cd46f
commit
41dba68bda
|
@ -171,7 +171,7 @@ Kilometer:: `km` or `kilometers`
|
|||
Meter:: `m` or `meters`
|
||||
Centimeter:: `cm` or `centimeters`
|
||||
Millimeter:: `mm` or `millimeters`
|
||||
|
||||
Nautical mile:: `NM`, `nmi` or `nauticalmiles`
|
||||
|
||||
[[fuzziness]]
|
||||
[float]
|
||||
|
|
|
@ -37,11 +37,14 @@ public enum DistanceUnit {
|
|||
INCH(0.0254, "in", "inch"),
|
||||
YARD(0.9144, "yd", "yards"),
|
||||
FEET(0.3048, "ft", "feet"),
|
||||
MILES(1609.344, "mi", "miles"),
|
||||
KILOMETERS(1000.0, "km", "kilometers"),
|
||||
NAUTICALMILES(1852.0, "NM", "nmi", "nauticalmiles"),
|
||||
MILLIMETERS(0.001, "mm", "millimeters"),
|
||||
CENTIMETERS(0.01, "cm", "centimeters"),
|
||||
|
||||
// 'm' is a suffix of 'nmi' so it must follow 'nmi'
|
||||
MILES(1609.344, "mi", "miles"),
|
||||
|
||||
// since 'm' is suffix of other unit
|
||||
// it must be the last entry of unit
|
||||
// names ending with 'm'. otherwise
|
||||
|
|
|
@ -35,6 +35,7 @@ public class DistanceUnitTests extends ElasticsearchTestCase {
|
|||
assertThat(DistanceUnit.KILOMETERS.convert(10, DistanceUnit.MILES), closeTo(16.09344, 0.001));
|
||||
assertThat(DistanceUnit.MILES.convert(10, DistanceUnit.MILES), closeTo(10, 0.001));
|
||||
assertThat(DistanceUnit.MILES.convert(10, DistanceUnit.KILOMETERS), closeTo(6.21371192, 0.001));
|
||||
assertThat(DistanceUnit.NAUTICALMILES.convert(10, DistanceUnit.MILES), closeTo(8.689762, 0.001));
|
||||
assertThat(DistanceUnit.KILOMETERS.convert(10, DistanceUnit.KILOMETERS), closeTo(10, 0.001));
|
||||
assertThat(DistanceUnit.KILOMETERS.convert(10, DistanceUnit.METERS), closeTo(0.01, 0.00001));
|
||||
assertThat(DistanceUnit.KILOMETERS.convert(1000,DistanceUnit.METERS), closeTo(1, 0.001));
|
||||
|
@ -46,6 +47,8 @@ public class DistanceUnitTests extends ElasticsearchTestCase {
|
|||
assertThat(DistanceUnit.Distance.parseDistance("50km").unit, equalTo(DistanceUnit.KILOMETERS));
|
||||
assertThat(DistanceUnit.Distance.parseDistance("500m").unit, equalTo(DistanceUnit.METERS));
|
||||
assertThat(DistanceUnit.Distance.parseDistance("51mi").unit, equalTo(DistanceUnit.MILES));
|
||||
assertThat(DistanceUnit.Distance.parseDistance("53nmi").unit, equalTo(DistanceUnit.NAUTICALMILES));
|
||||
assertThat(DistanceUnit.Distance.parseDistance("53NM").unit, equalTo(DistanceUnit.NAUTICALMILES));
|
||||
assertThat(DistanceUnit.Distance.parseDistance("52yd").unit, equalTo(DistanceUnit.YARD));
|
||||
assertThat(DistanceUnit.Distance.parseDistance("12in").unit, equalTo(DistanceUnit.INCH));
|
||||
assertThat(DistanceUnit.Distance.parseDistance("23mm").unit, equalTo(DistanceUnit.MILLIMETERS));
|
||||
|
|
Loading…
Reference in New Issue