forked from mapnik/node-mapnik
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add isSolid/getPixel implementations for mapnik.GridView - closes map…
- Loading branch information
Dane Springmeyer
committed
Jan 30, 2012
1 parent
4dd846b
commit 0345b66
Showing
3 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var mapnik = require('mapnik'); | ||
var assert = require('assert'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
|
||
exports['test grid view getPixel'] = function(beforeExit) { | ||
var grid = new mapnik.Grid(256, 256); | ||
var view = grid.view(0,0,256,256); | ||
assert.equal(view.isSolid(),true); | ||
|
||
var pixel = view.getPixel(0,0); | ||
assert.equal(pixel,0); | ||
|
||
var map = new mapnik.Map(256, 256); | ||
map.loadSync('./examples/stylesheet.xml'); | ||
map.zoomAll(); | ||
var options = {'layer': 0, | ||
'fields': ['NAME'] | ||
}; | ||
var grid = new mapnik.Grid(map.width, map.height, {key: '__id__'}); | ||
map.render(grid, options, function(err, grid) { | ||
|
||
var view = grid.view(0,0,256,256); | ||
assert.equal(view.isSolid(),false); | ||
// hit alaska (USA is id 207) | ||
assert.equal(view.getPixel(25,100),207); | ||
}) | ||
|
||
}; |