unit Map;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, ExtCtrls, StdCtrls, Buttons, DB, DBTables, Mask,
  inputdat,setplace,Isosis,math;

type
  TDrawMapa = class(TForm)
    Panel1: TPanel;
    ComboBox2: TComboBox;
    Label1: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    SpeedButton2: TSpeedButton;
    Panel2: TPanel;
    Label2: TLabel;
    PaintBox1: TPaintBox;
    PaintBox2: TPaintBox;
    PaintBox3: TPaintBox;
    PaintBox4: TPaintBox;
    PaintBox5: TPaintBox;
    PaintBox6: TPaintBox;
    PaintBox7: TPaintBox;
    PaintBox8: TPaintBox;
    PaintBox9: TPaintBox;
    PaintBox10: TPaintBox;
    PaintBox11: TPaintBox;
    PaintBox13: TPaintBox;
    PaintBox15: TPaintBox;
    PaintBox16: TPaintBox;
    PaintBox17: TPaintBox;
    PaintBox18: TPaintBox;
    PaintBox19: TPaintBox;
    PaintBox20: TPaintBox;
    PaintBox12: TPaintBox;
    PaintBox14: TPaintBox;
    PaintBox21: TPaintBox;
    PaintBox22: TPaintBox;
    PaintBox23: TPaintBox;
    PaintBox24: TPaintBox;
    Label3: TLabel;
    PrintFoco: TLabel;
    Button1: TButton;
    LongEdit: TMaskEdit;
    LatEdit: TMaskEdit;
    ProfEdit: TMaskEdit;
    AzimutEdit: TMaskEdit;
    ABEdit: TMaskEdit;
    Editmag: TMaskEdit;
    Label4: TLabel;
    Button2: TButton;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    SpeedButton1: TSpeedButton;
    PrintDialog1: TPrintDialog;
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure PaintBox18Paint(Sender: TObject);
    procedure PaintBox21Paint(Sender: TObject);
    procedure PaintBox7Paint(Sender: TObject);
    procedure PaintBox10Paint(Sender: TObject);
    procedure PaintBox2Paint(Sender: TObject);
    procedure PaintBox3Paint(Sender: TObject);
    procedure PaintBox4Paint(Sender: TObject);
    procedure PaintBox5Paint(Sender: TObject);
    procedure PaintBox6Paint(Sender: TObject);
    procedure PaintBox8Paint(Sender: TObject);
    procedure PaintBox9Paint(Sender: TObject);
    procedure PaintBox11Paint(Sender: TObject);
    procedure PaintBox13Paint(Sender: TObject);
    procedure PaintBox15Paint(Sender: TObject);
    procedure PaintBox16Paint(Sender: TObject);
    procedure PaintBox17Paint(Sender: TObject);
    procedure PaintBox19Paint(Sender: TObject);
    procedure PaintBox20Paint(Sender: TObject);
    procedure PaintBox12Paint(Sender: TObject);
    procedure PaintBox14Paint(Sender: TObject);
    procedure PaintBox22Paint(Sender: TObject);
    procedure PaintBox23Paint(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
    procedure PaintBox24Paint(Sender: TObject);
    procedure FormActivate(Sender: TObject);    procedure SpeedButton2Click(Sender: TObject);
    procedure PaintBox24MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure PaintBox24MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure PaintBox24MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure PaintBox24DblClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure PaintBox24Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public

   Procedure Simbolo_0(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_n(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_2(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_25(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_3(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_35(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_4(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_45(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_5(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_55(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_6(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_65(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_7(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_75(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_8(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_85(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_9(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_95(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_10(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_105(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_11(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_115(Sender:TPaintBox; x,y:integer);
   Procedure Simbolo_12(Sender:TPaintBox; x,y:integer);
   function fintensity(r:real):real;
   function fderivaInt(x:real):real;
   function elipse(I:real):real;
   procedure Isosista(xi,yi,a,b,n:integer;ang:real;color:TColor);
   procedure PintaIsosista;
   procedure readlimitmap(var maxlongit,minlongit,
                                 maxlat,minlat:real);
   procedure getscale(var Escx,Escy: real);
   procedure Savevalue;
    { Public declarations }
  end;

type
TCord=record
  longitud:double;
  latitud:double;
  end;

TViewCord=record
  x1,y1,x2,y2:real;
end;

const
 Escala:array[1..5] of integer=(1,2,4,8,20);
 Lcolor:array[1..11] of TColor=(clBlack,clBlue,clRed,clGreen,clPurple,
 clLime,clGray,clNavy,clTeal,clOlive,clMaroon);
var
  DrawMapa: TDrawMapa;
  Puntos:TCord;
  ViewCord:TViewCord;
  clon,clat,middlex:real;
  screenmidd,screenmiddy:integer;
  EscX,EscY:real;
  xi,yi,xz,yz,Xfin,Yfin:integer;
  {azimut,a_b:real; }
  Zoom,Cuadro:Boolean;
  Xp,Yp:integer;
  ancho,alto,Xmouse,Ymouse:integer;
  indiceEsc:integer;
  F:Text;
  Maxlongit,minlongit,maxlat,minlat:real;
  Iflat:array[2..12] of integer;   {array for paint the intensity number}
  LongEditText:string;
  LatEditText:string;
  datosterr1:TDatosTerr;

  implementation

{$R *.DFM}

procedure getprojection(plon,plat,polon,polat:real;var x,y:real);
var
deg_to_rad,max_lat,tolerance:Extended;
lat0,lon0,lat,lon,dlon,dlon1,x1:Extended;
cosl,sinl,cos0,sin0,cosd,sind,A,B,C,value:Extended;
label cont;
begin
  dlon1:=0;
  tolerance:=8.72E-03;
  deg_to_rad:=Pi/180;
  max_lat:=90*deg_to_rad;
  lat0 := polat * deg_to_rad;         {Reference latitude in radians.}
  lon0 := polon * deg_to_rad;
  if lat0 > max_lat then lat0:=max_lat; {Truncate at pole.}
  if lat0 < -max_lat then lat0:=-max_lat; {Truncate at south pole.}

{    ==========================
C    Forward Transformations...
C    ==========================
C    Preliminaries...
C    ================
}
 lat  := plat * deg_to_rad;          {Point latitude in radians.}
 lon  := plon * deg_to_rad;          {Ditto.}
 dlon := lon - lon0;                  {Longitude displacement.}
 if dlon > max_lat then
  begin
   dlon1:=dlon - max_lat;
   dlon:= max_lat;
  end else
  if dlon < -max_lat then
  begin
   dlon1:=dlon + max_lat;
   dlon:= -max_lat;
  end;
  if lat > max_lat then lat:=max_lat; {Truncate at pole.}
  if lat < -max_lat then lat:=-max_lat; {Truncate at south pole.}

{    Azimuthal equidistant...
C    ========================
}
         cosl := cos(lat);
         sinl := sin(lat);
         cos0 := cos(lat0);
         sin0 := sin(lat0);
cont:    cosd := cos(dlon);
         sind := sin(dlon);
         A := cos0*sinl - sin0*cosl*cosd;      {Parameters.}
         B := sin0*sinl + cos0*cosl*cosd;      {Ditto.}
         C := cosl*sind;      {Et ditto.}
{
C    If B = +- 1.0 then invalid..adjust longitude displacement to
C    ------------------------------------------------------------
C    to make valid...
C    ----------------
}
            if( B = 1.0 ) then
            begin                        { Invalid.}
            x := 0.0;                      {Centre point.}
            y := 0.0;                      {Ditto.}
            end
            else if( B = -1.0 ) then      {Invalid.}
             begin
             if( dlon <= -pi ) then     {Small adjustment.}
               dlon := dlon + tolerance
               else                          { Ditto.}
               dlon := dlon - tolerance;
            goto cont;                    { Try again.}
            end
{
C    Calculate the co-ordinates...
C    -----------------------------
}
            else
             begin                   {Otherwise valid.}
              value := ArcCos(B);              {Parameter.}
              value := value / sin(value);
              x := value*C;                  {Map co-ordinate easting.}
              y := value*A;                  {& northings.}
              x := x * 180/Pi;
              y := y * 180/Pi;
              if trunc(dlon1)>0 then
               begin
                cosd := cos(dlon1);
                sind := sin(dlon1);
                B := sin0*sinl + cos0*cosl*cosd;      {Ditto.}
                C := cosl*sind;      {Et ditto.}
                value := ArcCos(B);              {Parameter.}
                value := value / sin(value);
                x1 := value*C;                  {Map co-ordinate easting.}
                x := x + (x1 * 180/Pi);
               end;
            end;
   end;

procedure TDrawMapa.FormCreate(Sender: TObject);
begin
left:=0;
Top:=0;
indiceEsc:=5;
Xp:=10;
yp:=8;
ancho:=0;
alto:=0;
Xfin:=PaintBox24.width-35;
Yfin:=PaintBox24.height-27;
screenmidd:=XFin div 2;
screenmiddy:=YFin div 2;
Zoom:=False;
Cuadro:=False;
xz:=-50;
yz:=-50;
xi:=-50;
yi:=-50;
end;

procedure TDrawMapa.getscale(var Escx,Escy: real);
var
 distx,disty: real;
 i,max:real;
begin
 i:=ViewCord.y1;
 max:=0;
 while i<ViewCord.y2 do
  begin
   getprojection(ViewCord.x1,i,clon,clat,distx,disty);
   if abs(max)<abs(distx) then max:=distx;
   i:=i+0.1;
  end;
 EscX:= abs(XFin/(2*max));
 getprojection(ViewCord.x1,ViewCord.y2,clon,clat,distx,disty);
 EscY:= abs(YFin/(2*disty));
 if EscX > EscY then EscX:=EscY else EscY:=EscX;
end;

procedure getfirstnum(var cad:string; var firstcad:string);
var
i:integer;
cad1:string;
 begin
  i:=1;
    if length(cad)>0 then
    while (i<=length(cad)) and (cad[i]=' ') or (ord(cad[i])=9) do
      i:=i+1;
        cad1:=Copy(cad,i,length(cad)-i+1);
        i:=2;
     if length(cad1)>0 then
      while (i<=length(cad1)) and (cad1[i]<>'-') and (cad1[i]<>' ')
      and (ord(cad1[i])<>9) do
         i:=i+1;
        firstcad:=Copy(cad1,1,i-1);
        cad := Copy(cad1,i,length(cad1)-i+1);
  end;

procedure TDrawMapa.readlimitmap(var maxlongit,minlongit,
                                 maxlat,minlat:real);
var
i:integer;
cant,cod:integer;
cad,cad1:string;
begin
i:=0;
cad:='';
maxlongit:=0;
minlongit:=0;
maxlat:=0;
minlat:=0;
AssignFile(F, syspath+'dat\'+BtnBottomDlg.listmap.text);
maxlongit:=-180;
minlongit:=180;
maxlat:=-90;
minlat:=90;
{$I-}
Reset(F);
{$I+}
if IOResult = 0 then
begin
readln(f,cant);
   while not eof(f) do
    begin
     i:=i+1;
     if length(cad)<6 then
     readln(f,cad);
     getfirstnum(cad,cad1);
     val(cad1,Puntos.latitud,cod);
     getfirstnum(cad,cad1);
     val(cad1,Puntos.longitud,cod);
    if (i<cant) then
    begin
     if (abs(Puntos.latitud)<90)
      and (abs(Puntos.longitud)<180) then
      begin
       if Puntos.latitud<minlat then
        minlat:=Puntos.latitud;
      if Puntos.latitud>maxlat then
        maxlat:=Puntos.latitud;
      if Puntos.longitud<minlongit then
        minlongit:=Puntos.longitud;
      if Puntos.longitud>maxlongit then
        maxlongit:=Puntos.longitud;
      end;
      end
      else
       begin
       readln(f,cant);
       i:=0;
       cad:='';
       end
      end;
      closefile(f);
     end
    end;

procedure TDrawMapa.FormResize(Sender: TObject);
begin
PaintBox24.Width:=ClientWidth-90;
PaintBox24.Height:=ClientHeight-86;
Xfin:=PaintBox24.Width;
YFin:=PaintBox24.Height;
Panel1.Left:=XFin+10;
Panel2.Top:=YFin+13;
Panel2.Width:=Xfin+Panel1.Width+10;
Panel1.Height:=YFin+Panel2.Height;
Xfin:=PaintBox24.Width-35;
YFin:=PaintBox24.Height-27;
screenmidd:=XFin div 2;
screenmiddy:=YFin div 2;
getscale(EscX,EscY);
Invalidate;
end;

Procedure TDrawMapa.Simbolo_0(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clBlack;
 Sender.Canvas.Ellipse(X-2,Y-2,X+2,Y+2);
end;

Procedure TDrawMapa.Simbolo_n(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Ellipse(X-4,Y-4,X+4,Y+4);
end;

Procedure TDrawMapa.Simbolo_2(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Pen.Width:=2;
 Sender.Canvas.moveto(x-3,y);
 Sender.Canvas.lineto(x+3,y);
 Sender.Canvas.moveto(x,y-3);
 Sender.Canvas.lineto(x,y+3);
end;

Procedure TDrawMapa.Simbolo_25(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Pen.Width:=1;
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Ellipse(X-4,Y-4,X+4,Y+4);
 Sender.Canvas.Pen.Width:=8;
 Sender.Canvas.Pixels[X,Y-1]:=clBlack;
end;

Procedure TDrawMapa.Simbolo_3(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Pen.Width:=2;
 Sender.Canvas.moveto(x-3,y-3);
 Sender.Canvas.lineto(x+3,y+3);
 Sender.Canvas.moveto(x+3,y-3);
 Sender.Canvas.lineto(x-3,y+3);
end;

Procedure TDrawMapa.Simbolo_35(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clBlue;
 Sender.Canvas.Pen.Width:=1;
 Sender.Canvas.moveto(x,y-3);
 Sender.Canvas.lineto(x-3,y+3);
 Sender.Canvas.lineto(x+3,y+3);
 Sender.Canvas.lineto(x,y-3);
 Sender.Canvas.Floodfill(X,Y,ClBlack,fsBorder);
end;

Procedure TDrawMapa.Simbolo_4(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clRed;
 Sender.Canvas.rectangle(x-3,y-3,x+3,y+3);
end;

Procedure TDrawMapa.Simbolo_45(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Ellipse(X-4,Y-4,X+4,Y+4);
 Sender.Canvas.Moveto(x-5,y);
 Sender.Canvas.Lineto(x+5,y);
end;

Procedure TDrawMapa.Simbolo_5(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clRed;
 Sender.Canvas.Ellipse(X-4,Y-4,X+4,Y+4);
end;

Procedure TDrawMapa.Simbolo_55(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clBlue;
 Sender.Canvas.rectangle(x-3,y-3,x+3,y+3);
end;

Procedure TDrawMapa.Simbolo_6(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clRed;
 Sender.Canvas.Pen.Width:=1;
 Sender.Canvas.moveto(x-3,y-3);
 Sender.Canvas.lineto(x,y+3);
 Sender.Canvas.lineto(x+3,y-3);
 Sender.Canvas.lineto(x-3,y-3);
 Sender.Canvas.Floodfill(X,Y,ClBlack,fsBorder);
end;

Procedure TDrawMapa.Simbolo_65(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Pen.Width:=1;
 Sender.Canvas.moveto(x,y-3);
 Sender.Canvas.lineto(x-3,y+3);
 Sender.Canvas.lineto(x+3,y+3);
 Sender.Canvas.lineto(x,y-3);
 Sender.Canvas.Floodfill(X,Y,ClBlack,fsBorder);
end;

Procedure TDrawMapa.Simbolo_7(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Pen.Width:=1;
 Sender.Canvas.moveto(x-3,y-3);
 Sender.Canvas.lineto(x,y+3);
 Sender.Canvas.lineto(x+3,y-3);
 Sender.Canvas.lineto(x-3,y-3);
 Sender.Canvas.Floodfill(X,Y,ClBlack,fsBorder);
end;

Procedure TDrawMapa.Simbolo_75(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Ellipse(X-4,Y-4,X+4,Y+4);
 Sender.Canvas.Moveto(x,y-5);
 Sender.Canvas.Lineto(x,y+5);
end;

Procedure TDrawMapa.Simbolo_8(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Ellipse(X-4,Y-4,X+4,Y+4);
 Sender.Canvas.Moveto(x,y-5);
 Sender.Canvas.Lineto(x,y+5);
 Sender.Canvas.Moveto(x-5,y);
 Sender.Canvas.Lineto(x+5,y);
end;

Procedure TDrawMapa.Simbolo_85(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.Moveto(x,y-4);
 Sender.Canvas.lineto(X-4,Y);
 Sender.Canvas.lineto(X,Y+4);
 Sender.Canvas.lineto(X+4,Y);
 Sender.Canvas.lineto(X,Y-4);
 Sender.Canvas.Floodfill(X,Y,ClBlack,fsBorder);
end;

Procedure TDrawMapa.Simbolo_9(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clRed;
 Sender.Canvas.Moveto(x,y-4);
 Sender.Canvas.lineto(X-4,Y);
 Sender.Canvas.lineto(X,Y+4);
 Sender.Canvas.lineto(X+4,Y);
 Sender.Canvas.lineto(X,Y-4);
 Sender.Canvas.Floodfill(X,Y,ClBlack,fsBorder);
end;

Procedure TDrawMapa.Simbolo_95(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.rectangle(x-4,y-4,x+4,y+4);
 Sender.Canvas.moveto(x-4,y);
 Sender.Canvas.lineto(x+4,y);
end;

Procedure TDrawMapa.Simbolo_10(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.rectangle(x-4,y-4,x+4,y+4);
 Sender.Canvas.moveto(x,y-4);
 Sender.Canvas.lineto(x,y+4);
end;

Procedure TDrawMapa.Simbolo_105(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clWhite;
 Sender.Canvas.rectangle(x-4,y-4,x+4,y+4);
 Sender.Canvas.moveto(x,y-4);
 Sender.Canvas.lineto(x,y+4);
 Sender.Canvas.moveto(x-4,y);
 Sender.Canvas.lineto(x+4,y);
end;

Procedure TDrawMapa.Simbolo_11(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clBlue;
 Sender.Canvas.Moveto(x,y-4);
 Sender.Canvas.lineto(X-4,Y);
 Sender.Canvas.lineto(X,Y+4);
 Sender.Canvas.lineto(X+4,Y);
 Sender.Canvas.lineto(X,Y-4);
 Sender.Canvas.Floodfill(X,Y,ClBlack,fsBorder);
end;

Procedure TDrawMapa.Simbolo_115(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clYellow;
 Sender.Canvas.rectangle(x-3,y-3,x+3,y+3);
end;

Procedure TDrawMapa.Simbolo_12(Sender: TPaintBox; x,y:integer);
begin
 Sender.Canvas.Brush.Color:=clGreen;
 Sender.Canvas.rectangle(x-3,y-3,x+3,y+3);
end;

procedure TDrawMapa.PaintBox2Paint(Sender: TObject);
begin
  Simbolo_n( PaintBox2,Xp,Yp)
end;

procedure TDrawMapa.PaintBox3Paint(Sender: TObject);
begin
 Simbolo_2( PaintBox3,Xp,Yp);
end;

procedure TDrawMapa.PaintBox4Paint(Sender: TObject);
begin
  Simbolo_25( PaintBox4,Xp,Yp);
end;

procedure TDrawMapa.PaintBox5Paint(Sender: TObject);
begin
  Simbolo_3( PaintBox5,Xp,Yp);
end;

procedure TDrawMapa.PaintBox6Paint(Sender: TObject);
begin
  Simbolo_35( PaintBox6,Xp,Yp);
end;

procedure TDrawMapa.PaintBox7Paint(Sender: TObject);
begin
 Simbolo_4( PaintBox7,Xp,Yp);
end;

procedure TDrawMapa.PaintBox8Paint(Sender: TObject);
begin
  Simbolo_45( PaintBox8,Xp,Yp);
end;

procedure TDrawMapa.PaintBox9Paint(Sender: TObject);
begin
  Simbolo_5( PaintBox9,Xp,Yp);
end;

procedure TDrawMapa.PaintBox10Paint(Sender: TObject);
begin
 Simbolo_55( PaintBox10,Xp,Yp);
end;

procedure TDrawMapa.PaintBox11Paint(Sender: TObject);
begin
  Simbolo_6( PaintBox11,Xp,Yp);
end;

procedure TDrawMapa.PaintBox13Paint(Sender: TObject);
begin
  Simbolo_65( PaintBox13,Xp,Yp);
end;

procedure TDrawMapa.PaintBox15Paint(Sender: TObject);
begin
  Simbolo_7( PaintBox15,Xp,Yp);
end;

procedure TDrawMapa.PaintBox16Paint(Sender: TObject);
begin
  Simbolo_75( PaintBox16,Xp,Yp);
end;

procedure TDrawMapa.PaintBox17Paint(Sender: TObject);
begin
  Simbolo_8( PaintBox17,Xp,Yp);
end;

 procedure TDrawMapa.PaintBox18Paint(Sender: TObject);
begin
 Simbolo_85( PaintBox18,Xp,Yp);
end;

procedure TDrawMapa.PaintBox19Paint(Sender: TObject);
begin
  Simbolo_9( PaintBox19,Xp,Yp);
end;

procedure TDrawMapa.PaintBox20Paint(Sender: TObject);
begin
 Simbolo_95( PaintBox20,Xp,Yp);
end;

procedure TDrawMapa.PaintBox12Paint(Sender: TObject);
begin
 Simbolo_10( PaintBox12,Xp,Yp);
end;

procedure TDrawMapa.PaintBox14Paint(Sender: TObject);
begin
 Simbolo_105( PaintBox14,Xp,Yp);
end;

procedure TDrawMapa.PaintBox21Paint(Sender: TObject);
begin
 Simbolo_11( PaintBox21,Xp,Yp);
end;

procedure TDrawMapa.PaintBox22Paint(Sender: TObject);
begin
 Simbolo_115( PaintBox22,Xp,Yp);
end;

procedure TDrawMapa.PaintBox23Paint(Sender: TObject);
begin
 Simbolo_12( PaintBox23,Xp,Yp);
end;

procedure TDrawMapa.PaintBox1Paint(Sender: TObject);
begin
  Simbolo_0( PaintBox1,Xp,Yp);
end;

function TDrawMapa.fintensity(r:real):real;
var
a,b,c,d:real;
 begin
  a:=Datosterr.a;
  b:=Datosterr.b;
  c:=Datosterr.c;
  d:=Datosterr.d;
  fintensity:=a*DatosTerr.Mag_M + b*(ln(r)/ln(10))+ c*r + d;
 end;

function TDrawMapa.fderivaInt(x:real):real;
 begin
  fderivaInt:=( Datosterr.b/(x*ln(10)) + Datosterr.c);
 end;

function TDrawMapa.elipse(I:real):real;
 var
  valor_it,valor:real;
  it:integer;
 begin
   valor:=1;
   valor_it:=fintensity(valor) - I;
   while abs(valor_it) > 0.0001 do
    begin
     it:=it+1;
     valor := valor - valor_it/fderivaInt(valor);
     if valor<0 then
      begin
       valor:=0;
       break;
      end;
     {valor:=valor1;}
     valor_it:= fintensity(valor) - I;
    end;
    valor:=valor*valor - sqr(DatosTerr.H_M);
    if valor<0 then elipse:=0 else
    elipse:=sqrt(valor);
 end;

 procedure TDrawMapa.Isosista(xi,yi,a,b,n:integer;ang:real;color:TColor);
  var
   sx,sy,cang,sang,x,y,cua:real;
   i,px,py,xc,yc:integer;
  begin
   ang:=ang*Pi/180;
   cang:=cos(ang);
   sang:=sin(ang);
   cua:=a;
   cua:=sqr(cua);
   PaintBox24.Canvas.Pen.Color:=color;
   PaintBox24.Canvas.Pixels[xi,Yfin-yi]:= PaintBox24.Canvas.Pixels[xi,Yfin-yi]
                                          xor PaintBox24.Canvas.Pen.Color;
   for i:=-a to a do
    begin
     x:=i;
     y:=b*sqrt(1 - sqr(x)/cua);
     sx:=x*cang + y*sang;
     sy:=-x*sang + y*cang;
     px:=xi + trunc(sx);
     py:=yi + trunc(sy);
     if (px>0) and (px<PaintBox24.width) and
        (py>0) and (py<PaintBox24.height)then
     PaintBox24.Canvas.Pixels[px,py]:= PaintBox24.Canvas.Pixels[px,py]
                                      xor PaintBox24.Canvas.Pen.Color;
     sx:=sx-2*y*sang;
     sy:=sy-2*y*cang;
     px:=xi + trunc(sx);
     py:=yi + trunc(sy);
     if (px>0) and (px<PaintBox24.width) and
        (py>0) and (py<PaintBox24.height)then
     PaintBox24.Canvas.Pixels[px,py]:= PaintBox24.Canvas.Pixels[px,py]
                                    xor PaintBox24.Canvas.Pen.Color;
      if i=-a then
      begin
       xc := px;
       yc := py;
      end
    end;
    PaintBox24.Canvas.Pen.Color:=clBlack;
    if IFlat[n]=1 then
     begin
      PaintBox24.Canvas.TextOut(xc,yc,IntToStr(n));
      IFlat[n]:=0;
     end
  end;

procedure TDrawMapa.PintaIsosista;
var
 I,Io,A,B,Kms,dx,dy:real;
 A_int,B_int,x,y:integer;
begin
 if DatosTerr.H_M<=0 then DatosTerr.H_M:=1;
 if (DatosTerr.a_b>0) then
 begin
 Io:=fintensity(DatosTerr.H_M);
 I:=trunc(Io);
 if I+0.75 < Io then I:=I + 0.75
 else I:=I - 0.25;
 PrintFoco.Caption:='Io = ' + IntToStr(round(I));
 repeat
   kms:=elipse(I);
   case DatosTerr.Direccion[1] of
       'A': begin
             A:=kms;
             B:=Kms/DatosTerr.a_b;
            end;
       'B': begin
             B:=Kms;
             A:=B*DatosTerr.a_b;
            end;
    end;
    getprojection(DatosTerr.Long_M,DatosTerr.Lat_M,clon,clat,dx,dy);
    x:= screenmidd+trunc(dx*EscX);
    y:= screenmiddy-trunc(dy*EscY);
    A_int:= trunc((A/111)*EscY);
    B_int:= trunc((B/111)*EscY);
    if (A_int<>0) and (B_int<>0) then
     begin
    isosista(x,y,A_int,B_int,round(I),-DatosTerr.azimut,clWhite);
    end;
   I:=I-1;
   until I<=1.5;
  end
end;

procedure TDrawMapa.PaintBox24Paint(Sender: TObject);
var
 i,x,y,x1,y1,cant,cod:integer;
 salta:boolean;
 cad,cad1:string;
 cx1,cy1,quater,dx,dy:real;
 begin
 for i:=2 to 12 do
  IFlat[i]:=1;
 AssignFile(F, syspath+'dat\'+BtnBottomDlg.listmap.text);
    {$I-}
    Reset(F);
    {$I+}
    if IOResult <> 0 then
    Application.MessageBox('Missing Map File', 'Warning',mb_DefButton1)
    else
    begin
     PaintBox24.Canvas.brush.color:=clWhite;
 cx1 := ViewCord.x1;
 quater := (ViewCord.x2 - ViewCord.x1)/4;
 for i:=1 to 5 do
 begin
  cy1:=ViewCord.y2;
  x1:=-1;
  while cy1>=ViewCord.y1 do
   begin
  getprojection(cx1,cy1,clon,clat,dx,dy);
  x:= screenmidd+trunc(dx*EscX);
  y:= screenmiddy-trunc(dy*EscY);
  PaintBox24.Canvas.MoveTo(x,y);
  if (x1>0) and (abs(cx1-clon) < 90) then
   PaintBox24.Canvas.LineTo(x1,y1);
    cy1:=cy1-0.1;
    x1:=x;
    y1:=y;
   end;
    getprojection(cx1,ViewCord.y1,clon,clat,dx,dy);
    y:= screenmiddy-trunc(dy*EscY);
    PaintBox24.Canvas.LineTo(x,y);
  {if i=1 then
  PaintBox24.Canvas.TextOut(x,y+5,floatToStrF(cx1,ffFixed,4,1))
  else}
  if abs(cx1-clon) < 90 then
  PaintBox24.Canvas.TextOut(x,y+5,floatToStrF(cx1,ffFixed,4,1));
  cx1 := cx1 + quater
 end;
  cy1 := ViewCord.y1;
  quater := (ViewCord.y2 - ViewCord.y1)/4;
 for i:=1 to 5 do
 begin
  cx1:=ViewCord.x1;
  x1:=-1;
  while cx1<=ViewCord.x2 do
   begin
    getprojection(cx1,cy1,clon,clat,dx,dy);
    x:= screenmidd+trunc(dx*EscX);
    y:= screenmiddy-trunc(dy*EscY);
    PaintBox24.Canvas.MoveTo(x,y);
    if (x1>0) and (abs(cx1-clon) < 90) then
     PaintBox24.Canvas.LineTo(x1,y1);
     x1:=x;
     y1:=y;
    cx1:=cx1+0.05;
   end;
   getprojection(ViewCord.x2,cy1,clon,clat,dx,dy);
   x:= screenmidd+trunc(dx*EscX);
   PaintBox24.Canvas.LineTo(x,y);
{  if i=1 then
  PaintBox24.Canvas.TextOut(XFin+2,y-15,floatToStrF(cy1,ffFixed,4,1))
  else   }
  if i=5 then
     PaintBox24.Canvas.TextOut(x+5,y,floatToStrF(cy1,ffFixed,4,1))
  else
     PaintBox24.Canvas.TextOut(x+5,y-8,floatToStrF(cy1,ffFixed,4,1));
  cy1 := cy1 + quater;
  if cy1>ViewCord.y2 then cy1:=ViewCord.y2;
 end;
  i:=0;
  cad:='';
  salta:=True;
  readln(f,cant);
   while not eof(f) do
    begin
     i:=i+1;
     if length(cad)<6 then
      readln(f,cad);
     getfirstnum(cad,cad1);
     val(cad1,Puntos.latitud,cod);
     getfirstnum(cad,cad1);
     val(cad1,Puntos.longitud,cod);
     if i<cant then
      begin
     if (Puntos.longitud<ViewCord.x2) and (Puntos.latitud>ViewCord.y1)
       and (Puntos.longitud>ViewCord.x1) and (Puntos.latitud<ViewCord.y2)
       and (abs(Puntos.longitud-clon)< 90 )  then
     begin
       getprojection(Puntos.longitud,Puntos.latitud,clon,clat,dx,dy);
       x:= screenmidd+trunc(dx*EscX);
       y:= screenmiddy-trunc(dy*EscY);
       if salta then
        begin
         PaintBox24.Canvas.moveto(x,y);
         salta:=False;
        end;
        PaintBox24.Canvas.Lineto(x,y);
      end else salta:=true
      end
      else
       begin
       salta:=True;
       readln(f,cant);
       i:=0;
       cad:='';
       end
    end;
    closefile(f);
    end;
    PintaIsosista;
    if BtnBottomDlg.GPuntos.ItemIndex=0 then
     for i:=1 to MaxSelSite do
      begin
        if (SelSite[i].longitud<ViewCord.x2) and (SelSite[i].latitud>ViewCord.y1)
       and (SelSite[i].longitud>ViewCord.x1) and (SelSite[i].latitud<ViewCord.y2)
       and (abs(SelSite[i].longitud-clon)< 90 )  then
       getprojection(SelSite[i].longitud,SelSite[i].latitud,clon,clat,dx,dy);
       x:= screenmidd+trunc(dx*EscX);
       y:= screenmiddy -trunc(dy*EscY);
       if SelSite[i].intensidad=0 then Simbolo_0(PaintBox24,x,y);
       if SelSite[i].intensidad=2 then Simbolo_2(PaintBox24,x,y);
       if SelSite[i].intensidad=2.5 then Simbolo_25(PaintBox24,x,y);
       if SelSite[i].intensidad=3 then Simbolo_3(PaintBox24,x,y);
       if SelSite[i].intensidad=3.5 then Simbolo_35(PaintBox24,x,y);
       if SelSite[i].intensidad=4 then Simbolo_4(PaintBox24,x,y);
       if SelSite[i].intensidad=4.5 then Simbolo_45(PaintBox24,x,y);
       if SelSite[i].intensidad=5 then Simbolo_5(PaintBox24,x,y);
       if SelSite[i].intensidad=5.5 then Simbolo_55(PaintBox24,x,y);
       if SelSite[i].intensidad=6 then Simbolo_6(PaintBox24,x,y);
       if SelSite[i].intensidad=6.5 then Simbolo_65(PaintBox24,x,y);
       if SelSite[i].intensidad=7 then Simbolo_7(PaintBox24,x,y);
       if SelSite[i].intensidad=7.5 then Simbolo_75(PaintBox24,x,y);
       if SelSite[i].intensidad=8 then Simbolo_8(PaintBox24,x,y);
       if SelSite[i].intensidad=8.5 then Simbolo_85(PaintBox24,x,y);
       if SelSite[i].intensidad=9 then Simbolo_9(PaintBox24,x,y);
       if SelSite[i].intensidad=9.5 then Simbolo_95(PaintBox24,x,y);
       if SelSite[i].intensidad=10 then Simbolo_10(PaintBox24,x,y);
       if SelSite[i].intensidad=10.5 then Simbolo_105(PaintBox24,x,y);
       if SelSite[i].intensidad=11 then Simbolo_11(PaintBox24,x,y);
       if SelSite[i].intensidad=11.5 then Simbolo_115(PaintBox24,x,y);
       if SelSite[i].intensidad=12 then Simbolo_12(PaintBox24,x,y);
       PaintBox24.Canvas.pen.width:=1;
      end
     end;

procedure TDrawMapa.FormActivate(Sender: TObject);
var
Along,a,b,y1,x:real;
cad:string;
begin
  Datosterr1:=datosterr;
  Along:=5;
  if (DatosTerr.long_m=0) and (datosterr.lat_m=0) then
  readlimitmap(Maxlongit,Minlongit,Maxlat,Minlat)
  else
  begin
   y1:=datosterr.lat_m + 5;
   b := 90 - y1;
   b := b*Pi/180;
   a := 5*Pi/180;
   x:= (cos(a)-cos(b)*cos(b))/(sin(b)*sin(b));
 if (x<>0) and ((1-sqr (x))>0) then
 begin
  Along:=ArcTan (sqrt (1-sqr (x)) /x);
  Along:=Along*180/Pi;
 end;
  Maxlongit:=DatosTerr.long_m+Along;
  Minlongit:=DatosTerr.long_m-Along;
  Maxlat:=datosterr.lat_m+5;
  Minlat:=datosterr.lat_m-5;
  end;
  ViewCord.x1:=Minlongit;
  ViewCord.x2:=Maxlongit;
  ViewCord.y1:=Minlat;
  ViewCord.y2:=Maxlat;
  clon:=ViewCord.x1+(ViewCord.x2-ViewCord.x1)/2;
  clat:=ViewCord.y1+(ViewCord.y2-ViewCord.y1)/2;
  getscale(Escx,Escy);
  Str(DatosTerr.Long_M:7:2,cad);
  LongEdit.Text:=cad;
  Str(DatosTerr.Lat_M:6:2,cad);
  LatEdit.Text:=cad;
  Str(DatosTerr.Mag_M:3:1,cad);
  Editmag.Text:=cad;
  Str(DatosTerr.H_M:5:1,cad);
  ProfEdit.Text:=cad;
  Str(DatosTerr.azimut:3,cad);
  AzimutEdit.Text:=cad;
  Str(DatosTerr.a_b:3:1,cad);
  ABEdit.Text:=cad;
  ComboBox2.Text:=DatosTerr.Direccion;
end;

procedure TDrawMapa.SpeedButton2Click(Sender: TObject);
begin
 Zoom:= not Zoom;
 SpeedButton2.Down:= Zoom;
end;

procedure TDrawMapa.PaintBox24MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if (Button=mbLeft)  then
   begin
     {PaintBox24.Cursor := crSizeNWSE;}
    Cuadro:=True;
   end else begin
    PaintBox24.Canvas.Pen.Mode:=pmXor;
    PaintBox24.Canvas.Pen.Color:=clWhite;
    PaintBox24.Canvas.moveto(xi,yi);
    PaintBox24.Canvas.lineto(xz,yi);
    PaintBox24.Canvas.lineto(xz,yz);
    PaintBox24.Canvas.lineto(xi,yz);
    PaintBox24.Canvas.lineto(xi,yi);
    PaintBox24.Canvas.Pen.Mode:=pmCopy;
    PaintBox24.Canvas.Pen.Color:=clBlack;
    xz:=xi;
    yz:=yi;
   end
 end;

procedure TDrawMapa.PaintBox24MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
  var
    gx,gy:real;

  begin
     Xmouse := X;
     Ymouse := Y;
 if Zoom then begin
     if xi=-50 then begin
     xi:=X;
     yi:=Y;
     xz:=X+ancho;
     yz:=Y+alto;
    end else
    begin
     PaintBox24.Canvas.Pen.Mode:=pmXor;
     PaintBox24.Canvas.Pen.Color:=clWhite;
     PaintBox24.Canvas.moveto(xi,yi);
     PaintBox24.Canvas.lineto(xz,yi);
     PaintBox24.Canvas.lineto(xz,yz);
     PaintBox24.Canvas.lineto(xi,yz);
     PaintBox24.Canvas.lineto(xi,yi);
    end;
  if Cuadro {and (BtnBottomDlg.Escala.itemIndex=0)}  then begin
  {  PaintBox24.Cursor := crSizeNWSE;}
    if (y<>yi) and (x<>xi) then begin
       gx := PaintBox24.Height/PaintBox24.Width;
       gy := PaintBox24.width/PaintBox24.Height;
       if abs(x-xi)/abs(y-yi) > gy then
         yi:= trunc(y - gx * abs(x-xi))
       else if abs(x-xi)/abs(y-yi) < gy then
         xi:= trunc(X - gy * abs(y-yi));
     end;
   xz:=X;
   yz:=Y;
  end
  else begin
    xi:=xz-xi;
    yi:=yz-yi;
    xz:=X;
    yz:=y;
    xi:=x-xi;
    yi:=y-yi;
  end;
 PaintBox24.Canvas.moveto(xi,yi);
 PaintBox24.Canvas.lineto(xz,yi);
 PaintBox24.Canvas.lineto(xz,yz);
 PaintBox24.Canvas.lineto(xi,yz);
 PaintBox24.Canvas.lineto(xi,yi);
 PaintBox24.Canvas.Pen.Mode:=pmCopy;
 PaintBox24.Canvas.Pen.Color:=clBlack;
 end {else
    PaintBox24.Cursor := crDefault;}
 end;

 procedure TDrawMapa.PaintBox24MouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
 Cuadro:=False;
end;

procedure TDrawMapa.PaintBox24DblClick(Sender: TObject);
var
 dy,dx,a,b,Along,x,y1:real;
begin
if Zoom then
 begin
 dx := (xi - screenmidd)/EscX;
 dy := (screenmiddy - yi)/EscY;
 y1:=(clat + dy);
 b := 90 - y1;
 b := b*Pi/180;
 a := dx*Pi/180;
 x:= (cos(a)-cos(b)*cos(b))/(sin(b)*sin(b));
 if (x<>0) and ((1-sqr (x))>0) then
 begin
 Along:=ArcTan (sqrt (1-sqr (x)) /x);
 Along:=Along*180/Pi;
 if dx<0 then Along := -Along;
 ViewCord.x1:=clon + Along;
 ViewCord.y2:=y1;
 end;
 dx := (xz - screenmidd)/EscX;
 dy := (screenmiddy - yz)/EscY;
 y1:=(clat + dy);
 b := 90 - y1;
 b := b*Pi/180;
 a := dx*Pi/180;
 x:= (cos(a)-cos(b)*cos(b))/(sin(b)*sin(b));
 if (x<>0) and ((1-sqr (x))>0) then
 begin
  Along:=ArcTan (sqrt (1-sqr (x)) /x);
  Along:=Along*180/Pi;
  if dx<0 then Along := -Along;
  ViewCord.x2:=clon + Along;
  ViewCord.y1:=y1;
 end;
 clon:=ViewCord.x1+(ViewCord.x2-ViewCord.x1)/2;
 clat:=ViewCord.y1+(ViewCord.y2-ViewCord.y1)/2;
 getscale(EscX,EscY);
 Invalidate;
 Zoom:=False;
 SpeedButton2.Down:= Zoom;
 Cuadro:=False;
 xi:=-50;
 ancho:=0;
 alto:=0;
 end
end;

procedure TDrawMapa.SpeedButton1Click(Sender: TObject);
var
i:integer;
temp:real;
begin
if PrintDialog1.execute then
  begin
  {if (BtnBottomDlg.Escala.itemindex>0) then
   begin
     ScaleBy(200,100);
        PaintBox24.width:= trunc(PaintBox24.width / (Escala[BtnBottomDlg.Escala.itemIndex]/
                                              Escala[indiceEsc])) ;
        PaintBox24.Height:=trunc(PaintBox24.Height / (Escala[BtnBottomDlg.Escala.itemIndex]/
                                              Escala[indiceEsc])) ;
     DrawMapa.PixelsPerInch:=69;
     Width:=PaintBox24.width+102;
     Height:=PaintBox24.height+100;
     ClientWidth:=PaintBox24.width+90;
     ClientHeight:=PaintBox24.height+60;
   end; }
{  DrawMapa.PixelsPerInch:=69;}
   Panel1.Color:=clWhite;
   Panel2.Color:=clWhite;
   SpeedButton1.Visible:=False;
   SpeedButton2.Visible:=False;
   Button1.Visible:=False;
   Button2.Visible:=False;
   BitBtn1.Visible:=False;
   BitBtn2.Visible:=False;
   Print;
  { DrawMapa.PixelsPerInch:=120;}
   SpeedButton1.Visible:=True;
   SpeedButton2.Visible:=True;
   Panel1.Color:=clBtnFace;
   Panel2.Color:=clBtnFace;
   Button1.Visible:=true;
   Button2.Visible:=true;
   BitBtn1.Visible:=true;
   BitBtn2.Visible:=true;
  end
  end;

procedure TDrawMapa.Button1Click(Sender: TObject);
begin
ViewCord.x1:=Minlongit;
ViewCord.x2:=Maxlongit;
ViewCord.y1:=Minlat;
ViewCord.y2:=Maxlat;
clon:=ViewCord.x1+(ViewCord.x2-ViewCord.x1)/2;
clat:=ViewCord.y1+(ViewCord.y2-ViewCord.y1)/2;
getscale(EscX,EscY);
PaintBox24.Repaint;
end;

procedure TDrawMapa.SpeedButton3Click(Sender: TObject);
begin
Application.HelpJump('Map');
end;

procedure TDrawMapa.PaintBox24Click(Sender: TObject);
var
 dy,dx,a,b,Along,x,x1,y1,lmin:Extended;
 cad:String;
begin
if not Zoom then
begin
 dx := (Xmouse - screenmidd)/EscX;
 dy := (screenmiddy - Ymouse)/EscY;
 y1:=clat + dy;
 b := 90 - y1;
 b := b*Pi/180;
 a := dx*Pi/180;
 x:= (cos(a)-cos(b)*cos(b))/(sin(b)*sin(b));
 if (x<>0) and ((1-sqr (x))>0) then
 begin
  Along:=ArcTan (sqrt (1-sqr (x)) /x);
  Along:=Along*180/Pi;
  if dx<0 then Along := -Along;
  x1:=clon + Along;
  Str(x1:7:2,cad);
  LongEdit.Text:=cad;
  Str(y1:6:2,cad);
  LatEdit.Text:=cad;
 end;
 end
end;

procedure TDrawMapa.Savevalue;
var
cad:string;
cod:integer;
begin
cad:=LongEdit.text;
fillspace(cad);
val(cad,DatosTerr.Long_M,cod);
cad:=LatEdit.text;
fillspace(cad);
val(cad,DatosTerr.Lat_M,cod);
cad:=ProfEdit.text;
fillspace(cad);
val(cad,DatosTerr.H_M,cod);
cad:=Editmag.text;
fillspace(cad);
val(cad,DatosTerr.Mag_M,cod);
cad:=AzimutEdit.Text;
fillspace(cad);
val(cad,DatosTerr.azimut,cod);
cad:=ABEdit.text;
fillspace(cad);
val(cad,DatosTerr.a_b,cod);
DatosTerr.Direccion:=ComboBox2.text;
end;


procedure TDrawMapa.Button2Click(Sender: TObject);
begin
SaveValue;
PaintBox24.invalidate;
end;

procedure TDrawMapa.BitBtn1Click(Sender: TObject);
begin
SaveValue;
close;
end;

procedure TDrawMapa.BitBtn2Click(Sender: TObject);
begin
Datosterr:=datosterr1;
close;
end;

end.

