Beispiel #1
0
    def _collectGaugeData(self, bundle, trackway, sitemap):
        """ Collects the trackway gauge data by generating projections for each series and then
            iterating over every track in the trackway and extracting the gauge information from
            the CurveSeries projection data.

            @param bundle: TrackSeriesBundle
            @param trackway: Tracks_Trackway
            @param sitemap: Tracks_Sitemap
            @return: dict """

        trackway.cache.set('data', {'points':[], 'gauges':self._GAUGE_DATA_NT([], [], [], [])})

        for key, series in bundle.items():
            series.cache.set('referenceWidth', series.averageTrackWidth)
            if series.count < 2:
                continue

            curve = CurveSeries(stage=self, series=series)
            try:
                curve.compute()
            except Exception as err:
                self.logger.writeError([
                    '[ERROR]: Failed to compute track curve projection',
                    'TRACKWAY: %s' % trackway.name,
                    'SERIES: %s[%s]' % (series.fingerprint, series.count) ], err)
                raise

            curve.draw(sitemap.cache.get('drawing'), drawPairs=False)
            series.cache.set('curve', curve)

        super(SimpleGaugeStage, self)._analyzeTrackway(trackway=trackway, sitemap=sitemap)

        for key, series in bundle.items():
            series.cache.remove('referenceWidth')
        return trackway.cache.extract('data')
Beispiel #2
0
    def _analyzeTrackway(self, trackway, sitemap):

        analysisTrackway = trackway.getAnalysisPair(self.analysisSession)
        if not analysisTrackway or not analysisTrackway.curveSeries:
            # Ignore trackways that are too short to have a curve series
            return

        # Fetch the curve series from the analysisTrackway.curveSeries value
        curveSeries = None
        bundle = self.owner.getSeriesBundle(trackway)
        for value in bundle.asList():
            if value.firstTrackUid == analysisTrackway.curveSeries:
                curveSeries = value
                break

        if not curveSeries:
            # Abort if no curve series was found. This should only occur if the there's a data
            # corruption between the Tracks_Trackway table and the Analysis_Trackway.curveSeries
            # value.
            self.logger.write(
                [
                    "[ERROR]: No curve series found",
                    "TRACKWAY[%s]: %s" % (trackway.index, trackway.name),
                    "CURVE_SERIES: %s" % analysisTrackway.curveSeries,
                ]
            )
            return

        curve = CurveSeries(stage=self, series=curveSeries, saveToAnalysisTracks=True)

        try:
            curve.compute()
        except ZeroDivisionError as err:
            self.logger.writeError(
                [
                    "[ERROR]: Failed to compute curve series",
                    "TRACKWAY: %s" % trackway.name,
                    "SITEMAP: %s" % sitemap.name,
                ],
                err,
            )
            raise

        self.data[trackway.uid] = curve
        for error in curve.errors:
            self.logger.write(error)
        curve.draw(sitemap.cache.get("drawing"))