#!/usr/bin/env python3 """Rebuild data/jesus-walk-routes.json: straight-line and OpenStreetMap foot-route distances for each leg of the journeys of Jesus recorded in the Gospels. Used by /how-far-did-jesus-walk/. Run from the repo root: python3 scripts/jesus-walk-routes.py (about 1 request a second).""" import json,time,urllib.request from math import radians,sin,cos,asin,sqrt P={ 'Bethlehem':(31.7054,35.2024),'Jerusalem':(31.7781,35.2354),'Nazareth':(32.7021,35.2978), 'Capernaum':(32.8810,35.5750),'Cana':(32.7470,35.3420),'Nain':(32.6320,35.3480), 'Bethsaida':(32.9100,35.6310),'Tyre':(33.2710,35.1960),'Sidon':(33.5600,35.3750), 'Caesarea Philippi':(33.2480,35.6940),'Sychar':(32.2090,35.2850),'Jericho':(31.8570,35.4440), 'Bethany':(31.7710,35.2620),'Jordan crossing':(31.8380,35.5340),'Ephraim':(31.9540,35.3000), 'Scythopolis':(32.5000,35.5000),'Hippos':(32.7790,35.6600),'Emmaus':(31.8400,35.1700), } VIA={'Scythopolis','Hippos'} def hv(a,b): (la1,lo1),(la2,lo2)=P[a],P[b] d=sin(radians(la2-la1)/2)**2+cos(radians(la1))*cos(radians(la2))*sin(radians(lo2-lo1)/2)**2 return 2*6371.0*asin(sqrt(d)) cache={} def foot(a,b): k=(a,b) if k in cache: return cache[k] url=f"https://routing.openstreetmap.de/routed-foot/route/v1/foot/{P[a][1]},{P[a][0]};{P[b][1]},{P[b][0]}?overview=false" req=urllib.request.Request(url,headers={'User-Agent':'bible-distance-study/1.0'}) r=json.load(urllib.request.urlopen(req,timeout=30)); time.sleep(1.2) cache[k]=r['routes'][0]['distance']/1000 if r.get('code')=='Ok' else None return cache[k] J=[ # (id, phase, label, refs, stops) ('age12','childhood','To Jerusalem for Passover at age 12, and home','Luke 2:41-51',['Nazareth','Scythopolis','Jericho','Jerusalem','Jericho','Scythopolis','Nazareth']), ('baptism','ministry','From Nazareth to the Jordan to be baptized','Mark 1:9; John 1:28',['Nazareth','Scythopolis','Jordan crossing']), ('cana','ministry','Back to Galilee, to a wedding in Cana','John 1:43; 2:1',['Jordan crossing','Scythopolis','Cana']), ('capernaum1','ministry','Cana to Capernaum','John 2:12',['Cana','Capernaum']), ('passover1','ministry','To Jerusalem for Passover','John 2:13',['Capernaum','Scythopolis','Jericho','Jerusalem']), ('samaria','ministry','North through Samaria, to the well at Sychar','John 4:3-5',['Jerusalem','Sychar']), ('cana2','ministry','On to Cana in Galilee','John 4:43-46',['Sychar','Cana']), ('nazareth','ministry','To Nazareth, where His hometown rejected Him','Luke 4:16-30',['Cana','Nazareth']), ('capernaum2','ministry','Down to Capernaum','Luke 4:31',['Nazareth','Capernaum']), ('feast','ministry','To a feast in Jerusalem, and back to Galilee','John 5:1; 6:1',['Capernaum','Scythopolis','Jericho','Jerusalem','Jericho','Scythopolis','Capernaum']), ('nain','ministry','To Nain, where He raised a widow\'s son, and back','Luke 7:11-17',['Capernaum','Nain','Capernaum']), ('tyre','ministry','North to Tyre and Sidon, then around through the Decapolis','Mark 7:24, 31',['Capernaum','Tyre','Sidon','Caesarea Philippi','Hippos','Bethsaida']), ('philippi','ministry','From Bethsaida to Caesarea Philippi, and back to Capernaum','Mark 8:22, 27; 9:33',['Bethsaida','Caesarea Philippi','Capernaum']), ('tabernacles','ministry','To Jerusalem for the Feast of Tabernacles, through Samaria','John 7:10; Luke 9:51-53',['Capernaum','Nazareth','Sychar','Jerusalem']), ('beyond','ministry','Across the Jordan, where John had baptized','John 10:40',['Jerusalem','Jericho','Jordan crossing']), ('lazarus','ministry','To Bethany, to raise Lazarus','John 11:7, 17',['Jordan crossing','Jericho','Bethany']), ('ephraim','ministry','To Ephraim, near the wilderness','John 11:54',['Bethany','Ephraim']), ('final','ministry','Through Jericho to Bethany, six days before Passover','Luke 19:1; John 12:1',['Ephraim','Jericho','Bethany']), ('week','ministry','Bethany to Jerusalem and back, three times in the last week','Mark 11:11, 19; 14:3',['Bethany','Jerusalem','Bethany','Jerusalem','Bethany','Jerusalem','Bethany']), ('emmaus','resurrection','With two disciples on the road to Emmaus','Luke 24:13-15',['Jerusalem','Emmaus']), ] out=[] for jid,phase,label,refs,stops in J: legs=[] for a,b in zip(stops,stops[1:]): legs.append({'from':a,'to':b,'line':round(hv(a,b),2),'foot':foot(a,b)}) out.append({'id':jid,'phase':phase,'label':label,'refs':refs,'stops':stops,'legs':legs}) print(jid,[ (l['from'][:6],l['to'][:6],round(l['line'],1),l['foot'] and round(l['foot'],1), l['foot'] and round(l['foot']/l['line'],2)) for l in legs]) json.dump({'source':'Walking distances: OpenStreetMap foot routing via routing.openstreetmap.de (OSRM). Straight-line: haversine, R=6371 km.','places':P,'journeys':out},open('data/jesus-walk-routes.json','w'),indent=1)