33namespace Netgen \Bundle \OpenWeatherMapBundle \Controller ;
44
55use Netgen \Bundle \OpenWeatherMapBundle \API \OpenWeatherMap \Weather \WeatherStationsInterface ;
6- use Symfony \Bundle \ FrameworkBundle \ Controller \ Controller ;
6+ use Symfony \Component \ HttpFoundation \ Response ;
77
88/**
99 * Class WeatherStationsController
1010 * @package Netgen\Bundle\OpenWeatherMapBundle\Controller
1111 */
12- class WeatherStationsController extends Controller
12+ class WeatherStationsController
1313{
1414 /**
1515 * @var \Netgen\Bundle\OpenWeatherMapBundle\API\OpenWeatherMap\Weather\WeatherStationsInterface
@@ -25,4 +25,58 @@ public function __construct(WeatherStationsInterface $weatherStations)
2525 {
2626 $ this ->weatherStations = $ weatherStations ;
2727 }
28+
29+ /**
30+ * Returns data from one stations by station id
31+ *
32+ * @param int $stationId
33+ *
34+ * @return \Symfony\Component\HttpFoundation\Response
35+ */
36+ public function getFromOnStationById ($ stationId )
37+ {
38+ $ data = $ this ->weatherStations ->fetchFromOnStationById ($ stationId );
39+
40+ return new Response ($ data );
41+ }
42+
43+ /**
44+ * Returns data from several stations by rectangle zone
45+ *
46+ * @param float $longitudeTopLeft
47+ * @param float $latitudeTopLeft
48+ * @param float $longitudeBottomRight
49+ * @param float $latitudeBottomRight
50+ * @param int $mapZoom
51+ * @param string $cluster
52+ * @param int $numberOfStations
53+ *
54+ * @return \Symfony\Component\HttpFoundation\Response
55+ */
56+ public function getFromSeveralByRectangleZone ($ longitudeTopLeft , $ latitudeTopLeft , $ longitudeBottomRight , $ latitudeBottomRight , $ mapZoom , $ cluster = 'yes ' , $ numberOfStations = 10 )
57+ {
58+ $ boundingBox = array (
59+ $ longitudeTopLeft , $ latitudeTopLeft , $ longitudeBottomRight , $ latitudeBottomRight , $ mapZoom
60+ );
61+
62+ $ data = $ this ->weatherStations ->fetchFromSeveralByRectangleZone ($ boundingBox , $ cluster , $ numberOfStations );
63+
64+ return new Response ($ data );
65+ }
66+
67+ /**
68+ * Returns data from several stations by geo point
69+ *
70+ * @param float $latitude
71+ * @param float $longitude
72+ * @param int $numberOfStations
73+ *
74+ * @return \Symfony\Component\HttpFoundation\Response
75+ */
76+ public function getFromSeveralByGeoPoint ($ latitude , $ longitude , $ numberOfStations = 10 )
77+ {
78+ $ data = $ this ->weatherStations ->fetchFromSeveralByGeoPoint ($ latitude , $ longitude , $ numberOfStations );
79+
80+ return new Response ($ data );
81+ }
2882}
0 commit comments