Comparing version 3.5.0 to 3.6.0
@@ -24,2 +24,13 @@ /* | ||
// Initial message | ||
const header = document.createElement('h2'); | ||
header.style.cssText = ` | ||
font-family: Helvetica, sans-serif; | ||
font-size: 24px; | ||
margin: 1rem; | ||
color: darkgrey; | ||
`; | ||
header.innerHTML = 'Running benchmarks...'; | ||
document.body.appendChild(header); | ||
const suite = makeBenchmarks(); | ||
@@ -34,3 +45,3 @@ | ||
color: grey; | ||
margin: 1em; | ||
margin: 1rem; | ||
padding-bottom: 1em; | ||
@@ -37,0 +48,0 @@ border-bottom: 1px dashed grey; |
@@ -7,2 +7,11 @@ # Change Log | ||
## [3.6.0] - 2019-09-12 | ||
### Fixed | ||
- Removed `unhandledRejection` handling from emscripten build (#64) | ||
- Fixed TypeScript definition file, added a CI test to guard against regressions (#65) | ||
### Changed | ||
- Updated the core library to v3.6.0 (#61) | ||
### Added | ||
- Added bindings for `getPentagonIndexes` and `h3ToCenterChild` (#61) | ||
## [3.5.0] - 2019-07-24 | ||
@@ -9,0 +18,0 @@ ### Added |
@@ -64,2 +64,3 @@ 'use strict'; | ||
['h3ToChildren', null, [H3_LOWER, H3_UPPER, RESOLUTION, POINTER]], | ||
['h3ToCenterChild', H3_LOWER, [H3_LOWER, H3_UPPER, RESOLUTION]], | ||
['maxH3ToChildrenSize', NUMBER, [H3_LOWER, H3_UPPER, RESOLUTION]], | ||
@@ -85,3 +86,5 @@ ['h3IndexesAreNeighbors', BOOLEAN, [H3_LOWER, H3_UPPER, H3_LOWER, H3_UPPER]], | ||
['getRes0Indexes', null, [POINTER]], | ||
['res0IndexCount', NUMBER] | ||
['res0IndexCount', NUMBER], | ||
['getPentagonIndexes', null, [NUMBER, POINTER]], | ||
['pentagonIndexCount', NUMBER] | ||
]; | ||
@@ -88,0 +91,0 @@ |
@@ -78,5 +78,5 @@ /** | ||
* @param {Boolean} formatAsGeoJson Whether to provide GeoJSON output: [lng, lat], closed loops | ||
* @return {Array[]} Array of [lat, lng] pairs | ||
* @return {Number[][]} Array of [lat, lng] pairs | ||
*/ | ||
function h3ToGeoBoundary(h3Index: H3Index, formatAsGeoJson: boolean): Array[]; | ||
function h3ToGeoBoundary(h3Index: H3Index, formatAsGeoJson: boolean): Number[][]; | ||
/** | ||
@@ -99,2 +99,10 @@ * Get the parent of the given hexagon at a particular resolution | ||
/** | ||
* Get the center child of the given hexagon at a particular resolution | ||
* @static | ||
* @param {H3Index} h3Index H3 index to get center child for | ||
* @param {Number} res Resolution of hexagon to return | ||
* @return {H3Index} H3 index of child, or null for invalid input | ||
*/ | ||
function h3ToCenterChild(h3Index: H3Index, res: number): H3Index; | ||
/** | ||
* Get all hexagons in a k-ring around a given center. The order of the hexagons is undefined. | ||
@@ -133,3 +141,4 @@ * @static | ||
* @static | ||
* @param {Array[]} coordinates Array of loops, or a single loop | ||
* @param {Number[][] | Number[][][]} coordinates | ||
* Array of loops, or a single loop | ||
* @param {Number} res Resolution of hexagons to return | ||
@@ -140,3 +149,3 @@ * @param {Boolean} isGeoJson Whether to expect GeoJson-style [lng, lat] | ||
*/ | ||
function polyfill(coordinates: Array[], res: number, isGeoJson: boolean): H3Index[]; | ||
function polyfill(coordinates: Number[][] | Number[][][], res: number, isGeoJson: boolean): H3Index[]; | ||
/** | ||
@@ -151,5 +160,5 @@ * Get the outlines of a set of H3 hexagons, returned in GeoJSON MultiPolygon | ||
* [lng, lat], closed loops | ||
* @return {Array[]} MultiPolygon-style output. | ||
* @return {Number[][][][]} MultiPolygon-style output. | ||
*/ | ||
function h3SetToMultiPolygon(h3Indexes: H3Index[], formatAsGeoJson: boolean): Array[]; | ||
function h3SetToMultiPolygon(h3Indexes: H3Index[], formatAsGeoJson: boolean): Number[][][][]; | ||
/** | ||
@@ -231,5 +240,5 @@ * Compact a set of hexagons of the same resolution into a set of hexagons across | ||
* @param {Boolean} formatAsGeoJson Whether to provide GeoJSON output: [lng, lat] | ||
* @return {Array[]} Array of geo coordinate pairs | ||
* @return {Number[][]} Array of geo coordinate pairs | ||
*/ | ||
function getH3UnidirectionalEdgeBoundary(edgeIndex: H3Index, formatAsGeoJson: boolean): Array[]; | ||
function getH3UnidirectionalEdgeBoundary(edgeIndex: H3Index, formatAsGeoJson: boolean): Number[][]; | ||
/** | ||
@@ -341,2 +350,9 @@ * Get the grid distance between two hex indexes. This function may fail | ||
/** | ||
* Get the twelve pentagon indexes at a given resolution. | ||
* @static | ||
* @param {Number} res Hexagon resolution | ||
* @return {H3Index[]} All H3 pentagon indexes at res | ||
*/ | ||
function getPentagonIndexes(res: number): H3Index[]; | ||
/** | ||
* Convert degrees to radians | ||
@@ -343,0 +359,0 @@ * @static |
@@ -0,1 +1,3 @@ | ||
<img align="right" src="https://uber.github.io/res/h3Logo-color.svg" alt="H3 Logo" width="200"> | ||
# h3-js | ||
@@ -2,0 +4,0 @@ |
@@ -62,2 +62,3 @@ /* | ||
['h3ToChildren', null, [H3_LOWER, H3_UPPER, RESOLUTION, POINTER]], | ||
['h3ToCenterChild', H3_LOWER, [H3_LOWER, H3_UPPER, RESOLUTION]], | ||
['maxH3ToChildrenSize', NUMBER, [H3_LOWER, H3_UPPER, RESOLUTION]], | ||
@@ -83,3 +84,5 @@ ['h3IndexesAreNeighbors', BOOLEAN, [H3_LOWER, H3_UPPER, H3_LOWER, H3_UPPER]], | ||
['getRes0Indexes', null, [POINTER]], | ||
['res0IndexCount', NUMBER] | ||
['res0IndexCount', NUMBER], | ||
['getPentagonIndexes', null, [NUMBER, POINTER]], | ||
['pentagonIndexCount', NUMBER] | ||
]; |
@@ -369,3 +369,3 @@ /* | ||
* @param {Boolean} formatAsGeoJson Whether to provide GeoJSON output: [lng, lat], closed loops | ||
* @return {Array[]} MultiPolygon-style output. | ||
* @return {Number[][][][]} MultiPolygon-style output. | ||
*/ | ||
@@ -567,3 +567,3 @@ function readMultiPolygon(polygon, formatAsGeoJson) { | ||
* @param {Boolean} formatAsGeoJson Whether to provide GeoJSON output: [lng, lat], closed loops | ||
* @return {Array[]} Array of [lat, lng] pairs | ||
* @return {Number[][]} Array of [lat, lng] pairs | ||
*/ | ||
@@ -602,2 +602,7 @@ export function h3ToGeoBoundary(h3Index, formatAsGeoJson) { | ||
export function h3ToChildren(h3Index, res) { | ||
// Bad input in this case can potentially result in high computation volume | ||
// using the current C algorithm. Validate and return an empty array on failure. | ||
if (!h3IsValid(h3Index)) { | ||
return []; | ||
} | ||
const [lower, upper] = h3IndexToSplitLong(h3Index); | ||
@@ -613,2 +618,14 @@ const maxCount = H3.maxH3ToChildrenSize(lower, upper, res); | ||
/** | ||
* Get the center child of the given hexagon at a particular resolution | ||
* @static | ||
* @param {H3Index} h3Index H3 index to get center child for | ||
* @param {Number} res Resolution of hexagon to return | ||
* @return {H3Index} H3 index of child, or null for invalid input | ||
*/ | ||
export function h3ToCenterChild(h3Index, res) { | ||
const [lower, upper] = h3IndexToSplitLong(h3Index); | ||
return readH3Index(H3.h3ToCenterChild(lower, upper, res)); | ||
} | ||
/** | ||
* Get all hexagons in a k-ring around a given center. The order of the hexagons is undefined. | ||
@@ -692,3 +709,4 @@ * @static | ||
* @static | ||
* @param {Array[]} coordinates Array of loops, or a single loop | ||
* @param {Number[][] | Number[][][]} coordinates | ||
* Array of loops, or a single loop | ||
* @param {Number} res Resolution of hexagons to return | ||
@@ -729,3 +747,3 @@ * @param {Boolean} isGeoJson Whether to expect GeoJson-style [lng, lat] | ||
* [lng, lat], closed loops | ||
* @return {Array[]} MultiPolygon-style output. | ||
* @return {Number[][][][]} MultiPolygon-style output. | ||
*/ | ||
@@ -919,3 +937,3 @@ export function h3SetToMultiPolygon(h3Indexes, formatAsGeoJson) { | ||
* @param {Boolean} formatAsGeoJson Whether to provide GeoJSON output: [lng, lat] | ||
* @return {Array[]} Array of geo coordinate pairs | ||
* @return {Number[][]} Array of geo coordinate pairs | ||
*/ | ||
@@ -1151,2 +1169,18 @@ export function getH3UnidirectionalEdgeBoundary(edgeIndex, formatAsGeoJson) { | ||
/** | ||
* Get the twelve pentagon indexes at a given resolution. | ||
* @static | ||
* @param {Number} res Hexagon resolution | ||
* @return {H3Index[]} All H3 pentagon indexes at res | ||
*/ | ||
export function getPentagonIndexes(res) { | ||
validateRes(res); | ||
const count = H3.pentagonIndexCount(); | ||
const hexagons = C._malloc(SZ_H3INDEX * count); | ||
H3.getPentagonIndexes(res, hexagons); | ||
const out = readArrayOfHexagons(hexagons, count); | ||
C._free(hexagons); | ||
return out; | ||
} | ||
/** | ||
* Convert degrees to radians | ||
@@ -1153,0 +1187,0 @@ * @static |
{ | ||
"name": "h3-js", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"description": "Emscripten transpiled libh3 'bindings' for Node/Web JS", | ||
"author": "David Ellis <isv.damocles@gmail.com>", | ||
"author": "Nick Rabinowitz <nickr@uber.com>", | ||
"contributors": [ | ||
"Nick Rabinowitz <nickr@uber.com>" | ||
"David Ellis <isv.damocles@gmail.com>" | ||
], | ||
@@ -42,5 +42,5 @@ "license": "Apache-2.0", | ||
"rollup-bindings": "rollup build/print-bindings.js --file dist/print-bindings.js --format cjs", | ||
"rollup-benchmark-browser": "rollup benchmark/browser.js --file dist/benchmark.browser.js --format=umd --external=benchmark", | ||
"rollup-benchmark-browser": "rollup benchmark/browser.js --file dist/benchmark.browser.js --format=umd --external=benchmark --globals=benchmark:Benchmark", | ||
"rollup-benchmark-node": "rollup benchmark/node.js --file dist/benchmark.node.js --format=cjs --external=benchmark", | ||
"docker-boot": "docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-tag-1.38.29-64bit bash", | ||
"docker-boot": "docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-tag-1.38.43-64bit bash", | ||
"docker-reboot": "docker stop emscripten && docker rm emscripten && yarn docker-boot", | ||
@@ -53,2 +53,3 @@ "docker-emscripten": "yarn docker-emscripten-umd", | ||
"check-docs": "yarn build-docs && git diff --exit-code", | ||
"check-tsd": "yarn build-tsd && tsc --strict --noEmit dist/types.d.ts", | ||
"lint": "eslint lib* test/*", | ||
@@ -84,8 +85,14 @@ "test": "yarn lint && yarn test-fast", | ||
"tape": "^4.8.0", | ||
"tsd-jsdoc": "^2.3.1" | ||
"tsd-jsdoc": "^2.3.1", | ||
"typescript": "^3.6.3" | ||
}, | ||
"resolutions": { | ||
"lodash": "4.17.15", | ||
"js-yaml": "3.13.1", | ||
"ws": "3.3.3" | ||
}, | ||
"engines": { | ||
"node": ">=4", | ||
"npm": ">=3", | ||
"yarn": ">=1.3.0" | ||
"yarn": ">=1.17.0" | ||
}, | ||
@@ -92,0 +99,0 @@ "nyc": { |
@@ -0,4 +1,6 @@ | ||
<img align="right" src="https://uber.github.io/res/h3Logo-color.svg" alt="H3 Logo" width="200"> | ||
# h3-js | ||
[![H3 Version](https://img.shields.io/badge/h3_api-v3.5.0-blue.svg)](https://github.com/uber/h3/releases/tag/v3.5.0) [![Build Status](https://travis-ci.com/uber/h3-js.svg?branch=master)](https://travis-ci.com/uber/h3-js) [![Coverage Status](https://coveralls.io/repos/github/uber/h3-js/badge.svg?branch=master)](https://coveralls.io/github/uber/h3-js?branch=master) | ||
[![H3 Version](https://img.shields.io/badge/h3_api-v3.6.0-blue.svg)](https://github.com/uber/h3/releases/tag/v3.6.0) [![Build Status](https://travis-ci.com/uber/h3-js.svg?branch=master)](https://travis-ci.com/uber/h3-js) [![Coverage Status](https://coveralls.io/repos/github/uber/h3-js/badge.svg?branch=master)](https://coveralls.io/github/uber/h3-js?branch=master) | ||
@@ -96,5 +98,6 @@ 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. | ||
* [.h3ToGeo(h3Index)](#module_h3.h3ToGeo) ⇒ <code>Array.<Number></code> | ||
* [.h3ToGeoBoundary(h3Index, formatAsGeoJson)](#module_h3.h3ToGeoBoundary) ⇒ <code>Array.<Array></code> | ||
* [.h3ToGeoBoundary(h3Index, formatAsGeoJson)](#module_h3.h3ToGeoBoundary) ⇒ <code>Array.<Array.<Number>></code> | ||
* [.h3ToParent(h3Index, res)](#module_h3.h3ToParent) ⇒ <code>H3Index</code> | ||
* [.h3ToChildren(h3Index, res)](#module_h3.h3ToChildren) ⇒ <code>Array.<H3Index></code> | ||
* [.h3ToCenterChild(h3Index, res)](#module_h3.h3ToCenterChild) ⇒ <code>H3Index</code> | ||
* [.kRing(h3Index, ringSize)](#module_h3.kRing) ⇒ <code>Array.<H3Index></code> | ||
@@ -104,3 +107,3 @@ * [.kRingDistances(h3Index, ringSize)](#module_h3.kRingDistances) ⇒ <code>Array.<Array.<H3Index>></code> | ||
* [.polyfill(coordinates, res, isGeoJson)](#module_h3.polyfill) ⇒ <code>Array.<H3Index></code> | ||
* [.h3SetToMultiPolygon(h3Indexes, formatAsGeoJson)](#module_h3.h3SetToMultiPolygon) ⇒ <code>Array.<Array></code> | ||
* [.h3SetToMultiPolygon(h3Indexes, formatAsGeoJson)](#module_h3.h3SetToMultiPolygon) ⇒ <code>Array.<Array.<Array.<Array.<Number>>>></code> | ||
* [.compact(h3Set)](#module_h3.compact) ⇒ <code>Array.<H3Index></code> | ||
@@ -115,3 +118,3 @@ * [.uncompact(compactedSet, res)](#module_h3.uncompact) ⇒ <code>Array.<H3Index></code> | ||
* [.getH3UnidirectionalEdgesFromHexagon(h3Index)](#module_h3.getH3UnidirectionalEdgesFromHexagon) ⇒ <code>Array.<H3Index></code> | ||
* [.getH3UnidirectionalEdgeBoundary(edgeIndex, formatAsGeoJson)](#module_h3.getH3UnidirectionalEdgeBoundary) ⇒ <code>Array.<Array></code> | ||
* [.getH3UnidirectionalEdgeBoundary(edgeIndex, formatAsGeoJson)](#module_h3.getH3UnidirectionalEdgeBoundary) ⇒ <code>Array.<Array.<Number>></code> | ||
* [.h3Distance(origin, destination)](#module_h3.h3Distance) ⇒ <code>Number</code> | ||
@@ -125,2 +128,3 @@ * [.h3Line(origin, destination)](#module_h3.h3Line) ⇒ <code>Array.<H3Index></code> | ||
* [.getRes0Indexes()](#module_h3.getRes0Indexes) ⇒ <code>Array.<H3Index></code> | ||
* [.getPentagonIndexes(res)](#module_h3.getPentagonIndexes) ⇒ <code>Array.<H3Index></code> | ||
* [.degsToRads(deg)](#module_h3.degsToRads) ⇒ <code>Number</code> | ||
@@ -251,3 +255,3 @@ * [.radsToDegs(rad)](#module_h3.radsToDegs) ⇒ <code>Number</code> | ||
### h3.h3ToGeoBoundary(h3Index, formatAsGeoJson) ⇒ <code>Array.<Array></code> | ||
### h3.h3ToGeoBoundary(h3Index, formatAsGeoJson) ⇒ <code>Array.<Array.<Number>></code> | ||
Get the vertices of a given hexagon (or pentagon), as an array of [lat, lng] | ||
@@ -257,3 +261,3 @@ points. For pentagons and hexagons on the edge of an icosahedron face, this | ||
**Returns**: <code>Array.<Array></code> - Array of [lat, lng] pairs | ||
**Returns**: <code>Array.<Array.<Number>></code> - Array of [lat, lng] pairs | ||
@@ -298,2 +302,17 @@ | Param | Type | Description | | ||
<a name="module_h3.h3ToCenterChild"></a> | ||
### h3.h3ToCenterChild(h3Index, res) ⇒ <code>H3Index</code> | ||
Get the center child of the given hexagon at a particular resolution | ||
**Returns**: <code>H3Index</code> - H3 index of child, or null for invalid input | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| h3Index | <code>H3Index</code> | H3 index to get center child for | | ||
| res | <code>Number</code> | Resolution of hexagon to return | | ||
* * * | ||
<a name="module_h3.kRing"></a> | ||
@@ -363,3 +382,3 @@ | ||
| --- | --- | --- | | ||
| coordinates | <code>Array.<Array></code> | Array of loops, or a single loop | | ||
| coordinates | <code>Array.<Array.<Number>></code> \| <code>Array.<Array.<Array.<Number>>></code> | Array of loops, or a single loop | | ||
| res | <code>Number</code> | Resolution of hexagons to return | | ||
@@ -373,3 +392,3 @@ | isGeoJson | <code>Boolean</code> | Whether to expect GeoJson-style [lng, lat] pairs instead of [lat, lng] | | ||
### h3.h3SetToMultiPolygon(h3Indexes, formatAsGeoJson) ⇒ <code>Array.<Array></code> | ||
### h3.h3SetToMultiPolygon(h3Indexes, formatAsGeoJson) ⇒ <code>Array.<Array.<Array.<Array.<Number>>>></code> | ||
Get the outlines of a set of H3 hexagons, returned in GeoJSON MultiPolygon | ||
@@ -380,3 +399,3 @@ format (an array of polygons, each with an array of loops, each an array of | ||
**Returns**: <code>Array.<Array></code> - MultiPolygon-style output. | ||
**Returns**: <code>Array.<Array.<Array.<Array.<Number>>>></code> - MultiPolygon-style output. | ||
@@ -532,7 +551,7 @@ | Param | Type | Description | | ||
### h3.getH3UnidirectionalEdgeBoundary(edgeIndex, formatAsGeoJson) ⇒ <code>Array.<Array></code> | ||
### h3.getH3UnidirectionalEdgeBoundary(edgeIndex, formatAsGeoJson) ⇒ <code>Array.<Array.<Number>></code> | ||
Get the vertices of a given edge as an array of [lat, lng] points. Note that for edges that | ||
cross the edge of an icosahedron face, this may return 3 coordinates. | ||
**Returns**: <code>Array.<Array></code> - Array of geo coordinate pairs | ||
**Returns**: <code>Array.<Array.<Number>></code> - Array of geo coordinate pairs | ||
@@ -718,2 +737,16 @@ | Param | Type | Description | | ||
<a name="module_h3.getPentagonIndexes"></a> | ||
### h3.getPentagonIndexes(res) ⇒ <code>Array.<H3Index></code> | ||
Get the twelve pentagon indexes at a given resolution. | ||
**Returns**: <code>Array.<H3Index></code> - All H3 pentagon indexes at res | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| res | <code>Number</code> | Hexagon resolution | | ||
* * * | ||
<a name="module_h3.degsToRads"></a> | ||
@@ -720,0 +753,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
46495
852
4714607
16
33