Ejemplo n.º 1
0
    def test_suit_leg_list_coghq(self):
        # Generate and store 5 points
        # STREET_POINT(0, 0, 0) -> COGHQ_IN_POINT(0, 10, 0, 1) -> STREET_POINT(0, 20, 0) -> COGHQ_OUT_POINT(0, 30, 0, 2)
        # -> STREET_POINT(0, 40, 0)

        path = DNASuitPath()
        points = [
            self.make_suit_point(0, DNASuitPoint.STREET_POINT, (0, 0, 0)),
            self.make_suit_point(1,
                                 DNASuitPoint.COGHQ_IN_POINT, (0, 10, 0),
                                 landmark_building_index=1),
            self.make_suit_point(2, DNASuitPoint.STREET_POINT, (0, 20, 0)),
            self.make_suit_point(3,
                                 DNASuitPoint.COGHQ_OUT_POINT, (0, 30, 0),
                                 landmark_building_index=2),
            self.make_suit_point(4, DNASuitPoint.STREET_POINT, (0, 40, 0))
        ]

        for point in points:
            self.store.storeSuitPoint(point)
            path.addPoint(point)

        for i in xrange(5):
            self.store.storeSuitEdge(i, i + 1, 2000 + i)

        leg_list = SuitLegList(path, self.store, SUIT_WALK_SPEED)

        # Test types
        self.assertEqual(leg_list.getNumLegs(), 9)
        self.assertEqual(leg_list.getLeg(0).getType(), SuitLeg.TFromSky)
        self.assertEqual(leg_list.getLeg(1).getType(), SuitLeg.TWalk)
        self.assertEqual(leg_list.getLeg(2).getType(), SuitLeg.TToCoghq)
        self.assertEqual(leg_list.getLeg(3).getType(), SuitLeg.TWalk)
        self.assertEqual(leg_list.getLeg(4).getType(), SuitLeg.TWalk)
        self.assertEqual(leg_list.getLeg(5).getType(), SuitLeg.TFromCoghq)
        self.assertEqual(leg_list.getLeg(6).getType(), SuitLeg.TWalk)
        self.assertEqual(leg_list.getLeg(7).getType(), SuitLeg.TToSky)
        self.assertEqual(leg_list.getLeg(8).getType(), SuitLeg.TOff)

        # Test times
        walk_leg_time = leg_list.getLegTime(1)
        self.assertEqual(walk_leg_time, 10 / SUIT_WALK_SPEED)
        elapsed = 0
        self.assertEqual(leg_list.getStartTime(0), elapsed)
        elapsed += SuitTimings.FromSky
        self.assertEqual(leg_list.getStartTime(1), elapsed)
        elapsed += walk_leg_time
        self.assertEqual(leg_list.getStartTime(2), elapsed)
        elapsed += SuitTimings.ToSuitBuilding
        self.assertEqual(leg_list.getStartTime(3), elapsed)
        elapsed += walk_leg_time
        self.assertEqual(leg_list.getStartTime(4), elapsed)
        elapsed += walk_leg_time
        self.assertEqual(leg_list.getStartTime(5), elapsed)
        elapsed += SuitTimings.FromSuitBuilding
        self.assertEqual(leg_list.getStartTime(6), elapsed)
        elapsed += walk_leg_time
        self.assertEqual(leg_list.getStartTime(7), elapsed)
        elapsed += SuitTimings.ToSky
        self.assertEqual(leg_list.getStartTime(8), elapsed)
Ejemplo n.º 2
0
    def test_suit_leg_list(self):
        # Generate and store 6 points
        # STREET_POINT(0, 0, 0) -> STREET_POINT(0, 10, 0) -> STREET_POINT(0, 20, 0) -> STREET_POINT(0, 30, 0) -> STREET_POINT(0, 40, 0)
        # -> FRONT_DOOR_POINT(0, 50, 0)
        points = [self.make_suit_point(i, pos=(0, 10 * i, 0)) for i in xrange(5)]
        for point in points:
            self.store.storeSuitPoint(point)

        for i in xrange(4):
            self.store.storeSuitEdge(i, i + 1, 2000 + i)

        end_point = self.make_suit_point(5, type=DNASuitPoint.FRONT_DOOR_POINT, pos=(0, 50, 0),
                                         landmark_building_index=11)

        self.store.storeSuitPoint(end_point)
        self.store.storeSuitEdge(4, 5, 2004)

        path = DNASuitPath()
        for point in points:
            path.addPoint(point)

        path.addPoint(end_point)

        leg_list = SuitLegList(path, self.store, SUIT_WALK_SPEED)

        # Test types
        self.assertEqual(leg_list.getNumLegs(), 8)
        self.assertEqual(leg_list.getLeg(0).getType(), SuitLeg.TFromSky)
        for i in xrange(1, 5):
            self.assertEqual(leg_list.getLeg(i).getType(), SuitLeg.TWalk)

        self.assertEqual(leg_list.getLeg(5).getType(), SuitLeg.TWalkFromStreet)
        self.assertEqual(leg_list.getLeg(6).getType(), SuitLeg.TToToonBuilding)
        self.assertEqual(leg_list.getLeg(7).getType(), SuitLeg.TOff)

        # Test times
        walk_leg_time = leg_list.getLegTime(1)
        self.assertEqual(walk_leg_time, 10 / SUIT_WALK_SPEED)
        self.assertEqual(leg_list.getStartTime(0), 0)
        self.assertEqual(leg_list.getStartTime(1), SuitTimings.FromSky)
        self.assertEqual(leg_list.getStartTime(2), SuitTimings.FromSky + walk_leg_time)
        self.assertEqual(leg_list.getStartTime(3), SuitTimings.FromSky + walk_leg_time * 2)
        self.assertEqual(leg_list.getStartTime(4), SuitTimings.FromSky + walk_leg_time * 3)
        self.assertEqual(leg_list.getStartTime(5), SuitTimings.FromSky + walk_leg_time * 4)
        self.assertEqual(leg_list.getStartTime(6), SuitTimings.FromSky + walk_leg_time * 5)
        self.assertEqual(leg_list.getStartTime(7), SuitTimings.FromSky + walk_leg_time * 5 + SuitTimings.ToToonBuilding)
Ejemplo n.º 3
0
    def make_suit_path(self, point_indexes, test=False):
        points = [self.make_suit_point(index) for index in point_indexes]
        path = DNASuitPath()

        for point in points:
            path.addPoint(point)

        if test:
            self.assertEqual(path.getNumPoints(), len(points))

            for i in xrange(len(points)):
                self.assertEqual(path.getPoint(i), points[i])
                self.assertEqual(path.getPointIndex(i), points[i].getIndex())

            path.reversePath()

            for i in xrange(len(points)):
                self.assertEqual(path.getPoint(i), points[-i - 1])
                self.assertEqual(path.getPointIndex(i), points[-i - 1].getIndex())

        return path