Skip to content

Commit

Permalink
Merge pull request #29 from grumlimited/rg/refresher
Browse files Browse the repository at this point in the history
Renamed to haversine
  • Loading branch information
gr211 authored Oct 3, 2020
2 parents cebf654 + d2b2c72 commit 1132b21
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: java
jdk:
- oraclejdk8
- openjdk8
21 changes: 9 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<name>${project.groupId}.${project.artifactId}</name>
<url>http://www.grumlimited.co.uk</url>

<prerequisites>
<maven>3.1.0</maven>
</prerequisites>

<description>Geocalc is a simple java library aimed at doing arithmetics with Earth coordinates.</description>
<licenses>
<license>
Expand Down Expand Up @@ -54,7 +58,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -66,7 +70,7 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -86,27 +90,20 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<version>1.7.30</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<version>1.7.30</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/grum/geocalc/EarthCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public static double gcdDistance(Point standPoint, Point forePoint) {
}

/**
* Returns the distance between two points at Harvesine formula.
* Returns the distance between two points at Haversine formula.
*
* @param standPoint The stand point
* @param forePoint The fore point
* @return The distance, in meters
*/
public static double harvesineDistance(Point standPoint, Point forePoint) {
public static double haversineDistance(Point standPoint, Point forePoint) {

double diffLongitudes = toRadians(abs(forePoint.longitude - standPoint.longitude));
double slat = toRadians(standPoint.latitude);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/grum/geocalc/DistanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testDistanceToBuenosAires() {
}

@Test
public void testHarvesineDistanceToBuenosAires() {
public void testHaversineDistanceToBuenosAires() {
//Kew
Coordinate lat = Coordinate.fromDMS(51, 29, 3.7572);
Coordinate lng = Coordinate.fromDMS(0, 17, 28.3338);
Expand All @@ -83,7 +83,7 @@ public void testHarvesineDistanceToBuenosAires() {

Point buenosAires = Point.at(lat, lng);

assertEquals(11146, (int) (EarthCalc.harvesineDistance(buenosAires, kew) / 1000)); //km
assertEquals(11146, (int) (EarthCalc.haversineDistance(buenosAires, kew) / 1000)); //km
}

@Test
Expand Down Expand Up @@ -127,7 +127,7 @@ public void testZeroDistance() {

assertEquals(0, EarthCalc.gcdDistance(kew, kew), 0);
assertEquals(0, EarthCalc.vincentyDistance(kew, kew), 0);
assertEquals(0, EarthCalc.harvesineDistance(kew, kew), 0);
assertEquals(0, EarthCalc.haversineDistance(kew, kew), 0);
}

@Test
Expand All @@ -139,7 +139,7 @@ public void testZeroDistanceWaldshutGermany() {

assertEquals(0, EarthCalc.gcdDistance(waldshut, waldshut), 0);
assertEquals(0, EarthCalc.vincentyDistance(waldshut, waldshut), 0);
assertEquals(0, EarthCalc.harvesineDistance(waldshut, waldshut), 0);
assertEquals(0, EarthCalc.haversineDistance(waldshut, waldshut), 0);
}

@Test
Expand Down

0 comments on commit 1132b21

Please sign in to comment.