def get_stations_by_latlon(self, latitudes, longitudes, **kwargs): """ retrieves Station objects from Nerrs determined by the series of latitudes and longitudes - latitudes: comma-deliminated string of latitude values - longitudes: comma-deliminated string of longitude values optionals: - min_date - max_date - observed_property returns a StationCollection object from the parser """ if latitudes is None or longitudes is None: return None lats = str(latitudes).split(',') lons = str(longitudes).split(',') # make sure the lists are equal in size while len(lats) > len(lons): noop = lats.pop() while len(lons) > len(lats): noop = lons.pop() metadata = self.__get_metadata() desired_stations = list() for station in metadata: for index, value in enumerate(lats): if station.location.latitude == float(value) and station.location.longitude == float(lons[index]) and station not in desired_stations: desired_stations.append(station) args = dict(min_date=kwargs.get('min_date'),max_date=kwargs.get('max_date'),observed_property=kwargs.get('observed_property')) reply = Reply(None) return reply.parse_station_collection(self.get_station, args, desired_stations)
def get_stations_by_bbox(self, south, west, north, east, **kwargs): """ retrieves Station objects from Nerrs determined by the boundaries given - south: the southern-most latitude (in degrees North) - west: western-most longitude (in degrees West) - north: northern-most latitude (in degrees North) - east: eastern-most longitude (in degrees West) optionals: - min_date - max_date - observed_property returns a StationCollection object from the parser """ metadata = self.__get_metadata() desired_stations = list() for station in metadata: if station.location.longitude >= east and station.location.longitude <= west: if station.location.latitude <= north and station.location.longitude >= south: desired_stations.append(station) args = dict(min_date=kwargs.get('min_date'),max_date=kwargs.get('max_date'),observed_property=kwargs.get('observed_property')) reply = Reply(None) return reply.parse_station_collection(self.get_station, args, desired_stations)