"""
Places of interest generation
=============================

"""

@@ -58,12 +58,2517 @@
 ======%0A%0A
-%22%22%22
+This module defines a class for places of interest and the functions for%0Agenerating the data structure for all of them from the OSM raw data.%0A%0AEach place of interest will basically just carry the information about its%0Alocation in the **network** as the identity of the network node which is%0Anearest to its actual location. And additionally, a name can be given for it,%0Aas well as a weight that can be used for the random allocation for the%0Atravellers.%0A%0AThe places of interest will be bundled in a dictionary, with the name of the%0Acategory as the key and a list of the actual places as the value.%0A%0A%22%22%22%0A%0A%0Aclass Place(object):%0A%0A    %22%22%22The places of interest for the travellers%0A%0A    Since the category is going to be stored one level upper as the dictionary%0A    key, here just a few attributes are needed%0A%0A    .. py:attribute:: node%0A%0A        The node identity for the place of interest in the network%0A%0A    .. py::attribute:: name%0A%0A        The name of the place of interest%0A%0A    .. py::attribute:: weight%0A%0A        The weight for it during the place allocation. The probability of being%0A        selected.%0A%0A    %22%22%22%0A%0A    __slots__ = %5B%0A        'node',%0A        'name',%0A        'weight',%0A        %5D%0A%0A    def __init__(self, node, name, weight):%0A%0A        %22%22%22Initializes the place instance%22%22%22%0A%0A        self.node = node%0A        self.name = name%0A        self.weight = weight%0A%0A%0A#%0A# Home generation%0A# ---------------%0A#%0A# The home generation is different from all the other places, since it is going%0A# to be based on the existance of residential road, rather than specific%0A# locations on the map.%0A#%0A# The generation code will iterate over all the nodes of the graph, find out%0A# the total length of residential road edges on it, and use that length as the%0A# weight. For nodes with no residential road, no people will live there.%0A#%0A%0Adef _gen_homes(net):%0A%0A    %22%22%22Generates a list of homes for a given network%0A%0A    :param net: The NetworkX graph for the simulation%0A    :returns: A list of :py:class:%60Place%60 instances for the homes%0A%0A    %22%22%22%0A%0A    homes = %5B%5D%0A%0A    for node in net.nodes_iter():%0A%0A        weight = 0.0%0A        for road in net%5Bnode%5D.itervalues():%0A            if road%5B'highway'%5D == 'residential':%0A                weight += road%5B'length'%5D%0A%0A        # 0.01 is an arbitrary delta to skip nodes with few residents%0A        if weight %3E 0.01:%0A            homes.append(%0A                Place(node, 'home', weight)%0A                )%0A%0A    return homes%0A%0A%0A#%0A# Some constance for place generation%0A# -----------------------------------%0A#%0A
 %0A

Implement place class and homes generation