コード例 #1
0
ファイル: SimpleGaugeStage.py プロジェクト: sernst/Cadence
    def _analyzeTrack(self, track, series, trackway, sitemap):
        if series.count < 1 or not track.pes:
            return

        segmentPair = None
        segmentSeries = None
        skipped = 0
        for key, otherSeries in series.bundle.items():
            if not otherSeries.pes:
                continue

            if otherSeries == series or otherSeries.left == series.left or otherSeries.count < 2:
                # If the series isn't suitable for comparison then mark this as a skipped attempt
                # and continue.
                skipped += 1
                continue

            segment = otherSeries.cache.get('curve').getTrackSegment(track)
            if segment is None:
                continue

            for pair in segment.pairs:
                if pair['track'] != track:
                    continue
                if segmentPair is None or pair['line'].length.raw < segmentPair['line'].length.raw:
                    # Store the shortest of the available gauge lengths
                    segmentPair = pair
                    segmentSeries = otherSeries
                break

        if skipped == 4:
            # If skipped is 4 it means that no suitable series existed for calculating a gauge
            # value and the method should abort quietly
            self._ignoreTracks.append(track)
            return

        if segmentPair is None:
            self._errorTracks.append(track)
            return

        color = 'blue' if segmentSeries.pes == series.pes else 'orange'

        data = trackway.cache.get('data')
        gauges = data['gauges']

        line = segmentPair['line']
        sitemap.cache.get('drawing').lineSegment(
            line, stroke=color, stroke_width=1, stroke_opacity='0.5')

        length = line.length
        gauges.abs.append(length)

        analysisTrack = track.getAnalysisPair(self.analysisSession)
        analysisTrack.simpleGauge = line.length.raw
        analysisTrack.simpleGaugeUnc = line.length.rawUncertainty

        widthNormGauge = NumericUtils.divideValueUncertainties(
            numeratorValue=length,
            denominatorValue=series.cache.get('referenceWidth'))
        gauges.width.append(widthNormGauge)

        point = PositionValue2D(
            x=analysisTrack.curvePosition, xUnc=0.0,
            y=widthNormGauge.value, yUnc=widthNormGauge.uncertainty)
        data['points'].append(point)

        if analysisTrack.paceLength:
            gauges.pace.append(NumericUtils.divideValueUncertainties(
                length, analysisTrack.paceLengthValue))

        if analysisTrack.strideLength:
            gauges.stride.append(NumericUtils.divideValueUncertainties(
                length, analysisTrack.strideLengthValue))

        self._count += 1