summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-geo/pst-map2d.tex
blob: e93eecd1b6bd1b91d0116be9b065eb51a708e6f0 (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
%%
%% This is file `pst-map2d.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-map2d.tex'
%%
%% Manuel Luque <Mluque5130@aol.com> (France)
%% Giuseppe Matarazzo <joematara@hotmail.com> (Italy)
%% Herbert Voss <voss@perce.de> (Germany)
%%
%% May 09, 2004
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-map2d' is a PSTricks package to create geographical objects
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\csname PSTMaptwod\endcsname
\let\PSTMaptwodLoaded\endinput

% Require PSTricks
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey\fi
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax

\pst@addfams{pst-map2d}% added 2004-09-29 hv
%
\def\fileversion{1.07}
\def\filedate{2005/11/11}
\message{`PST-map2d' v\fileversion, \filedate\space (ML/GM/HV)}
%
\SpecialCoor
%
\define@key[psset]{pst-map2d}{path}{\edef\psk@WorldMap@Path{#1}} % chemin des données
\psset{path=data}
%\openin1=chemin.txt
%\read1 to \psk@WorldMap@Path
%
\define@key[psset]{pst-map2d}{level}{\edef\psk@WorldMap@level{#1}}
\psset{level=1}
%
\define@key[psset]{pst-map2d}{type}{\edef\psk@WorldMap@type{#1}}
\psset{type=1}
% type=1 ==> Mercator
% type=2 ==> Lambert
% type=3 ==> simple
% type=4 ==> Sanson-Flamsteed
% type=5 ==> cylindrical
% type=6 ==> Babinet
% type=7 ==> Collignon
% type=8 ==> Bonne
\define@key[psset]{pst-map2d}{n}{\edef\psk@WorldMap@n{#1}}
\psset{n=1.77245} % sqrt(pi) % pour Collignon
%
\define@key[psset]{pst-map2d}{limiteL}{\edef\psk@WorldMap@limiteL{#1}}
\psset{limiteL=180} % longitude limite
%
\define@key[psset]{pst-map2d}{latitude0}{\edef\psk@WorldMap@latitudeO{#1}}
\psset{latitude0=45}  % pour Bonne latitude 0
%
\define@key[psset]{pst-map2d}{longitude0}{\edef\psk@WorldMap@longitudeO{#1}}
\psset{longitude0=0}  % pour Bonne longitude 0
%
\define@key[psset]{pst-map2d}{increment}{\edef\psk@WorldMap@increment{#1}}
\psset{increment=10}
%
\define@key[psset]{pst-map2d}{MapFillColor}{\edef\psk@WorldMap@Fillcolor{#1}} % couleur des continents
\psset{MapFillColor= 0.99 0.95 0.7 }
%
\newif\ifPst@WorldMap@capitals
\define@key[psset]{pst-map2d}{capital}[false]{\@nameuse{Pst@WorldMap@capitals#1}}
\psset{capital=false}
%
\newif\ifPst@WorldMap@city
\define@key[psset]{pst-map2d}{city}[false]{\@nameuse{Pst@WorldMap@city#1}}
\psset{city=false}
%
\newif\ifPst@WorldMap@Rivers
\define@key[psset]{pst-map2d}{rivers}[true]{\@nameuse{Pst@WorldMap@Rivers#1}}
\psset{rivers=true}
%
\newif\ifPst@WorldMap@Borders
\define@key[psset]{pst-map2d}{borders}[true]{\@nameuse{Pst@WorldMap@Borders#1}}
\psset{borders=false}
%
\newif\ifPst@WorldMap@maillage
\define@key[psset]{pst-map2d}{maillage}[true]{\@nameuse{Pst@WorldMap@maillage#1}}
\psset{maillage=true}
%
\newif\ifPst@WorldMap@Fill
\define@key[psset]{pst-map2d}{Fill}[true]{\@nameuse{Pst@WorldMap@Fill#1}}
\psset{Fill=true}
%
\newif\ifPst@WorldMap@USA
\define@key[psset]{pst-map2d}{USA}[false]{\@nameuse{Pst@WorldMap@USA#1}}
\psset{USA=false}
%
\newif\ifPst@WorldMap@AUS
\define@key[psset]{pst-map2d}{AUS}[false]{\@nameuse{Pst@WorldMap@AUS#1}}
\psset{AUS=false}
%
\newif\ifPst@WorldMap@MEX
\define@key[psset]{pst-map2d}{MEX}[false]{\@nameuse{Pst@WorldMap@MEX#1}}
\psset{MEX=false}
%
\def\VariablesMap{%
  /Coeff_mercatorY {2 div 45 add dup sin exch cos div ln 57.2958 mul} def % Mercator
  /Coeff_simpleY {1 mul} def % simple
  /Coeff_lambertY {sin 57.2958 mul} def % Lambert
  /Coeff_sanson_flamsteedY {1 mul} def % Sanson_Flamstead
  /Coeff_cylindricalY { dup sin exch cos div 57.2958 mul} def % Cylindrical
  /Coeff_babinetY { sin 2 sqrt mul 57.2958 mul} def % Babinet
  /n \psk@WorldMap@n\space def
  /Coeff_collignonY { 0 ge { 1 2 sqrt 90 Y sub 2 div sin mul sub 57.2958 mul n mul}
     { 1 2 sqrt 90 Y add 2 div sin mul sub 57.2958 mul n mul neg} ifelse }def % Collignon
  /Coeff_BonneY {pop /RHO l0 dup cos exch sin div Y neg l0 add 57.2958 div add def
    /Theta Y cos X L0 sub mul RHO div def
    Theta cos RHO mul neg 57.2958 mul}def % Bonne
%
  /Coeff_mercatorX {1 mul} def % Mercator
  /Coeff_simpleX {1 mul} def % simple
  /Coeff_lambertX {1 mul} def % Lambert
  /Coeff_sanson_flamsteedX {Y cos mul} def % Sanson_Flamstead
  /Coeff_cylindricalX { 1 mul } def % Cylindrical
  /Coeff_babinetX { 2 mul 2 sqrt mul 3.1415926 div Y cos mul} def % Babinet
  /Coeff_collignonX { 2 mul 2 sqrt mul 90 Y abs sub 2 div sin mul n div} def % Collignon
  /l0 \psk@WorldMap@latitudeO\space def
  /L0 \psk@WorldMap@longitudeO\space def
  /Coeff_BonneX { pop /RHO l0 dup cos exch sin div Y neg l0 add 57.2958 div add def
    /Theta Y cos X L0 sub mul RHO div def
    Theta sin RHO mul 57.2958 mul } def % Bonne
  \ifcase\psk@WorldMap@type\or
    /CoeffY {Coeff_mercatorY} def
    /CoeffX {Coeff_mercatorX} def
    /StartY -85 def
  \or
    /CoeffY {Coeff_simpleY} def
    /CoeffX {Coeff_simpleX} def
    /StartY -90 def
  \or
    /CoeffY {Coeff_lambertY} def
    /CoeffX {Coeff_lambertX} def
    /StartY -90 def
  \or
    /CoeffY {Coeff_sanson_flamsteedY} def
    /CoeffX {Coeff_sanson_flamsteedX} def
    /StartY -90 def
  \or
    /CoeffY {Coeff_cylindricalY} def
    /CoeffX {Coeff_cylindricalX} def
    /StartY -85 def
  \or
    /CoeffY {Coeff_babinetY} def
    /CoeffX {Coeff_babinetX} def
    /StartY -90 def
  \or
    /CoeffY {Coeff_collignonY} def
    /CoeffX {Coeff_collignonX} def
    /StartY -90 def
  \or
    /CoeffY {Coeff_BonneY} def
    /CoeffX {Coeff_BonneX} def
    /StartY -90 def
  \fi%
  /step \psk@WorldMap@level\space def % hv 2004-05-04
}
\newcount\TypeProjection
\def\WorldMap{\pst@object{WorldMap}}
\def\WorldMap@i{\@ifnextchar[{\WorldMap@do}{\WorldMap@do[]}}
\def\WorldMap@do[#1]{{%
  \psset{#1}%
  \begin@ClosedObj
  \addto@pscode{%
    \VariablesMap
    (\psk@WorldMap@Path/river.dat) run
    (\psk@WorldMap@Path/pcoast.dat) run
    (\psk@WorldMap@Path/pisland.dat) run
    (\psk@WorldMap@Path/pborder.dat) run
    (\psk@WorldMap@Path/plake.dat) run
    (\psk@WorldMap@Path/usa.dat) run
    (\psk@WorldMap@Path/aus.dat) run
    (\psk@WorldMap@Path/mex.dat) run
    1 setlinejoin
    0 0 translate
    /xunit {\pst@number\psxunit\space mul 20 div }def
    /yunit {\pst@number\psyunit\space mul 20 div }def
    /increment \psk@WorldMap@increment\space def
    /limiteLongitude \psk@WorldMap@limiteL\space def
%
    \ifPst@WorldMap@Fill
      gsave
      newpath
      /X limiteLongitude neg def
      /Y StartY def
      X CoeffX xunit Y CoeffY yunit moveto
      StartY 2 StartY neg {%
        /Y exch def
        X CoeffX xunit Y CoeffY yunit lineto
      } for
     /X limiteLongitude def
     StartY neg -2 StartY {
       /Y exch def
       X CoeffX xunit Y CoeffY yunit lineto
     } for
     closepath
     /Color {0.5 0.8 0.8} def
     Color setrgbcolor
     fill
    grestore
  \fi
  /CalculsPoints {
    /region exch def
    newpath
    /nbr region length def % nombre de régions
    region 0 get aload pop
    /Y exch def /X exch def
    X CoeffX xunit Y CoeffY yunit moveto
    /ncount 0 def % hv 2004-05-04
    0 1 nbr 1 sub {
      /ncount ncount 1 add def % hv 2004-05-04
      region exch get aload pop
      ncount step mod 0 eq nbr ncount sub 0 lt or { % hv 2004-05-04
        /Y exch def /X exch def
        X CoeffX xunit Y CoeffY yunit lineto
      }{ pop pop } ifelse % hv 2004-05-04
    } for
  } def
%
  /Draw { {
    CalculsPoints
    \ifPst@WorldMap@Fill
      closepath
% Colour in earth's surfaces
      gsave
      Color setrgbcolor
      fill
      grestore
    \fi
    stroke
  } forall
  } def
\ifPst@WorldMap@Borders
  border
\else
  coasts
\fi
%/Color {0.5 0.8 0.5} def
/Color {\psk@WorldMap@Fillcolor} def
    Draw
islands
    Draw
\ifPst@WorldMap@MEX
mexico
    Draw
\fi
\ifPst@WorldMap@USA
usa
    Draw
\fi
\ifPst@WorldMap@AUS
australia
    Draw
\fi
/Color {0.5 0.8 0.8} def
lake
    Draw
% les rivières
\ifPst@WorldMap@Rivers
/DrawRivers {
    {
CalculsPoints
0 0 1 setrgbcolor
stroke
} forall
}def
river
DrawRivers
\fi
%
\ifPst@WorldMap@maillage
% meridiens
limiteLongitude neg increment limiteLongitude {% for X
    /X exch def
    newpath
    /Y StartY def
     X CoeffX xunit StartY CoeffY yunit moveto
StartY increment 10 div StartY neg { % for Y
    /Y exch def
    X CoeffX xunit Y CoeffY yunit lineto
} for
gsave
% 11 janvier 2004
X 0 eq {1 0 0 setrgbcolor}{0.2 setgray} ifelse
%
0.25 setlinewidth
stroke
grestore
} for
% parallèles
StartY increment StartY neg {% for Y
    /Y exch def
newpath
    /X limiteLongitude neg def
     X CoeffX xunit Y CoeffY yunit moveto
limiteLongitude neg increment 10 div limiteLongitude { % for X
    /X exch def
    X CoeffX xunit Y CoeffY yunit lineto
} for
% 11 janvier 2004
Y 0 eq {1 0 0 setrgbcolor}{0.2 setgray} ifelse
%
0.25 setlinewidth
stroke
} for
\fi
/DrawCitys {
/CITY exch def
/Rayon exch def
/nbr CITY length def % nombre de villes
0 1 nbr 1 sub {
  /compteur exch def
  CITY compteur get aload pop
  /X exch def /Y exch def
   gsave
   1 0 0 setrgbcolor newpath
   X CoeffX xunit Y CoeffY yunit
   Rayon 0 360 arc closepath fill
   grestore
} for
} def
\ifPst@WorldMap@city
% les capitales
  (\psk@WorldMap@Path/c-cap.dat) run
  1.5 % rayon du point
  citycapitals
  DrawCitys
% les autres villes
  (\psk@WorldMap@Path/c-sub.dat) run
  0.5 % rayon du point
  CitySub
DrawCitys
\fi
\ifPst@WorldMap@capitals
% les capitales
  (\psk@WorldMap@Path/c-cap.dat) run
  1.5
  citycapitals
  DrawCitys
\fi
}%
\end@ClosedObj
}}
%
\def\pnodeMap(#1,#2)#3{%   hv 2004-05-09
  \pst@killglue
  \pnode(!
      \VariablesMap
      /Y #2 def
      /X #1 def
      X CoeffX 20 div Y CoeffY 20 div){#3}%
}
%
%------------------- hv 2004-05-08 ----------------------
\def\psNodeLabelStyle{}
\define@key[psset]{pst-map2d}{mapCountry}{\edef\psk@WorldMap@mapCountry{#1}}
\psset{mapCountry=all}
\define@key[psset]{pst-map2d}{nodeWidth}{\edef\psk@WorldMap@nodeWidth{#1}}
\psset{nodeWidth=1mm}
\newpsstyle{psNodeMapStyle}{fillstyle=solid,fillcolor=red}
%
\def\mapput{\@ifnextchar[{\mapput@i}{\mapput@i[90]}}
\def\mapput@i[#1](#2,#3){\@ifnextchar[{\mapput@iii[#1](#2,#3)}{\mapput@ii[#1](#2,#3)}}
\def\mapput@ii[#1](#2,#3)#4{\mapput@iii[#1](#2,#3)[#4]{#4}}
\def\mapput@iii[#1](#2,#3)[#4]#5{%
  \@ifnextchar[{\mapput@iv[#1](#2,#3)[#4]#5}{\mapput@iv[#1](#2,#3)[#4]#5[\@empty]}}
\def\mapput@iv[#1](#2,#3)[#4]#5[#6]{{%
% [angle](longitude,lattitude)[node name]{node label}[country]
  \def\pst@tempb{all}
  \ifx\pst@tempb\psk@WorldMap@mapCountry
    \mapput@v[#1](#2,#3)[#4]{#5}
  \else
    \def\pst@tempb{#6}
%    \typeout{Compare \pst@tempb{} with \psk@WorldMap@mapCountry}
    \ifx\pst@tempb\psk@WorldMap@mapCountry
      \mapput@v[#1](#2,#3)[#4]{#5}
    \fi%
  \fi%
}}
\def\mapput@v[#1](#2,#3)[#4]#5{{%
  \pnodeMap(#2,#3){#4}
%  \typeout{Node: #4}
  \pst@dima=\psk@WorldMap@nodeWidth
  \pscircle[style=psNodeMapStyle](#4){\pst@dima}
  \pscircle*(#4){0.5\pst@dima}
  \uput{1.2\pst@dima}[#1](#4){{\psNodeLabelStyle #5}}%
}}
%------------------- hv 2004-05-08 ----------------------
%
\catcode`\@=\PstAtCode\relax
\endinput