1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| procedure TCreeCarte.InitCarte(Titre: String; R, C: Integer);
{Problème : si ImgCarte.Align = alClient d'entrée de jeu, un rectangle parasite
apparaît sur les petites images. Pour y pallier, on met ImgCarte.Align à alNone
et on le rétablit à alClient seulement après le ShowModal à l'aide d'un Timer.
Il faut aussi que le coin haut et gauche du TImage soit le plus loin possible
du coin haut et gauche de la ScrollBox. ??}
begin
ImgCarte.Align:= alNone;
Caption:= Titre;
ImgGradOk:= False;
ChargeDalles(LstCartes[R], ValZoom[C]);
Timer.Enabled:= True;
ShowModal;
end;
procedure TCreeCarte.ChargeDalles(Carte: TLstCartes; Zoom: String);
var
SRLon, SRLat: TSearchRec;
i, OSMLa, OSMLo, Z: Integer;
NomFch: String;
begin
{$I-}
NomFch:= RepCartes+SepRep+Carte.Nom+Zoom;
ChDir(RepCartes+SepRep+Carte.Nom+Zoom);
SetLength(NomDalle, 0);
OSMLaMin:= 100000;
OSMLaMax:= -100000;
OSMLoMin:= 100000;
OSMLoMax:= -100000;
if IOresult = 0 then
begin
if FindFirst ('*', faDirectory, SRLon) = 0 then
repeat // Recherche des longitudes
if (SRLon.Name <> '.') and (SRLon.Name <> '..') then
if (SRLon.Attr and faDirectory) = faDirectory then
begin
OSMLo:= StrToInt(SRLon.Name);
if OSMLo < OSMLoMin then
OSMLoMin:= OSMLo;
if OSMLo > OSMLoMax then
OSMLoMax:= OSMLo;
ChDir(RepCartes+SepRep+Carte.Nom+Zoom+SepRep+SRLon.Name);
if FindFirst ('*.jpg', faArchive, SRLat) = 0 then
repeat // Recherche des latitudes dans les fichiers des longitudes
if ((SRLat.Attr and faArchive) = faArchive) then
begin
OSMLa:= StrToInt(ChangeFileExt(SRLat.Name, ''));
if OSMLa < OSMLaMin then
OSMLaMin:= OSMLa;
if OSMLa > OSMLaMax then
OSMLaMax:= OSMLa;
SetLength(NomDalle, Length(NomDalle) + 1);
NomDalle[High(NomDalle)].OSMLon:= OSMLo;
NomDalle[High(NomDalle)].OSMLat:= OSMLa;
end;
until FindNext(SRLat) <> 0;
FindClose(SRLat);
end;
until FindNext(SRLon) <> 0;
FindClose(SRLon);
end;
{$I+}
Z:= StrToInt(Zoom);
ZoomAff:= Z;
with Carte do begin
LatMax:= LatOSM(OSMLaMin, Z);
LatMin:= LatOSM(OSMLaMax+1, Z);
LonMax:= LonOSM(OSMLoMax+1, Z);
LonMin:= LonOSM(OSMLoMin, Z);
AffBase.Infos.Panels[3].Text:= Format('LatMin = %.4f° LatMax = %.4f° LonMin = %.4f° LonMax = %.4f°', [LatMin, LatMax, LonMin, LonMax]);
end;
CarteAff:= Carte;
i:= Length(NomDalle);
NbLa:= Abs(OSMLaMax-OSMLaMin)+1;
NbLo:= Abs(OSMLoMax-OSMLoMin)+1;
FeLon:= DimRed/(LonOSM(OSMLoMax+1, Z)-LonOSM(OSMLoMax, Z));
FeLat:= (DimRed/(LatOSM(OSMLaMax, Z)-LatOSM(OSMLaMax+1, Z))
+ DimRed/(LatOSM(OSMLaMin, Z)-LatOSM(OSMLaMin+1, Z)))/2;
AfficheDalles(Carte, Zoom);
end;
procedure TCreeCarte.AfficheDalles(Carte: TLstCartes; Zoom: String);
var
i: Integer;
Img: TJPEGImage;
RctSrc, RctDst: Trect;
k: Double;
NomFch: String;
begin
ImgCarte.Picture.Clear; // Nécessaire sinon, la carte ne s'affiche qu'une fois sur deux ?
with ImgCarte.Picture.Bitmap do
begin
Brush.Color:= clCream;
Canvas.Pen.Style:= psSolid;
Canvas.Pen.Mode:= pmCopy;
Canvas.Pen.Color:= clBlue;
Font.Color:= clBlue;
Width:= NbLo*DimRed;
Height:= NbLa*DimRed;
Canvas.FillRect(Rect(0, 0, Width, Height));
end;
Caption:= Caption+' Nombre de dalles en X : '+ IntToStr(NbLo)+' ; en Y : '+IntToStr(NbLa);
RctSrc:= Rect(0, 0, DimRed, DimRed);
k:= TblCartes.ProgressCharg.Max/Length(NomDalle);
Img:= TJPEGImage.Create;
for i:= 0 to High(NomDalle) do
with NomDalle[i] do
begin
NomFch:= RepCartes+SepRep+Carte.Nom+Zoom+SepRep+IntToStr(OSMLon)+SepRep+IntToStr(OSMLat)+'.jpg';
Img.LoadFromFile(NomFch);
RctDst:= Rect(DimRed*(OSMLon-OSMLoMin), DimRed*(OSMLat-OSMLaMin), DimRed*(OSMLon-OSMLoMin+1), DimRed*(OSMLat-OSMLaMin+1));
ImgCarte.Picture.Bitmap.Canvas.CopyRect(RctDst, Img.Canvas, RctSrc);
end;
FreeAndNil(Img);
// Graduation(Carte, StrToInt(Zoom));
end; |
Partager