Skip to content

Instantly share code, notes, and snippets.

View morganherlocker's full-sized avatar
☠️
computing

Morgan Herlocker morganherlocker

☠️
computing
View GitHub Profile
{
"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,
  • Contributor: @morganherlocker
  • Task: Hausdorf Distance
  • Issue: Turfjs/turf#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.
cat line-delimitted-geo-data.json | node to-collection.js > valid-geojson.json
JSON.stringify(require('tilebelt').tileToGeoJSON(require('tilebelt').quadkeyToTile('1231002')))
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))
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()
})
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 = {
var cover = require('tile-cover')
var tilebelt = require('tilebelt')
var turf = require('@turf/turf')
var features = [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
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],
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
})