src/fwidm/dwdHourlyCrawler/hourly/DWDHourlyCrawler.php
public function getDataByDay(Coordinate $coordinatesRequest, DateTime $day)
    {
        $parameters = [];
        $queriedStations = [];
        $day = Carbon::instance($day)->setTimezone('utc');
        foreach ($this->services as $var => $hourlyService) {
            /* @var AbstractHourlyService $hourlyService */

            $stations = $this->getStations($hourlyService, true);
            if (isset($stations)) {
                try {
                    $nearestStations = DWDStationsController::getNearestStations($stations, $coordinatesRequest);
                } catch (DWDLibException $exception) {
                    $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;
                    }

                    $start = Carbon::instance($day)->startOfDay();
                    $end = Carbon::instance($day)->endOfDay();
                    $parameters[$var] = $hourlyService->parseHourlyData($content, $nearestStation, $coordinatesRequest, $start, $end);//$this->retrieveData2($content, $hourlyService, $start, $end);

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

                    }
                    if (isset($parameters[$var]))
                        break;
                }
            }
        }
        return [$parameters,$queriedStations];
    }
public function getDataByDay(Coordinate $coordinatesRequest, DateTime $day)
    {
        $parameters = [];
        $queriedStations = [];
        $day = Carbon::instance($day)->setTimezone('utc');
        foreach ($this->services as $var => $hourlyService) {
            /* @var AbstractHourlyService $hourlyService */

            $stations = $this->getStations($hourlyService, true);
            if (isset($stations)) {
                try {
                    $nearestStations = DWDStationsController::getNearestStations($stations, $coordinatesRequest);
                } catch (DWDLibException $exception) {
                    $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;
                    }

                    $start = Carbon::instance($day)->startOfDay();
                    $end = Carbon::instance($day)->endOfDay();
                    $parameters[$var] = $hourlyService->parseHourlyData($content, $nearestStation, $coordinatesRequest, $start, $end);//$this->retrieveData2($content, $hourlyService, $start, $end);

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

                    }
                    if (isset($parameters[$var]))
                        break;
                }
            }
        }
        return [$parameters,$queriedStations];
    }
public function getDataByDay ( Coordinate $ coordinatesRequest , DateTime $ day ) { $ parameters = [ ] ; $ queriedStations = [ ] ; $ day = Carbon :: instance ( $ day ) -> setTimezone ( 'utc' ) ; foreach ( $ this -> services as $ var => $ hourlyService ) { /* @var AbstractHourlyService $hourlyService */ $ stations = $ this -> getStations ( $ hourlyService , true ) ; if ( isset ( $ stations ) ) { try { $ nearestStations = DWDStationsController :: getNearestStations ( $ stations , $ coordinatesRequest ) ; } catch ( DWDLibException $ exception ) { $ 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 ; } $ start = Carbon :: instance ( $ day ) -> startOfDay ( ) ; $ end = Carbon :: instance ( $ day ) -> endOfDay ( ) ; $ parameters [ $ var ] = $ hourlyService -> parseHourlyData ( $ content , $ nearestStation , $ coordinatesRequest , $ start , $ end ) ; //$this->retrieveData2($content, $hourlyService, $start, $end); //addStation if ( count ( $ parameters [ $ var ] ) > 0 && ! isset ( $ queriedStations [ 'station-' . $ nearestStation -> getId ( ) ] ) ) { $ queriedStations [ 'station-' . $ nearestStation -> getId ( ) ] = $ nearestStation ; } if ( isset ( $ parameters [ $ var ] ) ) break ; } } } return [ $ parameters , $ queriedStations ] ; }
Get all data for the given day. The parameter day is converted to UTC!
@param Coordinate $coordinatesRequest
@param DateTime $day
@return array [params, stations]
Get all data for the given day . The parameter day is converted to UTC!