dfellis / h3-node Goto Github PK
View Code? Open in Web Editor NEWH3 binding to Node using N-API
License: MIT License
H3 binding to Node using N-API
License: MIT License
Scanned through the docs of both projects, this is what's missing to reach parity:
h3GetFaces
h3ToCenterChild
pointDist
cellArea
exactEdgeLength
getPentagonIndexes
These all seem simple enough functions that it shouldn't be a problem to add them all in one PR. Maybe a bit later today depending on spare time.
So before h3-node
can reach parity with h3-js
, I have to implement the h3SetToMultiPolygon
function from it, which has the interesting distinction of being the only H3 function that is only available to h3-js
users, since a critical component of it is written in the binding instead of at the C level.
There are roughly three ways that I can tackle this, in order of difficulty:
h3SetToLinkedGeo
and destroyLinkedPolyon
functions and then mostly-copy-paste the h3-js Javascript implementation.readMultiPolygon
function in C using N-API to construct the Array-of-Arrays-of-Arrays-of-Doubles.readMultiPolygon
function in C in the core H3 library with a new struct type to construct the Array-of-Arrays-of-Arrays-of-Doubles and then port h3-js
and h3-node
to use this form, instead.The third option is the most preferable, because that will unlock this functionality for the Python, Go, and Java bindings, as well as, of course, the direct C users and any third-party bindings (though none of the third party bindings have prioritized 100% parity that I can see so far). But I also don't know when I will be able to get time to do it, because the other bindings have all been relatively simple and I could squeeze in a few here or there in my schedule, besides polyfill
(but since I wrote that originally for the C, JS, and Python H3s I knew what to do), while this will probably require literal full working days of time in larger contiguous blocks so I can keep the problem in my head.
The first option is basically punting the can down the road, and the second option seems like an evolutionary cul-de-sac since it would be extra effort to do but would also be thrown away like the first option once the third is done.
@isaacbrodsky @nrabinowitz what are your thoughts on this problem?
I am facing issue as mentioned below while installing the h3-node :
C:\users\pranjal gupta\Desktop\app-server\node_modules\h3-node>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild --target=10.16.0 --target_arch=x64 --release ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild --target=10.16.0 --target_arch=x64 --release )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Pranjal Gupta\AppData\Local\Programs\Python\Python38\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=10.16.0" "--target_arch=x64" "--release"
gyp ERR! cwd C:\users\pranjal gupta\Desktop\app-server\node_modules\h3-node
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-gyp exited with 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] prebuild: bash .prebuild.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Pranjal Gupta\AppData\Roaming\npm-cache_logs\2020-04-08T05_42_42_844Z-debug.log
npm WARN [email protected] requires a peer of rbush@^2.0.2 but none is installed. You must install peer dependencies yourself.npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: bash -c "if node-gyp-build-test; then node-gyp-build; else npm run prebuild && node-gyp-build; fi"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Pranjal Gupta\AppData\Roaming\npm-cache_logs\2020-04-08T05_42_44_597Z-debug.log
npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! [email protected] install:
bash -c "if node-gyp-build-test; then node-gyp-build; else npm run prebuild && node-gyp-build; fi"`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ptipl\AppData\Roaming\npm-cache_logs\2021-03-02T10_19_35_292Z-debug.log`
npm ERR! code 127
npm ERR! path /Users/patrickjarnfelt/projects/SpiritWorld/spirit_world_server_cms/node_modules/h3-node
npm ERR! command failed
npm ERR! command sh -c bash -c "if node-gyp-build-test; then node-gyp-build; else npm run prebuild && node-gyp-build; fi"
npm ERR! > [email protected] prebuild
npm ERR! > bash .prebuild.sh
npm ERR!
npm ERR!
npm ERR! > [email protected] clean
npm ERR! > node-gyp clean && rm -rf h3
npm ERR!
npm ERR! /usr/bin/make
npm ERR! /Users/patrickjarnfelt/projects/SpiritWorld/spirit_world_server_cms/node_modules/node-gyp-build/index.js:60
npm ERR! throw new Error('No native build was found for ' + target + '\n loaded from: ' + dir + '\n')
npm ERR! ^
npm ERR!
npm ERR! Error: No native build was found for platform=darwin arch=x64 runtime=node abi=93 uv=1 libc=glibc node=16.13.2
npm ERR! loaded from: /Users/patrickjarnfelt/projects/SpiritWorld/spirit_world_server_cms/node_modules/h3-node
npm ERR!
npm ERR! at Function.load.path (/Users/patrickjarnfelt/projects/SpiritWorld/spirit_world_server_cms/node_modules/node-gyp-build/index.js:60:9)
npm ERR! at load (/Users/patrickjarnfelt/projects/SpiritWorld/spirit_world_server_cms/node_modules/node-gyp-build/index.js:22:30)
npm ERR! at Object.<anonymous> (/Users/patrickjarnfelt/projects/SpiritWorld/spirit_world_server_cms/node_modules/node-gyp-build/build-test.js:19:19)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1101:14)
npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:981:32)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:822:12)
npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR! at node:internal/main/run_main_module:17:47
npm ERR!
npm ERR! COMMON_CMAKE_ARGS=-DCMAKE_BUILD_TYPE=Release
npm ERR! + COMMON_CMAKE_ARGS=-DCMAKE_BUILD_TYPE=Release
npm ERR!
npm ERR! npm run clean &&
npm ERR! git clone https://github.com/uber/h3 &&
npm ERR! cd h3 &&
npm ERR! git checkout v3.7.2 &&
npm ERR! if command -v make; then
npm ERR! if [[ "${ARCH}" == "ia32" ]]; then
npm ERR! cmake . ${COMMON_CMAKE_ARGS} -DCMAKE_C_FLAGS="-fPIC -m32";
npm ERR! else
npm ERR! cmake . ${COMMON_CMAKE_ARGS} -DCMAKE_C_FLAGS=-fPIC;
npm ERR! fi
npm ERR! else
npm ERR! if [[ "${Platform}" == "x64" ]]; then
npm ERR! cmake . ${COMMON_CMAKE_ARGS} -DCMAKE_VS_PLATFORM_NAME=${Platform} -G "Visual Studio 14 Win64";
npm ERR! else
npm ERR! cmake . ${COMMON_CMAKE_ARGS} -DCMAKE_VS_PLATFORM_NAME=${Platform};
npm ERR! fi
npm ERR! fi &&
npm ERR! cmake --build . --target h3 --config Release &&
npm ERR! cd .. &&
npm ERR! prebuildify --target=node@`node --version | sed s/v//`
npm ERR! + npm run clean
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info ok
npm ERR! + git clone https://github.com/uber/h3
npm ERR! Cloning into 'h3'...
npm ERR! + cd h3
npm ERR! + git checkout v3.7.2
npm ERR! Note: switching to 'v3.7.2'.
npm ERR!
npm ERR! You are in 'detached HEAD' state. You can look around, make experimental
npm ERR! changes and commit them, and you can discard any commits you make in this
npm ERR! state without impacting any branches by switching back to a branch.
npm ERR!
npm ERR! If you want to create a new branch to retain commits you create, you may
npm ERR! do so (now or later) by using -c with the switch command. Example:
npm ERR!
npm ERR! git switch -c <new-branch-name>
npm ERR!
npm ERR! Or undo this operation with:
npm ERR!
npm ERR! git switch -
npm ERR!
npm ERR! Turn off this advice by setting config variable advice.detachedHead to false
npm ERR!
npm ERR! HEAD is now at 26a6409 Backport fix potential segfault in kRing due to invalid digit (#498) (#500)
npm ERR! + command -v make
npm ERR! + [[ '' == \i\a\3\2 ]]
npm ERR! + cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fPIC
npm ERR! .prebuild.sh: line 15: cmake: command not found
I am considering using this in one of my projects. Just wanted to ask whether there is a plan to port to H3 4.x? There are some new functions in 4.x that I need.
Thanks for the awesome work.
command not found: cmake
is happing while installing.
Now that it's been converted to Github Actions and build artifacts are working, it should be possible to write a publish script that downloads the artifacts, shoves the relevant pieces into the prebuildify
directory, and then includes them in the artifact published to NPM.
But I've spent way more than the time I wanted to allot to working on this repo today, so this is a reminder to tackle this another day.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.