Skip to content

Instantly share code, notes, and snippets.

Avatar
☠️
computing

Morgan Herlocker morganherlocker

☠️
computing
View GitHub Profile
View feature.json
{
"distance": 0.04162350800625099,
"curve": 0.009039173454286032,
"oneway=yes": 1.0,
"highway=trunk_link": 0.0,
"highway=primary": 0.0,
"lanes=2": 0.0,
"maxspeed=35 mph": 0.0,
"lanes=3": 0.0,
"highway=secondary": 0.0,
View bounty-example.md
  • Contributor: @morganherlocker
  • Task: Hausdorf Distance
  • Issue: https://github.com/Turfjs/turf/issues/1286
  • Estimated Time: 5 hours
  • Deadline: 3/10/18
  • Requested Budget: $50
  • Impact: Allows you to compare the similarity between two lines to find the most similar in a Collection or Set of lines.
View readme.md
cat line-delimitted-geo-data.json | node to-collection.js > valid-geojson.json
View quad-to-geojson
JSON.stringify(require('tilebelt').tileToGeoJSON(require('tilebelt').quadkeyToTile('1231002')))
View geojson-transform-stream.js
var through2 = require('through2')
var byline = require('byline')
process.stdin
.pipe(byline.createStream())
.pipe(through2(function(chunk, enc, next){
var data = JSON.parse(chunk.toString())
this.push(toGeoJSON(data))
View doublestream.js
var through2 = require('through2')
var fs = require('fs')
var byline = require('byline')
var combine = through2(function(chunk, enc, next){
console.log(chunk.toString())
console.log('--')
next()
})
View largest-hulls.js
var fc = // ... a featurecollection of polygons and multipolygons
var polys = turf.featurecollection([])
fc.features.forEach(function(poly){
if (poly.geometry.type === 'Polygon') {
polys.features.push(poly)
} else if (poly.geometry.type === 'MultiPolygon') {
// start max area at -Infinity
var max = {
View tile-out.js
var cover = require('tile-cover')
var tilebelt = require('tilebelt')
var turf = require('@turf/turf')
var features = [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
View not-inside-quick.js
var pts = // my point featurecollection
var polys = // my poly featurecollection
var tree = rbush()
polys.features.forEach(function(poly, i){
var bbox = turf.bbox(poly)
var idx = {
minX: bbox[0],
minY: bbox[1],
View inside-filter.js
var pts = // my point featurecollection
var polys = // my poly featurecollection
pts.features = pts.features.filter(function(pt){
var isInside = false
polys.features.forEach(function(poly){
if(turf.inside(pt, poly)) isInside = true
})
return isInside
})