Upload files to "/"
This commit is contained in:
103
meteoutil.pas
Normal file
103
meteoutil.pas
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
unit meteoutil;
|
||||||
|
|
||||||
|
{$mode ObjFPC}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, fpjson, jsonparser;
|
||||||
|
|
||||||
|
|
||||||
|
function calcolaprecipitazione (oggettoJSON:TJSONObject; ora:integer):string;
|
||||||
|
function FormattaAstroLinea(linea:string):string;
|
||||||
|
function MeseToText(mese:integer):string;
|
||||||
|
function stringarichiesta(https:boolean; lat, long: double):string;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
|
||||||
|
function calcolaprecipitazione (oggettoJSON:TJSONObject; ora:integer):string;
|
||||||
|
var
|
||||||
|
codice:integer;
|
||||||
|
precipitazione:string;
|
||||||
|
begin
|
||||||
|
|
||||||
|
codice:=oggettoJSON.FindPath('hourly.weather_code['+inttostr(ora)+']').AsInteger;
|
||||||
|
|
||||||
|
case codice of
|
||||||
|
0: precipitazione:= 'Sereno';
|
||||||
|
1: precipitazione:= 'Prev. Sereno';
|
||||||
|
2: precipitazione:= 'Parz. Nuvoloso';
|
||||||
|
3: precipitazione:= 'Nuvoloso';
|
||||||
|
45..48: precipitazione:= 'Nebbia';
|
||||||
|
51..57: precipitazione:= 'Pioviggine';
|
||||||
|
61..65: precipitazione:= 'Pioggia';
|
||||||
|
66..67:precipitazione:= 'Grandine';
|
||||||
|
71..77: precipitazione:= 'Neve';
|
||||||
|
80..82: precipitazione:= 'Rovesci';
|
||||||
|
85..86:precipitazione:= 'Neve';
|
||||||
|
95..99:precipitazione:= 'Temporale';
|
||||||
|
end;
|
||||||
|
|
||||||
|
result:=precipitazione;
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function FormattaAstroLinea(linea:string):string;
|
||||||
|
var
|
||||||
|
mese:string;
|
||||||
|
begin
|
||||||
|
|
||||||
|
mese:=MeseToText(strtoint(copy(linea, 1,2)));
|
||||||
|
result:=copy(linea, 5, 2)+' '+copy(mese, 1, 3)+' ' +copy(linea, 16);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function MeseToText(mese:integer):string;
|
||||||
|
begin
|
||||||
|
case mese of
|
||||||
|
1: result:='Gennaio';
|
||||||
|
2: result:='Febbraio';
|
||||||
|
3: result:='Marzo';
|
||||||
|
4: result:='Aprile';
|
||||||
|
5: result:='Maggio';
|
||||||
|
6: result:='Giugno';
|
||||||
|
7: result:='Luglio';
|
||||||
|
8: result:='Agosto';
|
||||||
|
9: result:='Settembre';
|
||||||
|
10: result:='Ottobre';
|
||||||
|
11: result:='Novembre';
|
||||||
|
12: result:='Dicembre';
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function stringarichiesta(https:boolean; lat, long: double):string;
|
||||||
|
var
|
||||||
|
segnaposto:string;
|
||||||
|
defaultseparator:char;
|
||||||
|
begin
|
||||||
|
if https then segnaposto:='https://' else segnaposto:='http://';
|
||||||
|
defaultseparator:=DefaultFormatSettings.DecimalSeparator;
|
||||||
|
DefaultFormatSettings.DecimalSeparator:='.'; //fa in modo che venga usato il punto nelle conversioni e non la virgola viene usato il punto e la virgola in base alla provenienza dell'utente di solito
|
||||||
|
//per la richiesta serve che rappresentiamo con i punti
|
||||||
|
segnaposto:=segnaposto+'api.open-meteo.com/v1/forecast?latitude='+floattostr(lat)+'&longitude='+floattostr(long)+'&hourly=weather_code,temperature_2m,wind_speed_10m,wind_speed_180m,visibility,cloud_cover';
|
||||||
|
DefaultFormatSettings.DecimalSeparator:=defaultseparator; //rimette il separatore a quello di default
|
||||||
|
result:=segnaposto;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
BIN
starstreetapp.ico
Normal file
BIN
starstreetapp.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
BIN
starstreetapp_icona.ico
Normal file
BIN
starstreetapp_icona.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
200
unit1.pas
Normal file
200
unit1.pas
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
{ Un incredibile programma di ForeCast Astronomico
|
||||||
|
|
||||||
|
Copyright (C) 2025 starstreet_sardegna
|
||||||
|
|
||||||
|
This source is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This code is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
details.
|
||||||
|
|
||||||
|
A copy of the GNU General Public License is available on the World Wide Web
|
||||||
|
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
|
||||||
|
to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
|
||||||
|
Boston, MA 02110-1335, USA.
|
||||||
|
}
|
||||||
|
unit Unit1;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
||||||
|
EditBtn, Buttons, astronomy, framegrafico, frameluna, meteo_frame,
|
||||||
|
DateUtils, FileInfo, typinfo, ImpostazioniForm, settingsutils, info_form
|
||||||
|
,LCLType, Menus, DateTimePicker, VisualizzaEventiForm;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TForm1 }
|
||||||
|
|
||||||
|
TForm1 = class(TForm)
|
||||||
|
DateEdit1: TDateEdit;
|
||||||
|
impostazionibutton: TSpeedButton;
|
||||||
|
ContenitoreTop: TPanel;
|
||||||
|
InfoButton: TSpeedButton;
|
||||||
|
EventiListButton: TSpeedButton;
|
||||||
|
LunaView1: TLunaView;
|
||||||
|
MenuMac: TMenuItem;
|
||||||
|
InfoMenu: TMenuItem;
|
||||||
|
MenuGlobale: TMainMenu;
|
||||||
|
MeteoView1: TMeteoView;
|
||||||
|
PianetiGraph1: TPianetiGraph;
|
||||||
|
tempooggi: TSpeedButton;
|
||||||
|
BarraStrumenti: TPanel;
|
||||||
|
avanti: TSpeedButton;
|
||||||
|
indietro: TSpeedButton;
|
||||||
|
indietroveloce: TSpeedButton;
|
||||||
|
avantiveloce: TSpeedButton;
|
||||||
|
procedure AggiungiClick(Sender: TObject);
|
||||||
|
procedure DateEdit1ButtonClick(Sender: TObject);
|
||||||
|
procedure DateEdit1Change(Sender: TObject);
|
||||||
|
procedure EventiListButtonClick(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure FormResize(Sender: TObject);
|
||||||
|
procedure InfoButtonClick(Sender: TObject);
|
||||||
|
procedure impostazionibuttonClick(Sender: TObject);
|
||||||
|
procedure SottraiClick(Sender: TObject);
|
||||||
|
procedure avantiClick(Sender: TObject);
|
||||||
|
procedure indietroClick(Sender: TObject);
|
||||||
|
procedure indietroveloceClick(Sender: TObject);
|
||||||
|
procedure avantiveloceClick(Sender: TObject);
|
||||||
|
procedure tempooggiClick(Sender: TObject);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
public
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var
|
||||||
|
Form1: TForm1;
|
||||||
|
tempo:TDateTime;
|
||||||
|
|
||||||
|
OraSimulazione: integer;
|
||||||
|
httpsIsEnabled:boolean;
|
||||||
|
LinguaApp:string;
|
||||||
|
|
||||||
|
impostazionidati:TImpostazioniDati;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
|
{ TForm1 }
|
||||||
|
|
||||||
|
|
||||||
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
|
var
|
||||||
|
versione:TVersionQuad; //variabile per la versione del programma
|
||||||
|
versionnumber:string;
|
||||||
|
begin
|
||||||
|
{$ifdef darwin}
|
||||||
|
MenuMac.Visible:=True;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
|
PianetiGraph1.colorform:=Form1.Color; //passa al frame il colore del form
|
||||||
|
Tempo:=EncodeDateTime(YearOf(Now), MonthOf(Now), DayOf(Now),0,0,0,0);
|
||||||
|
Impostazionidati:=settingsutils.LeggiImpostazioni;
|
||||||
|
Tempo:=DateEdit1.Date;
|
||||||
|
|
||||||
|
Form1.tempooggiClick(nil);
|
||||||
|
FileInfo.GetProgramVersion(versione);
|
||||||
|
Form1.tempooggiClick(nil);
|
||||||
|
versionnumber:=FileInfo.VersionQuadToStr(versione);
|
||||||
|
Form1.Caption:='StarStreet Forecast App v'+versionnumber;
|
||||||
|
info_form.versionnumber:=versionnumber; //passo la variabile di versione a info_form
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TForm1.FormResize(Sender: TObject);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.InfoButtonClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
info_form.Informazioni.ShowModal;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.impostazionibuttonClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ImpostazioniForm.Impostazioni.ShowModal;
|
||||||
|
impostazionidati:=ImpostazioniForm.impostazionidati;
|
||||||
|
|
||||||
|
Form1.DateEdit1Change(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.SottraiClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.avantiClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DateEdit1.Date:=DateUtils.IncDay(Tempo,1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.indietroClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DateEdit1.Date:=DateUtils.IncDay(Tempo,-1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.indietroveloceClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DateEdit1.Date:=DateUtils.IncDay(Tempo,-5);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.avantiveloceClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DateEdit1.Date:=DateUtils.IncDay(Tempo,5);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TForm1.tempooggiClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DateEdit1.Date:=EncodeDate(YearOf(Now), MonthOf(Now), DayOf(Now));
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.AggiungiClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.DateEdit1ButtonClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.DateEdit1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Tempo:=DateEdit1.Date;
|
||||||
|
PianetiGraph1.ImpostaTempoClick(nil, Tempo, impostazionidati.Latitudine,impostazionidati.Longitudine);
|
||||||
|
LunaView1.ImpostaDataClick(nil, Tempo, impostazionidati.OraSimulazione);
|
||||||
|
Form1.MeteoView1.OttieniMeteoClick(nil, Tempo, impostazionidati.httpsIsEnabled, impostazionidati.Latitudine, impostazionidati.Longitudine, impostazionidati.OraSimulazione);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.EventiListButtonClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
VisualizzaEventiForm.Form2.Show;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
Reference in New Issue
Block a user