root/trunk/mp-geo/mp-geo.mp

Revision 65, 37.6 kB (checked in by christophe, 2 years ago)
Line 
1%Package mp-geographie
2%Auteur:Christophe Poulain
3%Version 0.61
4%11/04/2008
5
6input marith;
7input sarith;
8input TEX;
9
10pi:=3.141592654;
11c:=57.29578; % conversion d'un radian en degrés
12
13color _T[],rouge,vert,bleu,jaune,noir,blanc,orange,rose,violet,ciel,cielfonce,orangevif,gris,tan,payscolor;
14
15rouge=(1,0,0);
16bleu=(0,0,1);
17noir=(0,0,0);
18blanc=(1,1,1);
19orange=(1,0.5,0);
20violet=(1,0,1);
21rose=(1,0.7,0.7);
22cielfonce=(0.25,0.75,1);
23ciel=(0,1,1);
24orangevif=(1,0.25,0.1);
25vert=(0,1,0);
26jaune=(1,1,0);
27gris=0.8*white;
28
29tan=(0.824,0.705,0.55);
30payscolor=tan;
31
32vardef flamme=reverse(2mm*(0.5,1){dir90}..2mm*(0.75,1.5)..{dir90}2mm*(1,2))--2mm*(0.5,1){dir=-90}..2mm*(1,0.5)..{dir=90}2mm*(1.5,1)--((2mm*(0.5,1){dir90}..2mm*(0.75,1.5)..{dir90}2mm*(1,2)) reflectedabout (2mm*(1,0),2mm*(1,0)+2mm*(0,1)))--cycle
33enddef;
34
35%Les marques
36
37string marque_p;
38marque_p := "non";
39marque_r := 20;
40
41def MarquePoint(expr p)=
42  if marque_p = "creux":
43    if color p:
44      fill fullcircle scaled (marque_r/5) shifted (Projgeo(p)) withcolor white;
45      draw fullcircle scaled (marque_r/5) shifted (Projgeo(p));
46    else:
47      fill fullcircle scaled (marque_r/5) shifted (p) withcolor white;
48      draw fullcircle scaled (marque_r/5) shifted (p);
49    fi;
50  fi;
51enddef;
52
53vardef pointe(text t) =
54  for p_ = t: if (pair p_) or (color p_): MarquePoint(p_); fi endfor;
55enddef;
56
57%Définition pour la feuille
58
59path feuillet;
60numeric _tfig,_nfig;
61_nfig:=0;
62u:=1cm;
63
64def feuille(expr xa,ya,xb,yb) =
65  numeric Xa,Ya;
66  Xa=xa;
67  Ya=ya;
68  feuillet := (xa,ya)--(xa,yb)--(xb,yb)--(xb,ya)--cycle;
69  extra_endfig := "clip currentpicture to feuillet;" & extra_endfig;
70enddef;
71
72def figureespace(expr xa,ya,xb,yb) =
73  _nfig:=_nfig+1;
74  beginfig(_nfig);
75    feuille(xa,ya,xb,yb);
76enddef; 
77
78def finespace=
79endfig;
80enddef;
81
82def figure(expr xa,ya,xb,yb)=figureespace(xa,ya,xb,yb)
83enddef;
84
85def fin=finespace
86enddef;
87
88%definitions mathématiques
89vardef cercles(text t)=
90  save Cer;
91  save n;
92  n:=0;
93  for p_=t:
94    if color p_:
95      n:=n+1;
96      _T[n]:=p_;
97    fi;
98  endfor;
99  path Cer;
100  color ptcer[];
101  for k=0 step 5 until 360 :
102    ptcer[k div 5]-_T[1]=Distance(_T[1],_T[2])*((_T[4]-_T[3])*cosd(k)/Distance(_T[3],_T[4])+(_T[5]-_T[3])*sind(k)/Distance(_T[3],_T[5]));
103  endfor;
104  Cer=Projgeo(ptcer0)
105  for k=0 step 5 until 360 :
106    ..Projgeo(ptcer[k div 5])
107  endfor
108  ..cycle;
109  Cer
110enddef;
111
112vardef arcsind(expr x)=%en degré ici :)
113  angle((sqrt(1-x**2),x))
114enddef;
115
116vardef tand(expr x)=sind(x)/cosd(x)%
117enddef;
118
119vardef cotand(expr x)=cosd(x)/sind(x)%
120enddef;
121
122vardef ln(expr t)=mlog(t)/256%
123enddef;
124
125%représentation paramétrique de la sphère terrestre.
126vardef FX(expr t,v)=rayon*cosd(c*t)*cosd(c*v)
127enddef;
128
129vardef FY(expr t,v)=rayon*cosd(c*t)*sind(c*v)
130enddef;
131
132vardef FZ(expr t,v)=rayon*sind(c*t)
133enddef;
134
135%Paramètres et macros de représentation
136vardef Initialisation(expr r,t,p,d)=
137  Rho:=r;
138  Theta:=t;
139  Phi:=p;
140  DE:=d;
141  Aux1:=sind(Theta);
142  Aux2:=sind(Phi);
143  Aux3:=cosd(Theta);
144  Aux4:=cosd(Phi);
145  Aux5:=Aux3*Aux2;
146  Aux6:=Aux1*Aux2;
147  Aux7:=Aux3*Aux4;
148  Aux8:=Aux1*Aux4;
149enddef;
150
151vardef Oeil=(Rho*Aux7,Rho*Aux8,Rho*Aux2)
152enddef;
153
154vardef Vision(expr num)=
155  save bb;
156  color bb;
157  bb=(redpart(Oeil-Sommet[num]),greenpart(Oeil-Sommet[num]),bluepart(Oeil-Sommet[num])); 
158  bb
159enddef;
160
161vardef Normal(expr vecun,vecde,vectr)=
162  save aa;
163  color aa;
164  P1:=redpart(vecde-vecun);
165  P2:=greenpart(vecde-vecun);
166  P3:=bluepart(vecde-vecun);
167  Q1:=redpart(vectr-vecun);
168  Q2:=greenpart(vectr-vecun);
169  Q3:=bluepart(vectr-vecun);
170  aa=(P2*Q3-Q2*P3,P3*Q1-Q3*P1,P1*Q2-Q1*P2);
171  aa
172enddef;
173
174vardef ProduitScalaire(expr wec,mor)=
175  redpart(wec)*redpart(mor)+greenpart(wec)*greenpart(mor)+bluepart(wec)*bluepart(mor)
176enddef;
177
178vardef Distance(expr aa,bb)=%Entre deux points
179  sqrt((redpart(bb)-redpart(aa))*(redpart(bb)-redpart(aa))+(greenpart(bb)-greenpart(aa))*(greenpart(bb)-greenpart(aa))+(bluepart(bb)-bluepart(aa))*(bluepart(bb)-bluepart(aa)))
180enddef;
181
182vardef MaillageS=
183  path Maillage[];
184  color CentMaillage[];
185  %numeric Vmin,Vmax;
186  %total:=0;
187  for k=Udebut step 0.5*pasU until (Ufin):
188    for l=Vdebut step pasV until (Vfin):
189      Maillage[100*k+l]=Projgeo((FX(k,l),FY(k,l),FZ(k,l)))--Projgeo((FX(k,l+pasV),FY(k,l+pasV),FZ(k,l+pasV)))--Projgeo((FX(k+pasU,l+pasV),FY(k+pasU,l+pasV),FZ(k+pasU,l+pasV)))--Projgeo((FX(k+pasU,l),FY(k+pasU,l),FZ(k+pasU,l)))--cycle;
190      if ProduitScalaire(1/2[(FX(k,l),FY(k,l),FZ(k,l)),(FX(k+pasU,l+pasV),FY(k+pasU,l+pasV),FZ(k+pasU,l+pasV))]-pte3,Oeil-pte3)>0:
191        %total:=total+1;
192        %if total=1:
193        %  Vmin:=l;
194        %fi;
195        draw Maillage[100*k+l];
196      fi;
197    endfor;
198  endfor;
199  %drawoptions();
200  %for k=(Udebut+pasU) step pasU until (Ufin-pasU):
201  %  if abs(round(k*c))<100:
202  %    label.urt(TEX(""&decimal(round(k*c))&""),Projgeo(rayon*(cosd(round(k*c))*cosd(Theta),cosd(round(k*c))*sind(Theta),sind(round(k*c)))))
203  %  fi;
204  %endfor;
205  %Vmax:=0;
206  %Vmax:=Vmin+2*((Theta/c)-Vmin);
207  %label.top(TEX(""&decimal(round(Vmin*c))&"") rotated angle(Projgeo(rayon*(cosd(phim+10)*cosd(round(Vmin*c)),cosd(phim+10)*sind(round(Vmin*c)),sind(phim+10)))-Projgeo(rayon*(cosd(phim)*cosd(round(Vmin*c)),cosd(phim)*sind(round(Vmin*c)),sind(phim)))),Projgeo(rayon*(cosd(phim)*cosd(round(Vmin*c)),cosd(phim)*sind(round(Vmin*c)),sind(phim))));
208  %label.top(TEX(""&decimal(round(Theta))&"") rotated angle(Projgeo(rayon*(cosd(phim+10)*cosd(round(Theta)),cosd(phim+10)*sind(round(Theta)),sind(phim+10)))-Projgeo(rayon*(cosd(phim)*cosd(round(Theta)),cosd(phim)*sind(round(Theta)),sind(phim)))),Projgeo(rayon*(cosd(phim)*cosd(round(Theta)),cosd(phim)*sind(round(Theta)),sind(phim))));
209  %label.top(TEX(""&decimal(round(Vmax*c))&"") rotated angle(Projgeo(rayon*(cosd(phim+10)*cosd(round(Vmax*c)),cosd(phim+10)*sind(round(Vmax*c)),sind(phim+10)))-Projgeo(rayon*(cosd(phim)*cosd(round(Vmax*c)),cosd(phim)*sind(round(Vmax*c)),sind(phim)))),Projgeo(rayon*(cosd(phim)*cosd(round(Vmax*c)),cosd(phim)*sind(round(Vmax*c)),sind(phim))));
210enddef;
211
212vardef InitialiseMaillage(expr ud,uf,up,vd,vf,vp)=
213  Udebut:=ud;
214  Ufin:=uf;
215  pasU:=up;
216  Vdebut:=vd;
217  Vfin:=vf;
218  pasV:=vp;
219enddef;
220
221vardef MaillageSphere=
222  InitialiseMaillage(((phim div 10)+1)*pi/18,((phip div 10)-1)*pi/18,pi/18,-pi,pi,pi/36);
223  MaillageS;
224enddef;
225
226boolean maille;
227maille=false;
228
229vardef ParaMeri(expr lonn,latt)=%longitude et latitude en degrés%Parallèle et méridien particulier pour une représentation 3d.
230  maille:=true;
231  latpar:=latt;
232  lonpar:=lonn;
233enddef;
234
235vardef Maille=
236  InitialiseMaillage(((phim div 10)+1)*pi/18,((phip div 10)-1)*pi/18,pi/36,-pi,pi,pi/72);
237  path SMaillage[];picture Smaille;
238  drawoptions(withpen pencircle scaled 2bp withcolor orangevif);
239  for l=Vdebut step pasV until (Vfin+pasV):
240    SMaillage[100*latpar+l]=Projgeo((FX(latpar/c,l),FY(latpar/c,l),FZ(latpar/c,l)))--Projgeo((FX(latpar/c,l+pasV),FY(latpar/c,l+pasV),FZ(latpar/c,l+pasV)));
241    if ProduitScalaire(1/2[(FX(latpar/c,l),FY(latpar/c,l),FZ(latpar/c,l)),(FX(latpar/c,l+pasV),FY(latpar/c,l+pasV),FZ(latpar/c,l+pasV))]-pte3,Oeil-pte3)>0:
242      draw SMaillage[100*latpar+l];
243    fi;
244  endfor;
245  for k=Udebut step pasU until (Ufin+pasU):
246    SMaillage[k+100*lonpar]:=Projgeo((FX(k,lonpar/c),FY(k,lonpar/c),FZ(k,lonpar/c)))--Projgeo((FX(k+pasU,lonpar/c),FY(k+pasU,lonpar/c),FZ(k+pasU,lonpar/c)));
247    if ProduitScalaire(1/2[(FX(k,lonpar/c),FY(k,lonpar/c),FZ(k,lonpar/c)),(FX(k+pasU,lonpar/c),FY(k+pasU,lonpar/c),FZ(k+pasU,lonpar/c))]-pte3,Oeil-pte3)>0:
248      draw SMaillage[k+100*lonpar];
249    fi;
250  endfor;
251  drawoptions();
252    %);
253enddef;
254
255vardef Projgeo(expr X)=
256  pair $;
257  numeric Xobs,Yobs,Zobs,XProj,YProj;
258  Xobs = -redpart(X)*Aux1 + greenpart(X)*Aux3;
259  Yobs = -redpart(X)*Aux5 - greenpart(X)*Aux6 + bluepart(X)*Aux4;
260  Zobs = -redpart(X)*Aux7 - greenpart(X)*Aux8 - bluepart(X)*Aux2 + Rho;
261  XProj = DE*Xobs/Zobs;
262  YProj = DE*Yobs/Zobs;
263  $=(XProj,YProj);
264  $
265enddef;
266
267%Début du package
268numeric nbpts,nblec,nbcapitales;
269
270string arborescence;
271arborescence:="data/";
272
273vardef lecture(expr nomfichier,fond)=
274  color Coord[],Pays[];
275  numeric ll;
276  ll:=0;
277  nbpts:=scantokens readfrom nomfichier;
278  for k=1 upto (nbpts div 3):
279    pair latlon;
280    latlon=((scantokens readfrom nomfichier)+(scantokens readfrom nomfichier)+(scantokens readfrom nomfichier))/3;
281    Coord[k]=rayon*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
282    if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
283      if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
284        ll:=ll+1;
285        Pays[k]=Coord[k];
286      else:
287        Pays[k]=2*Coord[k];
288      fi;
289    else:
290      Pays[k]=2*Coord[k];
291    fi;
292  endfor;
293  closefrom nomfichier;
294  path pays;
295  if ll>0:
296    pays=Projgeo(Pays[1])
297    for l=2 upto (nbpts div 3):
298      --Projgeo(Pays[l])
299    endfor;
300    if noncolore=true:
301      fill pays--cycle withcolor payscolor;
302    else:
303      fill pays--cycle withcolor fond;
304    fi;
305    draw pays;
306    clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
307  fi;
308enddef;
309
310string nomfichiermul,NomFichier;
311
312vardef Lectureiles=
313  nomfichiermul:=arborescence&"iles.dat";
314  nblec:=scantokens readfrom nomfichiermul;
315  for p=1 upto nblec:
316    color Coord[],fond,Pays[];
317    numeric ll;
318    ll:=0;
319    nbpts:=scantokens readfrom nomfichiermul;
320    fond=scantokens readfrom nomfichiermul;
321    for k=1 upto nbpts:
322      pair latlon;
323      latlon=scantokens readfrom nomfichiermul;
324      Coord[k]=rayon*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
325      if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
326        if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
327          ll:=ll+1;
328          Pays[k]=Coord[k];
329        else:
330          Pays[k]=2*Coord[k];
331        fi;
332      else:
333        Pays[k]=2*Coord[k];
334      fi;
335    endfor;
336    path pays;
337     if ll>0:
338      pays=Projgeo(Pays[1])
339      for l=2 upto nbpts:
340        --Projgeo(Pays[l])
341      endfor;
342      if noncolore=true:
343        fill pays--cycle withcolor payscolor;
344      else:
345        fill pays--cycle withcolor fond;
346      fi;
347      draw pays;
348      clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
349    fi;
350  endfor;
351  closefrom nomfichiermul;
352enddef;
353
354vardef Lecturelacs=
355  nomfichiermul:=arborescence&"lacs.dat";
356  nblec:=scantokens readfrom nomfichiermul;
357  for p=1 upto nblec:
358    color Coord[],Pays[];
359    numeric ll;
360    ll:=0;
361    nbpts:=scantokens readfrom nomfichiermul;
362    for k=1 upto nbpts:
363      pair latlon;
364      latlon=scantokens readfrom nomfichiermul;
365      Coord[k]=rayon*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
366      if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
367        if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
368          ll:=ll+1;
369          Pays[k]=Coord[k];
370        else:
371          Pays[k]=2*Coord[k];
372        fi;
373      else:
374        Pays[k]=2*Coord[k];
375      fi;
376    endfor;
377    path pays;
378    if ll>0:
379      pays=Projgeo(Pays[1])
380      for l=2 upto nbpts:
381        --Projgeo(Pays[l])
382      endfor;
383      fill pays--cycle withcolor cielfonce;
384      draw pays;
385      clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
386    fi;
387  endfor;
388  closefrom nomfichiermul;
389enddef;
390
391vardef Lecturelacssup=
392  nomfichiermul:=arborescence&"lacssup.dat";
393  nblec:=scantokens readfrom nomfichiermul;
394  for p=1 upto nblec:
395    color Coord[],Pays[];
396    numeric ll;
397    ll:=0;
398    nbpts:=scantokens readfrom nomfichiermul;
399    for k=1 upto nbpts:
400      pair latlon;
401      latlon=scantokens readfrom nomfichiermul;
402      Coord[k]=rayon*(cosd(xpart(latlon))*cosd(ypart(latlon)),cosd(xpart(latlon))*sind(ypart(latlon)),sind(xpart(latlon)));
403      if ((xpart(latlon)>phim) and (xpart(latlon)<phip)):
404        if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
405          ll:=ll+1;
406          Pays[k]=Coord[k];
407        else:
408          Pays[k]=2*Coord[k];
409        fi;
410      else:
411        Pays[k]=2*Coord[k];
412      fi;
413    endfor;
414    path pays;
415    if ll>0:
416      pays=Projgeo(Pays[1])
417      for l=2 upto nbpts:
418        --Projgeo(Pays[l])
419      endfor;
420      fill pays--cycle withcolor cielfonce;
421      draw pays;
422      clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
423    fi;
424  endfor;
425  closefrom nomfichiermul;
426enddef;
427
428vardef Lecturevolcans=
429  drawoptions(withcolor orange);
430  nomfichiermul:=arborescence&"volcans.dat";
431  nblec:=scantokens readfrom nomfichiermul;
432  show nblec;
433  for p=1 upto nblec:
434    color Coord[],Pays[];
435    pair latlon;
436    latlon=scantokens readfrom nomfichiermul;
437    Coord[p]=rayon*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
438    if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
439      if ProduitScalaire(Coord[p]-pte3,Oeil-pte3)>0:
440        Pays[p]=Coord[p];
441        fill flamme shifted Projgeo(Pays[p]) withcolor 1/2[orange,jaune];
442      %else:
443%       Pays[k]=2*Coord[k];
444      fi;
445%    else:
446%      Pays[k]=2*Coord[k];
447    fi;
448  endfor;
449closefrom nomfichiermul;
450drawoptions();
451enddef;
452
453vardef Lecturerivieres=
454  nomfichiermul:=arborescence&"rivieres.dat";
455  nblec:=scantokens readfrom nomfichiermul;
456  for p=1 upto nblec:
457    color Coord[],fond,Pays[];
458    numeric ll;
459    ll:=0;
460    nbpts:=scantokens readfrom nomfichiermul;
461    for k=1 upto nbpts:
462      pair latlon;
463      latlon=scantokens readfrom nomfichiermul;
464      Coord[k]=rayon*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
465      if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
466        if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
467          ll:=ll+1;
468          Pays[k]=Coord[k];
469        else:
470          Pays[k]=2*Coord[k];
471        fi;
472      else:
473        Pays[k]=2*Coord[k];
474      fi;
475    endfor;
476    path pays;
477    if ll>0:
478      pays=Projgeo(Pays[1])
479      for l=2 upto nbpts:
480        --Projgeo(Pays[l])
481      endfor;
482      draw pays withcolor cielfonce;
483      clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
484    fi;
485  endfor;
486  closefrom nomfichiermul;
487enddef;
488
489vardef Lecturerivieressup=
490  nomfichiermul:=arborescence&"fleuveseurope.dat";
491  nblec:=scantokens readfrom nomfichiermul;
492  for p=1 upto nblec:
493    color Coord[],fond,Pays[];
494    numeric ll;
495    ll:=0;
496    nbpts:=scantokens readfrom nomfichiermul;
497    for k=1 upto nbpts:
498      pair latlon;
499      latlon=scantokens readfrom nomfichiermul;
500      Coord[k]=rayon*(cosd(xpart(latlon))*cosd(ypart(latlon)),cosd(xpart(latlon))*sind(ypart(latlon)),sind(xpart(latlon)));
501      if ((xpart(latlon)>phim) and (xpart(latlon)<phip)):
502        if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
503          ll:=ll+1;
504          Pays[k]=Coord[k];
505        else:
506          Pays[k]=2*Coord[k];
507        fi;
508      else:
509        Pays[k]=2*Coord[k];
510      fi;
511    endfor;
512    path pays;
513    if ll>0:
514      pays=Projgeo(Pays[1])
515      for l=2 upto nbpts:
516        --Projgeo(Pays[l])
517      endfor;
518      draw pays withcolor cielfonce;
519      clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
520    fi;
521  endfor;
522  closefrom nomfichiermul;
523enddef;
524
525vardef Lecturecapitales=
526  marque_p:="creux";
527  nomfichiermul:=arborescence&"capitales.dat";
528  nbcapitales:=scantokens readfrom nomfichiermul;
529  for p=1 upto nbcapitales:
530    color Coord[];
531    pair latlon;
532    picture Nom;
533    string p_;
534    p_=scantokens readfrom nomfichiermul;
535    latlon=scantokens readfrom nomfichiermul;
536    Coord[p]=rayon*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
537    Nom=image(
538      label.top(p_,Projgeo(Coord[p]));
539      );
540    if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
541      if ProduitScalaire(Coord[p]-pte3,Oeil-pte3)>0:
542        pointe(Coord[p]);
543        %draw Nom;
544      fi;
545    fi;
546  endfor;
547  closefrom nomfichiermul;
548  marque_p:="non";
549enddef;
550
551vardef Lecture(expr Nomfichier)=
552  NomFichier:=arborescence&Nomfichier;
553  nblec:=scantokens readfrom NomFichier;
554  for w=1 upto nblec:
555    if projection="non":
556      lecture(scantokens readfrom NomFichier);
557    else:
558      lecturep(scantokens readfrom NomFichier);
559    fi;
560  endfor;
561  closefrom NomFichier;
562enddef;
563
564%Pour les projections
565string projection;
566projection:="non";
567
568vardef zoom(expr nbzoom)=
569  if projection="mercator":
570    xunit:=nbzoom;
571    yunit:=nbzoom*2*cm;
572  elseif projection="cylindrique":
573    xunit:=2.5*nbzoom;
574    yunit:=nbzoom*10*cm;
575  elseif projection="simple":
576    xunit:=nbzoom*0.5*mm;
577    yunit:=nbzoom*0.5*mm;
578  elseif projection="bonne":
579    xunit:=nbzoom*4*cm;
580    yunit:=xunit;
581  fi;
582enddef;
583
584vardef mercatorc(expr aa,bb)=
585  (xunit*(bb-theta),yunit*(ln(abs(tand(45+(aa/2))))-ln(abs(tand(45+(phi/2))))))
586enddef;
587
588vardef coniquec(expr aa,bb,pc)=
589  abscon:=5*cm*(cosd(aa)*sind(bb*sind(pc)))/(sind(pc)*cosd(aa-pc));
590  ordcon:=5*cm*(cosd(aa)*cosd(bb*sind(pc)))/(sind(pc)*cosd(aa-pc));
591  (abscon,ordcon)
592enddef;
593
594vardef cylindriquec(expr aa,bb)=
595  (xunit*(bb-theta),yunit*(sind(aa)-sind(phi)))
596enddef;
597
598vardef simplec(expr aa,bb)=
599  (xunit*(bb-theta),yunit*(aa-phi))
600enddef;
601
602vardef bonnec(expr aaa,bbb)=
603  save tt;
604  pair tt;
605  rho:=cotand(phi)+(phi-aaa)/c;
606  E:=(((bbb-theta)/c)*cosd(aaa))/rho;
607  tt=xunit*(rho*sind(E*c),cotand(phi)-rho*cosd(E*c));
608  tt
609enddef;
610
611vardef lecturep(expr nomfichier,fond)=
612  pair Coord[];
613  nbpts:=scantokens readfrom nomfichier;
614  numeric ll;
615  ll=0;
616  for k=1 upto nbpts:
617    pair latlon;
618    latlon=scantokens readfrom nomfichier;
619    if projection="mercator":
620      Coord[k]=mercatorc(xpart(latlon/60),ypart(latlon/60))
621    elseif projection="cylindrique":
622      Coord[k]=cylindriquec(xpart(latlon/60),ypart(latlon/60));
623    elseif projection="simple":
624      Coord[k]=simplec(xpart(latlon/60),ypart(latlon/60));
625    elseif projection="bonne":
626      Coord[k]=bonnec(xpart(latlon/60),ypart(latlon/60));
627    elseif projection="coniqueh":
628      if (xpart(latlon)>0) or (xpart(latlon)=0):
629        ll:=ll+1;
630        Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),45);
631      fi;
632    elseif projection="coniqueb":
633      if (xpart(latlon)<0):
634        ll:=ll+1;
635        Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),-45);
636      fi;
637    fi;
638  endfor;
639  closefrom nomfichier;
640  path pays;
641  if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
642    ll:=nbpts
643  fi;
644  if ll>0:
645    pays=Coord[1]
646    for l=2 upto ll:
647      --Coord[l]
648    endfor;
649    if noncolore=true:
650      fill pays--cycle withcolor payscolor;
651    else:
652      fill pays--cycle withcolor fond;
653    fi;
654    draw pays;
655  fi;
656enddef;
657
658vardef Lectureilesp=
659  if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
660    nomfichiermul:=arborescence&"Ile.dat";
661  else:
662    nomfichiermul:=arborescence&"iles.dat";
663  fi;
664  nblec:=scantokens readfrom nomfichiermul;
665  if projection="bonne":
666    nblec:=nblec-1
667  fi;
668  for p=1 upto nblec:
669    pair Coord[];color fond;
670    nbpts:=scantokens readfrom nomfichiermul;
671    fond=scantokens readfrom nomfichiermul;
672    numeric ll;
673    ll=0;
674    for k=1 upto nbpts:
675      pair latlon;
676      latlon=scantokens readfrom nomfichiermul;
677      if projection="mercator":
678        Coord[k]=mercatorc(xpart(latlon/60),ypart(latlon/60))
679      elseif projection="simple":
680        Coord[k]=simplec(xpart(latlon/60),ypart(latlon/60));
681      elseif projection="cylindrique":
682        Coord[k]=cylindriquec(xpart(latlon/60),ypart(latlon/60));
683      elseif projection="bonne":
684        Coord[k]=bonnec(xpart(latlon/60),ypart(latlon/60));
685      elseif projection="coniqueh":
686        if (xpart(latlon)>0) or (xpart(latlon)=0):
687          ll:=ll+1;
688          Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),45)
689        fi;
690      elseif projection="coniqueb":
691        if (xpart(latlon)<0):
692          ll:=ll+1;
693          Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),-45);
694        fi;
695      fi;
696    endfor;
697    path pays;
698    if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
699      ll:=nbpts
700    fi;
701    if ll>0:
702      pays=Coord[1]
703      for l=2 upto ll:
704        --Coord[l]
705      endfor;
706      if noncolore=true:
707        fill pays--cycle withcolor payscolor;
708      else:
709        fill pays--cycle withcolor fond;
710      fi;
711      draw pays;
712    fi;
713  endfor;
714  closefrom nomfichiermul;
715 if (projection="mercator") or (projection="cylindrique") or (projection="simple"):
716    clip currentpicture to feuillet;
717  fi;
718  if projection="bonne":
719    lecturep(arborescence&"polesud.dat",blanc);
720    clip currentpicture to (bonnec(-90,-180) for k=-89 upto 90:..bonnec(k,-180) endfor)..reverse(bonnec(-90,180) for k=-89 upto 90:..bonnec(k,180) endfor)..cycle;
721  fi;
722enddef;
723
724vardef Lecturevillesp(expr nompays)=
725  nomfichiermul:=arborescence&"villes"&nompays&".dat";
726  nblec:=scantokens readfrom nomfichiermul;
727  drawoptions(withcolor (0.15,0.15,0.15));
728  for p=1 upto nblec:
729    pair Coord[],latlon;string p_;
730    latlon=scantokens readfrom nomfichiermul;
731    p_=scantokens readfrom nomfichiermul;
732    if projection="mercator":
733      Coord[p]=mercatorc(ypart(latlon),xpart(latlon));
734    elseif projection="simple":
735      Coord[p]=simplec(ypart(latlon),xpart(latlon));
736    elseif projection="cylindrique":
737      Coord[p]=cylindriquec(ypart(latlon),xpart(latlon));
738    elseif projection="bonne":
739        Coord[p]=bonnec(ypart(latlon),xpart(latlon));
740    fi;
741    if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
742      dotlabel.scantokens readfrom nomfichiermul(TEX(""&p_&""),Coord[p]);
743    fi;
744  endfor;
745  drawoptions();
746  closefrom nomfichiermul;
747enddef;
748
749vardef Lecturelacsp=
750  nomfichiermul:=arborescence&"lacs.dat";
751  nblec:=scantokens readfrom nomfichiermul;
752  for p=1 upto nblec:
753    pair Coord[];
754    nbpts:=scantokens readfrom nomfichiermul;
755    numeric ll;
756    ll=0;
757    for k=1 upto nbpts:
758      pair latlon;
759      latlon=scantokens readfrom nomfichiermul;
760      if projection="mercator":
761        Coord[k]=mercatorc(xpart(latlon/60),ypart(latlon/60));
762      elseif projection="simple":
763        Coord[k]=simplec(xpart(latlon/60),ypart(latlon/60));
764      elseif projection="cylindrique":
765        Coord[k]=cylindriquec(xpart(latlon/60),ypart(latlon/60));
766      elseif projection="bonne":
767        Coord[k]=bonnec(xpart(latlon/60),ypart(latlon/60));
768      elseif projection="coniqueh":
769        if (xpart(latlon)>0) or (xpart(latlon)=0):
770          ll:=ll+1;
771          Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),45);
772        fi;
773      elseif projection="coniqueb":
774        if (xpart(latlon)<0):
775          ll:=ll+1;
776          Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),-45);
777        fi;
778      fi;
779    endfor;
780    path lac;
781    if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
782      ll:=nbpts
783    fi;
784    if ll>0:
785      lac=Coord[1]
786      for l=2 upto ll:
787        --Coord[l]
788      endfor;
789      fill lac--cycle withcolor cielfonce;
790      draw lac;
791    fi;
792  endfor;
793  closefrom nomfichiermul;
794enddef;
795
796vardef Lecturelacspsup=
797  nomfichiermul:=arborescence&"lacssup.dat";
798  nblec:=scantokens readfrom nomfichiermul;
799  for p=1 upto nblec:
800    pair Coord[];
801    nbpts:=scantokens readfrom nomfichiermul;
802    numeric ll;
803    ll=0;
804    for k=1 upto nbpts:
805      pair latlon;
806      latlon=scantokens readfrom nomfichiermul;
807      if projection="mercator":
808        Coord[k]=mercatorc(xpart(latlon),ypart(latlon));
809      elseif projection="simple":
810        Coord[k]=simplec(xpart(latlon),ypart(latlon));
811      elseif projection="cylindrique":
812        Coord[k]=cylindriquec(xpart(latlon),ypart(latlon));
813      elseif projection="bonne":
814        Coord[k]=bonnec(xpart(latlon),ypart(latlon));
815      elseif projection="coniqueh":
816        if (xpart(latlon)>0) or (xpart(latlon)=0):
817          ll:=ll+1;
818          Coord[ll]=coniquec(xpart(latlon),ypart(latlon),45);
819        fi;
820      elseif projection="coniqueb":
821        if (xpart(latlon)<0):
822          ll:=ll+1;
823          Coord[ll]=coniquec(xpart(latlon),ypart(latlon),-45);
824        fi;
825      fi;
826    endfor;
827    path lac;
828    if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
829      ll:=nbpts
830    fi;
831    if ll>0:
832      lac=Coord[1]
833      for l=2 upto ll:
834        --Coord[l]
835      endfor;
836      fill lac--cycle withcolor cielfonce;
837      draw lac;
838    fi;
839  endfor;
840  closefrom nomfichiermul;
841enddef;
842
843vardef Lecturerivieresp=
844  nomfichiermul:=arborescence&"rivieres.dat";
845  nblec:=scantokens readfrom nomfichiermul;
846  for p=1 upto nblec:
847    pair Coord[];
848    nbpts:=scantokens readfrom nomfichiermul;
849    numeric ll;
850    ll:=0;
851    for k=1 upto nbpts:
852      pair latlon;
853      latlon=scantokens readfrom nomfichiermul;
854      if projection="mercator":
855        Coord[k]=mercatorc(xpart(latlon/60),ypart(latlon/60));
856      elseif projection="simple":
857        Coord[k]=simplec(xpart(latlon/60),ypart(latlon/60));
858      elseif projection="cylindrique":
859        Coord[k]=cylindriquec(xpart(latlon/60),ypart(latlon/60));
860      elseif projection="bonne":
861        Coord[k]=bonnec(xpart(latlon/60),ypart(latlon/60));
862      elseif projection="coniqueh":
863        if (xpart(latlon)>0) or (xpart(latlon)=0):
864          ll:=ll+1;
865          Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),45);
866        fi;
867      elseif projection="coniqueb":
868        if (xpart(latlon)<0):
869          ll:=ll+1;
870          Coord[ll]=coniquec(xpart(latlon/60),ypart(latlon/60),-45);
871        fi;
872      fi;
873    endfor;
874    path riv;
875    if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
876      ll:=nbpts;
877    fi;
878    if ll>0:
879      riv=Coord[1]
880      for l=2 upto ll:
881        --Coord[l]
882      endfor;
883      draw riv withcolor cielfonce;
884    fi;
885  endfor;
886  closefrom nomfichiermul;
887enddef;
888
889vardef Lecturerivierespsup=
890  nomfichiermul:=arborescence&"fleuveseurope.dat";
891  nblec:=scantokens readfrom nomfichiermul;
892  for p=1 upto nblec:
893    pair Coord[];
894    nbpts:=scantokens readfrom nomfichiermul;
895    numeric ll;
896    ll:=0;
897    for k=1 upto nbpts:
898      pair latlon;
899      latlon=scantokens readfrom nomfichiermul;
900      if projection="mercator":
901        Coord[k]=mercatorc(xpart(latlon),ypart(latlon));
902      elseif projection="simple":
903        Coord[k]=simplec(xpart(latlon),ypart(latlon));
904      elseif projection="cylindrique":
905        Coord[k]=cylindriquec(xpart(latlon),ypart(latlon));
906      elseif projection="bonne":
907        Coord[k]=bonnec(xpart(latlon),ypart(latlon));
908      elseif projection="coniqueh":
909        if (xpart(latlon)>0) or (xpart(latlon)=0):
910          ll:=ll+1;
911          Coord[ll]=coniquec(xpart(latlon),ypart(latlon),45);
912        fi;
913      elseif projection="coniqueb":
914        if (xpart(latlon)<0):
915          ll:=ll+1;
916          Coord[ll]=coniquec(xpart(latlon),ypart(latlon),-45);
917        fi;
918      fi;
919    endfor;
920    path riv;
921    if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
922      ll:=nbpts;
923    fi;
924    if ll>0:
925      riv=Coord[1]
926      for l=2 upto ll:
927        --Coord[l]
928      endfor;
929      draw riv withcolor cielfonce;
930    fi;
931  endfor;
932  closefrom nomfichiermul;
933enddef;
934
935vardef Lecturecapitalesp=
936  marque_p:="creux";
937  nomfichiermul:=arborescence&"capitales.dat";
938  nbcapitales:=scantokens readfrom nomfichiermul;
939  for p=1 upto nbcapitales:
940    pair Coord[],latlon;
941    string p_;
942    p_=scantokens readfrom nomfichiermul;
943    latlon=scantokens readfrom nomfichiermul;
944    ll:=0;
945    if projection="mercator":
946      Coord[p]=mercatorc(xpart(latlon/60),ypart(latlon/60));
947      ll:=1;
948    elseif projection="simple":
949      Coord[p]=simplec(xpart(latlon/60),ypart(latlon/60));
950      ll:=1;
951    elseif projection="cylindrique":
952      Coord[p]=cylindriquec(xpart(latlon/60),ypart(latlon/60));
953      ll:=1;
954    elseif projection="bonne":
955      Coord[p]=bonnec(xpart(latlon/60),ypart(latlon/60));
956      ll:=1;
957    elseif projection="coniqueh":
958      if (xpart(latlon)>0) or (xpart(latlon)=0):
959        ll:=1;
960        Coord[p]=coniquec(xpart(latlon/60),ypart(latlon/60),45);
961      fi;
962    elseif projection="coniqueb":
963      if (xpart(latlon)<0):
964        ll:=1;
965        Coord[p]=coniquec(xpart(latlon/60),ypart(latlon/60),-45);
966      fi;
967    fi;
968    if ll>0:
969      drawoptions(withcolor rouge);
970      pointe(Coord[p]);
971      drawoptions();
972      if (projection="mercator") or (projection="cylindrique") or (projection="simple") or (projection="bonne"):
973        label.top(p_,Coord[p]);
974      fi;
975    fi;
976  endfor;
977  closefrom nomfichiermul;
978  marque_p:="non";
979enddef;
980
981vardef MeridienParallele=
982  if (projection="mercator") or (projection="cylindrique") or (projection="simple"):
983    pair Coord[];
984    for k=-80 step 10 until 80:
985      for j=-180 step 10 until 180:
986        if projection="mercator":
987          Coord[100*k+j]=mercatorc(k,j);
988        elseif projection="simple":
989          Coord[k]=simplec(k,j);
990        elseif projection="cylindrique":
991          Coord[100*k+j]=cylindriquec(k,j);
992        fi;
993      endfor;
994    endfor;
995    for k=-80 step 10 until 80:
996      draw Coord[100*k-180]
997      for j=-170 step 10 until 180:
998        --Coord[100*k+j]
999      endfor;
1000    endfor;
1001    pair Coord[];
1002    for k=-180 step 10 until 180:
1003      for j=-80 step 10 until 80:
1004        if projection="mercator":
1005          Coord[0.001*k+10*j]=mercatorc(j,k);
1006        elseif projection="simple":
1007          Coord[k]=simplec(j,k);
1008        elseif projection="cylindrique":
1009          Coord[0.001*k+10*j]=cylindriquec(j,k);
1010        fi;
1011      endfor;
1012    endfor;
1013    for k=-180 step 10 until 180:
1014      draw Coord[0.001*k-10*80]
1015      for j=-70 step 10 until 80:
1016        --Coord[0.001*k+10*j]
1017      endfor;
1018    endfor;
1019  elseif projection="bonne":
1020    pair Coord[][];
1021    for k=-90 step 10 until 90:
1022      for j=-180 step 10 until 180:
1023        Coord[k][j]=bonnec(k,j);
1024      endfor;
1025    endfor;
1026    for k=-90 step 10 until 90:
1027      draw Coord[k][-180]
1028      for j=-170 step 10 until 180:
1029        --Coord[k][j]
1030      endfor;
1031    endfor;
1032    pair Coord[][];
1033    for k=-170 step 10 until 170:
1034      for j=-90 step 10 until 90:
1035        Coord[k][j]=bonnec(j,k);
1036      endfor;
1037    endfor;
1038    for k=-170 step 10 until 170:
1039      draw Coord[k][-90]
1040      for j=-80 step 10 until 90:
1041        ..Coord[k][j]
1042      endfor;
1043    endfor;
1044  elseif projection="coniqueh":
1045    pair Coord[];
1046    for k=-180 step 10 until 180:
1047      for j=0 step 10 until 90:
1048        Coord[100*k+j]=coniquec(j,k,45);
1049      endfor;
1050    endfor;
1051    for k=-180 step 10 until 180:
1052      draw Coord[100*k]
1053      for j=10 step 10 until 90:
1054        --Coord[100*k+j]
1055      endfor;
1056    endfor;
1057    pair Coord[];
1058    for k=0 step 10 until 90:
1059      for j=-180 step 10 until 180:
1060        Coord[0.001*k+10*j]=coniquec(k,j,45);
1061      endfor;
1062    endfor;
1063    for k=0 step 10 until 90:
1064      draw Coord[0.001*k-10*180]
1065      for j=-170 step 10 until 180:
1066        --Coord[0.001*k+10*j]
1067      endfor;
1068    endfor;
1069    clip currentpicture to coniquec(90,0,45)--(Coord[-10*180]
1070      for j=-170 step 10 until 180:
1071        --Coord[10*j]
1072      endfor)--cycle;
1073  elseif projection="coniqueb":
1074    pair Coord[];
1075    for k=-180 step 10 until 180:
1076      for j=-90 step 10 until 0:
1077        Coord[100*k+j]=coniquec(j,k,-45);
1078      endfor;
1079    endfor;
1080    for k=-180 step 10 until 180:
1081      draw Coord[100*k-90]
1082      for j=-80 step 10 until 0:
1083        --Coord[100*k+j]
1084      endfor;
1085    endfor;
1086    pair Coord[];
1087    for k=-90 step 10 until 0:
1088      for j=-180 step 10 until 180:
1089        Coord[0.001*k+10*j]=coniquec(k,j,-45);
1090      endfor;
1091    endfor;
1092    for k=-90 step 10 until 0:
1093      draw Coord[0.001*k-10*180]
1094      for j=-170 step 10 until 180:
1095        --Coord[0.001*k+10*j]
1096      endfor;
1097    endfor;
1098    clip currentpicture to coniquec(-90,0,-45)--(Coord[-10*180]
1099      for j=-170 step 10 until 180:
1100        --Coord[10*j]
1101      endfor)--cycle;
1102  fi;
1103enddef;
1104
1105boolean Echelle;
1106Echelle=false;
1107
1108vardef echelle(expr Th,Ph,long)=%long en km.
1109  Echelle:=true;
1110  theta:=Th;
1111  phi:=Ph;
1112  Long:=long;
1113  zoom(1);
1114  numeric $;
1115  if projection="bonne":
1116    $=(cm*pi*cosd(Ph)*6340/36)/(long*abs(bonnec(Ph,Th)-bonnec(Ph,Th+5)));
1117  elseif projection="mercator":
1118    $=(cm*pi*cosd(Ph)*6340/36)/(long*abs(mercatorc(Ph,Th)-mercatorc(Ph,Th+5)));
1119  elseif projection="simple":
1120    $=(cm*pi*cosd(Ph)*6340/36)/(long*abs(simplec(Ph,Th)-simplec(Ph,Th+5)));
1121  elseif projection="cylindrique":
1122    $=(cm*pi*cosd(Ph)*6340/36)/(long*abs(cylindriquec(Ph,Th)-cylindriquec(Ph,Th+5)));
1123  fi;
1124  $
1125enddef;
1126
1127boolean Amsud,Amnord,Amcentrale,Caraibes,Asie,Europe,Afrique,All;
1128
1129Amsud:=false;
1130Amnord:=false;
1131Amcentrale:=false;
1132Caraibes:=false;
1133Asie:=false;
1134Europe:=false;
1135Afrique:=false;
1136All:=true;
1137
1138vardef Projection(expr TH,PH,Zoom)=
1139  theta:=TH;
1140  phi:=PH;
1141  zoom(Zoom);
1142  if projection="bonne":
1143    fill (bonnec(-90,-180) for k=-85 step 5 until 90:..bonnec(k,-180) endfor)..reverse(bonnec(-90,180) for k=-85 step 5 until 90:..bonnec(k,180) endfor)..cycle withcolor ciel;
1144  fi;
1145  if All=true:
1146    Lecture("Cameriquesud.dat");
1147    Lecture("Ccaraibes.dat");
1148    Lecture("Cameriquecentrale.dat");
1149    Lecture("Cameriquenord.dat");
1150    Lecture("Casia.dat");
1151    Lecture("Ceurope.dat");
1152    Lecture("Cafrique.dat");
1153  else:
1154    if Amsud=true:
1155      Lecture("Cameriquesud.dat");
1156    fi;
1157    if Amnord=true:
1158      Lecture("Cameriquenord.dat");
1159    fi;
1160    if Amcentrale=true:
1161      Lecture("Cameriquecentrale.dat");
1162    fi;
1163    if Caraibes=true:
1164      Lecture("Ccaraibes.dat");
1165    fi;
1166    if Asie=true:
1167      if projection="bonne":
1168        Lecture("Casie.dat");
1169      else:
1170        Lecture("Casia.dat");
1171      fi;
1172    fi;
1173    if Europe=true:
1174      Lecture("Ceurope.dat");
1175    fi;
1176    if Afrique=true:
1177      Lecture("Cafrique.dat");
1178    fi;
1179  fi;
1180  if lacs=true:
1181    Lecturelacsp;
1182    Lecturelacspsup;
1183  fi;
1184  Lectureilesp;
1185  if capitales=true:
1186    Lecturecapitalesp;
1187  fi;
1188  if fleuves=true:
1189    Lecturerivieresp;
1190    Lecturerivierespsup;
1191  fi;
1192  if maillage=true:
1193    drawoptions(withcolor gris);
1194    MeridienParallele
1195    drawoptions();
1196  fi;
1197  if Echelle=true:
1198    draw ((Xa,Ya)+u*(1,1))--((Xa,Ya)+u*(2,1));
1199    labeloffset:=labeloffset*1.5;
1200    label.top(btex 0 etex,(Xa,Ya)+u*(1,1));
1201    label.top(TEX(""&decimal(Long)&"~km"),(Xa,Ya)+u*(2,1));
1202    labeloffset:=labeloffset/1.5;
1203    draw ((Xa,Ya)+u*(1,1.1))--((Xa,Ya)+u*(1,0.9));
1204    draw (((Xa,Ya)+u*(1,1.1))--((Xa,Ya)+u*(1,0.9))) shifted(u*(1,0));
1205  fi;
1206enddef;
1207
1208vardef Simple(expr TH,PH,Zoom)=
1209  projection:="simple";
1210  theta:=TH;
1211  phi:=PH;
1212  zoom(Zoom);
1213  Lecture("Cameriquesud.dat");
1214  Lecture("Ccaraibes.dat");
1215  Lecture("Cameriquecentrale.dat");
1216  Lecture("Cameriquenord.dat");
1217  Lecture("Casia.dat");
1218  Lecture("Ceurope.dat");
1219  Lecture("Cafrique.dat");
1220  if lacs=true:
1221    Lecturelacsp;
1222    Lecturelacspsup;
1223  fi;
1224  Lectureilesp;
1225  if capitales=true:
1226    Lecturecapitalesp;
1227  fi;
1228  if fleuves=true:
1229    Lecturerivieresp;
1230   fi;
1231  if maillage=true:
1232    MeridienParallele
1233  fi;
1234enddef;
1235
1236vardef Mercator(expr TH,PH,Zoom)=
1237  projection:="mercator";
1238  theta:=TH;
1239  phi:=PH;
1240  zoom(Zoom);
1241  Lecture("Cameriquesud.dat");
1242  Lecture("Ccaraibes.dat");
1243  Lecture("Cameriquecentrale.dat");
1244  Lecture("Cameriquenord.dat");
1245  Lecture("Casia.dat");
1246  Lecture("Ceurope.dat");
1247  Lecture("Cafrique.dat");
1248  if lacs=true:
1249    Lecturelacsp;
1250    Lecturelacspsup;
1251  fi;
1252  Lectureilesp;
1253  if capitales=true:
1254    Lecturecapitalesp;
1255  fi;
1256  if fleuves=true:
1257    Lecturerivieresp;
1258  fi;
1259  if maillage=true:
1260    MeridienParallele
1261  fi;
1262enddef;
1263
1264vardef Cylindrique(expr TH,PH,Zoom)=
1265  projection:="cylindrique";
1266  theta:=TH;
1267  phi:=PH;
1268  zoom(Zoom);
1269  Lecture("Cameriquesud.dat");
1270  Lecture("Ccaraibes.dat");
1271  Lecture("Cameriquecentrale.dat");
1272  Lecture("Cameriquenord.dat");
1273  Lecture("Casia.dat");
1274  Lecture("Ceurope.dat");
1275  Lecture("Cafrique.dat");
1276  if lacs=true:
1277    Lecturelacsp;
1278    Lecturelacspsup;
1279  fi;
1280  Lectureilesp;
1281  if capitales=true:
1282    Lecturecapitalesp;
1283  fi;
1284  if fleuves=true:
1285    Lecturerivieresp;
1286  fi;
1287  if maillage=true:
1288    MeridienParallele
1289  fi;
1290enddef;
1291
1292vardef Bonne(expr TH,PH,Zoom)=
1293  projection:="bonne";
1294  theta:=TH;
1295  phi:=PH;
1296  zoom(Zoom);
1297  fill (bonnec(-90,-180) for k=-85 step 5 until 90:..bonnec(k,-180) endfor)..reverse(bonnec(-90,180) for k=-85 step 5 until 90:..bonnec(k,180) endfor)..cycle withcolor ciel;
1298  Lecture("Cameriquesud.dat");
1299  Lecture("Ccaraibes.dat");
1300  Lecture("Cameriquecentrale.dat");
1301  Lecture("Cameriquenord.dat");
1302  Lecture("Casie.dat");
1303  Lecture("Ceurope.dat");
1304  Lecture("Cafrique.dat");
1305  if lacs=true:
1306    Lecturelacsp;
1307    Lecturelacspsup;
1308  fi;
1309  Lectureilesp;
1310  if capitales=true:
1311    Lecturecapitalesp;
1312  fi;
1313  if fleuves=true:
1314    Lecturerivieresp;
1315  fi;
1316  if maillage=true:
1317    drawoptions(withcolor gris);
1318    MeridienParallele;
1319    drawoptions();
1320  fi;
1321  draw (bonnec(-90,-180) for k=-85 step 5 until 90:..bonnec(k,-180) endfor)..reverse(bonnec(-90,180) for k=-85 step 5 until 90:..bonnec(k,180) endfor)..cycle;
1322enddef;
1323
1324vardef ConiqueH=
1325  projection:="coniqueh";
1326  Lecture("Cameriquesud.dat");
1327  Lecture("Ccaraibes.dat");
1328  Lecture("Cameriquecentrale.dat");
1329  Lecture("Cameriquenord.dat");
1330  Lecture("Casie.dat");
1331  Lecture("Ceurope.dat");
1332  Lecture("Cafrique.dat");
1333  if lacs=true:
1334    Lecturelacsp;
1335    Lecturelacspsup;
1336  fi;
1337  Lectureilesp;
1338  if capitales=true:
1339    Lecturecapitalesp;
1340  fi;
1341  if fleuves=true:
1342    Lecturerivieresp;
1343    Lecturerivierespsup;
1344  fi;
1345  drawoptions(withcolor gris);
1346  MeridienParallele;
1347  drawoptions();
1348enddef;
1349
1350vardef ConiqueB=
1351  projection:="coniqueb";
1352  Lecture("Cameriquesud.dat");
1353  Lecture("Ccaraibes.dat");
1354  Lecture("Cameriquecentrale.dat");
1355  Lecture("Cameriquenord.dat");
1356  Lecture("Casie.dat");
1357  Lecture("Ceurope.dat");
1358  Lecture("Cafrique.dat");
1359  if lacs=true:
1360    Lecturelacsp;
1361    Lecturelacspsup;
1362  fi;
1363  Lectureilesp;
1364  if capitales=true:
1365    Lecturecapitalesp;
1366  fi;
1367  if fleuves=true:
1368    Lecturerivieresp;
1369    Lecturerivierespsup;
1370  fi;
1371  drawoptions(withcolor gris);
1372  MeridienParallele;
1373  drawoptions();
1374enddef;
1375
1376%%%%%%%
1377
1378rayon:=2;
1379
1380boolean fleuves,lacs,capitales,noncolore,maillage,volcans;
1381fleuves=true;
1382lacs=true;
1383capitales=true;
1384noncolore=false;
1385maillage=false;
1386volcans=false;
1387
1388vardef Mappemonde(expr longobs,latobs)=
1389  projection:="non";
1390  figureespace(-100u,-100u,100u,100u);
1391  Initialisation(5,longobs,latobs,750);
1392  numeric phim,phip,phii;%phi moins -- phi plus - phi intermédiaire
1393  phim=Phi+arcsind(rayon/Rho)-90;
1394  phip=Phi+90-arcsind(rayon/Rho);
1395  color pte[];
1396  pte1=rayon*(cosd(phim)*cosd(Theta),cosd(phim)*sind(Theta),sind(phim));
1397  pte2=rayon*(cosd(phip)*cosd(Theta),cosd(phip)*sind(Theta),sind(phip));
1398  pte3=1/2[pte1,pte2];
1399  pte4-pte3=Normal((0,0,0),pte1,pte2);
1400  if (Phi>90):
1401    phip:=180-phip;
1402    phii:=180-phim;
1403    phim:=phip;
1404    phip:=phii;
1405  fi;
1406  if (Phi<-90):
1407    phip:=-180-phip;
1408    phii:=-180-phim;
1409    phim:=phip;
1410    phip:=phii;
1411  fi;
1412  fill cercles(pte3,pte1,pte3,pte1,pte4) withcolor ciel;
1413  Lecture("Cameriquesud.dat");
1414  Lecture("Ccaraibes.dat");
1415  Lecture("Cameriquecentrale.dat");
1416  Lecture("Cameriquenord.dat");
1417  Lecture("Casie.dat");
1418  Lecture("Ceurope.dat");
1419  Lecture("Cafrique.dat");
1420  if volcans=true:
1421    Lecturevolcans;
1422  fi;
1423  if lacs=true:
1424    Lecturelacs;
1425    Lecturelacssup;
1426  fi;
1427  Lectureiles;
1428  if capitales=true:
1429    Lecturecapitales;
1430  fi;
1431  if fleuves=true:
1432    Lecturerivieres;
1433    %Lecturerivieressup;
1434  fi;
1435  if maillage=true:
1436    drawoptions(withcolor gris);
1437    MaillageSphere;
1438    drawoptions();
1439  fi;
1440  if maille=true:
1441    Maille;
1442  fi;
1443  draw cercles(pte3,pte1,pte3,pte1,pte4);
1444  finespace;
1445enddef;
1446
1447endinput;
Note: See TracBrowser for help on using the browser.