refine and add README
parent
d723f35a71
commit
2c91d36498
@ -0,0 +1 @@
|
|||||||
|
python initial_pano_id.py 53.168051 8.647656 | python walk_pano_id.py 10 | python streetview.py 5
|
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import urllib2
|
||||||
|
from xml.etree.ElementTree import ElementTree, fromstring
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
exit("need to supply lat and lon")
|
||||||
|
|
||||||
|
lat = sys.argv[1]
|
||||||
|
lon = sys.argv[2]
|
||||||
|
|
||||||
|
# yaw north: 0 south: 180 east: 90 west: 270
|
||||||
|
# pitch up: -90 down: 90
|
||||||
|
# http://cbk0.google.com/cbk?output=xml&panoid=p-DIQUVaFuGHWxVqpLstbA
|
||||||
|
|
||||||
|
try:
|
||||||
|
xml = urllib2.urlopen("http://cbk0.google.com/cbk?output=xml&ll=%s,%s"%(lat, lon))
|
||||||
|
except urllib2.HTTPError as e:
|
||||||
|
exit(e.code + " " + e.msg)
|
||||||
|
|
||||||
|
doc = fromstring(xml.read())
|
||||||
|
pano_id = doc.find("data_properties")
|
||||||
|
|
||||||
|
if pano_id is None:
|
||||||
|
exit("no streetview data avaiable here")
|
||||||
|
|
||||||
|
print pano_id.get("pano_id")
|
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import urllib2
|
||||||
|
from xml.etree.ElementTree import ElementTree, fromstring
|
||||||
|
|
||||||
|
def links_from_panoid(panoid):
|
||||||
|
try:
|
||||||
|
xml = urllib2.urlopen("http://cbk0.google.com/cbk?output=xml&panoid=%s"%panoid)
|
||||||
|
except urllib2.HTTPError as e:
|
||||||
|
exit(e.code + " " + e.msg)
|
||||||
|
doc = fromstring(xml.read())
|
||||||
|
return [link.get("pano_id") for link in doc.findall("annotation_properties/link")]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
exit("need to supply maximum number of positions")
|
||||||
|
|
||||||
|
from_stdin = sys.stdin.readlines()
|
||||||
|
if len(from_stdin) != 1:
|
||||||
|
exit("only one initial pano_id expected on stdin")
|
||||||
|
init_pano = from_stdin[0].strip()
|
||||||
|
max_pos = int(sys.argv[1])
|
||||||
|
|
||||||
|
result = set([init_pano])
|
||||||
|
toprocess = [init_pano]
|
||||||
|
|
||||||
|
# breadth first search
|
||||||
|
while len(result) < max_pos and toprocess:
|
||||||
|
newtoprocess = []
|
||||||
|
for panoid in toprocess:
|
||||||
|
if len(result) >= max_pos:
|
||||||
|
break
|
||||||
|
ids = links_from_panoid(panoid)
|
||||||
|
for p in ids:
|
||||||
|
if p not in result:
|
||||||
|
newtoprocess.append(p)
|
||||||
|
result.update(ids)
|
||||||
|
toprocess = newtoprocess
|
||||||
|
|
||||||
|
for p in result:
|
||||||
|
print p
|
Loading…
Reference in New Issue