# Path: pyweed/signals.py
# class SignalingThread(QtCore.QThread):
#     """
#     Mixin that serves to standardize how we use signals to pass information around
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
#     def __del__(self):
#         self.wait()
# 
# class SignalingObject(QtCore.QObject):
#     """
#     Mixin for other objects that manage threaded work, and need to signal completion
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
# Path: pyweed/dist_from_events.py
# def get_combined_locations(points, distance):
#     """
#     Given a set of points and a distance, return a reasonable set of
#     bounding areas covering everything within that distance of any point.
#     """
#     # Very simple implementation, try to draw a box around all points
#     box = LatLonBox(distance)
# 
#     if not points:
#         return []
# 
#     for lat, lon in points:
#         box.add_point(lat, lon)
#     LOGGER.info("Combined points into: %s", box)
#     return [box]
# 
# class CrossBorderException(Exception):
#     pass


import logging
import concurrent.futures
    import doctest
from pyweed.signals import SignalingThread, SignalingObject
from obspy.core.inventory.inventory import Inventory
from pyweed.pyweed_utils import get_service_url, CancelledException, DataRequest, get_distance
from PyQt5 import QtCore
from pyweed.dist_from_events import get_combined_locations, CrossBorderException
        else:
            self.sub_requests = [base_options]

    def filter_one_station(self, station):
        """
        Filter one station from the results
        """
        for lat, lon in self.event_locations:
            dist = get_distance(lat, lon, station.latitude, station.longitude)
            if self.distance_range['mindistance'] <= dist <= self.distance_range['maxdistance']:
                return True
        return False

    def process_result(self, result):
        """
        If the request is based on distance from a set of events, we need to perform
        a filter after the request, since the low-level request probably overselected.
        """
        result = super(StationsDataRequest, self).process_result(result)
        if isinstance(result, Inventory) and self.event_locations and self.distance_range:
            filtered_networks = []
            for network in result:
                filtered_stations = [station for station in network if self.filter_one_station(station)]
                if filtered_stations:
                    network.stations = filtered_stations
                    filtered_networks.append(network)
            result.networks = filtered_networks
        return result



# Path: pyweed/signals.py
# class SignalingThread(QtCore.QThread):
#     """
#     Mixin that serves to standardize how we use signals to pass information around
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
#     def __del__(self):
#         self.wait()
# 
# class SignalingObject(QtCore.QObject):
#     """
#     Mixin for other objects that manage threaded work, and need to signal completion
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
# Path: pyweed/dist_from_events.py
# def get_combined_locations(points, distance):
#     """
#     Given a set of points and a distance, return a reasonable set of
#     bounding areas covering everything within that distance of any point.
#     """
#     # Very simple implementation, try to draw a box around all points
#     box = LatLonBox(distance)
# 
#     if not points:
#         return []
# 
#     for lat, lon in points:
#         box.add_point(lat, lon)
#     LOGGER.info("Combined points into: %s", box)
#     return [box]
# 
# class CrossBorderException(Exception):
#     pass


# Path: pyweed/stations_handler.py
import logging
import concurrent.futures
    import doctest
from pyweed.signals import SignalingThread, SignalingObject
from obspy.core.inventory.inventory import Inventory
from pyweed.pyweed_utils import get_service_url, CancelledException, DataRequest, get_distance
from PyQt5 import QtCore
from pyweed.dist_from_events import get_combined_locations, CrossBorderException

        else:
            self.sub_requests = [base_options]

    def filter_one_station(self, station):
        """
        Filter one station from the results
        """
        for lat, lon in self.event_locations:
            dist = get_distance(lat, lon, station.latitude, station.longitude)
            if self.distance_range['mindistance'] <= dist <= self.distance_range['maxdistance']:
                return True
        return False

    def process_result(self, result):
        """
        If the request is based on distance from a set of events, we need to perform
        a filter after the request, since the low-level request probably overselected.
        """
        result = super(StationsDataRequest, self).process_result(result)
        if isinstance(result, Inventory) and self.event_locations and self.distance_range:
            filtered_networks = []
            for network in result:
                filtered_stations = [station for station in network if self.filter_one_station(station)]
                if filtered_stations:
                    network.stations = filtered_stations
                    filtered_networks.append(network)
            result.networks = filtered_networks
        return result



class StationsHandler(SignalingObject):