-
Notifications
You must be signed in to change notification settings - Fork 6
/
globalclimate.cpp
14505 lines (10968 loc) · 504 KB
/
globalclimate.cpp
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// globalclimate.cpp
// Undiscovered Worlds
//
// Created by Jonathan Hill on 04/09/2019.
//
// Please see functions.hpp for notes.
#include <iostream>
#include <cmath>
#include <fstream>
#include <stdio.h>
#include "classes.hpp"
#include "planet.hpp"
#include "region.hpp"
#include "functions.hpp"
//#include "profiler.h"
using namespace std;
// This function creates the global climate.
void generateglobalclimate(planet& world, bool dorivers, bool dolakes, bool dodeltas, boolshapetemplate smalllake[], boolshapetemplate largelake[], boolshapetemplate landshape[], vector<vector<vector<int>>>& mountaindrainage, vector<vector<vector<bool>>>& shelves, vector<float>& longitude, vector<float>& latitude, vector<fourglobepoints>& dirpoint, int& progressval, string& progresstext)
{
//highres_timer_t timer("Generate Global Climate"); // 9.4s => 8.2s
long seed = world.seed();
fast_srand(seed);
int edge = world.edge();
int maxelev = world.maxelevation();
int sealevel = world.sealevel();
int seatotal = world.seatotal();
int landtotal = world.landtotal();
// If there is no sea on a world, it may still have rain, provided we can find somewhere to put some salt lakes for the rivers to run into.
int desertrainchance = 4; // On worlds with no sea, chance of trying to create rain anyway.
int lakeattempts = random(1, 8); // On worlds with no sea where there may be rain, make this many attempts to place a salt lake.
int saltlakesplaced = 0;
// If there's no sea, we will probably raise the sea level to be just below the lowest land.
int raisesealevelchance = 6; // The higher this is, the *more* likely we are to try this.
if (seatotal == 0 && random(1, raisesealevelchance) != 1)
{
int lowest = maxelev;
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
int thiselev = world.nom(face, i, j);
if (thiselev < lowest)
lowest = thiselev;
}
}
}
sealevel = lowest - random(5, 10);
if (sealevel < 1)
sealevel = 1;
world.setsealevel(sealevel);
}
// If there is no sea but there is rain, we need to try to create some small bits of sea that will later become saltwater lakes, and fill depressions, to ensure that rivers run towards them.
// First we need to prepare a no-lake template, marking out areas too close to the coasts, where lakes can't go. (We'll use this later whether or not the world has sea, so may as well do it now.)
int minseadistance = 15; // Points closer to the shore than this can't be the centre of lakes, normally.
int minseadistance2 = 8; // This is for any lake tile, not just the centre.
vector<twointegers> saltlakemap(6 * edge * edge);
vector<int> nolake(6 * edge * edge);
vector<int> basins(6 * edge * edge);
if (dolakes)
{
for (int face = 0; face < 6; face++)
{
int vface = face * edge * edge;
for (int i = 0; i < edge; i++)
{
int vi = vface + i * edge;
for (int j = 0; j < edge; j++)
{
int index = vi + j;
saltlakemap[index].x = 0;
saltlakemap[index].y = 0;
}
}
}
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
if (world.outline(face, i, j) == 1)
{
for (int k = - minseadistance2; k <= minseadistance2; k++)
{
for (int l = -minseadistance2; l <= minseadistance2; l++)
{
globepoint lpoint = getglobepoint(edge, face, i, j, k, l);
if (lpoint.face != -1)
nolake[lpoint.face * edge * edge + lpoint.x * edge + lpoint.y] = 1;
}
}
for (int k = -minseadistance2; k <= minseadistance2; k++)
{
for (int l = -minseadistance2; l <= minseadistance2; l++)
{
globepoint lpoint = getglobepoint(edge, face, i, j, k, l);
int lindex = lpoint.face * edge * edge + lpoint.x * edge + lpoint.y;
if (lpoint.face != -1 && nolake[lindex] == 0)
nolake[lindex] = 2;
}
}
}
}
}
}
}
bool desertworldrain = 0; // If this is 1, then this is a world with no sea but which will have rain.
if (dorivers && seatotal == 0 && random(1, desertrainchance) == 1)
{
int highestelev = 0;
int lowestelev = maxelev;
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
int thiselev = world.nom(face, i, j);
if (thiselev < lowestelev)
lowestelev = thiselev;
if (thiselev > highestelev)
highestelev = thiselev;
}
}
}
int elevdiff = highestelev - lowestelev;
int maxlakeelev = lowestelev + elevdiff / 4;
vector<int> avoid(6 * edge * edge, 0); // This is for cells *not* to alter. This will remain empty (it's just here so we can use the depression-creating routine for normal lakes as well, where we don't want to mess with the path of the outflowing river.)
for (int n = 0; n < lakeattempts; n++)
{
int face = random(0, 5);
int x = random(1, edge - 1);
int y = random(10, edge - 11);
for (int m = 0; m < 1000; m++)
{
if (world.nom(face, x, y) > maxlakeelev)
{
int face = random(0, 5);
x = random(1, edge - 1);
y = random(10, edge - 11);
}
else
m = 1000;
}
placesaltlake(world, face, x, y, 1, 0, saltlakemap, basins, avoid, nolake, smalllake);
}
bool foundsea = 0; // Now look to see whether that worked. If it didn't, then there will be no rain on this world.
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
if (world.nom(face, i, j) <= sealevel)
{
desertworldrain = 1;
face = 6;
i = edge;
j = edge;
}
}
}
}
}
if (desertworldrain)
{
// Now remove depressions.
updatereport(progressval, progresstext, "Filling depressions");
depressionfill(world);
addlandnoise(world); // Add a bit of noise, then do remove depressions again. This is to add variety to the river courses.
depressionfill(world);
}
// Now, set the river land reduce factor.
float riverlandreduce = 20.0f * world.gravity() * world.gravity();
world.setriverlandreduce((int)riverlandreduce);
// Now, do the wind map.
updatereport(progressval, progresstext, "Generating wind map");
vector<bool> outsidehorse(6 * edge * edge, 0);
createwindmap(world, outsidehorse, longitude, latitude);
// Now create the temperature map.
updatereport(progressval, progresstext, "Generating global temperature map");
// Start by generating a new fractal map.
int grain = 8; // Level of detail on this fractal map.
float valuemod = 0.2f;
float valuemod2 = 3.0f;
vector<int> fractal(6 * edge * edge, 0);
createfractal(fractal, edge, grain, valuemod, valuemod2, 1, maxelev, 0, 0);
createtemperaturemap(world, fractal, latitude);
// Now do the sea ice
if (seatotal > 0)
{
updatereport(progressval, progresstext, "Generating sea ice map");
for (int face = 0; face < 6; face++)
{
int vface = face * edge * edge;
for (int i = 0; i < edge; i++)
{
int vi = vface + i * edge;
for (int j = 0; j < edge; j++)
fractal[vi + j] = 0;
}
}
createfractal(fractal, edge, grain, valuemod, valuemod2, 1, maxelev, 0, 0);
createseaicemap(world, fractal, longitude, latitude);
// Work out the tidal ranges.
updatereport(progressval, progresstext, "Calculating tides");
createtidalmap(world, dirpoint);
}
// Now do rainfall.
if (seatotal > 0 || desertworldrain)
{
for (int face = 0; face < 6; face++)
{
int vface = face * edge * edge;
for (int i = 0; i < edge; i++)
{
int vi = vface + i * edge;
for (int j = 0; j < edge; j++)
fractal[vi + j] = 0;
}
}
createfractal(fractal, edge, grain, valuemod, valuemod2, 1, maxelev, 0, 0);
createrainmap(world, fractal, landtotal, seatotal, outsidehorse, smalllake, landshape, longitude, latitude, dirpoint, progressval, progresstext);
}
// Now add fjord mountains.
if (seatotal > 0)
{
updatereport(progressval, progresstext, "Carving fjords");
addfjordmountains(world);
}
if (dorivers && (seatotal > 0 || desertworldrain))
{
// Now work out the rivers initially. We do this the first time so that after the first time we can place the salt lakes in appropriate places, and then we work out the rivers again.
updatereport(progressval, progresstext, "Planning river courses");
createrivermap(world, mountaindrainage, dirpoint);
if (dolakes || seatotal == 0) // If there's no sea we need at least one salt lake.
{
// Now create salt lakes.
updatereport(progressval, progresstext, "Placing hydrological basins");
createsaltlakes(world, saltlakesplaced, saltlakemap, nolake, basins, smalllake);
addlandnoise(world);
depressionfill(world);
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
world.setriverdir(face, i, j, 0);
world.setriverjan(face, i, j, 0);
world.setriverjul(face, i, j, 0);
}
}
}
// Now work out the rivers again.
updatereport(progressval, progresstext, "Generating rivers");
createrivermap(world, mountaindrainage, dirpoint);
}
// Now check river valleys in mountains.
updatereport(progressval, progresstext, "Checking mountain river valleys");
removerivermountains(world);
if (dolakes)
{
// Now create the lakes.
updatereport(progressval, progresstext, "Generating lakes");
convertsaltlakes(world, saltlakemap);
createlakemap(world, nolake, smalllake, largelake, dirpoint);
createriftlakemap(world, nolake);
}
else
{
if (seatotal == 0)
convertsaltlakes(world, saltlakemap);
}
}
world.setmaxriverflow();
// Now correct places where something has gone wrong with seasonal rainfall.
updatereport(progressval, progresstext, "Correcting rainfall");
correctseasonalrainfall(world);
// Now create the climate map.
updatereport(progressval, progresstext, "Calculating climates");
createclimatemap(world);
// Now specials.
updatereport(progressval, progresstext, "Generating sand dunes");
createergs(world, smalllake, largelake, landshape);
updatereport(progressval, progresstext, "Generating salt pans");
createsaltpans(world, smalllake, largelake);
// Add river deltas. (off for now as it doesn't work properly)
if (1 == 0) //(dodeltas)
{
updatereport(progressval, progresstext, "Generating river deltas");
createriverdeltas(world);
checkrivers(world); // Turned off as it seems buggy.
}
// Now wetlands.
updatereport(progressval, progresstext, "Generating wetlands");
createwetlands(world, smalllake);
removeexcesswetlands(world);
// Now it's time to finesse the roughness map.
updatereport(progressval, progresstext, "Refining roughness map");
refineroughnessmap(world);
// Check the rift lake map too.
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
if (world.lakestart(face, i, j) == 1 && world.riftlakesurface(face, i, j) == 0 && world.lakesurface(face, i, j) == 0)
world.setlakestart(face, i, j, 0);
}
}
}
if (dolakes == 0)
{
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
if (world.special(face, i, j) != 110)
{
world.setlakesurface(face, i, j, 0);
world.setlakestart(face, i, j, 0);
world.setriftlakesurface(face, i, j, 0);
world.setriftlakebed(face, i, j, 0);
}
}
}
}
}
removesealakes(world); // Also, make sure there are no weird bits of sea next to lakes.
connectlakes(world); // Make sure lakes aren't fragmented.
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++) // Check erg/salt pans are the right depth.
{
for (int j = 0; j < edge; j++)
{
int special = world.special(face, i, j);
if (special == 110 || special == 120)
{
int level = world.lakesurface(face, i, j);
if (level <= sealevel)
{
level = sealevel + 1;
world.setlakesurface(face, i, j, level);
}
world.setnom(face, i, j, level);
}
}
}
}
for (int face = 0; face < 6; face++) // Remove any craters where there are special features such as ergs or salt pans.
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
if (world.special(face, i, j) != 0)
{
world.setcraterrim(face, i, j, 0);
world.setcratercentre(face, i, j, 0);
}
}
}
}
// Now check for edge artefacts.
removeedgeartefacts(world);
// Now check the coastal temperatures.
updatereport(progressval, progresstext, "Checking coastal temperatures");
correctcoastaltemperatures(world);
}
// This creates the climate map.
void createclimatemap(planet& world)
{
int edge = world.edge();
short climate;
for (int face = 0; face < 6; face++)
{
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
{
climate = getclimate(world, face, i, j);
world.setclimate(face, i, j, climate);
}
}
}
}
// This returns the climate type of the given point.
short getclimate(planet& world, int face, int x, int y)
{
if (world.sea(face, x, y) == 1)
return (0);
int elev = world.map(face, x, y);
int sealevel = world.sealevel();
float wrain = (float)world.winterrain(face, x, y);
float srain = (float)world.summerrain(face, x, y);
float mintemp = (float)world.mintemp(face, x, y);
float maxtemp = (float)world.maxtemp(face, x, y);
short climate = calculateclimate(elev, sealevel, wrain, srain, mintemp, maxtemp);
return climate;
}
// The same thing, but for the regional map.
short getclimate(region& region, int x, int y)
{
if (region.sea(x, y) == 1)
return (0);
int elev = region.map(x, y);
int sealevel = region.sealevel();
float wrain = (float)region.winterrain(x, y);
float srain = (float)region.summerrain(x, y);
float mintemp = (float)region.mintemp(x, y);
float maxtemp = (float)region.maxtemp(x, y);
short climate = calculateclimate(elev, sealevel, wrain, srain, mintemp, maxtemp);
return climate;
}
// This does the actual climate calculations for the above two functions.
short calculateclimate(int elev, int sealevel, float wrain, float srain, float mintemp, float maxtemp)
{
float totalannualrain = 0;
if (srain > wrain) // If there's more rain in summer, assume a shorter rainy season. The greater the imbalance, the shorter the season.
{
float factor = (float)wrain / (float)srain; // 0-1. The higher it is, the more balanced the distribution of rain.
factor = factor * 12.0f;
if (factor < 4.0)
factor = 4.0f;
int sfactor = (int)factor;
int wfactor = 12 - sfactor;
totalannualrain = wrain * wfactor + srain * sfactor;
}
else
totalannualrain = (wrain + srain) * 6;
float meanannualrain = (wrain + srain) / 2;
float meanannualtemp = (mintemp + maxtemp) / 2;
float minrain = wrain;
float maxrain = srain;
if (wrain > srain)
{
minrain = srain;
maxrain = wrain;
}
string group, preptype, heattype; // These three variables define each climate type.
// First, establish the group (first letter).
if (maxtemp <= 10)
{
if (maxtemp >= 0)
group = "ET";
if (maxtemp < 0)
group = "EF";
}
if (group == "")
{
float precthreshold = (maxtemp + mintemp) * 10;
float checkpercent = (srain * 6) / totalannualrain;
if (checkpercent >= 0.7f)
precthreshold = precthreshold + 280.0f;
if (checkpercent >= 0.3 && checkpercent < 0.7f)
precthreshold = precthreshold + 140.0f;
if (totalannualrain < precthreshold * 0.5f)
group = "BW";
if (totalannualrain >= precthreshold * 0.5 && totalannualrain <= precthreshold)
group = "BS";
}
if (group == "" && mintemp >= 18)
group = "A";
if (group == "" && mintemp > -3 && mintemp < 18)
group = "C";
if (group == "" && mintemp <= -3)
group = "D";
// Now, establish the precipitation type (second letter).
if (group == "A")
{
if (minrain >= 60)
preptype = "f";
if (preptype == "" && minrain >= (100 - (totalannualrain / 25))) // meanannualrain>=(100-minrain))
preptype = "m";
if (preptype == "" && srain < 60)
preptype = "s";
if (preptype == "" && wrain < 60)
preptype = "w";
}
if (group == "C" || group == "D")
{
if (srain < wrain / 3 && srain < 40)
preptype = "s";
if (preptype == "" && wrain < srain / 10)
preptype = "w";
if (preptype == "")
preptype = "f";
}
// Now, establish the heat type (third letter).
if (group == "BW" || group == "BS")
{
if (meanannualtemp >= 18)
heattype = "h";
if (meanannualtemp < 18)
heattype = "k";
}
if (group != "A" && group != "BW" && group != "BS" && group != "ET" && group != "EF")
{
if (heattype == "" && maxtemp >= 22)
heattype = "a";
if (heattype == "" && maxtemp < 22 && maxtemp >= 14) // Should be: at least four months are >=10, but we can't track that accurately on our model.
heattype = "b";
if (heattype == "" && mintemp <= -38)
heattype = "d";
if (heattype == "")
heattype = "c";
}
string climate = group + preptype + heattype;
if (climate == "Af") // Af
return 1;
if (climate == "Am") // Am
return 2;
if (climate == "Aw") // Aw
return 3;
if (climate == "As") // As
return 4;
if (climate == "BWh") // Bwh
return 5;
if (climate == "BWk") // BWk
return 6;
if (climate == "BSh") // BSh
return 7;
if (climate == "BSk") // BSk
return 8;
if (climate == "Csa") // Csa
return 9;
if (climate == "Csb") // Csb
return 10;
if (climate == "Csc") // Csc
return 11;
if (climate == "Cwa") // Cwa
return 12;
if (climate == "Cwb") // Cwb
return 13;
if (climate == "Cwc") // Cwc
return 14;
if (climate == "Cfa") // Cfa
return 15;
if (climate == "Cfb") // Cfb
return 16;
if (climate == "Cfc") // Cfc
return 17;
if (climate == "Dsa") // Dsa
return 18;
if (climate == "Dsb") // Dsb
return 19;
if (climate == "Dsc") // Dsc
return 20;
if (climate == "Dsd") // Dsd
return 21;
if (climate == "Dwa") // Dwa
return 22;
if (climate == "Dwb") // Dwb
return 23;
if (climate == "Dwc") // Dwc
return 24;
if (climate == "Dwd") // Dwd
return 25;
if (climate == "Dfa") // Dfa
return 26;
if (climate == "Dfb") // Dfb
return 27;
if (climate == "Dfc") // Dfc
return 28;
if (climate == "Dfd") // Dfd
return 29;
if (climate == "ET") // ET
return 30;
if (climate == "EF") // EF
return 31;
return 0;
}
// This function gives the names of the climate types.
string getclimatename(short climate)
{
if (climate == 1) // Af
return "Tropical rainforest";
if (climate == 2) // Am
return "Monsoon";
if (climate == 3) // Aw
return "Savannah";
if (climate == 4) // As
return "Savannah";
if (climate == 5) // Bwh
return "Hot desert";
if (climate == 6) // BWk
return "Cold desert";
if (climate == 7) // BSh
return "Hot semi-arid";
if (climate == 8) // BSk
return "Cold steppe";
if (climate == 9) // Csa
return "Hot, dry-summer Mediterranean";
if (climate == 10) // Csb
return "Warm, dry-summer Mediterranean";
if (climate == 11) // Csc
return "Cold, dry-summer Mediterranean";
if (climate == 12) // Cwa
return "Dry-winter humid subtropical";
if (climate == 13) // Cwb
return "Dry-winter subtropical highland";
if (climate == 14) // Cwc
return "Dry-winter subpolar oceanic";
if (climate == 15) // Cfa
return "Humid subtropical";
if (climate == 16) // Cfb
return "Temperate oceanic";
if (climate == 17) // Cfc
return "Subpolar oceanic";
if (climate == 18) // Dsa
return "Mediterranean-influenced hot-summer humid continental";
if (climate == 19) // Dsb
return "Mediterranean-influenced warm-summer humid continental";
if (climate == 20) // Dsc
return "Mediterranean-influenced subarctic";
if (climate == 21) // Dsd
return "Mediterranean-influenced extremely cold subarctic";
if (climate == 22) // Dwa
return "Monsoon-influenced hot-summer humid continental";
if (climate == 23) // Dwb
return "Monsoon-influenced warm-summer humid continental";
if (climate == 24) // Dwc
return "Monsoon-influenced subarctic";
if (climate == 25) // Dwd
return "Monsoon-influenced extremely cold subarctic";
if (climate == 26) // Dfa
return "Hot-summer humid continental";
if (climate == 27) // Dfb
return "Warm-summer humid continental";
if (climate == 28) // Dfc
return "Subarctic";
if (climate == 29) // Dfd
return "Extremely cold subarctic";
if (climate == 30) // ET
return "Tundra";
if (climate == 31) // EF
return "Frost";
return "";
}
// This function gives the codes of the climate types.
string getclimatecode(short climate)
{
if (climate == 1) // Af
return "Af";
if (climate == 2) // Am
return "Am";
if (climate == 3) // Aw
return "Aw";
if (climate == 4) // As
return "As";
if (climate == 5) // Bwh
return "BWh";
if (climate == 6) // BWk
return "BWk";
if (climate == 7) // BSh
return "BSh";
if (climate == 8) // BSk
return "BSk";
if (climate == 9) // Csa
return "Csa";
if (climate == 10) // Csb
return "Csb";
if (climate == 11) // Csc
return "Csc";
if (climate == 12) // Cwa
return "Cwa";
if (climate == 13) // Cwb
return "Cwb";
if (climate == 14) // Cwc
return "Cwc";
if (climate == 15) // Cfa
return "Cfa";
if (climate == 16) // Cfb
return "Cfb";
if (climate == 17) // Cfc
return "Cfc";
if (climate == 18) // Dsa
return "Dsa";
if (climate == 19) // Dsb
return "Dsb";
if (climate == 20) // Dsc
return "Dsc";
if (climate == 21) // Dsd
return "Dsd";
if (climate == 22) // Dwa
return "Dwa";
if (climate == 23) // Dwb
return "Dwb";
if (climate == 24) // Dwc
return "Dwc";
if (climate == 25) // Dwd
return "Dwd";
if (climate == 26) // Dfa
return "Dfa";
if (climate == 27) // Dfb
return "Dfb";
if (climate == 28) // Dfc
return "Dfc";
if (climate == 29) // Dfd
return "Dfd";
if (climate == 30) // ET
return "ET";