src/fwidm/dwdHourlyCrawler/hourly/DWDHourlyCrawler.php
public function getDataInInterval($coordinatesRequest, DateTime $date, $timeMinuteLimit = 30, $sorted = true)
    {

        $parameters = [];
        $queriedStations = [];

        $date = Carbon::instance($date)->setTimezone('utc');
        foreach ($this->services as $var => $hourlyService) {
            $stations = $this->getStations($hourlyService, true);

            if (isset($stations)) {

                try {
                    $nearestStations = DWDStationsController::getNearestStations($stations, $coordinatesRequest);
                } catch (DWDLibException $exception) {
                    DWDUtil::log(self::class, "Failed to retrieve any nearest active stations. Retrying after forcedownloading new station infos.", Logger::WARNING);
                    $stations = $this->getStations($hourlyService, true, true);
                    $nearestStations = DWDStationsController::getNearestStations($stations, $coordinatesRequest);
                }


                foreach ($nearestStations as $nearestStation) {
                    /* @var $nearestStation DWDStation */
                    $zipFilePath = $this->retrieveFile($hourlyService, $nearestStation);
                    $content = isset($zipFilePath)
                        ? DWDUtil::getDataFromZip($zipFilePath, DWDConfiguration::getHourlyConfiguration()->zipExtractionPrefix)
                        : null;

                    //content can only be null if a station is listed as active but is not anymore.
                    if ($content == null) {
                        DWDUtil::log(self::class, 'file for station=' . $nearestStation . ' could not be loaded, trying next station');
                        continue;
                    }

                    $parameters[$var] = $this->retrieveData($content, $nearestStation, $coordinatesRequest, $hourlyService, $date, $timeMinuteLimit);

                    //addStation
                    if (count($parameters[$var]) > 0 && !isset($queriedStations['station-' . $nearestStation->getId()])) {
                        $queriedStations['station-' . $nearestStation->getId()] = $nearestStation;
                    }

                    if (count($parameters[$var])>0)
                        break;
                }
            }
        }
        if ($sorted && isset($parameters))
            ksort($parameters);
        return [$parameters, $queriedStations];
    }
public function getDataInInterval($coordinatesRequest, DateTime $date, $timeMinuteLimit = 30, $sorted = true)
    {

        $parameters = [];
        $queriedStations = [];

        $date = Carbon::instance($date)->setTimezone('utc');
        foreach ($this->services as $var => $hourlyService) {
            $stations = $this->getStations($hourlyService, true);

            if (isset($stations)) {

                try {
                    $nearestStations = DWDStationsController::getNearestStations($stations, $coordinatesRequest);
                } catch (DWDLibException $exception) {
                    DWDUtil::log(self::class, "Failed to retrieve any nearest active stations. Retrying after forcedownloading new station infos.", Logger::WARNING);
                    $stations = $this->getStations($hourlyService, true, true);
                    $nearestStations = DWDStationsController::getNearestStations($stations, $coordinatesRequest);
                }


                foreach ($nearestStations as $nearestStation) {
                    /* @var $nearestStation DWDStation */
                    $zipFilePath = $this->retrieveFile($hourlyService, $nearestStation);
                    $content = isset($zipFilePath)
                        ? DWDUtil::getDataFromZip($zipFilePath, DWDConfiguration::getHourlyConfiguration()->zipExtractionPrefix)
                        : null;

                    //content can only be null if a station is listed as active but is not anymore.
                    if ($content == null) {
                        DWDUtil::log(self::class, 'file for station=' . $nearestStation . ' could not be loaded, trying next station');
                        continue;
                    }

                    $parameters[$var] = $this->retrieveData($content, $nearestStation, $coordinatesRequest, $hourlyService, $date, $timeMinuteLimit);

                    //addStation
                    if (count($parameters[$var]) > 0 && !isset($queriedStations['station-' . $nearestStation->getId()])) {
                        $queriedStations['station-' . $nearestStation->getId()] = $nearestStation;
                    }

                    if (count($parameters[$var])>0)
                        break;
                }
            }
        }
        if ($sorted && isset($parameters))
            ksort($parameters);
        return [$parameters, $queriedStations];
    }
public function getDataInInterval ( $ coordinatesRequest , DateTime $ date , $ timeMinuteLimit = 30 , $ sorted = true ) { $ parameters = [ ] ; $ queriedStations = [ ] ; $ date = Carbon :: instance ( $ date ) -> setTimezone ( 'utc' ) ; foreach ( $ this -> services as $ var => $ hourlyService ) { $ stations = $ this -> getStations ( $ hourlyService , true ) ; if ( isset ( $ stations ) ) { try { $ nearestStations = DWDStationsController :: getNearestStations ( $ stations , $ coordinatesRequest ) ; } catch ( DWDLibException $ exception ) { DWDUtil :: log ( self :: class , "Failed to retrieve any nearest active stations. Retrying after forcedownloading new station infos." , Logger :: WARNING ) ; $ stations = $ this -> getStations ( $ hourlyService , true , true ) ; $ nearestStations = DWDStationsController :: getNearestStations ( $ stations , $ coordinatesRequest ) ; } foreach ( $ nearestStations as $ nearestStation ) { /* @var $nearestStation DWDStation */ $ zipFilePath = $ this -> retrieveFile ( $ hourlyService , $ nearestStation ) ; $ content = isset ( $ zipFilePath ) ? DWDUtil :: getDataFromZip ( $ zipFilePath , DWDConfiguration :: getHourlyConfiguration ( ) -> zipExtractionPrefix ) : null ; //content can only be null if a station is listed as active but is not anymore. if ( $ content == null ) { DWDUtil :: log ( self :: class , 'file for station=' . $ nearestStation . ' could not be loaded, trying next station' ) ; continue ; } $ parameters [ $ var ] = $ this -> retrieveData ( $ content , $ nearestStation , $ coordinatesRequest , $ hourlyService , $ date , $ timeMinuteLimit ) ; //addStation if ( count ( $ parameters [ $ var ] ) > 0 && ! isset ( $ queriedStations [ 'station-' . $ nearestStation -> getId ( ) ] ) ) { $ queriedStations [ 'station-' . $ nearestStation -> getId ( ) ] = $ nearestStation ; } if ( count ( $ parameters [ $ var ] ) > 0 ) break ; } } } if ( $ sorted && isset ( $ parameters ) ) ksort ( $ parameters ) ; return [ $ parameters , $ queriedStations ] ; }
Retrieve data from one of the nearest stations. This method retrieves all stations in a specific diameter around
the location. It then queries the stations one by one until one station's results could be found.

This is important if a station's files are missing on the ftp.
@param array $nearestStations
@param DateTime $date
@param int $timeMinuteLimit
@return array [params, stations]
Retrieve data from one of the nearest stations . This method retrieves all stations in a specific diameter around the location . It then queries the stations one by one until one station s results could be found .