Giter VIP home page Giter VIP logo

s2's Introduction

s2: R bindings for Google's s2 library for geometry on the sphere

Build Status Build status

The package (master branch) currently passes R CMD check without any errors and warnings on Linux, OSX and Windows. Only a minor subset of the C++ library is wrapped at the moment. Simple R data structures such as plain matrices and lists are used. The API is not stable and changes should be expected.

The core C++ code is in src/geometry. This code is a slightly modified copy of the corresponding directory in this repo. (The subdirectories python and test are removed since they aren't needed by the R package.) The modifications to the original code are minor edits to satisfy the R package checker, and no new functionality is introduced at the C++ level.

The original source code was compiled into several shared objects with cmake, but we simply build everything into one shared object using the R standard file Makevars.in (Makevars.win on Windows) together with a configure script. This decision was based on advice given by Dirk Eddelbuettel to the RcppCAF package at stackoverflow. The configure script checks for the system requirement openssl and is based on the configure script by Jeroen Ooms in the openssl R package.

s2's People

Contributors

edzer avatar jeroen avatar rubak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

s2's Issues

Adding AppendAllNeighbors functionality

Thank you for this package. Thus far I have used it for pretty basic grouping of spatial points. I'm now trying to apply spatial operations (distances calculations etc.) on a global dataset, where the comparisons are only important for points within the vicinity of one another. I would like to perform an initial join using neighboring s2cells and then apply the spatial calculations just for those points in neighboring s2cells. I had a quick look and I didn't seen an implementation of AppendAllNeighbors in the package. Is there any thought to adding this or any of the neighbor functions (GetEdgeNeighbors, GetVertexNeighbors)? That would be incredibly useful.

S2CellIdFromLatLng method is missing

Hello,
I have forked the project and added the code to support the S2CellIdFromLatLng.
Is there any instructions or script for making the package/library?

Thank you in advance.

Linking to openssl 1.1 on Debian not working

The package doesn't compile on Debian with openssl 1.1 which can be tested with rhub::check (with the root of the s2 package as current working directory):

rhub::check(platform = "debian-gcc-devel")

The problem arises when exactfloat.cc is compiled

g++ -std=gnu++11 -I/opt/R-devel/lib/R/include -DNDEBUG -DS2_USE_EXACTFLOAT -DHASH_NAMESPACE=std -DNDEBUG -I./geometry -I./geometry/s2 -I/usr/local/include -I"/home/docker/R/Rcpp/include"  -pthread -fpic  -Wall -pedantic -c geometry/util/math/exactfloat/exactfloat.cc -o geometry/util/math/exactfloat/exactfloat.o
In file included from geometry/util/math/exactfloat/exactfloat.cc:3:0:
./geometry/util/math/exactfloat/exactfloat.h:502:10: error: field ‘bn_’ has incomplete type ‘BIGNUM {aka bignum_st}’
   BIGNUM bn_;
          ^~~
In file included from /usr/include/openssl/bn.h:32:0,
                 from ./geometry/util/math/exactfloat/exactfloat.h:108,
                 from geometry/util/math/exactfloat/exactfloat.cc:3:
/usr/include/openssl/ossl_typ.h:80:16: note: forward declaration of ‘BIGNUM {aka struct bignum_st}’
 typedef struct bignum_st BIGNUM;
                ^~~~~~~~~
In file included from geometry/util/math/exactfloat/exactfloat.cc:3:0:
./geometry/util/math/exactfloat/exactfloat.h: In constructor ‘ExactFloat::ExactFloat()’:
./geometry/util/math/exactfloat/exactfloat.h:562:15: error: ‘BN_init’ was not declared in this scope
   BN_init(&bn_);
               ^
geometry/util/math/exactfloat/exactfloat.cc: In function ‘int BN_ext_count_low_zero_bits(const BIGNUM*)’:
geometry/util/math/exactfloat/exactfloat.cc:75:25: error: invalid use of incomplete type ‘const BIGNUM {aka const struct bignum_st}’
   for (int i = 0; i < bn->top; ++i) {
                         ^~
In file included from /usr/include/openssl/bn.h:32:0,
                 from ./geometry/util/math/exactfloat/exactfloat.h:108,
                 from geometry/util/math/exactfloat/exactfloat.cc:3:
/usr/include/openssl/ossl_typ.h:80:16: note: forward declaration of ‘BIGNUM {aka struct bignum_st}’
 typedef struct bignum_st BIGNUM;
                ^~~~~~~~~
geometry/util/math/exactfloat/exactfloat.cc:76:20: error: invalid use of incomplete type ‘const BIGNUM {aka const struct bignum_st}’
     BN_ULONG w = bn->d[i];
                    ^~
In file included from /usr/include/openssl/bn.h:32:0,
                 from ./geometry/util/math/exactfloat/exactfloat.h:108,
                 from geometry/util/math/exactfloat/exactfloat.cc:3:
/usr/include/openssl/ossl_typ.h:80:16: note: forward declaration of ‘BIGNUM {aka struct bignum_st}’
 typedef struct bignum_st BIGNUM;
                ^~~~~~~~~
geometry/util/math/exactfloat/exactfloat.cc: In constructor ‘ExactFloat::ExactFloat(double)’:
geometry/util/math/exactfloat/exactfloat.cc:90:15: error: ‘BN_init’ was not declared in this scope
   BN_init(&bn_);
               ^
geometry/util/math/exactfloat/exactfloat.cc: In constructor ‘ExactFloat::ExactFloat(int)’:
geometry/util/math/exactfloat/exactfloat.cc:113:15: error: ‘BN_init’ was not declared in this scope
   BN_init(&bn_);
               ^
geometry/util/math/exactfloat/exactfloat.cc: In copy constructor ‘ExactFloat::ExactFloat(const ExactFloat&)’:
geometry/util/math/exactfloat/exactfloat.cc:125:15: error: ‘BN_init’ was not declared in this scope
   BN_init(&bn_);
               ^

CPPFLAGS vs CXXFLAGS

From your Makevars files it seems you are confusing CPPFLAGS with CXXFLAGS / CXX1XFLAGS.

  • CPPFLAGS: C/C++ preprocessor flags. These are applied both to c and c++ preprocessor. Usually this only includes flags that start with -D and -I.
  • CFLAGS / CXXFLAGS / CXX1XFLAGS: Compiler flags for the c/c++/c++11 compiler that are not in the preprocessor. Things like -g -o -pthread. You should rarely set these as R automatically uses the appropriate defaults.

As a package author you do not have to manually pass any CXXFLAGS or CXX1X flags in your Makevars. R does that automatically: c++ code is always compiled with CXXFLAGS (or CXX1XFLAGS when CXX_STD = CXX11)

Hence the configure script should only set the CPPFLAGS which are system dependent based on how libssl was compiled and where it resides on the user system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.