mhulse / kludgy

Kludgy: A macOS Node.js module/app that generates a random Google Street View desktop wallpaper.
Apache License 2.0
4 stars 2 forks source link

Why do some panos fail? #4

Closed mhulse closed 7 years ago

mhulse commented 7 years ago

Can we stop the process if the image does fail?

Maybe regenerate another?

mhulse commented 7 years ago

Good test:

$ npm run esv -- "9.74885,-63.15585550000003" --zoom max > ./foo.png

https://www.instantstreetview.com/@9.74885,-63.155856,342.85h,-16.01p,1z

mhulse commented 7 years ago
$ npm run esv -- "CAoSLEFGMVFpcE9ZUE5CQ3phaTFfeTd6dDFpR3RuTlJpY3lPV3VrSnEwdS0yRl9J" --id --zoom max > ./foo.png
Error: could not find street view by id: CAoSLEFGMVFpcE9ZUE5CQ3phaTFfeTd6dDFpR3RuTlJpY3lPV3VrSnEwdS0yRl9J
    at handleResponse (/Users/mhulse/dev/github/mhulse/random-street-coords/node_modules/google-panorama-by-id/browser.js:38:10)
    at Q3 (https://maps.googleapis.com/maps-api-v3/api/js/27/14/streetview.js:68:394)
    at .En (https://maps.googleapis.com/maps-api-v3/api/js/27/14/common.js:39:135)
    at Object.c [as _ffozth] (https://maps.googleapis.com/maps-api-v3/api/js/27/14/common.js:49:404)
    at https://maps.googleapis.com/maps/api/js/GeoPhotoService.GetMetadata?pb=!1m5!1sapiv3!5sUS!11m2!1m1!1b0!2m2!1sen!2sUS!3m3!1m2!1e2!2sCAoSLEFGMVFpcE9ZUE5CQ3phaTFfeTd6dDFpR3RuTlJpY3lPV3VrSnEwdS0yRl9J!4m10!1e1!1e2!1e3!1e4!1e8!1e6!5m1!1e2!6m1!1e2&callback=_xdc_._ffozth:1:28

Get panorama id from here: https://istreetview.com/CAoSLEFGMVFpcE9ZUE5CQ3phaTFfeTd6dDFpR3RuTlJpY3lPV3VrSnEwdS0yRl9J

mhulse commented 7 years ago

Pano exists.

Thinking I need to just dissect the extract streetview module and get the code I need.

mhulse commented 7 years ago

Use this code:

https://github.com/mattdesl/google-panorama-equirectangular/tree/master/lib

And use browserify to pass pano.tiles to the above code; get images.

Next, create equirectangular.

mhulse commented 7 years ago

After researching this some more, it looks like custom panos are hard to predict in terms of URL as they contain some sort of USER id.

I think the best option will be to figure out how to exclude custom panos from my primary Google maps script.

https://github.com/mattdesl/google-panorama-equirectangular/issues/9

mhulse commented 7 years ago

Here's an alternative/simpler way of getting rand lat/lon:

<script src="https://maps.googleapis.com/maps/api/js?v=3&key=xxxxxx"></script>
<script>
function TryRandomLocation(callback) {
  //var lat = (Math.random() * 90) - 90;
  var lat = Math.random() * Math.max((180 - 0 * .25), 120) - (90 - Math.min(0 * .25, 45));
  var lng = Math.random() * 360 - 180;
  var sv = new google.maps.StreetViewService();

  // Try to find a panorama within 50 metres 
  sv.getPanorama({
      location: new google.maps.LatLng(lat, lng),
      radius: 50
  }, callback);
}

function HandleCallback(data, status) {
    if (status == 'OK') {
      // Call your code to display the panorama here.
      console.log(data)
    } else {
        console.log('Trying again')
      // Nothing here! Let's try another location.
      TryRandomLocation(HandleCallback);
    }
}

window.onload = function() {
  TryRandomLocation(HandleCallback);
}
</script>

https://stackoverflow.com/a/44478605/922323

Might need to rethink my approach.

Some have suggested working with bounds of a country as the earth has a lot of ocean.

mhulse commented 7 years ago

Going to just throw in check for copyright; if it's copyright Google, I'm going to assume streetview will work with the extensions I'm using.

mhulse commented 7 years ago

Just added in a conditional that checks the copyright. Works well enough for now.