Example #1
0
    def __get_results(self, riool):
        """Construct and return *WAAR records.

        Each *MRIO can be classified according to its percentage flooded.
        The class boundaries are printed in the ZZI and ZZJ fields of
        the *WAAR record. Only *WAAR records that mark a change of
        class are returned.
        """
        results = []
        prev_klasse = None
        for obj in self.rmb.pool[riool]:
            if isinstance(obj, Rioolmeting):
                try:
                    node = self.storedgraph_dict[obj.suf_id]
                except KeyError:
                    msg = "Skipping %s (not in stored graph)." % obj.suf_id
                    logger.debug(msg)
                    continue
                pct = node.flooded_percentage
                klasse, min_pct, max_pct = get_class_boundaries(pct)
                if klasse != prev_klasse:
                    waar = WAAR()
                    waar.ZZA = obj.ZYA
                    waar.ZZB = obj.ZYB
                    waar.ZZE = riool
                    waar.ZZF = 'BDD'
                    waar.ZZI = min_pct
                    waar.ZZJ = max_pct
                    waar.ZZV = 'Door Lizard Riool Toolkit'
                    results.append(str(waar))
                    prev_klasse = klasse
        return results
Example #2
0
    def generate_waar_lines(self):
        """Construct and return *WAAR records for in a RIB file.

        Each *MRIO can be classified according to its percentage flooded.
        The class boundaries are printed in the ZZI and ZZJ fields of
        the *WAAR record. Only *WAAR records that mark a change of
        class are returned.
        """

        prev_klasse = None
        for measurement in SewerMeasurement.objects.filter(
            sewer=self).order_by('dist'):
            pct = measurement.flooded_pct
            klasse, min_pct, max_pct = get_class_boundaries(pct)
            if klasse != prev_klasse:
                waar = WAAR()
                waar.ZZA = measurement.dist
                waar.ZZB = "1"
                waar.ZZE = self.code
                waar.ZZF = 'BDD'
                waar.ZZI = min_pct
                waar.ZZJ = max_pct
                waar.ZZV = 'Door Lizard Riool Toolkit'
                yield str(waar)
                prev_klasse = klasse