Skip to content

Commit ae8c4b4

Browse files
author
Isaac Brodsky
authored
Upgrade to v4.0.0-rc4 (#102)
* Upgrade to v4.0.0-rc4 * include PR number
1 parent 7781450 commit ae8c4b4

File tree

7 files changed

+39
-31
lines changed

7 files changed

+39
-31
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The public API of this library consists of the public functions declared in
66
file [H3Core.java](./src/main/java/com/uber/h3core/H3Core.java), and support
77
for the Linux x64 and Darwin x64 platforms.
88

9+
## [4.0.0-rc3] - 2022-07-26
10+
### Breaking Changes
11+
- Upgraded the core library to v4.0.0-rc4. (#102)
12+
- `distance` function renamed to `greatCircleDistance`. (#102)
13+
914
## [4.0.0-rc2] - 2022-06-09
1015
### Changed
1116
- Required version of glibc on Linux is 2.26. (#98)

h3version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
h3.git.reference=v4.0.0-rc2
1+
h3.git.reference=v4.0.0-rc4

src/main/c/h3-java/src/jniapi.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ H3Error CreateGeoPolygon(JNIEnv *env, jdoubleArray verts, jintArray holeSizes,
9999
polygon->holes = calloc(sizeof(GeoPolygon), polygon->numHoles);
100100
if (polygon->holes == NULL) {
101101
ThrowOutOfMemoryError(env);
102-
return E_MEMORY;
102+
return E_MEMORY_ALLOC;
103103
}
104104

105105
jint *holeSizesElements =
106106
(**env).GetIntArrayElements(env, holeSizes, 0);
107107
if (holeSizesElements == NULL) {
108108
free(polygon->holes);
109109
ThrowOutOfMemoryError(env);
110-
return E_MEMORY;
110+
return E_MEMORY_ALLOC;
111111
}
112112

113113
jdouble *holeVertsElements =
@@ -117,7 +117,7 @@ H3Error CreateGeoPolygon(JNIEnv *env, jdoubleArray verts, jintArray holeSizes,
117117
(**env).ReleaseIntArrayElements(env, holeSizes, holeSizesElements,
118118
0);
119119
ThrowOutOfMemoryError(env);
120-
return E_MEMORY;
120+
return E_MEMORY_ALLOC;
121121
}
122122

123123
size_t offset = 0;
@@ -136,7 +136,7 @@ H3Error CreateGeoPolygon(JNIEnv *env, jdoubleArray verts, jintArray holeSizes,
136136
return E_SUCCESS;
137137
} else {
138138
ThrowOutOfMemoryError(env);
139-
return E_MEMORY;
139+
return E_MEMORY_ALLOC;
140140
}
141141
}
142142

@@ -905,41 +905,44 @@ JNIEXPORT jdouble JNICALL Java_com_uber_h3core_NativeMethods_cellAreaM2(
905905

906906
/*
907907
* Class: com_uber_h3core_NativeMethods
908-
* Method: distanceRads
908+
* Method: greatCircleDistanceRads
909909
* Signature: (DDDD)D
910910
*/
911-
JNIEXPORT jdouble JNICALL Java_com_uber_h3core_NativeMethods_distanceRads(
911+
JNIEXPORT jdouble JNICALL
912+
Java_com_uber_h3core_NativeMethods_greatCircleDistanceRads(
912913
JNIEnv *env, jobject thiz, jdouble lat1, jdouble lng1, jdouble lat2,
913914
jdouble lng2) {
914915
LatLng c1 = {.lat = lat1, .lng = lng1};
915916
LatLng c2 = {.lat = lat2, .lng = lng2};
916-
return distanceRads(&c1, &c2);
917+
return greatCircleDistanceRads(&c1, &c2);
917918
}
918919

919920
/*
920921
* Class: com_uber_h3core_NativeMethods
921-
* Method: distanceKm
922+
* Method: greatCircleDistanceKm
922923
* Signature: (DDDD)D
923924
*/
924-
JNIEXPORT jdouble JNICALL Java_com_uber_h3core_NativeMethods_distanceKm(
925+
JNIEXPORT jdouble JNICALL
926+
Java_com_uber_h3core_NativeMethods_greatCircleDistanceKm(
925927
JNIEnv *env, jobject thiz, jdouble lat1, jdouble lng1, jdouble lat2,
926928
jdouble lng2) {
927929
LatLng c1 = {.lat = lat1, .lng = lng1};
928930
LatLng c2 = {.lat = lat2, .lng = lng2};
929-
return distanceKm(&c1, &c2);
931+
return greatCircleDistanceKm(&c1, &c2);
930932
}
931933

932934
/*
933935
* Class: com_uber_h3core_NativeMethods
934-
* Method: distanceM
936+
* Method: greatCircleDistanceM
935937
* Signature: (DDDD)D
936938
*/
937-
JNIEXPORT jdouble JNICALL Java_com_uber_h3core_NativeMethods_distanceM(
939+
JNIEXPORT jdouble JNICALL
940+
Java_com_uber_h3core_NativeMethods_greatCircleDistanceM(
938941
JNIEnv *env, jobject thiz, jdouble lat1, jdouble lng1, jdouble lat2,
939942
jdouble lng2) {
940943
LatLng c1 = {.lat = lat1, .lng = lng1};
941944
LatLng c2 = {.lat = lat2, .lng = lng2};
942-
return distanceM(&c1, &c2);
945+
return greatCircleDistanceM(&c1, &c2);
943946
}
944947

945948
/*

src/main/java/com/uber/h3core/H3Core.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,15 +844,15 @@ public double cellArea(long h3, AreaUnit unit) {
844844
* @param unit Unit to return the distance in.
845845
* @return Distance from point <code>a</code> to point <code>b</code>
846846
*/
847-
public double distance(LatLng a, LatLng b, LengthUnit unit) {
847+
public double greatCircleDistance(LatLng a, LatLng b, LengthUnit unit) {
848848
double lat1 = toRadians(a.lat);
849849
double lng1 = toRadians(a.lng);
850850
double lat2 = toRadians(b.lat);
851851
double lng2 = toRadians(b.lng);
852852

853-
if (unit == LengthUnit.rads) return h3Api.distanceRads(lat1, lng1, lat2, lng2);
854-
else if (unit == LengthUnit.km) return h3Api.distanceKm(lat1, lng1, lat2, lng2);
855-
else if (unit == LengthUnit.m) return h3Api.distanceM(lat1, lng1, lat2, lng2);
853+
if (unit == LengthUnit.rads) return h3Api.greatCircleDistanceRads(lat1, lng1, lat2, lng2);
854+
else if (unit == LengthUnit.km) return h3Api.greatCircleDistanceKm(lat1, lng1, lat2, lng2);
855+
else if (unit == LengthUnit.m) return h3Api.greatCircleDistanceM(lat1, lng1, lat2, lng2);
856856
else throw new IllegalArgumentException(String.format("Invalid unit: %s", unit));
857857
}
858858

src/main/java/com/uber/h3core/H3CoreV3.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ public double cellArea(long h3, AreaUnit unit) {
612612
* @return Distance from point <code>a</code> to point <code>b</code>
613613
*/
614614
public double pointDist(LatLng a, LatLng b, LengthUnit unit) {
615-
return h3Api.distance(a, b, unit);
615+
return h3Api.greatCircleDistance(a, b, unit);
616616
}
617617

618618
/**

src/main/java/com/uber/h3core/NativeMethods.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ native void polygonToCells(
8686

8787
native double cellAreaM2(long h3);
8888

89-
native double distanceRads(double lat1, double lon1, double lat2, double lon2);
89+
native double greatCircleDistanceRads(double lat1, double lon1, double lat2, double lon2);
9090

91-
native double distanceKm(double lat1, double lon1, double lat2, double lon2);
91+
native double greatCircleDistanceKm(double lat1, double lon1, double lat2, double lon2);
9292

93-
native double distanceM(double lat1, double lon1, double lat2, double lon2);
93+
native double greatCircleDistanceM(double lat1, double lon1, double lat2, double lon2);
9494

9595
native double exactEdgeLengthRads(long h3);
9696

src/test/java/com/uber/h3core/TestMiscellaneous.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ public void testPointDist() {
208208
LatLng b = testB[i];
209209
double expectedRads = Math.toRadians(testDistanceDegrees[i]);
210210

211-
double distRads = h3.distance(a, b, LengthUnit.rads);
212-
double distKm = h3.distance(a, b, LengthUnit.km);
213-
double distM = h3.distance(a, b, LengthUnit.m);
211+
double distRads = h3.greatCircleDistance(a, b, LengthUnit.rads);
212+
double distKm = h3.greatCircleDistance(a, b, LengthUnit.km);
213+
double distM = h3.greatCircleDistance(a, b, LengthUnit.m);
214214

215215
// TODO: Epsilon is unusually large in the core H3 tests
216216
assertEquals("radians distance is as expected", expectedRads, distRads, EPSILON * 10000);
@@ -228,9 +228,9 @@ public void testPointDist() {
228228
public void testPointDistNaN() {
229229
LatLng zero = new LatLng(0, 0);
230230
LatLng nan = new LatLng(Double.NaN, Double.NaN);
231-
double dist1 = h3.distance(nan, zero, LengthUnit.rads);
232-
double dist2 = h3.distance(zero, nan, LengthUnit.km);
233-
double dist3 = h3.distance(nan, nan, LengthUnit.m);
231+
double dist1 = h3.greatCircleDistance(nan, zero, LengthUnit.rads);
232+
double dist2 = h3.greatCircleDistance(zero, nan, LengthUnit.km);
233+
double dist3 = h3.greatCircleDistance(nan, nan, LengthUnit.m);
234234
assertTrue("nan distance results in nan", Double.isNaN(dist1));
235235
assertTrue("nan distance results in nan", Double.isNaN(dist2));
236236
assertTrue("nan distance results in nan", Double.isNaN(dist3));
@@ -240,23 +240,23 @@ public void testPointDistNaN() {
240240
public void testPointDistPositiveInfinity() {
241241
LatLng posInf = new LatLng(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
242242
LatLng zero = new LatLng(0, 0);
243-
double dist = h3.distance(posInf, zero, LengthUnit.m);
243+
double dist = h3.greatCircleDistance(posInf, zero, LengthUnit.m);
244244
assertTrue("+Infinity distance results in NaN", Double.isNaN(dist));
245245
}
246246

247247
@Test
248248
public void testPointDistNegativeInfinity() {
249249
LatLng negInf = new LatLng(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
250250
LatLng zero = new LatLng(0, 0);
251-
double dist = h3.distance(negInf, zero, LengthUnit.m);
251+
double dist = h3.greatCircleDistance(negInf, zero, LengthUnit.m);
252252
assertTrue("-Infinity distance results in NaN", Double.isNaN(dist));
253253
}
254254

255255
@Test(expected = IllegalArgumentException.class)
256256
public void testPointDistInvalid() {
257257
LatLng a = new LatLng(0, 0);
258258
LatLng b = new LatLng(0, 0);
259-
h3.distance(a, b, null);
259+
h3.greatCircleDistance(a, b, null);
260260
}
261261

262262
@Test(expected = IllegalArgumentException.class)

0 commit comments

Comments
 (0)