-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmap_loader_unit.pas
More file actions
2896 lines (2010 loc) · 94.5 KB
/
map_loader_unit.pas
File metadata and controls
2896 lines (2010 loc) · 94.5 KB
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
(*
================================================================================
This file is part of OpenTemplot2024, a computer program for the design of model railway track.
Copyright (C) 2024 Martin Wynne. email: martin@85a.uk
This program is free software: you may redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation, either version 3 of the Licence, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program. See the file: licence.txt
Or if not, refer to the web site: https://www.gnu.org/licenses/
================================================================================
This file was saved from Delphi5
This file was derived from Templot2 version 244e
*)
unit map_loader_unit; // 215a load map from web as tiles directly into picture shapes
{$MODE Delphi}
{$ALIGN OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Clipbrd;
// OT2024 HTTPSend;
type
Tmap_loader_form = class(TForm)
datestamp_label: TLabel;
location_groupbox: TGroupBox;
os_grid_radio_button: TRadioButton;
lat_lon_radio_button: TRadioButton;
os_easting_edit: TEdit;
os_northing_edit: TEdit;
os_letters_edit: TEdit;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
lon_edit: TEdit;
lat_edit: TEdit;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label16: TLabel;
Label14: TLabel;
load_tiles_button: TButton;
Label19: TLabel;
extend_area_groupbox: TGroupBox;
add_top_button: TButton;
add_left_button: TButton;
add_right_button: TButton;
add_bottom_button: TButton;
Shape2: TShape;
crop_area_groupbox: TGroupBox;
Shape3: TShape;
crop_top_button: TButton;
crop_left_button: TButton;
crop_right_button: TButton;
crop_bottom_button: TButton;
background_shapes_button: TButton;
delete_button: TButton;
Label20: TLabel;
Label21: TLabel;
name_edit: TEdit;
name_listbox: TListBox;
list_label: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
info_label: TLabel;
url_radio_button: TRadioButton;
url_edit: TEdit;
Label25: TLabel;
stop_button: TButton;
current_map_label: TLabel;
close_panel: TPanel;
close_button: TButton;
pause_button: TButton;
t_55_label: TLabel;
Label1: TLabel;
Label5: TLabel;
Label6: TLabel;
Label3: TLabel;
Label4: TLabel;
osm_radio_button: TRadioButton;
tf_radio_button: TRadioButton;
tf_style_groupbox: TGroupBox;
tfm_radio: TRadioButton;
tfp_radio: TRadioButton;
tfo_radio: TRadioButton;
Label23: TLabel;
nls_county_radio_button: TRadioButton;
nls_natgrid50_radio_button: TRadioButton;
county_combo: TComboBox;
next_county_combo: TComboBox;
load_new_label1: TLabel;
Label17: TLabel;
Label2: TLabel;
Label22: TLabel;
Label24: TLabel;
zoom_to_map_button: TButton;
nls_london_radio_button: TRadioButton;
clarity_button: TButton;
Shape4: TShape;
Label18: TLabel;
os_coverage_button: TButton;
nls_coverage_button: TButton;
nls_natgrid25_radio_button: TRadioButton;
tiles_button: TButton;
nls_town125_radio_button: TRadioButton;
nls_town60_radio_button: TRadioButton;
Label10: TLabel;
Label15: TLabel;
remove_borders_checkbox: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure Label3Click(Sender: TObject);
procedure Label4Click(Sender: TObject);
procedure Label3MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure Label4MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure Label6MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure Label5MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure Label6Click(Sender: TObject);
procedure Label5Click(Sender: TObject);
procedure Label14Click(Sender: TObject);
procedure Label14MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure location_groupboxMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure lon_editEnter(Sender: TObject);
procedure os_letters_editEnter(Sender: TObject);
// OT2024 procedure load_tiles_buttonClick(Sender: TObject);
procedure background_shapes_buttonClick(Sender: TObject);
procedure Label24Click(Sender: TObject);
procedure Label25Click(Sender: TObject);
procedure Label24MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure delete_buttonClick(Sender: TObject);
procedure add_top_buttonClick(Sender: TObject);
procedure name_editChange(Sender: TObject);
procedure name_listboxClick(Sender: TObject);
procedure add_bottom_buttonClick(Sender: TObject);
procedure add_left_buttonClick(Sender: TObject);
procedure add_right_buttonClick(Sender: TObject);
procedure osm_radio_buttonClick(Sender: TObject);
procedure nls_london_radio_buttonClick(Sender: TObject);
procedure nls_6inch_radio_buttonClick(Sender: TObject);
procedure url_editEnter(Sender: TObject);
procedure stop_buttonClick(Sender: TObject);
procedure close_buttonClick(Sender: TObject);
procedure pause_buttonClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure crop_top_buttonClick(Sender: TObject);
procedure crop_right_buttonClick(Sender: TObject);
procedure crop_bottom_buttonClick(Sender: TObject);
procedure crop_left_buttonClick(Sender: TObject);
procedure url_editClick(Sender: TObject);
procedure name_editClick(Sender: TObject);
procedure lon_editClick(Sender: TObject);
procedure lat_editClick(Sender: TObject);
procedure os_letters_editClick(Sender: TObject);
procedure os_easting_editClick(Sender: TObject);
procedure os_northing_editClick(Sender: TObject);
procedure info_labelMouseMove(Sender: TObject; Shift:TShiftState; X,Y:Integer);
procedure tf_radio_buttonClick(Sender: TObject);
procedure info_labelClick(Sender: TObject);
procedure zoom_to_map_buttonClick(Sender: TObject);
procedure nls_county_radio_buttonClick(Sender: TObject);
procedure nls_natgrid50_radio_buttonClick(Sender: TObject);
// OT2024 procedure clarity_buttonClick(Sender: TObject);
procedure os_coverage_buttonClick(Sender: TObject);
procedure nls_coverage_buttonClick(Sender: TObject);
procedure nls_natgrid25_radio_buttonClick(Sender: TObject);
procedure tiles_buttonClick(Sender: TObject);
procedure nls_town60_radio_buttonClick(Sender: TObject);
procedure nls_town125_radio_buttonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
map_loader_form: Tmap_loader_form;
map_src_code:integer=0;
// 0=NLS historic 25-inch (tiled) 1=NLS 50-inch (tiled) 2=Thunderforest(tiled) 3=OpenStreetMap(tiled) 4=NLS 60-inch (tiled)
// 5=NLS modern 25-inch(tiled) 6=NLS town plans 60-inch 7=NLS town plans 125-inch //no longer used 8=URL(screenshot)
procedure map_loader_form_update;
function format_his_name:string;
// OT2024 function parse_url(str:string; var zoom_level:integer; var lat_lon:Tlat_lon):boolean;
function check_browser_zoom:boolean;
implementation
{$R *.lfm}
uses
Math, control_room, bgnd_unit, pad_unit, grid_unit, math_unit, entry_sheet, alert_unit, help_sheet, gauge_unit;
// OT2024 map_clarity_unit;
var
xtile_min,ytile_min,xtile_max,ytile_max:integer;
xtile_min_p1,ytile_min_p1,xtile_max_p1,ytile_max_p1:Tpex;
xtile_min_p2,ytile_min_p2,xtile_max_p2,ytile_max_p2:Tpex;
location_code:integer=0; // 0=long/lat 1=OS Grid 2=from URL
map_tile_count_x:integer=0;
map_tile_count_y:integer=0;
map_tile_size_mm:extended=0;
map_num_tiles_x:integer=0;
map_num_tiles_y:integer=0;
map_org_x:extended=0;
map_org_y:extended=0;
map_name_str:string='';
tile_name_str:string=''; // 'map::'(1-5) + user name (padded with trailing spaces to 15 chars, 6-20) + map_src_code(21) + 'T'or'S'(tiled/screenshot)(22) + zoom_level(padded with trailing spaces to 2, 23-24) + separator'#'(25) + xtile_str(padded with trailing spaces to 10, 26-35) + separator'#'(36) + ytile_str(padded to 10, 37-46).
// total 46 characters. string index as above.
getting_tile:boolean=False; // global lock
abort_map:boolean=False;
map_loading_in_progress:boolean=False;
stop_loading:boolean=False;
pause_loading:boolean=False;
base_width:extended=4000; // arbitrary init ...
base_height:extended=2000;
map_exists:boolean=False; // 227a
manual_tile_url_str:string=''; // 229d
nls_legal_done:boolean=False; // 233d
function get_tile_extents(map_str:string):boolean;forward;
//______________________________________________________________________________
procedure Tmap_loader_form.FormCreate(Sender: TObject);
begin
ClientWidth:=956;
ClientHeight:=752;
AutoScroll:=True;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label3Click(Sender: TObject);
begin
Label3.Font.color:=clBlue;
go_to_url('https://www.thunderforest.com/');
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label4Click(Sender: TObject);
begin
Label4.Font.color:=clBlue;
go_to_url('https://www.thunderforest.com/maps/transport-dark/');
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label5Click(Sender: TObject);
begin
Label5.Font.color:=clBlue;
go_to_url('https://openstreetmap.org');
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label6Click(Sender: TObject);
begin
Label6.Font.color:=clBlue;
go_to_url('https://openstreetmap.org/about');
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label14Click(Sender: TObject);
begin
Label14.Font.color:=clBlue;
go_to_url('https://maps.nls.uk/geo/explore/#zoom=15&lat=51.9996&lon=-0.9989&layers=10');
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label24Click(Sender: TObject);
begin
Label24.Font.color:=clBlue;
go_to_url('https://maps.nls.uk/');
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label25Click(Sender: TObject);
begin
go_to_url('https://maps.nls.uk/os/6inch-2nd-and-later/index.html');
end;
//______________________________________________________________________________
procedure Tmap_loader_form.location_groupboxMouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label14.Font.color:=clBlue;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label3MouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label3.Font.color:=clRed;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label4MouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label4.Font.color:=clRed;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label5MouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label5.Font.color:=clRed;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label6MouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label6.Font.color:=clRed;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label14MouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label14.Font.color:=clRed;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.Label24MouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label24.Font.color:=clRed;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.FormMouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
begin
Label3.Font.color:=clBlue;
Label4.Font.color:=clBlue;
Label5.Font.color:=clBlue;
Label6.Font.color:=clBlue;
Label14.Font.color:=clBlue;
Label24.Font.color:=clBlue;
info_label.Font.color:=clBlue;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.lon_editEnter(Sender: TObject); // also lat edit Enter , lat_lon radio click
begin
location_code:=0; // 0=long/lat, 1=OS Grid, 2=URL
lat_lon_radio_button.Checked:=True;
lon_edit.Font.Color:=clBlue;
lat_edit.Font.Color:=clBlue;
url_edit.Font.Color:=clGray;
os_letters_edit.Font.Color:=clGray;
os_easting_edit.Font.Color:=clGray;
os_northing_edit.Font.Color:=clGray;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.os_letters_editEnter(Sender: TObject);
begin
location_code:=1; // 0=long/lat, 1=OS Grid, 2=URL
os_grid_radio_button.Checked:=True;
lon_edit.Font.Color:=clGray;
lat_edit.Font.Color:=clGray;
url_edit.Font.Color:=clGray;
os_letters_edit.Font.Color:=clBlue;
os_easting_edit.Font.Color:=clBlue;
os_northing_edit.Font.Color:=clBlue;
end;
//______________________________________________________________________________
procedure Tmap_loader_form.url_editEnter(Sender: TObject);
begin
location_code:=2; // 0=long/lat, 1=OS Grid, 2=URL
url_radio_button.Checked:=True;
lon_edit.Font.Color:=clGray;
lat_edit.Font.Color:=clGray;
os_letters_edit.Font.Color:=clGray;
os_easting_edit.Font.Color:=clGray;
os_northing_edit.Font.Color:=clGray;
url_edit.Font.Color:=clBlue;
end;
//______________________________________________________________________________
function format_his_name:string;
var
n:integer;
name_str:string;
begin
RESULT:=''; // init
name_str:=Copy(Trim(map_loader_form.name_edit.Text)+' ',1,15); // pad with spaces to 15 characters
// check and remove any UTF or control chars in his name ..
for n:=1 to Length(name_str) do begin
if (Ord(name_str[n])<32) or (Ord(name_str[n])>127) or (name_str[n]='#') then name_str[n]:='_'; // # is our separator
end;//next
RESULT:=name_str;
end;
//______________________________________________________________________________
procedure got_tile;
var
new_shape:Tbgnd_shape;
n:integer;
load_picture:TPicture;
begin
new_shape:=init_bgnd_shape; // 234b
with new_shape do begin
// defaults ...
shape_name:=tile_name_str; // global
shape_code:=-1; // -1=picture
shape_style:=0; // not used
wrap_offset:=0;
show_transparent:=False; // map_loader_form.transparent_checkbox.Checked; // map_transparent;
picture_is_metafile:=False;
hide_bits:=0; // normal visibility
option_bits:=$80; // msb=1 tile
p1.x:=map_org_x+map_tile_count_x*map_tile_size_mm;
p1.y:=map_org_y+(map_num_tiles_y-map_tile_count_y-1)*map_tile_size_mm;
p2.x:=p1.x+map_tile_size_mm; // square ..
p2.y:=p1.y+map_tile_size_mm;
rect_rot:=0; // 234b
end;//with
with bgnd_form.bgnd_shapes_listbox do begin
n:=Items.AddObject(new_shape.shape_name,Tbgshape.Create); // create and insert a new entry in the shapes list.
Tbgshape(Items.Objects[n]).bgnd_shape:=new_shape; // put data in list.
ItemIndex:=n; // make it current.
with Tbgshape(Items.Objects[n]) do begin
bgimage:=Tbgimage.Create; // create new image 3-2-01.
with bgimage.image_shape do begin
image_bitmap:=TBitmap.Create;
rotated_bitmap:=TBitmap.Create;
(* // OT2024
image_metafile:=TMetafile.Create; // 213b
rotated_metafile:=TMetafile.Create; // 213b
*)
rotated_picture:=TPicture.Create;
load_picture:=TPicture.Create; //0.93.a
try
case map_src_code of
0,1,4,5,6,7: load_picture.LoadFromFile(exe_str+'internal\tile\nls_tile.png'); // NLS PNG
2: load_picture.LoadFromFile(exe_str+'internal\tile\tfp_tile.png'); // Thunderforest PNG
3: load_picture.LoadFromFile(exe_str+'internal\tile\osm_tile.png'); // OpenStreetMap PNG
else load_picture.LoadFromFile(exe_str+'internal\empty_picture.bmp'); // ??? invalid map_src_code for tiled maps
end;//case
image_bitmap.Assign(load_picture.Graphic);
image_bitmap.PixelFormat:=pf24bit; // for deeper zooming (was probably 32 bit)
image_width:=image_bitmap.Width;
image_height:=image_bitmap.Height;
finally
load_picture.Free;
end;//try
end;//with
end;//with
copy_draw_to_pad; // remove any previous highlighting
ItemIndex:=n;
draw_bg_shapes(pad_form.Canvas,ItemIndex,clRed); // show new bitmap and highlight in red, directly on the pad.
end;//with
shapes_saved:=False; // need a resave.
shapes_current_state;
do_rollback:=False; // no need to put this change in rollback register on redraw.
redraw(True);
end;
//______________________________________________________________________________
function obtain_tile_from_server(zoom_str,xtile_str,ytile_str:string):boolean;
var
map_str,get_map_str:string;
http_count:integer;
http_result:Boolean;
// OT2024 http_sender:THTTPSend;
file_str:string;
no_tile_str:string;
county_str:string;
str,z_str:string;
map_server_list:TStringList;
//////////////////////////////////////////////////////////////////
function get_a_tile(co_str:string):boolean;
var
short_co_str:string;
map_list_index:integer;
begin
RESULT:=False; // init
(* // OT2024
// 0=NLS historic 25-inch (tiled) 1=NLS 50-inch (tiled) 2=Thunderforest(tiled) 3=OpenStreetMap(tiled) 4=NLS 60-inch (tiled)
// 5=NLS modern 25-inch(tiled) 6=NLS town plans 60-inch 7=NLS town plans 125-inch //no longer used 8=URL(screenshot)
if map_src_code=0 // NLS 25-inch
then begin
DeleteFile(exe_str+'internal\tile\nls_tile.png'); // if it already exists
file_str:=exe_str+'internal\tile\nls_tile.png'; // save file to
short_co_str:=StringReplace(co_str,'shire','',[]);
with map_server_list do begin
Clear;
if manual_tile_url_str<>'' then Add(manual_tile_url_str); // try this one first
if co_str<>'Scotland' // search England & Wales first...
then begin
Add('http://geo.nls.uk/mapdata2/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata2/os/25_inch/'+short_co_str);
Add('http://geo.nls.uk/mapdata3/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata3/os/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+short_co_str);
co_str:=LowerCase(co_str); // and again all lower case...
short_co_str:=LowerCase(short_co_str);
Add('http://geo.nls.uk/mapdata2/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata2/os/25_inch/'+short_co_str);
Add('http://geo.nls.uk/mapdata3/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata3/os/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+short_co_str);
Add('http://geo.nls.uk/mapdata3/os/25_inch/wales');
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/Shrop_Derby');
Add('http://geo.nls.uk/mapdata3/os/25_inch_holes_england'); // 229d Manchester
Add('http://geo.nls.uk/mapdata3/os/25_inch/holes_england');
Add('http://geo.nls.uk/mapdata2/os/25_inch/holes_england');
Add('http://geo.nls.uk/mapdata2/os/25_inch/scotland_1');
Add('http://geo.nls.uk/mapdata2/os/25_inch/scotland_2');
Add('http://geo.nls.uk/mapdata3/os/25_inch/scotland_1');
Add('http://geo.nls.uk/mapdata3/os/25_inch/scotland_2');
Add('http://geo.nls.uk/mapdata3/os/scotland_1250_country');
Add('http://geo.nls.uk/mapdata2/os/scotland_1250_country');
Add('http://geo.nls.uk/mapdata3/os/scotland_1250_2500_1969');
Add('http://geo.nls.uk/mapdata2/os/scotland_1250_2500_1969');
end
else begin // search Sctotland first...
Add('http://geo.nls.uk/mapdata2/os/25_inch/scotland_1');
Add('http://geo.nls.uk/mapdata2/os/25_inch/scotland_2');
Add('http://geo.nls.uk/mapdata3/os/25_inch/scotland_1');
Add('http://geo.nls.uk/mapdata3/os/25_inch/scotland_2');
Add('http://geo.nls.uk/mapdata3/os/scotland_1250_country');
Add('http://geo.nls.uk/mapdata2/os/scotland_1250_country');
Add('http://geo.nls.uk/mapdata3/os/scotland_1250_2500_1969');
Add('http://geo.nls.uk/mapdata2/os/scotland_1250_2500_1969');
Add('http://geo.nls.uk/mapdata2/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata2/os/25_inch/'+short_co_str);
Add('http://geo.nls.uk/mapdata3/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata3/os/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+short_co_str);
co_str:=LowerCase(co_str); // and again all lower case...
short_co_str:=LowerCase(short_co_str);
Add('http://geo.nls.uk/mapdata2/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata2/os/25_inch/'+short_co_str);
Add('http://geo.nls.uk/mapdata3/os/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://geo.nls.uk/mapdata3/os/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/'+short_co_str);
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+co_str);
if short_co_str<>co_str then Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/'+short_co_str);
Add('http://geo.nls.uk/mapdata3/os/25_inch/wales');
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/Shrop_Derby');
Add('http://geo.nls.uk/mapdata3/os/25_inch_holes_england'); // 229d Manchester
Add('http://geo.nls.uk/mapdata3/os/25_inch/holes_england');
Add('http://geo.nls.uk/mapdata2/os/25_inch/holes_england');
end;
Add('http://geo.nls.uk/mapdata3/os/25_inch/gloucester');
Add('http://geo.nls.uk/mapdata3/os/25_inch/gloucester_1st');
Add('http://geo.nls.uk/mapdata3/os/25_inch/gloucester_2nd');
Add('http://geo.nls.uk/mapdata3/os/25_inch/gloucester_3rd');
Add('http://geo.nls.uk/mapdata3/os/25_inch/gloucester_additions');
Add('http://geo.nls.uk/mapdata2/os/25_inch/gloucester');
Add('http://geo.nls.uk/mapdata2/os/25_inch/gloucester_1st');
Add('http://geo.nls.uk/mapdata2/os/25_inch/gloucester_2nd');
Add('http://geo.nls.uk/mapdata2/os/25_inch/gloucester_3rd');
Add('http://geo.nls.uk/mapdata2/os/25_inch/gloucester_additions');
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/gloucester');
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/gloucester_1st');
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/gloucester_2nd');
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/gloucester_3rd');
Add('http://mapseries-tilesets.s3.amazonaws.com/25_inch/gloucester_additions');
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/gloucester');
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/gloucester_1st');
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/gloucester_2nd');
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/gloucester_3rd');
Add('http://mapseries-tilesets.s2.amazonaws.com/25_inch/gloucester_additions');
end;//with
end;//code 0
if map_src_code=1 // NLS 50-inch
then begin
DeleteFile(exe_str+'internal\tile\nls_tile.png'); // if it already exists
file_str:=exe_str+'internal\tile\nls_tile.png'; // save file to
with map_server_list do begin
Clear;
if manual_tile_url_str<>'' then Add(manual_tile_url_str); // try this one first
Add('http://mapseries-tilesets.s3.amazonaws.com/london_1940s');
Add('http://mapseries-tilesets.s3.amazonaws.com/edinburgh_1250');
Add('http://mapseries-tilesets.s3.amazonaws.com/os/scotland_1250_country');
end;//with
end;//code 1
if map_src_code=5 // NLS modern 25-inch
then begin
DeleteFile(exe_str+'internal\tile\nls_tile.png'); // if it already exists
file_str:=exe_str+'internal\tile\nls_tile.png'; // save file to
with map_server_list do begin
Clear;
if manual_tile_url_str<>'' then Add(manual_tile_url_str); // try this one first
Add('http://mapseries-tilesets.s3.amazonaws.com/scotland_2500_doubles');
Add('http://geo.nls.uk/mapdata2/os/2500_1970');
end;//with
end;//code 5
// 0=NLS historic 25-inch (tiled) 1=NLS 50-inch (tiled) 2=Thunderforest(tiled) 3=OpenStreetMap(tiled) 4=NLS 60-inch (tiled)
// 5=NLS modern 25-inch(tiled) 6=NLS town plans 60-inch 7=NLS town plans 125-inch //no longer used 8=URL(screenshot)
if (map_src_code=6) or (map_src_code=7) // NLS town plans 60-inch or 125-inch
then begin
DeleteFile(exe_str+'internal\tile\nls_tile.png'); // if it already exists
file_str:=exe_str+'internal\tile\nls_tile.png'; // save file to
with map_server_list do begin
Clear;
if manual_tile_url_str<>'' then Add(manual_tile_url_str); // try this one first
Add('http://geo.nls.uk/mapdata3/os/town_england/North');
Add('http://geo.nls.uk/mapdata3/os/town_england/Midlands_East');
Add('http://geo.nls.uk/mapdata3/os/town_england/Midlands_West');
Add('http://geo.nls.uk/mapdata3/os/town_england/South');
Add('http://geo.nls.uk/mapdata3/os/town_england/Wales');
// more needed...
Add('http://geo.nls.uk/mapdata3/os/town_england/Bolton');
Add('http://geo.nls.uk/mapdata3/os/town_england/Swindon');
end;//with
end;//code 6 or 7
if map_src_code=2 // Thunderforest
then begin
DeleteFile(exe_str+'internal\tile\tfp_tile.png'); // if it already exists
file_str:=exe_str+'internal\tile\tfp_tile.png'; // save file to
if map_loader_form.tfp_radio.Checked=True
then map_str:='http://tile.thunderforest.com/pioneer/'+zoom_str+'/'+xtile_str+'/'+ytile_str+'.png?apikey=8511e4ab37b84c44bd55d19c08df49e5'
else if map_loader_form.tfo_radio.Checked=True
then map_str:='http://tile.thunderforest.com/outdoors/'+zoom_str+'/'+xtile_str+'/'+ytile_str+'.png?apikey=8511e4ab37b84c44bd55d19c08df49e5'
else map_str:='http://tile.thunderforest.com/transport-dark/'+zoom_str+'/'+xtile_str+'/'+ytile_str+'.png?apikey=8511e4ab37b84c44bd55d19c08df49e5'; // where from
end;
if map_src_code=3 // OpenStreetMap
then begin
DeleteFile(exe_str+'internal\tile\osm_tile.png'); // if it already exists
file_str:=exe_str+'internal\tile\osm_tile.png'; // save file to
// OSM transport map uses Thundeforest version...
map_str:='http://tile.thunderforest.com/transport/'+zoom_str+'/'+xtile_str+'/'+ytile_str+'.png?apikey=8511e4ab37b84c44bd55d19c08df49e5';
end;
if map_src_code=4 // NLS 60-inch London
then begin
DeleteFile(exe_str+'internal\tile\nls_tile.png'); // if it already exists
file_str:=exe_str+'internal\tile\nls_tile.png'; // save file to
map_str:='http://mapseries-tilesets.s3.amazonaws.com/london_1890s/'+zoom_str+'/'+xtile_str+'/'+ytile_str+'.png';
end;
if (map_src_code=0) or (map_src_code=1) or (map_src_code=5) or (map_src_code=6) or (map_src_code=7)
then begin
with map_server_list do begin
for map_list_index:=0 to (Count-1) do begin
get_map_str:=Strings[map_list_index]+'/'+zoom_str+'/'+xtile_str+'/'+ytile_str+'.png';
http_sender:=THTTPSend.Create;
http_result:=http_sender.HTTPMethod('GET',get_map_str);
if (http_sender.ResultCode>=100) and (http_sender.ResultCode<=299)
then begin
http_sender.Document.SaveToFile(file_str);
got_tile; // put in background shapes
getting_tile:=False; // ready for another one global
RESULT:=True;
abort_map:=False; // more tiles ok
http_sender.Free;
BREAK;
end
else begin
http_sender.Free;
Sleep(5);
CONTINUE;
end;
end;//next server
end;//with
end
else begin // other codes 2, 3, 4
http_sender:=THTTPSend.Create;
http_result:=http_sender.HTTPMethod('GET',map_str);
if (http_sender.ResultCode>=100) and (http_sender.ResultCode<=299)
then begin
http_sender.Document.SaveToFile(file_str);
got_tile; // put in background shapes
getting_tile:=False; // ready for another one global
RESULT:=True;
abort_map:=False; // more tiles ok
end;
http_sender.Free;
end;
*) // OT2024
end;
//////////////////////////////////////////////////////////////////
procedure get_county_tile_loc;
begin
county_str:=StringReplace(county_str,'Gloucestershire early','gloucester',[]);
county_str:=StringReplace(county_str,'Devon early','devon',[]);
county_str:=StringReplace(county_str,'Somerset early','somerset1',[]);
county_str:=StringReplace(county_str,'Wiltshire early','wiltshire',[]);
county_str:=StringReplace(county_str,'Gloucestershire later','gloucester2nd',[]);
county_str:=StringReplace(county_str,'Devon later','devon2nd',[]);
county_str:=StringReplace(county_str,'Somerset later','somerset',[]);
county_str:=StringReplace(county_str,'Wiltshire later','wiltshire2nd',[]);
county_str:=StringReplace(county_str,'Gloucestershire 1920s','gloucester_3rd',[]);
end;
//////////////////////////////////////////////////////////////////
begin
RESULT:=False; // init
abort_map:=True; // init fail
if map_src_code>7 then EXIT; // ??? not a tiled map
bgnd_form.picture_borders_checkbox.Checked:=True; // 233d show tile borders while loading
Sleep(5); // don't call server more than once every 5ms.
http_count:=0; // init reset
repeat
if getting_tile=False
then BREAK
else Sleep(100); // wait for previous tile to finish 1/10th second
INC(http_count);
if http_count>120 // 12 seconds
then begin
ShowMessage('Sorry, unable to obtain the map tile. The server is taking too long to respond.'+#13+#13+'Please check your internet connection.');
EXIT;
end;
until 0<>0;
getting_tile:=True; // global lock
// create shape name = map name (padded with spaces to 20 chars) + map_src_code(1) + spare(1) + zoom_level(padded to 2) + separator(#) + xtile_str(padded to 10) + separator(#) + ytile_str(padded to 10).
tile_name_str:=map_name_str+Copy(IntToStr(map_src_code),1,1)+'T'+Copy(zoom_str+' ',1,2)+'#'+Copy(xtile_str+' ',1,10)+'#'+Copy(ytile_str+' ',1,10);
map_str:=''; // init
get_map_str:='';
map_server_list:=TStringList.Create;
if map_src_code=0 // NLS 25-inch
then begin
with map_loader_form.county_combo do begin
if ItemIndex<0
then county_str:='Scotland' // default if not selected
else begin
county_str:=Trim(Items.Strings[ItemIndex]);
get_county_tile_loc;
end;
end;//with
if get_a_tile(county_str)=False // try again in next county
then begin
with map_loader_form.next_county_combo do begin
if ItemIndex<0
then county_str:='Scotland' // default if not selected