Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created April 17, 2014 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/11000335 to your computer and use it in GitHub Desktop.
Save tmcw/11000335 to your computer and use it in GitHub Desktop.

Brute-force find which ASCII characters are used in polyline encodings, because I was too tired to think harder.

var polyline = require('polyline');
var chars = {};
function generate(length) {
var coords = [];
var loc = [0, 0];
for (var i = 0; i < length; i++) {
coords.push([loc[0], loc[1]]);
loc[0] += 3 * (Math.random() - 0.5);
loc[1] += 3 * (Math.random() - 0.5);
}
return coords;
}
for (var i = 0; i < 10000; i++) {
var encoded = polyline.encode(generate(1000));
for (var j = 0; j < encoded.length; j++) {
chars[encoded[j]] = true;
}
}
process.stdout.write(JSON.stringify(Object.keys(chars).sort()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment