Кнопка записать записывает координаты и описание во второй мемо.
Кнопка отправить отправляет через выбранную программу.
procedure Preobr(Aa, Ab, Ea, Eb, B, Lat, H, dx, dy, dz, wx, wy, wz, mm: double);
var
a, e2, da, de2, M, n: double;
begin
a := (Ab + Aa) / 2;
e2 := (sqr(Eb) + sqr(Ea)) / 2;
da := Ab - Aa;
de2 := sqr(Eb) - sqr(Ea);
M := a * (1 - e2) * Power((1 - e2 * sqr(sin(B))), -3 / 2);
n := a * Power((1 - e2 * sqr(sin(B))), -1 / 2);
dB := p / (M + H) * ((n / a) * e2 * sin(B) * cos(B) * da +
(sqr(n) / sqr(a) + 1) * n * sin(B) * cos(B) * (de2 / 2) (dx * cos(L) + dy * sin(L)) * sin(B) + dz * cos(B)) - wx * sin(L) *
(1 + e2 * cos(2 * B)) + wy * cos(L) * (1 + e2 * cos(2 * B)) - p * mm * e2 *
sin(B) * cos(B);
dL := (p / ((n + H) * cos(B))) * (-dx * sin(L) + dy * cos(L)) + tan(B) *
(1 - e2) * (wx * cos(L) + wy * sin(L)) - wz;
dH := (-a / n) * da + n * sqr(sin(B)) * (de2 / 2) + (dx * cos(L) + dy * sin(L)
) * cos(B) + dz * sin(B) - n * e2 * sin(B) * cos(B) *
((wx / p) * sin(L) - (wy / p) * cos(L)) + (sqr(a) / n + H) * mm;
end;
// из ВГС в СК
procedure TForm1.WGS_SK;
begin
Lat := DegToRad(Lat);
Lon := DegToRad(Lon);
Preobr(6378137, 6378136, 1 / 298.257223563, 1 / 298.25784, Lat, Lon, Heig,
1.08, 0.27, 0.9, 0, 0, 0.16, 0.12E-6); // из ВГС в ПЗ
dB := dB / 3600;
dL := dL / 3600;
Lat := RadToDeg(Lat) + dB;
Lon := RadToDeg(Lon) + dL;
Heig := LocationSensor1.Sensor.Altitude; // Heig + dH;
Lat := DegToRad(Lat);
Lon := DegToRad(Lon);
Preobr(6378136, 6378245, 1 / 298.25784, 1 / 298.3, Lat, Lon, Heig, -25.9,
130.94, 81.76, 0, 0, 0, 0); // из ПЗ в СК 95
dB := dB / 3600;
dL := dL / 3600;
Lat := RadToDeg(Lat) + dB;
Lon := RadToDeg(Lon) + dL;
Heig := Heig + dH;
B := Lat;
L := Lon;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
F1 := LocationSensor1.Sensor.Latitude;
L1 := LocationSensor1.Sensor.Longitude;
WGS_SK(F1, L1, LocationSensor1.Sensor.Altitude);
SK_Pr(B, L);
Координаты заносятся вручную и обрисовываются на планшете. При закрытии программы
сохраняются в четырех текстовых файлах. При запуске программы из этих файлов
считывается информация и рисует на планшете. Кнопка добавить добавляет данные из
введенных в поля. Кнопка удалить удаляет отдельно в каждом поле.
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Add(Edit1.text);
ListBox2.Items.Add(Edit2.text);
ListBox3.Items.Add(Edit3.text);
ListBox4.Items.Add(Edit4.text);
//circle
C := Tcircle.Create(Image1);
C.Parent := Image1;
C.Position.X := Edit3.text.ToSingle;
C.Position.Y := Edit4.text.ToSingle;
C.Width := 10;
C.Height := 10;
//number place
L := TLabel.Create(Image1);
L.Parent := Image1;
L.Position.X := Edit3.text.ToSingle - 10;
L.Position.Y := Edit4.text.ToSingle;
L.text := Edit2.text;
//number galse
L := TLabel.Create(Image1);
L.Parent := Image1;
L.Position.X := Edit3.text.ToSingle;
L.Position.Y := Edit4.text.ToSingle + 10;
if Edit2.Text='1' then L.text := 'г-'+Edit1.text;
// линия
if Edit2.Text '1' then
begin
dx := ListBox3.Items[ListBox3.Count - 1].ToExtended - ListBox3.Items[ListBox3.Count 2].ToExtended;
dy := ListBox4.Items[ListBox4.Count - 1].ToExtended - ListBox4.Items[ListBox4.Count 2].ToExtended;
s := Math.Hypot(dx, dy);
u := RadToDeg(arcsin(dx / s));
if -dy < 0 then
u := 180 - u;
if u < 0 then
u := 360 + u;
Lin := Tline.Create(Image1);
Lin.Parent := Image1;
Lin.Position.x := Edit3.Text.ToSingle+5;
Lin.Position.y := Edit4.Text.ToSingle+5;
Lin.RotationCenter.x := 0;
Lin.RotationCenter.y := 0;
Lin.RotationAngle := u;
Lin.Width := 1;
Lin.Height := s;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Items.Delete(ListBox1.ItemIndex);
ListBox2.Items.Delete(ListBox2.ItemIndex);
ListBox3.Items.Delete(ListBox3.ItemIndex);
ListBox4.Items.Delete(ListBox4.ItemIndex);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ListBox1.Items.SaveToFile('1.txt');
ListBox2.Items.SaveToFile('2.txt');
ListBox3.Items.SaveToFile('3.txt');
ListBox4.Items.SaveToFile('4.txt');
end;
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
try
ListBox1.Items.LoadFromFile('1.txt');
ListBox2.Items.LoadFromFile('2.txt');
ListBox3.Items.LoadFromFile('3.txt');
ListBox4.Items.LoadFromFile('4.txt');
for i := 0 to ListBox1.Items.Count-1 do
begin
//circle
C := Tcircle.Create(Image1);
C.Parent := Image1;
C.Position.X := ListBox3.Items[i].ToSingle;
C.Position.Y := ListBox4.Items[i].ToSingle;
C.Width := 10;
C.Height := 10;
//number place
L := TLabel.Create(Image1);
L.Parent := Image1;
L.Position.X := ListBox3.items[i].ToSingle - 10;
L.Position.Y := ListBox4.items[i].ToSingle;
L.text := ListBox2.Items[i];
//number galse
L := TLabel.Create(Image1);
L.Parent := Image1;
L.Position.X := ListBox3.Items[i].ToSingle;
L.Position.Y := ListBox4.Items[i].ToSingle + 10;
if ListBox2.Items[i]='1' then L.text := 'г-'+ListBox1.Items[i];
// линия
if ListBox2.Items[i] '1' then
begin
dx := ListBox3.Items[ListBox3.Count - 1].ToExtended - ListBox3.Items[ListBox3.Count 2].ToExtended;
dy := ListBox4.Items[ListBox4.Count - 1].ToExtended - ListBox4.Items[ListBox4.Count 2].ToExtended;
s := Math.Hypot(dx, dy);
u := RadToDeg(arcsin(dx / s));
if -dy < 0 then
u := 180 - u;
if u < 0 then
u := 360 + u;
Lin := Tline.Create(Image1);
Lin.Parent := Image1;
Lin.Position.x := ListBox3.Items[i].ToSingle+5;
Lin.Position.y := ListBox4.Items[i].ToSingle+5;
Lin.RotationCenter.x := 0;
Lin.RotationCenter.y := 0;
Lin.RotationAngle := u;
Lin.Width := 1;
Lin.Height := s;
end;
end;
finally
end;
3. Промер.
Лучше предыдущей написан на библиотеке vsl. Создание графических примитивов
поддерживается на канве компонента Image. На fairmanke не получилось с линиями. А
здесь поддерживается из начальной точки в конечную.
Edit2.Text:=IntToStr(StrToInt(Edit2.Text)+1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Items[ListBox1.ItemIndex];
ListBox2.Items[ListBox2.ItemIndex];
ListBox3.Items[ListBox3.ItemIndex];
ListBox4.Items[ListBox4.ItemIndex];
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ListBox1.Clear;
ListBox2.Clear;
ListBox3.Clear;
ListBox4.Clear;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ListBox1.Items.SaveToFile('1.txt');
ListBox2.Items.SaveToFile('2.txt');
ListBox3.Items.SaveToFile('3.txt');
ListBox4.Items.SaveToFile('4.txt');
end;
procedure TForm1.FormShow(Sender: TObject);
var
i,x1, y1, x2, y2, xLine1, yLine1, xLine2, yLine2: integer;
begin
ListBox1.Items.LoadFromFile('1.txt');
ListBox2.Items.LoadFromFile('2.txt');
ListBox3.Items.LoadFromFile('3.txt');
ListBox4.Items.LoadFromFile('4.txt');
for i := 0 to ListBox1.Items.Count-1 do
begin
x1:=ListBox3.Items[i].ToInteger;
y1:=ListBox4.Items[i].ToInteger;
x2:=x1+10;
y2:=y1+10;
Image1.Canvas.Ellipse(x1-5,y1-5,x2-5,y2-5);
Image1.Canvas.TextOut(x1-15,y1,ListBox2.Items[i]);
if ListBox2.Items[i]='1' then
Image1.Canvas.TextOut(x1,y1-20,'г-'+ListBox1.Items[i]);
if ListBox2.Items[i]'1' then
begin
xLine2:=ListBox3.Items[i].ToInteger;
yLine2:=ListBox4.Items[i].ToInteger;
xLine1:=ListBox3.Items[i-1].ToInteger;
Координирование промера по прямой засечке в местной системе координат от северо
западного угла планшета.
procedure TForm1.Button1Click(Sender: TObject);
var
xp, yp, x1, y1, x2, y2, cotan1, cotan2, x1line, y1line, tgA1p, b1, b2, a2, a3,
Строится планшет в проекции Гаусса-Крюгера
Пересчет происходит при изменении размеров формы.
procedure TForm1.FormResize(Sender: TObject);
begin
Edit6.Text:=FloatToStr(StrToFloat(Edit5.Text)+Form1.Width);
Edit1.Text:=FloatToStr(StrToFloat(Edit3.Text)+Form1.Height);
Edit5.Position.X:=-35;
Edit5.Position.Y:=Rectangle1.Height/2;
Edit6.Position.X:=Rectangle1.Width-15;
Edit6.Position.Y:=Rectangle1.Height/2;
end;
1. Сбор данных
Собирает данные спутника и отправляет через локальную сеть по порту 1025.
procedure TForm1.Button1Click(Sender: TObject);
begin
LocationSensor1.Active := true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
LocationSensor1.Active := false;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
IdTCPClient1.Socket.WriteLn(Memo1.Text);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
IdTCPClient1.Disconnect;
end;
procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
const OldLocation, NewLocation: TLocationCoord2D);
begin
Memo1.Lines.Add(FloatToStr(LocationSensor1.Sensor.Latitude) + ' ' +
FloatToStr(LocationSensor1.Sensor.Longitude) + ' ' +
FloatToStrF(LocationSensor1.Sensor.Altitude, ffFixed, 5, 0) + ' ' +
FloatToStrF(LocationSensor1.Sensor.TrueHeading, ffFixed, 3, 0) + ' ' +
FloatToStrF(LocationSensor1.Sensor.Speed, ffFixed, 3, 0)+' '+
FloatToStrF(LocationSensor1.Sensor.ErrorRadius,ffFixed,5,1));
end;
Собирается широта, долгота, высота, направление, скорость и ошибка места.
2. Предварительная прокладка.
Состоит из двух закладок. Первая карта Гугль. На ней можно отмечать точки. На второй
закладке можно производить расчеты между точками. Курс и скорость и время в пути.
Данные точек можно сохранять в текстовые файлы.
procedure TForm1.Button1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
Memo1.Lines.SaveToFile(SaveDialog1.FileName);
if SaveDialog2.Execute then
Memo2.Lines.SaveToFile(SaveDialog2.FileName);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Lines.Clear;
Memo2.Lines.Clear;
Memo3.Lines.Clear;
if OpenDialog1.Execute then
Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
if OpenDialog2.Execute then
Memo2.Lines.LoadFromFile(OpenDialog2.FileName);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i: integer;
f, l, d, d1, K, f1, f2, l1, l2: extended;
begin
Memo3.Lines.Clear;
d := 0;
for i := 0 to Memo1.Lines.Count - 2 do
begin
f1 := StrToFloat(Memo1.Lines[i]);
f2 := StrToFloat(Memo1.Lines[i + 1]);
l1 := StrToFloat(Memo2.Lines[i]);
l2 := StrToFloat(Memo2.Lines[i + 1]);
f := (f2 - f1) * 60;
l := ((l2 - l1) * cos(DegToRad((f2 + f1) / 2))) * 60;
d1 := Math.Hypot(f, l);
K := RadToDeg(arctan(f / l));
Memo3.Lines.Add('РШ=' + FloatToStr(f) + ' РД=' + FloatToStr(l) + ' Курс=' +
FloatToStrF(K,ffFixed,5,1) + ' Расстояние=' + FloatToStrF(d1,
ffFixed, 10, 0));
d := d + d1;
end;
Label1.Text := FloatToStrF(d, ffFixed, 10, 0) + ' миль';
Label4.Text := FloatToStrF(d*1.852, ffFixed, 10, 0) + ' км';
Label3.Text := FloatToStrF(d / StrToFloat(Edit1.Text) / 24, ffFixed, 10, 1)
+ ' суток';
end;
3. Промер гидрографический.
procedure TForm1.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
begin
Image1.Bitmap.Assign(Image);
end;
Можно задать границы планшета и выполнять промер на мобильном телефоне. Данные
отправлять по почте.
4. Перевод координат географических в прямоугольные.
procedure TForm1.Button1Click(Sender: TObject);
var N,cos_sqr_B,a0,a4,a6,a3,a5,B_sek,x,y,N_Z,B,L:Extended;
begin
B:=StrToFloat(Edit1.Text);
B:=DegToRad(B);//Широта в радианах
cos_sqr_B:= sqr(cos(B));
N:=6399698.902-(21562.267-(108.973-0.612*cos_sqr_B)*cos_sqr_B)*cos_sqr_B;
a0:=32140.404-(135.3302-(0.7092-0.004*cos_sqr_B)*cos_sqr_B)*cos_sqr_B;
a4:=(0.25+0.00252*cos_sqr_B)*cos_sqr_B-0.04166;
begin
FormatSettings.DecimalSeparator := '.';
end;
procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
const OldLocation, NewLocation: TLocationCoord2D);
begin
Label1.Text := NewLocation.Latitude.ToString;
Label2.Text := NewLocation.Longitude.ToString;
f:=Label1.Text;
l:=Label2.Text;
WebBrowser1.URL := 'maps.google.com/maps?q=' + f + ',' + l
+ '&output=emded';
end;
Сервер:
s,f,l:string;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.URL := 'maps.google.com/maps?q=' + f + ',' + l
+ '&output=emded';
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
IdTCPServer1.Active := false;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
IdTCPServer1.Active := true;
end;
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
begin
Edit1.Text := AContext.Connection.Socket.ReadLn;
s := Edit1.Text;
f := Copy(s, 1, pos(' ', s) - 1);
delete(s, 1, pos(' ', s));
l := Copy(s, 1, Length(s));
end;
Есть еще программа, передающая поправки к координатам на известной точке. Есть вариант
сервер на ровере и есть клиент на ровере.
8. Исправление координат поправками полученными на твердой точке.
Клиент программы.
var
Form1: TForm1; f,l,f1,f2,l1,l2:string;
implementation
{$R *.fmx}
//connect
procedure TForm1.Button1Click(Sender: TObject);
begin
IdTCPClient1.Host := Edit1.Text;
IdTCPClient1.Connect;
// отправка
IdTCPClient1.Socket.WriteLn(f + ' ' + l);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
FormatSettings.DecimalSeparator := '.';
end;
procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
const OldLocation, NewLocation: TLocationCoord2D);
begin
Label1.Text := NewLocation.Latitude.ToString;
Label2.Text := NewLocation.Longitude.ToString;
f:=Label1.Text;
l:=Label2.Text;
WebBrowser1.URL := 'maps.google.com/maps?q=' + f + ',' + l
+ '&output=emded';
end;
Программа сервер.
var
Form1: TForm1;
B, L, H, dB, dL, dH, x1, y1, x2, y2, x, y, D, ugol, x_old, y_old, ugol_old,
D_old: real;
F1, L1, F2, L2, F_Old, L_Old: real;
dX, dY: real;
const
p = 206264.8062;
ro: Extended = 206264.800023606351128218038600445;
implementation
{$R *.fmx}
procedure Preobr(Aa, Ab, Ea, Eb, B, Lat, H, dX, dY, dz, wx, wy, wz, mm: double);
var
a, e2, da, de2, M, n: double;
begin
a := (Ab + Aa) / 2;
e2 := (sqr(Eb) + sqr(Ea)) / 2;
da := Ab - Aa;
de2 := sqr(Eb) - sqr(Ea);
M := a * (1 - e2) * Power((1 - e2 * sqr(sin(B))), -3 / 2);
n := a * Power((1 - e2 * sqr(sin(B))), -1 / 2);
dB := p / (M + H) * ((n / a) * e2 * sin(B) * cos(B) * da +
(sqr(n) / sqr(a) + 1) * n * sin(B) * cos(B) * (de2 / 2) (dX * cos(L) + dY * sin(L)) * sin(B) + dz * cos(B)) - wx * sin(L) *
(1 + e2 * cos(2 * B)) + wy * cos(L) * (1 + e2 * cos(2 * B)) - p * mm * e2 *
sin(B) * cos(B);
dL := (p / ((n + H) * cos(B))) * (-dX * sin(L) + dY * cos(L)) + tan(B) *
(1 - e2) * (wx * cos(L) + wy * sin(L)) - wz;
Последние комментарии
8 часов 32 минут назад
8 часов 33 минут назад
15 часов 16 минут назад
15 часов 24 минут назад
21 часов 36 минут назад
21 часов 40 минут назад