Files
StarStreet-Forecast/graficimeteoform.pas
2026-03-23 09:27:37 +00:00

71 lines
10 KiB
ObjectPascal

unit graficimeteoform;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, TAGraph,
TASeries, fphttpclient, opensslsockets, fpjson, jsonparser;
type
{ TForm2 }
TForm2 = class(TForm)
Chart1: TChart;
Vento10m: TLineSeries;
Vento180m: TLineSeries;
CoperturaSeries: TLineSeries;
VisibilitaSeries: TLineSeries;
Chart2: TChart;
Chart3: TChart;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form2: TForm2;
implementation
{$R *.lfm}
{ TForm2 }
procedure TForm2.FormCreate(Sender: TObject);
var
MeteoJSON: TJSONData;
OggettoJSON: TJSONObject;
meteotext:string;
i: integer;
begin
meteotext:= '{"latitude":40.0,"longitude":9.0625,"generationtime_ms":0.45692920684814453,"utc_offset_seconds":0,"timezone":"GMT","timezone_abbreviation":"GMT","elevation":549.0,"hourly_units":{"time":"iso8601","temperature_2m":"°C","cloud_cover":"%","visibility":"m","wind_speed_10m":"km/h","wind_speed_180m":"km/h","precipitation":"mm"},"hourly":{"time":["2026-01-28T00:00","2026-01-28T01:00","2026-01-28T02:00","2026-01-28T03:00","2026-01-28T04:00","2026-01-28T05:00","2026-01-28T06:00","2026-01-28T07:00","2026-01-28T08:00","2026-01-28T09:00","2026-01-28T10:00","2026-01-28T11:00","2026-01-28T12:00","2026-01-28T13:00","2026-01-28T14:00","2026-01-28T15:00","2026-01-28T16:00","2026-01-28T17:00","2026-01-28T18:00","2026-01-28T19:00","2026-01-28T20:00","2026-01-28T21:00","2026-01-28T22:00","2026-01-28T23:00","2026-01-29T00:00","2026-01-29T01:00","2026-01-29T02:00","2026-01-29T03:00","2026-01-29T04:00","2026-01-29T05:00","2026-01-29T06:00","2026-01-29T07:00","2026-01-29T08:00","2026-01-29T09:00","2026-01-29T10:00","2026-01-29T11:00","2026-01-29T12:00","2026-01-29T13:00","2026-01-29T14:00","2026-01-29T15:00","2026-01-29T16:00","2026-01-29T17:00","2026-01-29T18:00","2026-01-29T19:00","2026-01-29T20:00","2026-01-29T21:00","2026-01-29T22:00","2026-01-29T23:00","2026-01-30T00:00","2026-01-30T01:00","2026-01-30T02:00","2026-01-30T03:00","2026-01-30T04:00","2026-01-30T05:00","2026-01-30T06:00","2026-01-30T07:00","2026-01-30T08:00","2026-01-30T09:00","2026-01-30T10:00","2026-01-30T11:00","2026-01-30T12:00","2026-01-30T13:00","2026-01-30T14:00","2026-01-30T15:00","2026-01-30T16:00","2026-01-30T17:00","2026-01-30T18:00","2026-01-30T19:00","2026-01-30T20:00","2026-01-30T21:00","2026-01-30T22:00","2026-01-30T23:00","2026-01-31T00:00","2026-01-31T01:00","2026-01-31T02:00","2026-01-31T03:00","2026-01-31T04:00","2026-01-31T05:00","2026-01-31T06:00","2026-01-31T07:00","2026-01-31T08:00","2026-01-31T09:00","2026-01-31T10:00","2026-01-31T11:00","2026-01-31T12:00","2026-01-31T13:00","2026-01-31T14:00","2026-01-31T15:00","2026-01-31T16:00","2026-01-31T17:00","2026-01-31T18:00","2026-01-31T19:00","2026-01-31T20:00","2026-01-31T21:00","2026-01-31T22:00","2026-01-31T23:00","2026-02-01T00:00","2026-02-01T01:00","2026-02-01T02:00","2026-02-01T03:00","2026-02-01T04:00","2026-02-01T05:00","2026-02-01T06:00","2026-02-01T07:00","2026-02-01T08:00","2026-02-01T09:00","2026-02-01T10:00","2026-02-01T11:00","2026-02-01T12:00","2026-02-01T13:00","2026-02-01T14:00","2026-02-01T15:00","2026-02-01T16:00","2026-02-01T17:00","2026-02-01T18:00","2026-02-01T19:00","2026-02-01T20:00","2026-02-01T21:00","2026-02-01T22:00","2026-02-01T23:00","2026-02-02T00:00","2026-02-02T01:00","2026-02-02T02:00","2026-02-02T03:00","2026-02-02T04:00","2026-02-02T05:00","2026-02-02T06:00","2026-02-02T07:00","2026-02-02T08:00","2026-02-02T09:00","2026-02-02T10:00","2026-02-02T11:00","2026-02-02T12:00","2026-02-02T13:00","2026-02-02T14:00","2026-02-02T15:00","2026-02-02T16:00","2026-02-02T17:00","2026-02-02T18:00","2026-02-02T19:00","2026-02-02T20:00","2026-02-02T21:00","2026-02-02T22:00","2026-02-02T23:00","2026-02-03T00:00","2026-02-03T01:00","2026-02-03T02:00","2026-02-03T03:00","2026-02-03T04:00","2026-02-03T05:00","2026-02-03T06:00","2026-02-03T07:00","2026-02-03T08:00","2026-02-03T09:00","2026-02-03T10:00","2026-02-03T11:00","2026-02-03T12:00","2026-02-03T13:00","2026-02-03T14:00","2026-02-03T15:00","2026-02-03T16:00","2026-02-03T17:00","2026-02-03T18:00","2026-02-03T19:00","2026-02-03T20:00","2026-02-03T21:00","2026-02-03T22:00","2026-02-03T23:00"],"temperature_2m":[10.9,10.6,10.5,10.3,9.7,9.1,8.4,7.4,6.8,6.7,8.1,8.9,9.2,9.5,8.7,8.5,7.9,7.3,7.1,7.1,7.2,7.6,7.4,6.9,6.2,5.9,5.8,5.5,5.5,5.5,5.5,5.8,6.3,7.1,7.9,8.5,9.2,9.6,9.4,8.9,8.1,7.4,7.0,6.8,7.1,7.3,7.2,7.4,7.6,7.6,7.7,7.6,7.5,7.5,7.2,7.1,7.8,8.7,8.5,8.2,8.4,9.2,9.0,8.4,8.0,7.6,7.3,7.6,7.4,7.4,7.3,7.1,6.3,5.9,6.0,6.0,6.1,6.3,5.7,5.7,6.0,7.3,8.9,9.5,9.3,9.4,8.8,7.9,7.1,6.6,6.4,6.1,5.9,5.8,5.7,5.6,5.6,5.5,5.4,5.3,5.2,5.1,5.3,5.9,6.8,7.6,8.4,9.1,9.5,9.3,8.8,8.3,8.0,7.7,7.5,7.5,7.7,7.8,7.8,7.6,7.4,7.1,6.8,6.5,6.1,5.7,5.7,6.3,7.4,8.5,9.7,10.9,11.6,11.3,10.4,9.8,9.7,9.7,9.8,9.6,9.4,9.3,9.7,10.2,10.5,10.6,10.5,10.4,10.4,10.4,10.3,10.3,10.3,10.2,10.0,9.7,9.6,9.6,9.7,9.6,9.2,8.6,8.1,7.9,7.7,7.6,7.5,7.4],"cloud_cover":[100,100,93,100,100,100,100,100,100,88,88,72,71,72,86,100,100,98,100,100,97,100,100,100,100,92,78,54,60,66,71,69,71,71,75,59,85,76,57,79,50,63,100,100,95,90,90,97,99,96,99,99,78,75,72,66,99,100,100,100,71,78,81,66,63,81,76,63,59,72,73,55,71,93,68,89,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,99,97,96,86,77,67,66,66,65,68,71,74,73,71,70,80,90,100,100,100,100,100,100,100,98,95,93,90,86,83,72,60,49,66,83,100,93,85,78,85,93,100,97,94,91,92,94,95,90,84,79,86,93,100,100,100,100,100,100,100,100,100,100,100,99,99,95,92,88,86,85,83,80,78,75,78,82],"visibility":[11280.00,1640.00,14040.00,1500.00,2060.00,840.00,860.00,500.00,420.00,480.00,22920.00,44460.00,51680.00,59120.00,37120.00,38920.00,25020.00,18380.00,12920.00,8400.00,21780.00,8680.00,16960.00,10100.00,15380.00,15540.00,20100.00,16320.00,17520.00,16780.00,8020.00,9260.00,9460.00,20120.00,38180.00,39360.00,56660.00,59180.00,51460.00,41480.00,34660.00,30160.00,22980.00,11840.00,7000.00,5640.00,3900.00,4340.00,2760.00,2520.00,2080.00,2180.00,2280.00,3940.00,3920.00,3300.00,9600.00,12700.00,680.00,11720.00,20080.00,40760.00,39160.00,22580.00,26680.00,33300.00,7020.00,7780.00,11300.00,10280.00,13200.00,8840.00,3560.00,2680.00,5440.00,14240.00,18900.00,38460.00,43440.00,51200.00,46580.00,37700.00,42140.00,30740.00,51780.00,51840.00,17480.00,18000.00,9800.00,23620.00,23600.00,22260.00,20920.00,19580.00,19920.00,20260.00,20600.00,18920.00,17220.00,15540.00,15560.00,15580.00,15600.00,18320.00,21060.00,23780.00,28380.00,32960.00,37560.00,27440.00,17340.00,7220.00,5200.00,3180.00,1160.00,1260.00,1340.00,1440.00,1920.00,2380.00,2860.00,8040.00,13240.00,18420.00,20320.00,22200.00,24100.00,26680.00,29240.00,31820.00,36620.00,36950.00,32785.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00,24140.00],"wind_speed_10m":[13.3,23.4,18.4,25.8,28.1,26.4,28.0,30.4,27.9,28.5,26.6,27.3,28.1,25.5,25.7,27.9,20.1,11.0,7.2,5.4,7.2,6.2,7.0,14.3,17.8,14.1,13.5,13.9,12.1,12.5,13.6,15.5,18.7,20.1,26.2,26.0,31.0,31.0,28.0,21.8,17.4,10.7,6.5,5.5,5.5,4.7,2.9,3.3,6.5,6.0,6.3,5.0,4.8,4.4,3.4,2.7,1.8,5.5,8.0,11.4,9.9,21.4,21.8,21.3,18.8,15.8,14.2,11.6,10.8,8.6,6.5,2.6,4.8,4.6,4.7,6.6,8.3,7.3,6.8,7.7,7.7,5.9,3.1,4.9,9.7,14.8,14.6,14.8,18.3,16.6,10.5,7.9,6.0,5.4,5.6,6.3,6.8,6.4,5.7,5.4,5.4,5.1,5.1,4.8,5.0,5.6,7.9,11.2,13.2,12.9,10.9,9.8,8.7,7.2,6.5,6.6,7.3,7.5,7.0,6.2,5.4,4.5,3.4,2.6,1.4,1.4,2.9,3.6,4.1,4.6,5.6,6.7,7.8,7.9,8.2,8.7,9.3,10.9,12.4,11.5,10.1,9.5,8.8,8.5,9.0,10.6,13.0,14.4,13.3,10.9,9.7,10.8,13.0,14.2,13.2,11.3,10.7,12.6,15.6,17.2,16.4,14.3,12.2,10.2,8.4,6.9,6.4,6.9],"wind_speed_180m":[35.9,52.1,49.3,58.3,60.2,55.3,61.5,64.7,59.1,61.8,55.6,53.2,51.4,46.4,45.8,51.5,41.6,30.6,21.7,20.9,17.7,18.1,3.5,28.5,44.3,37.1,35.9,38.5,37.1,39.5,41.2,44.9,47.5,42.0,50.2,46.9,59.1,59.5,53.2,42.3,37.8,33.2,23.0,24.3,21.8,19.7,16.6,19.1,24.5,23.5,23.3,21.1,21.2,19.1,16.0,14.1,7.7,11.3,18.4,25.6,18.4,40.3,42.0,44.5,45.1,43.3,40.0,36.5,34.6,33.3,25.2,15.2,8.1,12.0,12.1,9.6,15.5,17.0,10.6,14.8,10.5,7.1,9.2,9.3,19.9,29.1,32.6,34.9,44.7,42.1,30.7,25.6,20.9,19.0,19.8,21.7,23.2,23.5,23.6,23.3,23.2,23.2,21.9,18.8,14.5,12.1,13.4,16.9,19.9,20.3,19.9,19.9,20.7,22.2,23.4,24.1,24.5,24.2,23.0,21.0,19.5,18.2,17.5,16.1,14.6,12.9,10.7,7.6,4.7,5.2,6.9,8.7,10.5,12.8,15.8,18.3,20.8,24.9,28.1,26.3,22.1,19.4,19.4,21.9,24.9,28.2,31.9,33.5,31.0,26.3,24.5,26.9,30.9,33.2,31.6,28.7,27.6,30.5,35.2,38.1,37.3,34.9,32.9,29.2,24.6,21.1,20.9,21.9],"precipitation":[1.20,2.50,0.30,0.80,2.10,2.50,2.60,2.60,1.90,1.60,0.60,0.20,0.00,0.00,0.00,0.00,0.00,0.10,0.60,1.40,1.80,1.50,0.90,1.00,1.70,0.40,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.10,0.00,0.00,0.10,0.20,0.20,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.00,1.40,0.60,0.00,0.00,0.60,0.20,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.10,0.20,0.20,0.10,0.30,0.40,1.70,0.90,0.50,0.10,0.10,0.10,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.10,0.10,0.10,1.00,1.00,1.00,0.20,0.20,0.20,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.10,0.10,0.10,0.30,0.30,0.30,0.00,0.00,0.00,0.40,0.40,0.40,0.90,0.90,0.90,0.60,0.60,0.60,1.00,1.00,1.00,1.70,1.70,1.70,0.40,0.40,0.40,0.40,0.40,0.40,0.10,0.10,0.10,0.10,0.10]}}';
MeteoJSON:=fpJSON.GetJSON(meteotext);
OggettoJSON := MeteoJSON as TJSONObject; //questo è stato fatto per rendere i dati meglio estraibili
for i:=0 to 24 do
begin
VisibilitaSeries.AddXY(i, round(OggettoJSON.FindPath('hourly.visibility['+inttostr(i+1)+']').AsFloat/1000));
CoperturaSeries.AddXY(i, round(OggettoJSON.FindPath('hourly.cloud_cover['+inttostr(i+1)+']').AsFloat));
Vento10m.AddXY(i, round(OggettoJSON.FindPath('hourly.wind_speed_10m['+inttostr(i+1)+']').AsFloat));
Vento180m.AddXY(i, round(OggettoJSON.FindPath('hourly.wind_speed_180m['+inttostr(i+1)+']').AsFloat));
end;
end;
end.