Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'(._;>;);););out;')
query_str = query_template.format(north=north, south=south, east=east, west=west, timeout=timeout,
maxsize=maxsize, footprint_type=footprint_type)
response_json = overpass_request(data={'data':query_str}, timeout=timeout)
response_jsons.append(response_json)
msg = ('Got all footprint data within bounding box from '
'API in {:,} request(s) and {:,.2f} seconds')
log(msg.format(len(geometry), time.time()-start_time))
elif by_poly:
# project to utm, divide polygon up into sub-polygons if area exceeds a
# max size (in meters), project back to lat-long, then get a list of polygon(s) exterior coordinates
geometry_proj, crs_proj = project_geometry(polygon)
geometry_proj_consolidated_subdivided = consolidate_subdivide_geometry(geometry_proj, max_query_area_size=max_query_area_size)
geometry, _ = project_geometry(geometry_proj_consolidated_subdivided, crs=crs_proj, to_latlong=True)
polygon_coord_strs = get_polygons_coordinates(geometry)
log('Requesting footprint data within polygon from API in {:,} request(s)'.format(len(polygon_coord_strs)))
start_time = time.time()
# pass each polygon exterior coordinates in the list to the API, one at
# a time
for polygon_coord_str in polygon_coord_strs:
query_template = ('[out:json][timeout:{timeout}]{maxsize};('
'way(poly:"{polygon}")["{footprint_type}"];(._;>;);'
'relation(poly:"{polygon}")["{footprint_type}"];(._;>;););out;')
query_str = query_template.format(polygon=polygon_coord_str, timeout=timeout, maxsize=maxsize,
footprint_type=footprint_type)
response_json = overpass_request(data={'data':query_str}, timeout=timeout)
response_jsons.append(response_json)
msg = ('Got all footprint data within polygon from API in '
'{:,} request(s) and {:,.2f} seconds')
log(msg.format(len(polygon_coord_strs), time.time()-start_time))
'{west:.8f},{north:.8f},{east:.8f});(._;>;););(relation["building"]'
'({south:.8f},{west:.8f},{north:.8f},{east:.8f});(._;>;);););out;')
query_str = query_template.format(north=north, south=south, east=east, west=west, timeout=timeout, maxsize=maxsize)
response_json = overpass_request(data={'data':query_str}, timeout=timeout)
response_jsons.append(response_json)
msg = ('Got all building footprints data within bounding box from '
'API in {:,} request(s) and {:,.2f} seconds')
log(msg.format(len(geometry), time.time()-start_time))
elif by_poly:
# project to utm, divide polygon up into sub-polygons if area exceeds a
# max size (in meters), project back to lat-long, then get a list of polygon(s) exterior coordinates
geometry_proj, crs_proj = project_geometry(polygon)
geometry_proj_consolidated_subdivided = consolidate_subdivide_geometry(geometry_proj, max_query_area_size=max_query_area_size)
geometry, _ = project_geometry(geometry_proj_consolidated_subdivided, crs=crs_proj, to_latlong=True)
polygon_coord_strs = get_polygons_coordinates(geometry)
log('Requesting building footprints data within polygon from API in {:,} request(s)'.format(len(polygon_coord_strs)))
start_time = time.time()
# pass each polygon exterior coordinates in the list to the API, one at
# a time
for polygon_coord_str in polygon_coord_strs:
query_template = ('[out:json][timeout:{timeout}]{maxsize};(way'
'(poly:"{polygon}")["building"];(._;>;);relation'
'(poly:"{polygon}")["building"];(._;>;););out;')
query_str = query_template.format(polygon=polygon_coord_str, timeout=timeout, maxsize=maxsize)
response_json = overpass_request(data={'data':query_str}, timeout=timeout)
response_jsons.append(response_json)
msg = ('Got all building footprints data within polygon from API in '
'{:,} request(s) and {:,.2f} seconds')
log(msg.format(len(polygon_coord_strs), time.time()-start_time))