Skip to content

Instantly share code, notes, and snippets.

Avatar
☠️
computing

Morgan Herlocker morganherlocker

☠️
computing
View GitHub Profile
View named-svg.js
var geojson2svg = require('geojson2svg');
var turf = require('turf');
var fs = require('fs')
var polys = require('polygons.json') // a featurecollection of geojson polygons with a name property
polys.features.forEach(function(poly){
var extent = turf.bbox(poly)
var options = {
viewportSize: {width: 200, height: 100},
mapExtent: {left: extent[0], bottom: extent[1], right: extent[2], top: extent[3]},
@morganherlocker
morganherlocker / index.js
Last active May 3, 2016
tile-reduce + cheap-ruler example
View index.js
var tileReduce = require('tile-reduce');
var path = require('path');
tileReduce({
zoom: 14,
map: path.join(__dirname, '/process.js'),
sources: [
{name: 'ways', mbtiles: 'ways.mbtiles')}
]
});
View timezones.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View bay_to_breakers.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View tile-grid-aggregation.js
var turf = require('turf')
var tilebelt = require('tilebelt')
// put your own data here
var stargazers = [<list of lat lons>]
// this sets the size of your grid cells; each grid cell is a map tile at the given zoom
var zoom = 12
// tiles is a hash we can quickly add new tiles too and increment counts
var tiles = {}
View edge-extract.js
var turf = require('turf')
var polys = //my polygon featurecollection
var edges = []
polys.features.forEach(function(poly){
for(var i = 0; i < poly.geometry.coordinates[0].length-1; i++){
edges.push({
start: turf.point(poly.geometry.coordinates[0][i]),
stop: turf.point(poly.geometry.coordinates[0][i+1])
})
View extract-surface.sh
../wgrib2 000 -s | grep "TMP:surface" | ../wgrib2 -i 000 -csv out.csv
View intersect-distance.js
var poly = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
51.17431640625,
47.025206001585396
View API.md

MatchResult

name type description
matched_points Array<Array<Number>> Coordinates the points snapped to the road network as latitude, longitude pairs.
indices Array<Number> Array that gives the indices of the matched coordinates in the original trace.
geometry String Geometry of the matched trace in the road network, compressed as a polyline with 6 decimals of precision.