def add_missing_flight(self, observer_name: str,
                        injected_flight: InjectedFlight,
                        rect: s2sphere.LatLngRect, injection_target: str,
                        query: fetch.Query) -> None:
     flight_id = injected_flight.flight.details_responses[0].details.id
     timestamp = datetime.datetime.utcnow(
     )  #TODO: Use query timestamp instead
     span = injected_flight.flight.get_span()
     self.issues.append(
         Issue(
             test_code='MISSING_FLIGHT',
             relevant_requirements=['NET0610'],
             severity=Severity.Critical,
             injection_target=injection_target,
             observation_source=observer_name,
             subject=flight_id,
             summary='Expected flight not found',
             details=
             'Flight {} (from {} to {}) was expected inside ({}, {})-({}, {}) when {} was queried at {}'
             .format(flight_id, span[0], span[1],
                     rect.lo().lat().degrees,
                     rect.lo().lng().degrees,
                     rect.hi().lat().degrees,
                     rect.hi().lng().degrees, observer_name, timestamp),
             queries=[query]))
def _evaluate_observation(injected_flights: List[InjectedFlight],
                          observer: RIDSystemObserver,
                          rect: s2sphere.LatLngRect, observation: Optional[
                              observation_api.GetDisplayDataResponse],
                          query: fetch.Query, config: EvaluationConfiguration,
                          findings: Findings) -> None:
    diagonal = rect.lo().get_distance(
        rect.hi()).degrees * geo.EARTH_CIRCUMFERENCE_KM / 360
    if diagonal > rid.NetMaxDisplayAreaDiagonal:
        _evaluate_area_to_large_observation(observer, diagonal, query,
                                            findings)
    elif diagonal > rid.NetDetailsMaxDisplayAreaDiagonal:
        _evaluate_clusters_observation(findings)
    else:
        _evaluate_normal_observation(injected_flights, observer, rect,
                                     observation, query, config, findings)
 def add_observation_failure(self, observer_name: str,
                             rect: s2sphere.LatLngRect,
                             query: fetch.Query) -> None:
     self.issues.append(
         Issue(
             test_code='OBSERVATION_FAILED',
             severity=Severity.Critical,
             injection_target='N/A',
             observation_source=observer_name,
             summary='Observation attempt failed',
             details=
             'When queried for flights in ({}, {})-({}, {}), observer returned an invalid response with code {}'
             .format(rect.lo().lat().degrees,
                     rect.lo().lng().degrees,
                     rect.hi().lat().degrees,
                     rect.hi().lng().degrees, query.status_code),
             queries=[query]))
 def observe_system(
     self, rect: s2sphere.LatLngRect
 ) -> Tuple[Optional[observation_api.GetDisplayDataResponse], fetch.Query]:
     initiated_at = datetime.datetime.utcnow()
     resp = self.session.get('/display_data?view={},{},{},{}'.format(
         rect.lo().lat().degrees,
         rect.lo().lng().degrees,
         rect.hi().lat().degrees,
         rect.hi().lng().degrees),
                             scope=rid.SCOPE_READ)
     try:
         result = (ImplicitDict.parse(
             resp.json(), observation_api.GetDisplayDataResponse)
                   if resp.status_code == 200 else None)
     except ValueError as e:
         result = None
     return (result, fetch.describe_query(resp, initiated_at))
Exemple #5
0
def get_latlngrect_diagonal_km(rect: s2sphere.LatLngRect) -> float:
    """Compute the distance in km between two opposite corners of the rect"""
    return rect.lo().get_distance(
        rect.hi()).degrees * EARTH_CIRCUMFERENCE_KM / 360