Skip to content

Commit 43be742

Browse files
authored
Merge pull request #141 from isaacbrodsky/dev-v4-rc4
Upgrade to v4.0.0-rc4 Primary change here is renaming distance to greatCircleDistance. Did not change anything about version numbers as the previous release candidate upgrade was not released.
2 parents d052e6b + c482b77 commit 43be742

10 files changed

+30
-34
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. This librar
66
### Added
77
- Added vertex mode functions (#138)
88
### Breaking Changes
9+
- Updated the core library to `v4.0.0-rc4`. (#141)
910
- Updated the core library to `v4.0.0-rc2`. This update renames the majority of the H3 functions. You can see a [list of changed function names](https://h3geo.org/docs/next/library/migration-3.x/functions) in the core library documentation. For the most part, upgrading to v4 for Javascript consumers should be a straightforward search & replace between the old names and the new. (#139)
1011
- Added more cases in which JS errors may be thrown. In H3 v3, many functions would fail silently with invalid input, returning `null` or similar signal values. In H3 v4, we will throw descriptive errors for most instances of bad input. (#139)
1112

H3_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.0-rc2
1+
4.0.0-rc4

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Coverage Status](https://coveralls.io/repos/github/uber/h3-js/badge.svg?branch=master)](https://coveralls.io/github/uber/h3-js?branch=master)
99
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
1010
[![npm version](https://badge.fury.io/js/h3-js.svg)](https://badge.fury.io/js/h3-js)
11-
[![H3 Version](https://img.shields.io/static/v1?label=h3%20api&message=v4.0.0-rc2&color=blue)](https://github.com/uber/h3/releases/tag/v4.0.0-rc2)
11+
[![H3 Version](https://img.shields.io/static/v1?label=h3%20api&message=v4.0.0-rc4&color=blue)](https://github.com/uber/h3/releases/tag/v4.0.0-rc4)
1212

1313
The `h3-js` library provides a pure-JavaScript version of the [H3 Core Library](https://github.com/uber/h3), a hexagon-based geographic grid system. It can be used either in Node >= 6 or in the browser. The core library is transpiled from C using [emscripten](http://kripken.github.io/emscripten-site), offering full parity with the C API and highly efficient operations.
1414

@@ -130,7 +130,7 @@ const coordinates = h3.cellsToMultiPolygon(hexagons, true);
130130
* [.gridPathCells(origin, destination)](#module_h3.gridPathCells) ⇒ <code>Array.&lt;H3Index&gt;</code>
131131
* [.cellToLocalIj(origin, destination)](#module_h3.cellToLocalIj) ⇒ <code>CoordIJ</code>
132132
* [.localIjToCell(origin, coords)](#module_h3.localIjToCell) ⇒ <code>H3Index</code>
133-
* [.distance(latLng1, latLng2, unit)](#module_h3.distance) ⇒ <code>number</code>
133+
* [.greatCircleDistance(latLng1, latLng2, unit)](#module_h3.greatCircleDistance) ⇒ <code>number</code>
134134
* [.cellArea(h3Index, unit)](#module_h3.cellArea) ⇒ <code>number</code>
135135
* [.exactEdgeLength(edge, unit)](#module_h3.exactEdgeLength) ⇒ <code>number</code>
136136
* [.getHexagonAreaAvg(res, unit)](#module_h3.getHexagonAreaAvg) ⇒ <code>number</code>
@@ -703,9 +703,9 @@ to be compatible across different versions of H3.
703703

704704
* * *
705705

706-
<a name="module_h3.distance"></a>
706+
<a name="module_h3.greatCircleDistance"></a>
707707

708-
### h3.distance(latLng1, latLng2, unit) ⇒ <code>number</code>
708+
### h3.greatCircleDistance(latLng1, latLng2, unit) ⇒ <code>number</code>
709709
Great circle distance between two geo points. This is not specific to H3,
710710
but is implemented in the library and provided here as a convenience.
711711

doc-files/README.tmpl.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Coverage Status](https://coveralls.io/repos/github/uber/h3-js/badge.svg?branch=master)](https://coveralls.io/github/uber/h3-js?branch=master)
99
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
1010
[![npm version](https://badge.fury.io/js/h3-js.svg)](https://badge.fury.io/js/h3-js)
11-
[![H3 Version](https://img.shields.io/static/v1?label=h3%20api&message=v4.0.0-rc2&color=blue)](https://github.com/uber/h3/releases/tag/v4.0.0-rc2)
11+
[![H3 Version](https://img.shields.io/static/v1?label=h3%20api&message=v4.0.0-rc4&color=blue)](https://github.com/uber/h3/releases/tag/v4.0.0-rc4)
1212

1313
The `h3-js` library provides a pure-JavaScript version of the [H3 Core Library](https://github.com/uber/h3), a hexagon-based geographic grid system. It can be used either in Node >= 6 or in the browser. The core library is transpiled from C using [emscripten](http://kripken.github.io/emscripten-site), offering full parity with the C API and highly efficient operations.
1414

lib/bindings.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ export default [
8181
['getHexagonAreaAvgKm2', H3_ERROR, [RESOLUTION, POINTER]],
8282
['getHexagonEdgeLengthAvgM', H3_ERROR, [RESOLUTION, POINTER]],
8383
['getHexagonEdgeLengthAvgKm', H3_ERROR, [RESOLUTION, POINTER]],
84-
['distanceM', NUMBER, [POINTER, POINTER]],
85-
['distanceKm', NUMBER, [POINTER, POINTER]],
86-
['distanceRads', NUMBER, [POINTER, POINTER]],
84+
['greatCircleDistanceM', NUMBER, [POINTER, POINTER]],
85+
['greatCircleDistanceKm', NUMBER, [POINTER, POINTER]],
86+
['greatCircleDistanceRads', NUMBER, [POINTER, POINTER]],
8787
['cellAreaM2', H3_ERROR, [H3_LOWER, H3_UPPER, POINTER]],
8888
['cellAreaKm2', H3_ERROR, [H3_LOWER, H3_UPPER, POINTER]],
8989
['cellAreaRads2', H3_ERROR, [H3_LOWER, H3_UPPER, POINTER]],

lib/h3core.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1300,19 +1300,19 @@ export function localIjToCell(origin, coords) {
13001300
* @return {number} Great circle distance
13011301
* @throws {Error} If the unit is invalid
13021302
*/
1303-
export function distance(latLng1, latLng2, unit) {
1303+
export function greatCircleDistance(latLng1, latLng2, unit) {
13041304
const coord1 = storeLatLng(latLng1[0], latLng1[1]);
13051305
const coord2 = storeLatLng(latLng2[0], latLng2[1]);
13061306
let result;
13071307
switch (unit) {
13081308
case UNITS.m:
1309-
result = H3.distanceM(coord1, coord2);
1309+
result = H3.greatCircleDistanceM(coord1, coord2);
13101310
break;
13111311
case UNITS.km:
1312-
result = H3.distanceKm(coord1, coord2);
1312+
result = H3.greatCircleDistanceKm(coord1, coord2);
13131313
break;
13141314
case UNITS.rads:
1315-
result = H3.distanceRads(coord1, coord2);
1315+
result = H3.greatCircleDistanceRads(coord1, coord2);
13161316
break;
13171317
default:
13181318
result = null;

out/binding-functions

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ polygonToCells
88
cellsToMultiPolygon
99
degsToRads
1010
radsToDegs
11-
distance
11+
greatCircleDistance
1212
getHexagonAreaAvg
1313
cellArea
1414
getHexagonEdgeLengthAvg

out/libh3.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/h3core.spec.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1867,47 +1867,47 @@ test('exactEdgeLength - bad units', assert => {
18671867
assert.end();
18681868
});
18691869

1870-
test('distance', assert => {
1870+
test('greatCircleDistance', assert => {
18711871
assert.ok(
1872-
almostEqual(h3.distance([-10, 0], [10, 0], h3.UNITS.rads), h3.degsToRads(20)),
1872+
almostEqual(h3.greatCircleDistance([-10, 0], [10, 0], h3.UNITS.rads), h3.degsToRads(20)),
18731873
'Got expected angular distance for latitude along the equator'
18741874
);
18751875
assert.ok(
1876-
almostEqual(h3.distance([0, -10], [0, 10], h3.UNITS.rads), h3.degsToRads(20)),
1876+
almostEqual(h3.greatCircleDistance([0, -10], [0, 10], h3.UNITS.rads), h3.degsToRads(20)),
18771877
'Got expected angular distance for latitude along a meridian'
18781878
);
18791879
assert.equal(
1880-
h3.distance([23, 23], [23, 23], h3.UNITS.rads),
1880+
h3.greatCircleDistance([23, 23], [23, 23], h3.UNITS.rads),
18811881
0,
18821882
'Got expected angular distance for same point'
18831883
);
18841884
// Just rough tests for the other units
1885-
const distKm = h3.distance([0, 0], [39, -122], h3.UNITS.km);
1885+
const distKm = h3.greatCircleDistance([0, 0], [39, -122], h3.UNITS.km);
18861886
assert.ok(distKm > 12e3 && distKm < 13e3, 'has some reasonable distance in Km');
1887-
const distM = h3.distance([0, 0], [39, -122], h3.UNITS.m);
1887+
const distM = h3.greatCircleDistance([0, 0], [39, -122], h3.UNITS.m);
18881888
assert.ok(distM > 12e6 && distM < 13e6, 'has some reasonable distance in m');
18891889

18901890
assert.end();
18911891
});
18921892

1893-
test('distance - bad units', assert => {
1893+
test('greatCircleDistance - bad units', assert => {
18941894
assert.throws(
1895-
() => h3.distance([0, 0], [0, 0]),
1895+
() => h3.greatCircleDistance([0, 0], [0, 0]),
18961896
{code: E_UNKNOWN_UNIT},
18971897
'throws on missing unit'
18981898
);
18991899
assert.throws(
1900-
() => h3.distance([0, 0], [0, 0], 'foo'),
1900+
() => h3.greatCircleDistance([0, 0], [0, 0], 'foo'),
19011901
{code: E_UNKNOWN_UNIT},
19021902
'throws on unknown unit'
19031903
);
19041904
assert.throws(
1905-
() => h3.distance([0, 0], [0, 0], 42),
1905+
() => h3.greatCircleDistance([0, 0], [0, 0], 42),
19061906
{code: E_UNKNOWN_UNIT},
19071907
'throws on unknown unit'
19081908
);
19091909
assert.throws(
1910-
() => h3.distance([0, 0], [0, 0], h3.UNITS.m2),
1910+
() => h3.greatCircleDistance([0, 0], [0, 0], h3.UNITS.m2),
19111911
{code: E_UNKNOWN_UNIT},
19121912
'throws on invalid unit'
19131913
);

test/test-parity.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ const BINDING_FUNCTIONS = fs
2525
.split(/\s+/);
2626

2727
// Exclude methods that don't make sense for the JS bindings
28-
const EXCLUDE_METHODS = [
29-
'h3ToString',
30-
'stringToH3',
31-
// TODO: Unnecessary when https://github.com/uber/h3/pull/622 is released
32-
'distance'
33-
];
28+
const EXCLUDE_METHODS = ['h3ToString', 'stringToH3'];
3429

3530
test('implementsBindingFunctions', assert => {
3631
BINDING_FUNCTIONS.forEach(fn => {

0 commit comments

Comments
 (0)