def test_four_line_sets_should_result(self):
     lines = [LineSegment(Point(0, 0), Point(1, 0)), \
              LineSegment(Point(0.5, 1), Point(1.5, 1))]
     traj_lines = [TrajectoryLineSegment(lines[0], 0), \
                   TrajectoryLineSegment(lines[1], 1)]
     res = get_representative_trajectory_average_inputs(trajectory_line_segments=traj_lines, \
                                                       min_prev_dist=0.5, min_lines=1)
     expected = 4
     self.assertEquals(len(res), expected)
 def test_two_short_line_endpoints_get_picked(self):
     lines = [LineSegment(Point(0, 0), Point(1, 0)), \
              LineSegment(Point(0, 1), Point(1, 1))]
     traj_lines = [TrajectoryLineSegment(lines[0], 0), \
                   TrajectoryLineSegment(lines[1], 1)]
     res = get_representative_trajectory_average_inputs(trajectory_line_segments=traj_lines, \
                                                       min_prev_dist=1, min_lines=2)
     expected = 2
     self.assertEquals(len(res), expected)
예제 #3
0
    def test_num_neighbor_counting(self):
        line_segment = TrajectoryLineSegment(self.create_simple_line_seg((0, 0), (1, 1)), 1)
        line_segment.distance_to_candidate = lambda x: 0.0
        mock_canididates = [1, 2, 3, 4, 5, 6]
        index = TrajectoryLineSegmentCandidateIndex(mock_canididates, epsilon=0.1)

        self.assertRaises(Exception, line_segment.get_num_neighbors)
        index.find_neighbors_of(line_segment)
        self.assertEquals(line_segment.get_num_neighbors(), 6)
예제 #4
0
 def test_trajectory_factory(self):
     line_seg = self.create_simple_line_seg((0, 0), (1, 1))
     expected = TrajectoryLineSegment(line_seg, 1)
     res = TrajectoryLineSegmentFactory().new_trajectory_line_seg(
         line_seg, trajectory_id=1)
     self.assertEquals(res.line_segment, expected.line_segment)
     self.assertEquals(res.trajectory_id, expected.trajectory_id)
예제 #5
0
 def create_trajectory_line_seg(self,
                                start,
                                end,
                                traj_id,
                                original_position=None):
     return TrajectoryLineSegment(LineSegment(Point(start[0], start[1]), \
                                                           Point(end[0], end[1])), traj_id, original_position)
 def create_line(self,
                 horizontal_start,
                 horizontal_end,
                 line_set_ids,
                 trajectory_id,
                 orig_pos=None):
     if orig_pos == None:
         orig_pos = random.randint(0, 1000)
     return {'trajectory_line_segment': \
             TrajectoryLineSegment(LineSegment(Point(horizontal_start, random.randint(0, 1000)), \
                                                            Point(horizontal_end, random.randint(0, 1000))), \
                                   trajectory_id, orig_pos), \
             'line_set_ids': line_set_ids}
예제 #7
0
 def __init__(self, distances, line_segment, id):
     TrajectoryLineSegment.__init__(self, 
                                    line_segment, 
                                    trajectory_id=0, 
                                    id=id)
     self.distances = distances