src/fwidm/dwdHourlyCrawler/hourly/DWDStationsController.php
public static function getNearestStation($stations, $coordinatesRequest)
    {
        $calculator = new Vincenty();
        $nearestStation = null;
        $nextDist = INF;
        foreach ($stations as $activeStation) {
            if (is_object($activeStation) && $activeStation instanceof DWDStation) {

                $coordinatesStation = new Coordinate($activeStation->getLatitude(), $activeStation->getLongitude());
                $diff = $calculator->getDistance($coordinatesRequest, $coordinatesStation);
                if ($diff < $nextDist) {
                    $nearestStation = $activeStation;
                    $nextDist = $diff;
                }

            } else
                throw new DWDLibException("Stations parameter does contain an object that is no instance of DWDStation");
        }
        return $nearestStation;
    }
public static function getNearestStation($stations, $coordinatesRequest)
    {
        $calculator = new Vincenty();
        $nearestStation = null;
        $nextDist = INF;
        foreach ($stations as $activeStation) {
            if (is_object($activeStation) && $activeStation instanceof DWDStation) {

                $coordinatesStation = new Coordinate($activeStation->getLatitude(), $activeStation->getLongitude());
                $diff = $calculator->getDistance($coordinatesRequest, $coordinatesStation);
                if ($diff < $nextDist) {
                    $nearestStation = $activeStation;
                    $nextDist = $diff;
                }

            } else
                throw new DWDLibException("Stations parameter does contain an object that is no instance of DWDStation");
        }
        return $nearestStation;
    }
public static function getNearestStation ( $ stations , $ coordinatesRequest ) { $ calculator = new Vincenty ( ) ; $ nearestStation = null ; $ nextDist = INF ; foreach ( $ stations as $ activeStation ) { if ( is_object ( $ activeStation ) && $ activeStation instanceof DWDStation ) { $ coordinatesStation = new Coordinate ( $ activeStation -> getLatitude ( ) , $ activeStation -> getLongitude ( ) ) ; $ diff = $ calculator -> getDistance ( $ coordinatesRequest , $ coordinatesStation ) ; if ( $ diff < $ nextDist ) { $ nearestStation = $ activeStation ; $ nextDist = $ diff ; } } else throw new DWDLibException ( "Stations parameter does contain an object that is no instance of DWDStation" ) ; } return $ nearestStation ; }
Return the nearest stations from a stations array.
@param $stations - array of DWDStation
@param $coordinatesRequest
@return DWDStation|null
@throws DWDLibException - if stations is empty
Return the nearest stations from a stations array .