mapbox / node-s2 Goto Github PK
View Code? Open in Web Editor NEWbindings for s2 in node
bindings for s2 in node
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();
});
indexing & comparison look wrong here https://github.com/mapbox/node-s2/blob/master/index.js#L75 - either this check is always false or always true, or only compares longitude
A segfault occurs when a bad polygon array is input. This should be handled and output a more helpful message.
latlng.lat
would be better than latlng.lat()
. Need to figure out how to do this without changing object construction entirely
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
Can we ignore DISALLOW_EVIL_CONSTRUCTORS*? I would like to be able to expose s2polygon and s2polyline, but apparently we are not supposed to. I did notice that s2map uses s2polygon anyway.
*Note: I might be misunderstanding the purpose of this flag, but I am thinking of it as a sort of 'private' flag that means we should not instantiate whatever it is referring to.
https://github.com/blackmad/s2map/blob/master/s2map-server/http-server.c#L248
this will be a hot area of the code
pros:
cons:
this should be a parallel project that runs tests against node-s2 but migrates methods away from cpp
We should start building binaries for this module using node-pre-gyp
../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
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.
@morganherlocker want to try this out?
So: is the output of cellid.totoken ordered - as in, rangeMin and rangeMax will correctly compare as strings?
This is important because we need an index encoding that easily supports range queries.
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
This is just compiling code so far. Need to write bindings.
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.
../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]
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.
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.
The basic idea here is to allow some way to get a polygon into getCover from node. I am exploring options, but this may or may not involve exposing s2Polygon. This is the type of result I am looking to achieve:
Some methods are s1, s2, r2.
Oh man, pwn moment: S2 may expect tesselated polygons :/
warning: ‘char* NanCString(v8::Handle<v8::Value>, size_t*, char*, size_t, int)’ is deprecated (declared at ../node_modules/nan/nan.h:2285)
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
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.