def handle_map(self, bbox):

        nodelist = []
        relations = []
        ways = []

        # This implementation follows the current implementation of
        # the API server at api.openstreetmap.org (the 'rails' port).

        # Look up the geo coded documents covering the desired bbox.
        gckeys = self.get_geocodes(bbox)
        geodocs = self.datastore.fetch_keys(C.GEODOC, gckeys)

        # Step 1: Get the list of nodes contained in the given
        #    bounding box.
        nodeset = _filter_in_bbox(bbox,
                                  [gd for (st, gd) in geodocs if st])
        if len(nodeset) == 0:
            return (nodelist, ways, relations)

        nodelist = [z for (st, z) in self.datastore.fetch_keys(
                C.NODE, [n for n in nodeset]) if st]

        # Step 2: Retrieve all ways that reference at least one node
        #    in the given bounding box.
        wayset = filter_references(C.WAY, nodelist)


        # Step 3: Retrieve any additional nodes referenced by the ways
        # retrieved.
        waynodeset = set()

        for (st,w) in self.datastore.fetch_keys(C.WAY, [w for w in wayset]):
            if st:
                ways.append(w)
                waynodeset.update(w.get_node_ids())

        extranodeset = waynodeset - nodeset
        nodelist.extend([n for (st,n) in
                         self.datastore.fetch_keys(C.NODE,
                                                   [n for n in extranodeset])
                         if st])
        nodeset = nodeset | extranodeset

        # Step 4: Retrieve the relations associated with these nodes.

        # ... all relations that reference nodes being returned.
        relset = filter_references(C.RELATION, nodelist)

        # ... and relations that reference one of the ways in the wayset.
        relset.update(filter_references(C.RELATION, ways))

        # ... retrieve relations from the data store.
        relations = [xr for (st,xr) in
                     self.datastore.fetch_keys(C.RELATION,
                                               [r for r in relset])
                     if st]

        # ... and relations referenced by existing relations
        # (one-pass only).
        extrarelset = filter_references(C.RELATION, relations)
        newrelset = extrarelset - relset

        newrels = [nr for (st, nr) in
                   self.datastore.fetch_keys(C.RELATION,
                                             [r for r in newrelset])
                   if st]
        relations.extend(newrels)

        return (nodelist, ways, relations)
Implementation of the /map API.
dataset/ETHPy150Open MapQuest/mapquest-osm-server/src/python/frontend/maphandler.py/MapHandler.handle_map