forked from gregrs-uk/python-fhrs-osm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_osm_data.py
28 lines (24 loc) · 1002 Bytes
/
get_osm_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from fhrs_osm import *
import config
db = Database(dbname=config.dbname)
con = db.connect()
fhrs = FHRSDataset()
osm = OSMDataset()
print "Creating OSM database table"
osm.create_table(connection=con)
if config.use_xml_file is True:
print "Parsing OSM XML file"
result = osm.parse_xml_file('data/filtered.osm')
print "Writing OSM data to database"
osm.write_result_nodes_and_ways(result=result, connection=con, filter_ways=False)
else:
# get OSM data within matching bounding box
print 'Calculating geographical extent of FHRS data, ignoring outliers'
fhrs_bbox = fhrs.get_corrected_bbox(connection=con)
print "Running Overpass query"
result = osm.run_overpass_query(bbox=fhrs_bbox)
if len(result.get_node_ids()) + len(result.get_way_ids()) < 1:
print "Overpass query result appears to be empty. Stopping."
exit(1)
print "Writing OSM data to database"
osm.write_result_nodes_and_ways(result=result, connection=con, filter_ways=False)