1 /*
2  * Copyright 2011-2020 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.springframework.data.geo;
17
18 /**
19  * Commonly used {@link Metric}s.
20  *
21  * @author Oliver Gierke
22  * @author Thomas Darimont
23  * @since 1.8
24  */

25 public enum Metrics implements Metric {
26
27     KILOMETERS(6378.137, "km"), MILES(3963.191, "mi"), NEUTRAL(1, "");
28
29     private final double multiplier;
30     private final String abbreviation;
31
32     /**
33      * Creates a new {@link Metrics} using the given multiplier.
34      *
35      * @param multiplier the earth radius at equator, must not be {@literal null}.
36      * @param abbreviation the abbreviation to use for this {@link Metric}, must not be {@literal null}.
37      */

38     private Metrics(double multiplier, String abbreviation) {
39
40         this.multiplier = multiplier;
41         this.abbreviation = abbreviation;
42     }
43
44     /*
45      * (non-Javadoc)
46      * @see org.springframework.data.mongodb.core.geo.Metric#getMultiplier()
47      */

48     public double getMultiplier() {
49         return multiplier;
50     }
51
52     /*
53      * (non-Javadoc)
54      * @see org.springframework.data.geo.Metric#getAbbreviation()
55      */

56     @Override
57     public String getAbbreviation() {
58         return abbreviation;
59     }
60 }
61