Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def createGraph(file,dist):
- with open(file) as json_file:
- json_data = json.load(json_file)
- grafo = {}
- print(len(json_data['features']))
- for p in json_data['features']:
- coord = p["geometry"]["coordinates"]
- s = p["properties"]["code"]
- inserisciMarker(m, coord[1], coord[0], s, "", "blue")
- #print(s)
- grafo[s] = {}
- grafo[s]["coords"] = coord
- grafo[s]["adjacent"] = []
- #print(coord)
- coordtuple = (coord[1],coord[0])
- for pp in json_data['features']:
- if s != pp["properties"]["code"]:
- pptuple = (pp["geometry"]["coordinates"][1], pp["geometry"]["coordinates"][0])
- d = geodesic(coordtuple, pptuple).km
- if d < dist:
- l = []
- l.append(coordtuple)
- l.append(pptuple)
- inserisciLinea(m,l,"blue",3,0.2, d)
- grafo[s]["adjacent"].append(pp["properties"]["code"])
- with open('data.json', 'w') as fp:
- json.dump(grafo, fp, indent=4)
- return grafo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement