Giter VIP home page Giter VIP logo

node-s2's Introduction

Build Status

node-s2

Bindings for the S2 Geometry Library into node.js.

S2 is a library that does spherical math over the world, and supports a very fancy Hilbert curve-related indexing scheme. S2 has no documentation besides source comments and this presentation. Notably it's used for MongoDB's 2dsphere index, as well as in viewfinderco's DynamoDB-powered database. s2map.com also demonstrates one of the killer features of the library, 'coverings', which are intelligently computed groups of cells that can be used to index geometries.

Example

var s2 = require('s2');

var ll = new s2.S2LatLng(0, 0);
ll.isValid(); // true
var normalized = ll.normalized(); // true
var pt = ll.toPoint();

Build

npm install
npm build . --build-from-source
npm test

Geojson

node-s2 is a low level s2 wrapper. If you are simply looking to get geojson into s2, you should check out geojson-cover.

Notes

Some of the S2 API is not wrapped because it isn't meant to be exposed in this way, and is blocked from wrapping by DISALLOW_COPY_AND_ASSIGN.

  • S2CellUnion
  • S2Loop
  • S2Polyline
  • S2Polygon
  • S2RegionCoverer
  • S2RegionIntersection

See Also

node-s2's People

Contributors

dennisosrm avatar gerhardberger avatar joshie avatar markyen avatar mick avatar morganherlocker avatar rhagigi avatar tmcw 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  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  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  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  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  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  avatar  avatar  avatar  avatar  avatar

node-s2's Issues

NanCString deprecated

warning: ‘char* NanCString(v8::Handle<v8::Value>, size_t*, char*, size_t, int)’ is deprecated (declared at ../node_modules/nan/nan.h:2285) 

segfault exception

A segfault occurs when a bad polygon array is input. This should be handled and output a more helpful message.

polygon getcover array

current:

[
  [0, 2],
  [1, 1],
  [0, 0]
]

proposed:

[
  [
    [0, 2],
    [1, 1],
    [0, 0]
  ]
]

This would allow us to handle holes and multipolys. Not sure if we should have a seperate type option 'multipolygon'; leaning towards no.

‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated

../src/s2.cc:43:22: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:43:37: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:44:44: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:44:59: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:46:22: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:46:37: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:47:44: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:47:59: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:49:22: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:49:37: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:50:44: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:50:59: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:52:22: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:52:43: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:53:44: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:53:65: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:63:40: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]
../src/s2.cc:63:56: warning: ‘v8::Local<v8::String> NanSymbol(const char*, int)’ is deprecated (declared at ../node_modules/nan/nan.h:1026) [-Wdeprecated-declarations]

geobuf to<-->from

It is pretty simple to work with node-s2 from geojson now (or will be shortly; I have a few commits on the way). We may want to add this same sort of support from/to geobuf.

build failed on ubuntu

This looks like the most relevant part:

CXX(target) Release/obj.target/_s2/geometry/s2.o
In file included from ../geometry/s2.cc:197:0:
../geometry/util/math/exactfloat/exactfloat.h:109:24: fatal error: openssl/bn.h: No such file or directory
 #include "openssl/bn.h"
                        ^
compilation terminated.
make: *** [Release/obj.target/_s2/geometry/s2.o] Error 1
make: Leaving directory `/tmp/slugger.WvfAFuKh/api-data/node_modules/cardboard/node_modules/s2/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/tmp/slugger.WvfAFuKh/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Linux 3.13.0-24-generic
gyp ERR! command "node" "/tmp/slugger.WvfAFuKh/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/slugger.WvfAFuKh/api-data/node_modules/cardboard/node_modules/s2
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok

cc: @tmcw @morganherlocker

S2Cap constructor

hi
i just have a quick question: how do i call the constructors of the S2Cap class?
i figured out form the code that e.g. FromAxisAngle needs an S2Point and an S1Angle but I can't figured out the syntax
thanks

prefix-preserving id scheme

Right now we have ToToken and ToString. Neither of these properly preserve the prefix property of cell IDs: the only format that does is binary. It's possible to encode this, either as a binary string, or as some encoding that encodes each pair of bits in the string.

odd line covering

I noticed that the s2 line covering looks a bit off. I will dig in and see if it is some sort of orientation issue.

screenshot 2014-07-21 10 17 22

s2 from geojson (or some other standard)

There should probably be a direct way to use geojson (or some other standardized format; geobuf?) for generating covers. Currently the map to an s2LatLng array works, but is not be the most intuitive. Also, this function could handle things like orientation and holes in a consistent fashion. For reference, this is how we currently create an array representing a polyline or polygon:

var s2Line = [
        [0, 2],
        [1, 1],
        [0, 0]
    ].map(function(p) {
        return (new s2.S2LatLng(p[0], p[1])).normalized().toPoint();
    });

s2cell.h will not compile

../geometry/s2cell.cc:190:37: error: too many arguments provided to function-like macro invocation
  DCHECK_EQ(((face_ < 3) ? 1 : -1), S2::GetNorm(face_)[face_ % 3]);
                                    ^
../geometry/base/logging.h:38:43: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) CHECK(val1, val2)
                                          ^
../geometry/base/logging.h:26:9: note: macro 'CHECK' defined here
#define CHECK(x)        if(x){}else LogMessageFatal(__FILE__, __LINE__).stream() << "Check failed: " #x
        ^
../geometry/s2cell.cc:190:3: error: use of undeclared identifier 'CHECK'
  DCHECK_EQ(((face_ < 3) ? 1 : -1), S2::GetNorm(face_)[face_ % 3]);
  ^
../geometry/base/logging.h:38:31: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) CHECK(val1, val2)
                              ^
1 warning and 2 errors generated.
make: *** [Release/obj.target/_s2/geometry/s2cell.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Darwin 13.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/tmcw/src/node-s2
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok

Wrapping coordinates in Linear Rings for S2LatLngRect.toGeojson()

Should we wrap the coordinates of rings in the S2LatLngRect.toGeojson function?

Relevant text from the geojson spec:

A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.

Polygon cover

begin s2js

this should be a parallel project that runs tests against node-s2 but migrates methods away from cpp

Write bindings

This is just compiling code so far. Need to write bindings.

NanSymbol deprecated

From the nan May 2014 release:

We've deprecated NanSymbol(), you should just use NanNew() now.

This may cause issues in the future when we upgrade to node 0.11

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.