def obj2_knowing_every_trees(list_tree, way_id, new_geom, result1, result2): true_list = [] for tree in list_tree: way = Nominatim().query(tree[0], tree[1], reverse=True, zoom=17) id = way.toJSON()[0]["osm_id"] if id == way_id: true_list.append(tree) obj2_knowing_trees_of_way(true_list, new_geom, result1, result2)
def obj2_knowing_every_trees(list_tree, way_id, new_geom, result1, result2): """ Used if we have the list of EVERY TREES of a city and not only of our road. It's not the case here so this is basically useless. """ true_list = [] for tree in list_tree: way = Nominatim().query(tree[0], tree[1], reverse=True, zoom=17) id = way.toJSON()[0]["osm_id"] if id == way_id: true_list.append(tree) obj2_knowing_trees_of_way(true_list, new_geom, result1, result2)
def geo_to_way_info(lat, long): """ Return some information corresponding to the way in wich the point is: bbox, id, name """ way = Nominatim().query(lat, long, reverse=True, zoom=17) JSON = way.toJSON()[0] name = JSON['address']['road'] bbox = JSON["boundingbox"] id = JSON["osm_id"] realbbox = [ float(bbox[0]), float(bbox[2]), float(bbox[1]) + 0.005, float(bbox[3]) + 0.005 ] return realbbox, id, name
import sys, os sys.path.insert(1, os.path.abspath('..')) from helper.geoJsonHelper import groupBy from helper.geoJsonToFolium import generateFeatureCollectionForGroups, styleFunction, cmMapColorToHex from helper.overPassHelper import OverPassHelper # postfix for f.i. file_names areaName = "pieschen" # area to query pieschen = Nominatim().query('Pieschen, Dresden, Germany') osmDataFiles = OverPassHelper().fetch(pieschen.areaId(), areaName, overrideFiles=False) pieschenCoord = pieschen.toJSON()[0] map = folium.Map(location=[pieschenCoord["lat"], pieschenCoord["lon"]], tiles='Stamen Toner', zoom_start=15) # matplotlib colormap names colormaps = ["hsv", "BrBG", "coolwarm"] objectTypeTagMapping = { "streets": "highway", "buildings": "building", "landuse": "landuse" } for i, osmQuery in enumerate(osmDataFiles): file = open(osmQuery.filePath, encoding='UTF-8')
from folium.plugins.measure_control import MeasureControl import sys, os sys.path.insert(1, os.path.abspath('..')) from helper.geoJsonHelper import groupBy from helper.overPassHelper import OverPassHelper from helper.OsmDataQuery import OsmDataQuery from helper.OsmObjectType import OsmObjectType pieschen = Nominatim().query('Pieschen, Dresden, Germany') osmQuery = OsmDataQuery("streets", OsmObjectType.WAY, ["'highway'"], "highway") all_streets = next(OverPassHelper().directFetch(pieschen.areaId(), [osmQuery])) street_types = groupBy(all_streets, ["highway"]) piescheonCoord = [pieschen.toJSON()[0]["lat"], pieschen.toJSON()[0]["lon"]] streetMap = folium.Map(location=piescheonCoord, tiles='Stamen Toner', zoom_start=15) icon = folium.Icon(icon="pills", color='lightgray', icon_color='red') folium.Marker(location=piescheonCoord, tooltip="test", icon=icon).add_to(streetMap) for type, streets in street_types.items(): properties = list(streets["features"][0]["properties"].keys()) folium.GeoJson( streets, name=type, tooltip=folium.features.GeoJsonTooltip(fields=properties),