Permalink
Browse files

support returning 64bit Number for grid base_mask

  • Loading branch information...
Dane Springmeyer
Dane Springmeyer committed Dec 20, 2012
1 parent 238aafa commit 1bf95e45b1de40f59596241dca769349a2e49a27
Showing with 13 additions and 7 deletions.
  1. +1 −1 src/mapnik_grid.cpp
  2. +1 −1 src/mapnik_grid_view.cpp
  3. +6 −0 src/utils.hpp
  4. +5 −5 test/grid_view.test.js
View
@@ -44,7 +44,7 @@ void Grid::Initialize(Handle<Object> target) {
#if MAPNIK_VERSION < 200100
NODE_MAPNIK_DEFINE_CONSTANT(constructor->GetFunction(), "base_mask", 0);
#else
- NODE_MAPNIK_DEFINE_CONSTANT(constructor->GetFunction(), "base_mask", mapnik::grid::base_mask);
+ NODE_MAPNIK_DEFINE_64_BIT_CONSTANT(constructor->GetFunction(), "base_mask", mapnik::grid::base_mask);
#endif
}
View
@@ -251,7 +251,7 @@ Handle<Value> GridView::getPixel(const Arguments& args)
if (x < view->width() && y < view->height())
{
mapnik::grid_view::value_type pixel = view->getRow(y)[x];
- return Integer::New(pixel);
+ return Number::New(pixel);
}
return Undefined();
}
View
@@ -35,6 +35,12 @@
static_cast<v8::PropertyAttribute>( \
v8::ReadOnly|v8::DontDelete));
+#define NODE_MAPNIK_DEFINE_64_BIT_CONSTANT(target, name, constant) \
+ (target)->Set(v8::String::NewSymbol(name), \
+ v8::Number::New(constant), \
+ static_cast<v8::PropertyAttribute>( \
+ v8::ReadOnly|v8::DontDelete));
+
using namespace v8;
using namespace node;
View
@@ -23,20 +23,20 @@ describe('mapnik.GridView ', function() {
if (mapnik.versions.mapnik_number < 200100) {
assert.equal(pixel, 0);
} else {
- assert.equal(pixel, -2147483648);
- assert.equal(pixel, mapnik.Grid.base_mask);
+ assert.equal(pixel,-1 * 0x7FFFFFFFFFFFFFFF);
+ assert.equal(pixel, mapnik.Grid.base_mask.toFixed());
}
done();
});
});
- it('should have zero value for pixel', function() {
+ it('should report grid base_mask value for pixel', function() {
var pixel = view.getPixel(0, 0);
if (mapnik.versions.mapnik_number < 200100) {
assert.equal(pixel, 0);
} else {
- assert.equal(pixel, -2147483648);
- assert.equal(pixel, mapnik.Grid.base_mask);
+ assert.equal(pixel, -1 * 0x7FFFFFFFFFFFFFFF);
+ assert.equal(pixel.toFixed(), mapnik.Grid.base_mask.toFixed());
}
});

0 comments on commit 1bf95e4

Please sign in to comment.