Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A thoroughfare [] beat Across the wilderness #140

Open
everestpipkin opened this issue Nov 30, 2016 · 0 comments
Open

A thoroughfare [] beat Across the wilderness #140

everestpipkin opened this issue Nov 30, 2016 · 0 comments

Comments

@everestpipkin
Copy link

everestpipkin commented Nov 30, 2016

screen shot 2016-11-29 at 9 01 04 pm

A thoroughfare [] beat Across the wilderness

Pathway of long-distance fiber-optic internet service provider cabling, as followed by Google Streetview. Coast-to-coast line (New York Stock Exchange to Googleplex)

A necessary thank-you to Ramakrishnan Durairajan, Paul Barford, Joel Sommers, and Walter Willinger for their whitepaper InterTubes: A Study of the US Long-haul Fiber-optic Infrastructure

PDF of book

CODE (node js):
var fs = require('fs');
var request = require('request');

var points =
//your list of long/lang pairs.
//example; [[-74.01211,40.70727], [-74.01297,40.70623], [-74.0131,40.70609], [-74.01323,40.70597], [-74.01381,40.70524], [-74.01386,40.70519], [-74.01389,40.70513], [-74.01393,40.70508], [-74.01402,40.70493], [-74.01407,40.70478], [-74.01409,40.70475], [-74.0141,40.70472], [-74.01422,40.7046], [-74.01424,40.70462]];
//obtainable from any hand-made google map by selecting 'export to kmz' in 'share', or programmaticaly by signing up to a paid maps api

var counter = 0;

var running = setInterval(function(){ going(counter)
counter ++;
if (counter === points.length) {
cleanup();
htmlmaker();
clearInterval(running);
}
}, 500);

function going(counter){

var squareimage = "https://maps.googleapis.com/maps/api/streetview?size=150x150&location=" + points[counter][1]+","+points[counter][0]+"&fov=50&heading=45&pitch=-90&key=YOURKEY";

request(squareimage, {encoding: 'binary'}, function(error, response, body) {fs.writeFile('square/'+counter+'.png', body, 'binary', function (err) {});});

console.log(counter)
}

function cleanup(){

for (d=0;d<15000;d++){
try {
fs.accessSync('square/'+d+'.png', fs.F_OK);
} catch (e) {
console.log(d + " does not exist- trying again");
going(d)
}
}
}

function htmlmaker(){
var html;

for (c=0;c<15001;c++){
html = html + "<img src="+c+".png>";

if (c==15000){
var data = fs.readFileSync("collector.html"); // make a blank file named this
var fd = fs.openSync("collector.html", 'w+');
var buffer = new Buffer(html);
fs.writeSync(fd, buffer, 0, buffer.length);
fs.writeSync(fd, data, 0, data.length);
fs.close(fd);
}
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants