diff options
| author | Max Bringemo <maxbr167@student.liu.se> | 2020-11-02 15:54:52 +0100 |
|---|---|---|
| committer | Max Bringemo <maxbr167@student.liu.se> | 2020-11-02 15:54:52 +0100 |
| commit | 5a25e55b0fd59a032c4c85af452bd433427c3890 (patch) | |
| tree | 84252877002e3eec3f58f92d614c225557a21156 /store.py | |
| parent | 58f04e8c6d768fc8b912ec1af44442eebac03595 (diff) | |
| download | tdde25-5a25e55b0fd59a032c4c85af452bd433427c3890.tar.gz | |
finished introductory phase
Diffstat (limited to 'store.py')
| -rw-r--r-- | store.py | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +from osm_parser import get_default_parser + + +class Node: + def __init__(self, id, lat, lng): + self.id = id + self.lat = float(lat) + self.lng = float(lng) + + def coord_tuple(self): + return self.lat, self.lng + + +parser = None # Have a global reusable parser object + + +def extract_osm_nodes(f_name): + global parser + parser = get_default_parser(f_name) + nodes = dict() + + for node in parser.iter_nodes(): + nodes[node['id']] = Node(node['id'], node['lat'], node['lon']) + + return nodes + + +def select_nodes_in_rectangle(nodes, min_lat, max_lat, min_long, max_long): + return [node for node in nodes.values() + if min_lat <= node.lat <= max_lat + and min_long <= node.lng <= max_long] + |
