def test_location_filters(base_kwargs): result = AccidentMarker.bounding_box_query(yield_per=50, **base_kwargs) accident_markers = result.accident_markers rsa_markers = result.rsa_markers for marker in accident_markers: assert base_kwargs['sw_lat'] <= marker.latitude <= base_kwargs['ne_lat'] assert base_kwargs['sw_lng'] <= marker.longitude <= base_kwargs['ne_lng'] for marker in rsa_markers: assert base_kwargs['sw_lat'] <= marker.latitude <= base_kwargs['ne_lat'] assert base_kwargs['sw_lng'] <= marker.longitude <= base_kwargs['ne_lng']
def retrieve_clusters(**kwargs): start_time = time.time() result = AccidentMarker.bounding_box_query(is_thin=True, **kwargs) accident_markers_in_box = result.accident_markers.all() rsa_markers_in_box = result.rsa_markers.all() logging.debug("getting cluster data from db took %f seconds" % (time.time() - start_time)) start_time = time.time() clusters = calculate_clusters(accident_markers_in_box + rsa_markers_in_box, kwargs["zoom"]) logging.debug("calculating clusters took %f seconds" % (time.time() - start_time)) return clusters
def test_light_severity_filter(base_kwargs): base_kwargs['show_light'] = False markers = AccidentMarker.bounding_box_query(yield_per=50, **base_kwargs)[0] for marker in markers: assert marker.severity != 3
def test_approx_filter(base_kwargs): base_kwargs['accurate'] = False markers = AccidentMarker.bounding_box_query(yield_per=50, **base_kwargs)[0] for marker in markers: assert marker.locationAccuracy != 1
def test_location_filters(base_kwargs): query = AccidentMarker.bounding_box_query(yield_per=50, **base_kwargs)[0] for marker in query: assert base_kwargs['sw_lat'] <= marker.latitude <= base_kwargs['ne_lat'] assert base_kwargs['sw_lng'] <= marker.longitude <= base_kwargs['ne_lng']
def test_light_severity_filter(base_kwargs): base_kwargs['show_light'] = False result = AccidentMarker.bounding_box_query(yield_per=50, **base_kwargs) accident_markers = result.accident_markers for marker in accident_markers: assert marker.accident_severity != 3
def test_approx_filter(base_kwargs): base_kwargs['accurate'] = False result = AccidentMarker.bounding_box_query(yield_per=50, **base_kwargs) accident_markers = result.accident_markers for marker in accident_markers: assert marker.location_accuracy != 1