示例#1
0
 def get(self, request, data):
     bounds = data > maybe | X.get('in_polygon')
     return ((data or {}) > as_kwargs(get_car_position_data)
             | where(X['car'] | self.filter)
             | group_by(X['location'] | (grouping_precision, X, bounds))
             | X.iteritems()
             | foreach({
                 'location': X[1][0]['location'],
                 'cars': X[1] | foreach(X['car']) | self.get_car_data,
             })
             | tuple)
示例#2
0
 def get(self, request, data):
     bounds = data > maybe | X.get('in_polygon')
     return ((data or {}) > as_kwargs(get_car_position_data)
         | where(X['car'] | self.filter)
         | group_by(X['location'] | (grouping_precision, X, bounds))
         | X.iteritems()
         | foreach({
             'location': X[1][0]['location'],
             'cars': X[1] | foreach(X['car']) | self.get_car_data,
           })
         | tuple)
示例#3
0
    unit_id = unit_id or randint(1, 1000)
    length = length or randint(100, 1000)

    x_range = 0.004
    y_range = 0.004
    dx = random() * x_range * 2 - x_range
    dy = random() * y_range * 2 - y_range
    dx_range = 0.004
    dy_range = 0.004

    for index in xrange(length):
        yield dict(
            {
                'location': point,
                'unit_id': unit_id,
                'timestamp': timestamp,
            }, **get_extra_data(point, index))

        point = point[0] + dx, point[1] + dy
        if not within(bounds, point):
            point = random_move((point[0] - dx, point[1] - dy), bounds=bounds)
            dx = random() * x_range * 2 - x_range
            dy = random() * y_range * 2 - y_range
        dx += random() * dx_range * 2 - dx_range
        dy += random() * dy_range * 2 - dy_range
        d = time_step_variation_seconds
        timestamp += (time_step + timedelta(seconds=randint(-d, d)))


create_and_store_dummy_route = pipe | generate | foreach_do(as_kwargs(store))
示例#4
0
 def test_as_kwargs(self):
     d = {'foo': 4, 'bar': 2}
     assert as_kwargs(lambda **kw: kw)(d) == d
示例#5
0
 def test_as_kwargs(self):
     d = {'foo': 4, 'bar': 2}
     assert as_kwargs(lambda **kw: kw)(d) == d
示例#6
0
    timestamp = start_time or datetime.now()
    unit_id = unit_id or randint(1, 1000)
    length = length or randint(100, 1000)

    x_range = 0.004
    y_range = 0.004
    dx = random() * x_range * 2 - x_range
    dy = random() * y_range * 2 - y_range
    dx_range = 0.004
    dy_range = 0.004

    for index in xrange(length):
        yield dict({
            'location': point,
            'unit_id': unit_id,
            'timestamp': timestamp,
        }, **get_extra_data(point, index))

        point = point[0] + dx, point[1] + dy
        if not within(bounds, point):
            point = random_move((point[0] - dx, point[1] - dy), bounds=bounds)
            dx = random() * x_range * 2 - x_range
            dy = random() * y_range * 2 - y_range
        dx += random() * dx_range * 2 - dx_range
        dy += random() * dy_range * 2 - dy_range
        d = time_step_variation_seconds
        timestamp += (time_step + timedelta(seconds=randint(-d, d)))


create_and_store_dummy_route = pipe | generate | foreach_do(as_kwargs(store))