Skip to content

Instantly share code, notes, and snippets.

@mapsam
mapsam / .js
Created May 13, 2016 18:46
report node-mapnik validty/simplicity
#!/usr/bin/env node
"use strict";
var exists = require('fs').existsSync || require('path').existsSync;
var fs = require('fs');
var usage = 'usage:';
usage += '\n mapnik-info.js <tile.mvt> z x y';
var tile = process.argv[2];
@mapsam
mapsam / bench.js
Created May 12, 2016 23:22
node-mapnik bencharmking for protozero
var mapnik = require('mapnik');
var fs = require('fs');
var iterations = 20000,
i = total = 0,
max = -Infinity,
min = Infinity,
tile = './785.vector.pbf';
decode();
@mapsam
mapsam / .md
Last active April 7, 2016 22:29
c++ dependent dependents
version dependency dep version description
@mapsam
mapsam / error.point.geojson
Last active March 14, 2016 19:48
validity check
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mapsam
mapsam / ballard-labs.md
Last active March 10, 2016 23:01
Co-working spaces in Seattle
@mapsam
mapsam / usage.js
Created March 1, 2016 01:58
node-mapnik usage example
var fs = require('fs');
var map = new mapnik.Map(256, 256),
img = new mapnik.Image(256, 256),
data = fs.readFileSync('/path/to/data.shp'),
vectortile = new mapnik.VectorTile(0,0,0);
// add shapefile to vector tile
vectortile.addData(data, function(err) {
if (err) throw err;
@mapsam
mapsam / painted.md
Created February 19, 2016 20:22
Solid, painted, empty

Painted

Blake described a painted tile like this:

Think about if I was rendering a 0/0/0 tile from postgis and there was only a small park in my data. It would probably collapse to nothing at 0/0/0 resolution so the entire tile would be empty. So the tile would be considered empty, but there was originally data below it so for pyramid rendering we want to know that you can’t just copy this tile from now on. Therefore painted says “hey! there was some data!"(edited)

@mapsam
mapsam / readme.md
Created February 10, 2016 20:55
Mapnik Debug

Mapnik and the Mapnik-related tools have a series of useful debugging tools built into their repositories. Since these live across repos, it can be difficult to remember where they exist or even if know if they exist. This lists out all of the useful bin commands that have been built for debugging purposes when working on Mapnik.

node-mapnik

located at: https://github.com/mapnik/node-mapnik/tree/master/bin

  • mapnik-index.js
  • mapnik-inspect.js
  • mapnik-render.js
  • mapnik-shapeindex.js
@mapsam
mapsam / notes.md
Created February 9, 2016 20:12
Writing tests for node-mapnik

Writing tests for node-mapnik

node-mapnik is a Node.js module that binds the functionality of Mapnik to be used via a a JavaScript API.

They key parts

  • Mocha.js is our javascript testing suite that uses a set of functions and "assertions" to ensure the results of our code are as expected.
  • coveralls.io is a great tool that we use to check for coverage of our tests. It runs our tests for us, and is able to see which lines of code are used, and which are not during those tests. If a particular line of code isn't used during the tests, it shows as red, allowing us to write a particular test for that scenario.
  • The /test directory within the repository is where all of our tests are located.
  • make test is the command that runs our tests. This is actually running mocha -R spec
@mapsam
mapsam / README.md
Last active January 25, 2016 20:26
Benchmark: Encoding 1/22/2016

Benchmark numbers from node-mapnik version 3.4.15.

This is a visualization of the encoding benchmarks for the Mapnik implemention of Mapbox Vector Tile specification located here. Hovering on a line will show the file name. Clicking on that line will open a new tab to the data file for inspection or reference.