This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: Not sure how well it works with very large squares due to projection distortion | |
var turf = require('turf'); // For NodeJS | |
function getSquareAroundPointWithArea(point, area) { | |
// Area in m2 | |
var coordinates = []; | |
var areaInKm = area / 1000 / 1000; | |
var edgeLength = Math.sqrt(areaInKm); | |
var diagonal = Math.sqrt(Math.pow(edgeLength, 2) + Math.pow(edgeLength, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Query for a certain OSM ID in Overpass Turbo (https://overpass-turbo.eu/) | |
// e.g. for http://www.openstreetmap.org/way/329871559 | |
// Replace the number below with the OSM ID | |
[out:json][timeout:25]; | |
( | |
node(329871559); | |
way(329871559); | |
relation(329871559); | |
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var coordinatesString = "223.177496408,3814.53101376 210.997794052,3807.13302253 195.852458671,3793.15810611 193.993838635,3791.43941224 180.933214269,3772.19079794 170.136151235,3747.26405193 165.198319283,3723.470457 163.682660844,3678.3761749 156.176550135,3555.30499258 151.509512401,3480.88344101 145.426837106,3400.82934564 143.794799706,3364.1990739 143.798834889,3326.0160711 150.571949561,3300.02762516 160.269931448,3276.84312163 172.710136954,3253.09881653 191.619853303,3230.83282556 216.520246839,3210.98593792 239.837973955,3200.03271458 260.488917349,3192.51986408 274.107463498,3190.53640455 288.34689427,3188.89624907 304.890225132,3189.71668734 328.216563439,3192.98221144 345.935882157,3196.87585617 358.827514541,3202.22143433 371.831727975,3208.85035743 388.203233763,3219.72972793 409.103972729,3237.94034309 425.300490135,3258.88452843 444.210350636,3303.2243898 447.967830543,3319.477736 448.705200294,3345.05481017 443.331961433,3372.210188 429.295830231,3405.64584587 412.766832771,3427.98420714 39 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example(); | |
function calculateBendWay(vectorLengths, deltaAngles){ | |
if (vectorLengths.length !== deltaAngles.length) { | |
throw 'the number of vectors don\'t match up with the number of angles (one less angle than the number of vectors)' | |
} | |
var entireBendWay = 0; | |
for (var i = 0; i < vectorLengths.length; i++) { | |
var vectorLength = vectorLengths[i]; | |
var deltaAngle = deltaAngles[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var turf = require('turf'); | |
fs.readFile('feature.geojson', 'utf8', function (err,data) { | |
if (err) { | |
return console.log(err); | |
} | |
var feature = JSON.parse(data); | |
var length = turf.lineDistance(feature); | |
console.log(length + 'km'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(); | |
console.log('Examples'); | |
console.log(); | |
console.log('- All Bike (dot bottom right)'); | |
console.log(' ', mobilityTriangle(1123, 0, 0) ); | |
console.log(); | |
console.log('- All Car (dot top)'); | |
console.log(' ', mobilityTriangle(0, 124, 0) ); | |
console.log(); | |
console.log('- All Rail (dot bottom left)'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = {}; | |
addAverageData(data, 'averageAppleDiameter', 5); | |
addAverageData(data, 'averageAppleDiameter', 7); | |
addAverageData(data, 'averageAppleDiameter', 8); | |
addAverageData(data, 'averageAppleDiameter', 9); | |
addAverageData(data, 'averagePearDiameter', 9); | |
addAverageData(data, 'averagePearDiameter', 4); | |
addAverageData(data, 'averagePearDiameter', 6); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongodump --db <yourdb> --gzip --archive=/path/to/archive | |
mongorestore --gzip --archive=/path/to/archive | |
mongorestore --gzip --archive=/path/to/archive/fileName.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOffsetOutline(lineString, thickness, side) { | |
// thickness in km | |
var direction = 1; | |
if (side === 'left') { | |
direction = -1; | |
} else if (side === 'right') { | |
direction = 1; | |
} else { | |
console.log('Please specify direction as \'left\' or \'right\''); |
OlderNewer