Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helping to integrate h3 to php #95

Closed
neatlife opened this issue Jul 18, 2018 · 7 comments
Closed

helping to integrate h3 to php #95

neatlife opened this issue Jul 18, 2018 · 7 comments

Comments

@neatlife
Copy link
Contributor

I am wirting a php extension for h3: https://github.com/neatlife/php-h3, but when i call h3 function in php extension, it always report error like below:

image

hope someone help me to fix this error, thanks.

@dfellis
Copy link
Collaborator

dfellis commented Jul 18, 2018

degsToRads is not the function you think it is. It converts degrees to radians, not (lat, lng) coordinates + resolution to hexagon IDs. You want geoToH3 instead.

As for the error you're running into, I'm not sure if that's because the signature doesn't match (degsToRads only takes one double, not two doubles and an int) or if your .so file cannot be loaded because you're on a Mac (I think the standard there is .dylib; .so is the Linux file and .dll for Windows)

@isaacbrodsky
Copy link
Collaborator

@neatlife could you post the following?

  • output of uname -a
  • output of file path_to_your_h3.so
  • output of nm path_to_your_h3.so (if you're using Mac OSX)

Other than the naming issue @dfellis mentioned above, my guess is that this is happening because PHP is not loading the built H3 library, only your extension (which needs to statically include H3 or needs to find H3 dynamically) You could try using make install after building the Uber H3 library and see if that helps.

@neatlife
Copy link
Contributor Author

@dfellis Yes, you are right, i already fix nameing error: neatlife/php-h3@fcc9324

@neatlife
Copy link
Contributor Author

@isaacbrodsky Yes, of course

image

before write php extension, I already execute cmake and make and sudo make install command in h3 project

@isaacbrodsky
Copy link
Collaborator

One other thing I forgot to mention is running otool -L your_path_to_h3.so

Is the H3 library installed at /usr/local/lib/libh3.1.a (static library - this is the default) or at /usr/local/lib/libh3.1.dylib (dynamic library)?

If it's the first (.a), please try rebuilding and reinstalling H3 as a shared library:

cmake -DBUILD_SHARED_LIBS=ON .
make
sudo make install

You might need to rebuild your extension before retrying.

If that doesn't help, do you know if there's a way to set your extension to statically link to H3? This is what we do in the Java bindings and it avoids this issue.

@neatlife
Copy link
Contributor Author

neatlife commented Jul 20, 2018

@isaacbrodsky
otool output:

image

I run the below command, and recompile php extension, but error still exists

cmake -DBUILD_SHARED_LIBS=ON .
make
sudo make install

image

image

I search some article, but not find a way to link to h3 library in php extension.

@neatlife
Copy link
Contributor Author

@isaacbrodsky @dfellis I already fix this error, just pull the latest h3 code, and add link to h3 library neatlife/php-h3@6cedacd, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants