| 1 |
%% The LaTeX package mercatormap - version 1.3.0 (2026/02/19) |
| 2 |
%% mercatormap.sty: geographic coordinates (Mercator projection) and map tiles for TikZ pictures |
| 3 |
%% |
| 4 |
%% ------------------------------------------------------------------------------------------- |
| 5 |
%% Copyright (c) 2020-2026 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> |
| 6 |
%% ------------------------------------------------------------------------------------------- |
| 7 |
%% |
| 8 |
%% This work may be distributed and/or modified under the |
| 9 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 10 |
%% of this license or (at your option) any later version. |
| 11 |
%% The latest version of this license is in |
| 12 |
%% http://www.latex-project.org/lppl.txt |
| 13 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 14 |
%% version 2005/12/01 or later. |
| 15 |
%% |
| 16 |
%% This work has the LPPL maintenance status `author-maintained'. |
| 17 |
%% |
| 18 |
%% This work consists of all files listed in README |
| 19 |
%% |
| 20 |
\NeedsTeXFormat{LaTeX2e}[2023-11-01] |
| 21 |
\ProvidesExplPackage{mercatormap}{2026/02/19}{1.3.0} |
| 22 |
{A Web Mercator projection package with map tile support} |
| 23 |
|
| 24 |
\RequirePackage{siunitx,graphicx,tikz} |
| 25 |
|
| 26 |
\ExplSyntaxOff |
| 27 |
% space character problem if within explSyntax |
| 28 |
\usetikzlibrary{shadings} |
| 29 |
\ExplSyntaxOn |
| 30 |
|
| 31 |
%\debug_on:n {all} |
| 32 |
|
| 33 |
|
| 34 |
\ProvideExpandableDocumentCommand \mrcpkgprefix {}{} |
| 35 |
|
| 36 |
\NewDocumentCommand\mermapset{ m } { \keys_set:nn { mermap } {#1} } |
| 37 |
\NewDocumentCommand\mermapsetsupply{ m } { \keys_set:nn { mermap/supply } {#1} } |
| 38 |
\NewDocumentCommand\mermapsetmarker{ m } { \keys_set:nn { mermap/marker } {#1} } |
| 39 |
|
| 40 |
|
| 41 |
%---- scratch variables -------------------------------------------------------- |
| 42 |
|
| 43 |
\box_new:N \l__mermap_tmpa_box |
| 44 |
|
| 45 |
\clist_new:N \l__mermap_tmpa_clist |
| 46 |
|
| 47 |
\dim_new:N \l__mermap_tmpa_dim |
| 48 |
\dim_new:N \l__mermap_tmpb_dim |
| 49 |
|
| 50 |
\fp_new:N \l__mermap_tmpa_fp |
| 51 |
\fp_new:N \l__mermap_tmpb_fp |
| 52 |
|
| 53 |
\tl_new:N \g__mermap_tmpa_tl |
| 54 |
\tl_new:N \l__mermap_tmpa_tl |
| 55 |
\tl_new:N \l__mermap_tmpb_tl |
| 56 |
|
| 57 |
%---- constants ---------------------------------------------------------------- |
| 58 |
|
| 59 |
\fp_const:Nn \c__mermap_scale_radius_fp { 6371*pi/180 } |
| 60 |
\fp_const:Nn \c__mermap_mean_radius_fp { 637100000cm } |
| 61 |
\fp_const:Nn \c__mermap_mile_fp { 1.609344 } |
| 62 |
|
| 63 |
|
| 64 |
%---- map definition ----------------------------------------------------------- |
| 65 |
|
| 66 |
\dim_new:N \l__mermap_tile_size_dim |
| 67 |
|
| 68 |
\fp_new:N \l__mermap_mapeast_fp |
| 69 |
\fp_new:N \l__mermap_mapnorth_fp |
| 70 |
\fp_new:N \l__mermap_mapsouth_fp |
| 71 |
\fp_new:N \l__mermap_mapwest_fp |
| 72 |
\fp_new:N \l__mermap_tex_height_fp |
| 73 |
\fp_new:N \l__mermap_tex_width_fp |
| 74 |
\fp_new:N \l__mermap_tile_northoffset_fp |
| 75 |
\fp_new:N \l__mermap_tile_southoffset_fp |
| 76 |
\fp_new:N \l__mermap_tile_westoffset_fp |
| 77 |
|
| 78 |
\int_new:N \l__mermap_tile_xmax_int |
| 79 |
\int_new:N \l__mermap_tile_xmin_int |
| 80 |
\int_new:N \l__mermap_tile_ymax_int |
| 81 |
\int_new:N \l__mermap_tile_ymin_int |
| 82 |
\int_new:N \l__mermap_tile_zoom_int |
| 83 |
|
| 84 |
\tl_new:N \l__mermap_attribution_print_tl |
| 85 |
\tl_new:N \l__mermap_attribution_tl |
| 86 |
\tl_new:N \l__mermap_pixel_height_tl |
| 87 |
\tl_new:N \l__mermap_pixel_width_tl |
| 88 |
\tl_new:N \l__mermap_tile_basename_tl |
| 89 |
\tl_new:N \l__mermap_tile_resource_tl |
| 90 |
|
| 91 |
|
| 92 |
\keys_define:nn { mermap/mapdef } |
| 93 |
{ |
| 94 |
west .fp_set:N = \l__mermap_mapwest_fp, |
| 95 |
east .fp_set:N = \l__mermap_mapeast_fp, |
| 96 |
north .fp_set:N = \l__mermap_mapnorth_fp, |
| 97 |
south .fp_set:N = \l__mermap_mapsouth_fp, |
| 98 |
zoom .int_set:N = \l__mermap_tile_zoom_int, |
| 99 |
xmin .int_set:N = \l__mermap_tile_xmin_int, |
| 100 |
ymin .int_set:N = \l__mermap_tile_ymin_int, |
| 101 |
xmax .int_set:N = \l__mermap_tile_xmax_int, |
| 102 |
ymax .int_set:N = \l__mermap_tile_ymax_int, |
| 103 |
pixelwidth .tl_set:N = \l__mermap_pixel_width_tl, |
| 104 |
pixelheight .tl_set:N = \l__mermap_pixel_height_tl, |
| 105 |
westoffset .fp_set:N = \l__mermap_tile_westoffset_fp, |
| 106 |
northoffset .fp_set:N = \l__mermap_tile_northoffset_fp, |
| 107 |
southoffset .fp_set:N = \l__mermap_tile_southoffset_fp, |
| 108 |
basename .tl_set:N = \l__mermap_tile_basename_tl, |
| 109 |
resource .tl_set:N = \l__mermap_tile_resource_tl, |
| 110 |
attribution .tl_set:N = \l__mermap_attribution_tl, |
| 111 |
attribution~print .tl_set:N = \l__mermap_attribution_print_tl, |
| 112 |
tile~size .dim_set:N = \l__mermap_tile_size_dim, |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
\NewDocumentCommand{\mrcdefinemap}{ m } |
| 117 |
{ |
| 118 |
\keys_set:nn { mermap/mapdef } |
| 119 |
{ |
| 120 |
west=11, |
| 121 |
east=13, |
| 122 |
north=50, |
| 123 |
south=48, |
| 124 |
zoom=9, |
| 125 |
xmin=271, |
| 126 |
ymin=173, |
| 127 |
xmax=275, |
| 128 |
ymax=177, |
| 129 |
pixelwidth=100, |
| 130 |
pixelheight=100, |
| 131 |
westoffset=0, |
| 132 |
northoffset=0, |
| 133 |
southoffset=0, |
| 134 |
basename=tiles/tile, |
| 135 |
resource=none, |
| 136 |
attribution=, |
| 137 |
attribution~print=, |
| 138 |
#1 |
| 139 |
} |
| 140 |
\__mermap_reset: |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
%---- coordinate system -------------------------------------------------------- |
| 146 |
|
| 147 |
\fp_new:N \l__mermap_cs_lat_fp |
| 148 |
\fp_new:N \l__mermap_cs_lon_fp |
| 149 |
\fp_new:N \l__mermap_cs_southreference_fp |
| 150 |
\fp_new:N \l__mermap_cs_x_fp |
| 151 |
\fp_new:N \l__mermap_cs_xfactor_fp |
| 152 |
\fp_new:N \l__mermap_cs_y_fp |
| 153 |
\fp_new:N \l__mermap_cs_yfactor_fp |
| 154 |
\fp_new:N \l__mermap_result_fp |
| 155 |
\fp_new:N \l__mermap_scale_denominator_fp |
| 156 |
\fp_new:N \l__mermap_scale_fp |
| 157 |
\fp_new:N \l__mermap_vic_dim_fp |
| 158 |
\fp_new:N \l__mermap_vic_east_fp |
| 159 |
\fp_new:N \l__mermap_vic_north_fp |
| 160 |
\fp_new:N \l__mermap_vic_south_fp |
| 161 |
\fp_new:N \l__mermap_vic_west_fp |
| 162 |
\fp_new:N \l__mermap_vic_westeast_fp |
| 163 |
\fp_new:N \l__mermap_westeast_fp |
| 164 |
|
| 165 |
\int_new:N \l__mermap_tile_number_int |
| 166 |
|
| 167 |
|
| 168 |
\keys_define:nn { mermap } |
| 169 |
{ |
| 170 |
vicinity .fp_set:N = \l__mermap_vic_dim_fp |
| 171 |
} |
| 172 |
\keys_set:nn { mermap } { vicinity=2cm } |
| 173 |
|
| 174 |
|
| 175 |
\NewExpandableDocumentCommand\mrcmapwest{}{\fp_to_decimal:N \l__mermap_mapwest_fp} |
| 176 |
\NewExpandableDocumentCommand\mrcmapeast{}{\fp_to_decimal:N \l__mermap_mapeast_fp} |
| 177 |
\NewExpandableDocumentCommand\mrcmapnorth{}{\fp_to_decimal:N \l__mermap_mapnorth_fp} |
| 178 |
\NewExpandableDocumentCommand\mrcmapsouth{}{\fp_to_decimal:N \l__mermap_mapsouth_fp} |
| 179 |
\NewExpandableDocumentCommand\mrcpixelwidth{}{\tl_use:N \l__mermap_pixel_width_tl} |
| 180 |
\NewExpandableDocumentCommand\mrcpixelheight{}{\tl_use:N \l__mermap_pixel_height_tl} |
| 181 |
\NewDocumentCommand\mrcmapattribution{}{\tl_use:N \l__mermap_attribution_tl} |
| 182 |
\NewDocumentCommand\mrcmapattributionprint{}{\tl_use:N \l__mermap_attribution_print_tl} |
| 183 |
\NewExpandableDocumentCommand\mrctexwidth{}{\fp_to_dim:N \l__mermap_tex_width_fp} |
| 184 |
\NewExpandableDocumentCommand\mrctexheight{}{\fp_to_dim:N \l__mermap_tex_height_fp} |
| 185 |
\NewExpandableDocumentCommand\mrcscale{}{\fp_to_decimal:N \l__mermap_scale_fp} |
| 186 |
\NewExpandableDocumentCommand\mrcmapscaledenominator{}{\fp_to_decimal:N \l__mermap_scale_denominator_fp} |
| 187 |
|
| 188 |
|
| 189 |
\cs_new_nopar:Npn \__mermap_reset: |
| 190 |
{ |
| 191 |
\int_set:Nn \l__mermap_tile_number_int { \fp_to_int:n { 2^\l__mermap_tile_zoom_int }} |
| 192 |
\fp_set:Nn \l__mermap_westeast_fp { \l__mermap_mapeast_fp-\l__mermap_mapwest_fp } |
| 193 |
\fp_set:Nn \l__mermap_cs_xfactor_fp { \l__mermap_tile_size_dim*\l__mermap_tile_number_int/360 } |
| 194 |
\fp_set:Nn \l__mermap_cs_yfactor_fp { \l__mermap_tile_size_dim*\l__mermap_tile_number_int/2pi } |
| 195 |
\fp_set:Nn \l__mermap_cs_southreference_fp { tand(\l__mermap_mapsouth_fp/2+45) } |
| 196 |
|
| 197 |
\__mermap_longitude_to_x:n { \l__mermap_mapwest_fp } |
| 198 |
\__mermap_x_to_longitude:n { \l__mermap_cs_x_fp - \l__mermap_vic_dim_fp } |
| 199 |
\fp_set_eq:NN \l__mermap_vic_west_fp \l__mermap_cs_lon_fp |
| 200 |
|
| 201 |
\__mermap_longitude_to_x:n { \l__mermap_mapeast_fp } |
| 202 |
\__mermap_x_to_longitude:n { \l__mermap_cs_x_fp + \l__mermap_vic_dim_fp } |
| 203 |
\fp_set_eq:NN \l__mermap_vic_east_fp \l__mermap_cs_lon_fp |
| 204 |
|
| 205 |
\__mermap_latitude_to_y:n { \l__mermap_mapsouth_fp } |
| 206 |
\__mermap_y_to_latitude:n { \l__mermap_cs_y_fp - \l__mermap_vic_dim_fp } |
| 207 |
\fp_set_eq:NN \l__mermap_vic_south_fp \l__mermap_cs_lat_fp |
| 208 |
|
| 209 |
\__mermap_latitude_to_y:n { \l__mermap_mapnorth_fp } |
| 210 |
\fp_set_eq:NN \l__mermap_tex_height_fp \l__mermap_cs_y_fp |
| 211 |
\__mermap_y_to_latitude:n { \l__mermap_cs_y_fp + \l__mermap_vic_dim_fp } |
| 212 |
\fp_set_eq:NN \l__mermap_vic_north_fp \l__mermap_cs_lat_fp |
| 213 |
|
| 214 |
\fp_set:Nn \l__mermap_tex_width_fp { \l__mermap_westeast_fp*\l__mermap_cs_xfactor_fp } |
| 215 |
|
| 216 |
\fp_set:Nn \l__mermap_vic_westeast_fp { \l__mermap_vic_east_fp - \l__mermap_vic_west_fp } |
| 217 |
|
| 218 |
\__mermap_mean_latitude:NN \l__mermap_mapsouth_fp \l__mermap_mapnorth_fp |
| 219 |
\fp_set:Nn \l__mermap_scale_denominator_fp { 2*\c__mermap_mean_radius_fp |
| 220 |
*cosd(\l__mermap_result_fp)*pi/\l__mermap_tile_number_int/\l__mermap_tile_size_dim } |
| 221 |
\fp_set:Nn \l__mermap_scale_fp { \l__mermap_scale_denominator_fp / (1cm*100000) } |
| 222 |
|
| 223 |
\__mermap_if_inside_picture_environment:T |
| 224 |
{ |
| 225 |
\node[name=mrcmap,at={(0,0)},above~right, |
| 226 |
line~width=0mm,inner~sep=0mm,outer~sep=0mm,draw=none,fill=none,rectangle, |
| 227 |
minimum~width=\mrctexwidth,minimum~height=\mrctexheight]{}; |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
\cs_new_nopar:Npn \__mermap_mean_latitude:NN #1#2 |
| 233 |
{ |
| 234 |
\fp_set:Nn \l__mermap_result_fp { 2*atand(sqrt(tand(#1/2+45)*tand(#2/2+45))) - 90 } |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
\cs_new_nopar:Npn \__mermap_longitude_to_x:n #1 |
| 239 |
{ |
| 240 |
\fp_set:Nn \l__mermap_tmpa_fp { #1-\l__mermap_mapwest_fp } |
| 241 |
\fp_sub:Nn \l__mermap_tmpa_fp { 360*floor(\l__mermap_tmpa_fp/360) } |
| 242 |
\fp_set:Nn \l__mermap_tmpa_fp |
| 243 |
{ \l__mermap_tmpa_fp>\l__mermap_westeast_fp |
| 244 |
?(\l__mermap_tmpa_fp-\l__mermap_westeast_fp>360-\l__mermap_tmpa_fp |
| 245 |
?\l__mermap_tmpa_fp-360 |
| 246 |
:\l__mermap_tmpa_fp) |
| 247 |
:\l__mermap_tmpa_fp |
| 248 |
} |
| 249 |
\fp_set:Nn \l__mermap_cs_x_fp { \l__mermap_tmpa_fp*\l__mermap_cs_xfactor_fp } |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
\cs_new_nopar:Npn \__mermap_latitude_to_y:n #1 |
| 254 |
{ |
| 255 |
\fp_set:Nn \l__mermap_cs_y_fp |
| 256 |
{ |
| 257 |
ln( tand((#1)/2+45)/\l__mermap_cs_southreference_fp ) * \l__mermap_cs_yfactor_fp |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
\cs_new_nopar:Npn \__mermap_x_to_longitude:n #1 |
| 263 |
{ |
| 264 |
\fp_set:Nn \l__mermap_cs_lon_fp { \l__mermap_mapwest_fp+(#1)/\l__mermap_cs_xfactor_fp } |
| 265 |
} |
| 266 |
|
| 267 |
|
| 268 |
\cs_new_nopar:Npn \__mermap_y_to_latitude:n #1 |
| 269 |
{ |
| 270 |
\fp_set:Nn \l__mermap_cs_lat_fp |
| 271 |
{ |
| 272 |
2*atand( \l__mermap_cs_southreference_fp*exp((#1)/\l__mermap_cs_yfactor_fp) ) - 90 |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
\cs_new_nopar:Npn \__mermap_pgfpoint:nn #1#2 |
| 278 |
{ |
| 279 |
\__mermap_latitude_to_y:n {#1} |
| 280 |
\__mermap_longitude_to_x:n {#2} |
| 281 |
\pgfpoint{\fp_to_dim:N \l__mermap_cs_x_fp} |
| 282 |
{\fp_to_dim:N \l__mermap_cs_y_fp} |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
\use:x |
| 287 |
{ |
| 288 |
\cs_new_nopar:Npn \exp_not:N\__mermap_pgfpoint:w ##1 \c_colon_str ##2 \exp_not:N \q_stop |
| 289 |
} |
| 290 |
{ |
| 291 |
\__mermap_pgfpoint:nn {#1}{#2} |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
\cs_new_nopar:Npn \__mermap_pgfpoint:n #1 |
| 296 |
{ |
| 297 |
\__mermap_pgfpoint:w #1 \q_stop |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
\NewDocumentCommand{\mrcpgfpoint}{ mm }{ \__mermap_pgfpoint:nn {#1}{#2} } |
| 302 |
|
| 303 |
|
| 304 |
\keys_define:nn { mermap/cs } |
| 305 |
{ |
| 306 |
latitude .code:n = \__mermap_latitude_to_y:n {#1}, |
| 307 |
longitude .code:n = \__mermap_longitude_to_x:n{#1}, |
| 308 |
lat .code:n = \__mermap_latitude_to_y:n {#1}, |
| 309 |
lon .code:n = \__mermap_longitude_to_x:n{#1}, |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
\tikzdeclarecoordinatesystem{__mrc} |
| 314 |
{ |
| 315 |
\__mermap_pgfpoint:nn #1 |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
\tikzdeclarecoordinatesystem{mrcq} |
| 320 |
{ |
| 321 |
\__mermap_pgfpoint:w #1 \q_stop |
| 322 |
} |
| 323 |
|
| 324 |
|
| 325 |
\tikzdeclarecoordinatesystem{mrc}% |
| 326 |
{ |
| 327 |
\keys_set:nn { mermap/cs }{ #1 } |
| 328 |
\pgfpoint{\fp_to_dim:N \l__mermap_cs_x_fp} |
| 329 |
{\fp_to_dim:N \l__mermap_cs_y_fp} |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
\prg_new_conditional:Npnn \__mermap_if_in_map:nn #1#2 { p, T, F, TF } |
| 334 |
{ |
| 335 |
\fp_compare:nNnTF {#1} > \l__mermap_mapnorth_fp |
| 336 |
{ |
| 337 |
\prg_return_false: |
| 338 |
} |
| 339 |
{ |
| 340 |
\fp_compare:nNnTF {#1} < \l__mermap_mapsouth_fp |
| 341 |
{ |
| 342 |
\prg_return_false: |
| 343 |
} |
| 344 |
{ |
| 345 |
\fp_set:Nn \l__mermap_tmpa_fp { #2-\l__mermap_mapwest_fp } |
| 346 |
\fp_sub:Nn \l__mermap_tmpa_fp { 360*floor(\l__mermap_tmpa_fp/360) } |
| 347 |
\fp_compare:nNnTF \l__mermap_tmpa_fp > \l__mermap_westeast_fp |
| 348 |
{ |
| 349 |
\prg_return_false: |
| 350 |
} |
| 351 |
{ |
| 352 |
\fp_set:Nn \l__mermap_cs_x_fp { \l__mermap_tmpa_fp*\l__mermap_cs_xfactor_fp } |
| 353 |
\__mermap_latitude_to_y:n {#1} |
| 354 |
\pgfnoderename{mrclastpos}{mrcpos} |
| 355 |
\pgfcoordinate{mrcpos}{ |
| 356 |
\pgfpoint{\fp_to_dim:N \l__mermap_cs_x_fp} |
| 357 |
{\fp_to_dim:N \l__mermap_cs_y_fp} |
| 358 |
} |
| 359 |
\prg_return_true: |
| 360 |
} |
| 361 |
} |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
\NewDocumentCommand{\ifmrcinmap}{ mm } |
| 366 |
{ |
| 367 |
\__mermap_if_in_map:nnTF{#1}{#2} |
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
\prg_new_conditional:Npnn \__mermap_if_in_vicinity:nn #1#2 { p, T, F, TF } |
| 372 |
{ |
| 373 |
\fp_compare:nNnTF {#1} > \l__mermap_vic_north_fp |
| 374 |
{ |
| 375 |
\prg_return_false: |
| 376 |
} |
| 377 |
{ |
| 378 |
\fp_compare:nNnTF {#1} < \l__mermap_vic_south_fp |
| 379 |
{ |
| 380 |
\prg_return_false: |
| 381 |
} |
| 382 |
{ |
| 383 |
\fp_set:Nn \l__mermap_tmpa_fp { #2-\l__mermap_vic_west_fp } |
| 384 |
\fp_sub:Nn \l__mermap_tmpa_fp { 360*floor(\l__mermap_tmpa_fp/360) } |
| 385 |
\fp_compare:nNnTF \l__mermap_tmpa_fp > \l__mermap_vic_westeast_fp |
| 386 |
{ |
| 387 |
\prg_return_false: |
| 388 |
} |
| 389 |
{ |
| 390 |
\fp_set:Nn \l__mermap_cs_x_fp { \l__mermap_tmpa_fp*\l__mermap_cs_xfactor_fp - \l__mermap_vic_dim_fp } |
| 391 |
\__mermap_latitude_to_y:n {#1} |
| 392 |
\pgfnoderename{mrclastpos}{mrcpos} |
| 393 |
\pgfcoordinate{mrcpos}{ |
| 394 |
\pgfpoint{\fp_to_dim:N \l__mermap_cs_x_fp} |
| 395 |
{\fp_to_dim:N \l__mermap_cs_y_fp} |
| 396 |
} |
| 397 |
\prg_return_true: |
| 398 |
} |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
|
| 403 |
\NewDocumentCommand{\ifmrcinvicinity}{ mm } |
| 404 |
{ |
| 405 |
\__mermap_if_in_vicinity:nnTF{#1}{#2} |
| 406 |
} |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
%---- named positions ---------------------------------------------------------- |
| 412 |
|
| 413 |
|
| 414 |
\cs_new_nopar:Npn \__mermap_set_named_position #1#2#3 |
| 415 |
{ |
| 416 |
\cs_set_nopar:cpx {__mermap__lat__#1} { \fp_to_decimal:n {#2} } |
| 417 |
\cs_set_nopar:cpx {__mermap__lon__#1} { \fp_to_decimal:n {#3} } |
| 418 |
} |
| 419 |
|
| 420 |
|
| 421 |
\NewDocumentCommand{\mrcNPdef}{ mmm } |
| 422 |
{ |
| 423 |
\__mermap_set_named_position{#1}{#2}{#3} |
| 424 |
} |
| 425 |
|
| 426 |
|
| 427 |
\NewDocumentCommand{\mrcNPfrompoint}{ mm } |
| 428 |
{ |
| 429 |
\path (#2); |
| 430 |
\__mermap_y_to_latitude:n {\pgf@y} |
| 431 |
\__mermap_x_to_longitude:n{\pgf@x} |
| 432 |
\__mermap_set_named_position {#1} |
| 433 |
{\fp_to_decimal:N \l__mermap_cs_lat_fp} |
| 434 |
{\fp_to_decimal:N \l__mermap_cs_lon_fp} |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
\msg_new:nnnn{ mercatormap }{ np-undefined } |
| 439 |
{ Named~point~'#1'~is~undefined. } |
| 440 |
{ |
| 441 |
The~named~point~'#1'~is~not~known:~ |
| 442 |
perhaps~it~is~spelled~incorrectly. |
| 443 |
} |
| 444 |
|
| 445 |
|
| 446 |
\NewExpandableDocumentCommand \mrcNPlat { m } |
| 447 |
{ |
| 448 |
\cs_if_exist_use:cF{ __mermap__lat__#1 }{ 0 } |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
\NewExpandableDocumentCommand \mrcNPlon { m } |
| 453 |
{ |
| 454 |
\cs_if_exist_use:cF{ __mermap__lon__#1 }{ 0 } |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
\NewExpandableDocumentCommand \mrcNPcs { m } |
| 459 |
{ |
| 460 |
__mrc~cs \c_colon_str {{\mrcNPlat{#1}}{\mrcNPlon{#1}}} |
| 461 |
} |
| 462 |
|
| 463 |
|
| 464 |
\prg_new_conditional:Npnn \__mermap_if_NP_exists:n #1 { p, TF } |
| 465 |
{ |
| 466 |
\cs_if_exist:cTF{ __mermap__lat__#1 } |
| 467 |
{ |
| 468 |
\cs_if_exist:cTF{ __mermap__lon__#1 } |
| 469 |
{ |
| 470 |
\prg_return_true: |
| 471 |
} |
| 472 |
{ |
| 473 |
\prg_return_false: |
| 474 |
} |
| 475 |
} |
| 476 |
{ |
| 477 |
\prg_return_false: |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
|
| 482 |
\NewDocumentCommand{\ifmrcNPexists}{ m } |
| 483 |
{ |
| 484 |
\__mermap_if_NP_exists:nTF{ #1 } |
| 485 |
} |
| 486 |
|
| 487 |
|
| 488 |
\prg_new_conditional:Npnn \__mermap_if_NP_in_map:n #1 { p, TF } |
| 489 |
{ |
| 490 |
\__mermap_if_NP_exists:nTF { #1 } |
| 491 |
{ |
| 492 |
\__mermap_if_in_map:nnTF{ \mrcNPlat{#1} }{ \mrcNPlon{#1} } |
| 493 |
{ |
| 494 |
\prg_return_true: |
| 495 |
} |
| 496 |
{ |
| 497 |
\prg_return_false: |
| 498 |
} |
| 499 |
} |
| 500 |
{ |
| 501 |
\prg_return_false: |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
\NewDocumentCommand{\ifmrcNPinmap}{ m } |
| 507 |
{ |
| 508 |
\__mermap_if_NP_in_map:nTF { #1 } |
| 509 |
} |
| 510 |
|
| 511 |
|
| 512 |
\prg_new_conditional:Npnn \__mermap_if_NP_in_vicinity:n #1 { p, TF } |
| 513 |
{ |
| 514 |
\__mermap_if_NP_exists:nTF { #1 } |
| 515 |
{ |
| 516 |
\__mermap_if_in_vicinity:nnTF{ \mrcNPlat{#1} }{ \mrcNPlon{#1} } |
| 517 |
{ |
| 518 |
\prg_return_true: |
| 519 |
} |
| 520 |
{ |
| 521 |
\prg_return_false: |
| 522 |
} |
| 523 |
} |
| 524 |
{ |
| 525 |
\prg_return_false: |
| 526 |
} |
| 527 |
} |
| 528 |
|
| 529 |
|
| 530 |
\NewDocumentCommand{\ifmrcNPinvicinity}{ m } |
| 531 |
{ |
| 532 |
\__mermap_if_NP_in_vicinity:nTF{ #1 } |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
%---- map tile download -------------------------------------------------------- |
| 538 |
|
| 539 |
\group_begin: |
| 540 |
\char_set_catcode_space:n {`\ } |
| 541 |
\char_set_catcode_other:n {`\"} |
| 542 |
|
| 543 |
\tl_const:Nn \c__mermap_supply_call_boundaries_tl |
| 544 |
{ |
| 545 |
\l__mermap_python_tl\c_space_tl boundaries |
| 546 |
-u "\str_use:N\l__mermap_supply_url_str" |
| 547 |
-at "\str_use:N\l__mermap_supply_attribution_str" |
| 548 |
-atp "\str_use:N\l__mermap_supply_attribution_print_str" |
| 549 |
-f "\l__mermap_supply_basename_tl" |
| 550 |
-z \int_use:N\l__mermap_supply_zoom_int\c_space_tl |
| 551 |
-w \fp_use:N\l__mermap_supply_west_fp\c_space_tl |
| 552 |
-e \fp_use:N\l__mermap_supply_east_fp\c_space_tl |
| 553 |
-n \fp_use:N\l__mermap_supply_north_fp\c_space_tl |
| 554 |
-s \fp_use:N\l__mermap_supply_south_fp\c_space_tl |
| 555 |
-p \l__mermap_supply_pixel_tl\c_space_tl |
| 556 |
-ts \dim_use:N\l__mermap_tile_size_dim\c_space_tl |
| 557 |
-t \l__mermap_supply_target_tl\c_space_tl |
| 558 |
-d "\str_use:N\l__mermap_definition_id_str" |
| 559 |
} |
| 560 |
|
| 561 |
\tl_const:Nn \c__mermap_supply_call_reference_tl |
| 562 |
{ |
| 563 |
\l__mermap_python_tl\c_space_tl reference |
| 564 |
-u "\str_use:N\l__mermap_supply_url_str" |
| 565 |
-at "\str_use:N\l__mermap_supply_attribution_str" |
| 566 |
-atp "\str_use:N\l__mermap_supply_attribution_print_str" |
| 567 |
-f "\l__mermap_supply_basename_tl" |
| 568 |
-mw \fp_use:N\l__mermap_supply_width_fp\c_space_tl |
| 569 |
-mh \fp_use:N\l__mermap_supply_height_fp\c_space_tl |
| 570 |
-z \int_use:N\l__mermap_supply_zoom_int\c_space_tl |
| 571 |
-lat \fp_use:N\l__mermap_supply_latitude_fp\c_space_tl |
| 572 |
-lon \fp_use:N\l__mermap_supply_longitude_fp\c_space_tl |
| 573 |
-a \l__mermap_supply_align_tl\c_space_tl |
| 574 |
-p \l__mermap_supply_pixel_tl\c_space_tl |
| 575 |
-ts \dim_use:N\l__mermap_tile_size_dim\c_space_tl |
| 576 |
-t \l__mermap_supply_target_tl\c_space_tl |
| 577 |
-d "\str_use:N\l__mermap_definition_id_str" |
| 578 |
} |
| 579 |
|
| 580 |
|
| 581 |
\tl_const:Nn \c__mermap_supply_call_areafit_tl |
| 582 |
{ |
| 583 |
\l__mermap_python_tl\c_space_tl areafit |
| 584 |
-u "\str_use:N\l__mermap_supply_url_str" |
| 585 |
-at "\str_use:N\l__mermap_supply_attribution_str" |
| 586 |
-atp "\str_use:N\l__mermap_supply_attribution_print_str" |
| 587 |
-f "\l__mermap_supply_basename_tl" |
| 588 |
-mw \fp_use:N\l__mermap_supply_width_fp\c_space_tl |
| 589 |
-mh \fp_use:N\l__mermap_supply_height_fp\c_space_tl |
| 590 |
-w \fp_use:N\l__mermap_supply_west_fp\c_space_tl |
| 591 |
-e \fp_use:N\l__mermap_supply_east_fp\c_space_tl |
| 592 |
-n \fp_use:N\l__mermap_supply_north_fp\c_space_tl |
| 593 |
-s \fp_use:N\l__mermap_supply_south_fp\c_space_tl |
| 594 |
-a \l__mermap_supply_align_tl\c_space_tl |
| 595 |
-p \l__mermap_supply_pixel_tl\c_space_tl |
| 596 |
-ts \dim_use:N\l__mermap_tile_size_dim\c_space_tl |
| 597 |
-t \l__mermap_supply_target_tl\c_space_tl |
| 598 |
-d "\str_use:N\l__mermap_definition_id_str" |
| 599 |
} |
| 600 |
|
| 601 |
\group_end: |
| 602 |
|
| 603 |
|
| 604 |
\bool_new:N \l__mermap_script_activated_bool |
| 605 |
\bool_new:N \l__mermap_fail_on_missing_resource_bool |
| 606 |
|
| 607 |
\fp_new:N \l__mermap_supply_east_fp |
| 608 |
\fp_new:N \l__mermap_supply_height_fp |
| 609 |
\fp_new:N \l__mermap_supply_latitude_fp |
| 610 |
\fp_new:N \l__mermap_supply_longitude_fp |
| 611 |
\fp_new:N \l__mermap_supply_north_fp |
| 612 |
\fp_new:N \l__mermap_supply_south_fp |
| 613 |
\fp_new:N \l__mermap_supply_west_fp |
| 614 |
\fp_new:N \l__mermap_supply_width_fp |
| 615 |
|
| 616 |
\int_new:N \g__mermap_automap_int |
| 617 |
\int_new:N \l__mermap_supply_zoom_int |
| 618 |
|
| 619 |
\iow_new:N \l__mermap_iow |
| 620 |
|
| 621 |
\prop_new:N \g__mermap_apikey_prop |
| 622 |
\prop_new_linked:N \g__mermap_definition_prop |
| 623 |
|
| 624 |
\str_new:N \l__mermap_definition_id_str |
| 625 |
\str_new:N \l__mermap_definition_postfix_str |
| 626 |
\str_new:N \l__mermap_definition_prefix_str |
| 627 |
\str_new:N \l__mermap_supply_attribution_print_str |
| 628 |
\str_new:N \l__mermap_supply_attribution_str |
| 629 |
\str_new:N \l__mermap_supply_url_str |
| 630 |
|
| 631 |
\tl_new:N \l__mermap_last_mdfivesum_tl |
| 632 |
\tl_new:N \l__mermap_mdfivesum_tl |
| 633 |
\tl_new:N \l__mermap_python_tl |
| 634 |
\tl_new:N \l__mermap_supply_align_tl |
| 635 |
\tl_new:N \l__mermap_supply_basename_tl |
| 636 |
\tl_new:N \l__mermap_supply_call_tl |
| 637 |
\tl_new:N \l__mermap_supply_pixel_tl |
| 638 |
\tl_new:N \l__mermap_supply_target_tl |
| 639 |
\tl_new:N \l__mermap_supply_type_tl |
| 640 |
|
| 641 |
|
| 642 |
\use:x |
| 643 |
{ |
| 644 |
\cs_new_nopar:Npn \exp_not:N\__mermap_supply_position:w ##1 \c_colon_str ##2 \exp_not:N \q_stop |
| 645 |
} |
| 646 |
{ |
| 647 |
\fp_set:Nn \l__mermap_supply_latitude_fp {#1} |
| 648 |
\fp_set:Nn \l__mermap_supply_longitude_fp {#2} |
| 649 |
} |
| 650 |
|
| 651 |
|
| 652 |
\msg_new:nnnn{ mercatormap }{ api-key-undefined } |
| 653 |
{ Api~key~'#1'~is~undefined. } |
| 654 |
{ |
| 655 |
You~have~to~set~\token_to_str:N \mrcsetapikey |
| 656 |
\iow_char:N \{#1\iow_char:N \} |
| 657 |
\iow_char:N \{your~key\iow_char:N \}~first. |
| 658 |
} |
| 659 |
|
| 660 |
\cs_new:Npn \__mermap_supply_url_with_api_key:nnn #1#2#3 |
| 661 |
{ |
| 662 |
\str_set:Nn \l__mermap_supply_url_str {#1} |
| 663 |
\prop_get:NnNF \g__mermap_apikey_prop {#2} \l__mermap_tmpa_tl |
| 664 |
{ |
| 665 |
\msg_error:nnx{ mercatormap }{ api-key-undefined }{ #2 } |
| 666 |
} |
| 667 |
\str_put_right:NV \l__mermap_supply_url_str \l__mermap_tmpa_tl |
| 668 |
\str_put_right:Nn \l__mermap_supply_url_str {#3} |
| 669 |
} |
| 670 |
|
| 671 |
|
| 672 |
\cs_new:Npn \__mermap_supply_add_area_clist:N #1 |
| 673 |
{ |
| 674 |
\clist_map_inline:Nn #1 |
| 675 |
{ |
| 676 |
\cs_if_exist:cF{__mermap__lat__##1} |
| 677 |
{ |
| 678 |
\msg_error:nnx{ mercatormap }{ np-undefined }{ ##1 } |
| 679 |
} |
| 680 |
\fp_set:Nn \l__mermap_tmpa_fp { \mrcNPlat{##1} } |
| 681 |
\fp_compare:nNnT \l__mermap_tmpa_fp < \l__mermap_supply_south_fp |
| 682 |
{ \fp_set_eq:NN \l__mermap_supply_south_fp \l__mermap_tmpa_fp } |
| 683 |
\fp_compare:nNnT \l__mermap_tmpa_fp > \l__mermap_supply_north_fp |
| 684 |
{ \fp_set_eq:NN \l__mermap_supply_north_fp \l__mermap_tmpa_fp } |
| 685 |
\fp_set:Nn \l__mermap_tmpa_fp { \mrcNPlon{##1} } |
| 686 |
\fp_compare:nNnT \l__mermap_tmpa_fp < \l__mermap_supply_west_fp |
| 687 |
{ \fp_set_eq:NN \l__mermap_supply_west_fp \l__mermap_tmpa_fp } |
| 688 |
\fp_compare:nNnT \l__mermap_tmpa_fp > \l__mermap_supply_east_fp |
| 689 |
{ \fp_set_eq:NN \l__mermap_supply_east_fp \l__mermap_tmpa_fp } |
| 690 |
} |
| 691 |
} |
| 692 |
|
| 693 |
|
| 694 |
\msg_new:nnn { mercatormap }{ input-area-marker } |
| 695 |
{ The~marker~input~file~'#1'~does~not~exist. } |
| 696 |
|
| 697 |
\cs_new:Npn \__mermap_supply_add_area_marker_position: |
| 698 |
{ |
| 699 |
\fp_compare:nNnT \l__mermap_marker_latitude_fp < \l__mermap_supply_south_fp |
| 700 |
{ \fp_set_eq:NN \l__mermap_supply_south_fp \l__mermap_marker_latitude_fp } |
| 701 |
\fp_compare:nNnT \l__mermap_marker_latitude_fp > \l__mermap_supply_north_fp |
| 702 |
{ \fp_set_eq:NN \l__mermap_supply_north_fp \l__mermap_marker_latitude_fp } |
| 703 |
\fp_compare:nNnT \l__mermap_marker_longitude_fp < \l__mermap_supply_west_fp |
| 704 |
{ \fp_set_eq:NN \l__mermap_supply_west_fp \l__mermap_marker_longitude_fp } |
| 705 |
\fp_compare:nNnT \l__mermap_marker_longitude_fp > \l__mermap_supply_east_fp |
| 706 |
{ \fp_set_eq:NN \l__mermap_supply_east_fp \l__mermap_marker_longitude_fp } |
| 707 |
} |
| 708 |
|
| 709 |
\cs_new:Npn \__mermap_supply_add_area_marker:n #1 |
| 710 |
{ |
| 711 |
\group_begin: |
| 712 |
\RenewDocumentCommand \mrcmarker { m } |
| 713 |
{ |
| 714 |
\keys_set:nn { mermap/marker } { ##1 } |
| 715 |
\__mermap_supply_add_area_marker_position: |
| 716 |
} |
| 717 |
\file_if_exist_input:nF {#1} |
| 718 |
{ |
| 719 |
\msg_error:nnn { mercatormap }{ input-area-marker }{ #1 } |
| 720 |
} |
| 721 |
\tl_gset:Nx \g__mermap_tmpa_tl |
| 722 |
{ |
| 723 |
\exp_not:N\fp_set:Nn \exp_not:N\l__mermap_supply_west_fp { \fp_to_decimal:N\l__mermap_supply_west_fp } |
| 724 |
\exp_not:N\fp_set:Nn \exp_not:N\l__mermap_supply_east_fp { \fp_to_decimal:N\l__mermap_supply_east_fp } |
| 725 |
\exp_not:N\fp_set:Nn \exp_not:N\l__mermap_supply_south_fp { \fp_to_decimal:N\l__mermap_supply_south_fp } |
| 726 |
\exp_not:N\fp_set:Nn \exp_not:N\l__mermap_supply_north_fp { \fp_to_decimal:N\l__mermap_supply_north_fp } |
| 727 |
} |
| 728 |
\group_insert_after:N \g__mermap_tmpa_tl |
| 729 |
\group_end: |
| 730 |
} |
| 731 |
|
| 732 |
|
| 733 |
\keys_define:nn { mermap/supply } |
| 734 |
{ |
| 735 |
zoom .int_set:N = \l__mermap_supply_zoom_int, |
| 736 |
west .fp_set:N = \l__mermap_supply_west_fp, |
| 737 |
east .fp_set:N = \l__mermap_supply_east_fp, |
| 738 |
north .fp_set:N = \l__mermap_supply_north_fp, |
| 739 |
south .fp_set:N = \l__mermap_supply_south_fp, |
| 740 |
latitude .fp_set:N = \l__mermap_supply_latitude_fp, |
| 741 |
longitude .fp_set:N = \l__mermap_supply_longitude_fp, |
| 742 |
position .code:n = {\__mermap_supply_position:w #1 \q_stop}, |
| 743 |
named~position .meta:nn = {mermap/supply}{latitude=\mrcNPlat{#1},longitude=\mrcNPlon{#1}}, |
| 744 |
width .fp_set:N = \l__mermap_supply_width_fp, |
| 745 |
height .fp_set:N = \l__mermap_supply_height_fp, |
| 746 |
align .tl_set:N = \l__mermap_supply_align_tl, |
| 747 |
url .code:n = {\str_set:Nn\l__mermap_supply_url_str {#1}}, |
| 748 |
url~with~api~key .code:n = {\__mermap_supply_url_with_api_key:nnn #1}, |
| 749 |
basename .tl_set:N = \l__mermap_supply_basename_tl, |
| 750 |
type .tl_set:N = \l__mermap_supply_type_tl, |
| 751 |
target .tl_set:N = \l__mermap_supply_target_tl, |
| 752 |
pixel .tl_set:N = \l__mermap_supply_pixel_tl, |
| 753 |
attribution .code:n = { |
| 754 |
\str_set:Nn \l__mermap_supply_attribution_str {#1} |
| 755 |
\tl_set_rescan:Nnn \l__mermap_attribution_tl {}{#1} |
| 756 |
}, |
| 757 |
attribution~print .code:n = { |
| 758 |
\str_set:Nn \l__mermap_supply_attribution_print_str {#1} |
| 759 |
\tl_set_rescan:Nnn \l__mermap_attribution_print_tl {}{#1} |
| 760 |
}, |
| 761 |
dpi .code:n = { |
| 762 |
\tl_set:Nx \l__mermap_supply_pixel_tl { |
| 763 |
\fp_to_int:n { round(#1*\l__mermap_tile_size_dim/1in) } |
| 764 |
}}, |
| 765 |
tex~width .code:n = { |
| 766 |
\fp_set:Nn \l__mermap_supply_width_fp{#1/\l__mermap_tile_size_dim}}, |
| 767 |
tex~height .code:n = { |
| 768 |
\fp_set:Nn \l__mermap_supply_height_fp{#1/\l__mermap_tile_size_dim}}, |
| 769 |
source .code:n = { \exp_args:Nnx \keys_set:nn {mermap/supply} {_source=#1} }, |
| 770 |
source .value_required:n = true, |
| 771 |
_source .choice:, |
| 772 |
area .code:n = |
| 773 |
{ |
| 774 |
\clist_set:Nn \l__mermap_tmpa_clist { #1 } |
| 775 |
\fp_set:Nn \l__mermap_supply_west_fp { inf } |
| 776 |
\fp_set:Nn \l__mermap_supply_east_fp { -inf } |
| 777 |
\fp_set:Nn \l__mermap_supply_south_fp { 89 } |
| 778 |
\fp_set:Nn \l__mermap_supply_north_fp { -89 } |
| 779 |
\__mermap_supply_add_area_clist:N \l__mermap_tmpa_clist |
| 780 |
}, |
| 781 |
area .value_required:n = true, |
| 782 |
add~area .code:n = |
| 783 |
{ |
| 784 |
\clist_set:Nn \l__mermap_tmpa_clist { #1 } |
| 785 |
\__mermap_supply_add_area_clist:N \l__mermap_tmpa_clist |
| 786 |
}, |
| 787 |
area~from~marker~input .code:n = |
| 788 |
{ |
| 789 |
\fp_set:Nn \l__mermap_supply_west_fp { inf } |
| 790 |
\fp_set:Nn \l__mermap_supply_east_fp { -inf } |
| 791 |
\fp_set:Nn \l__mermap_supply_south_fp { 89 } |
| 792 |
\fp_set:Nn \l__mermap_supply_north_fp { -89 } |
| 793 |
\__mermap_supply_add_area_marker:n { #1 } |
| 794 |
}, |
| 795 |
area~from~marker~input .value_required:n = true, |
| 796 |
add~area~from~marker~input .code:n = |
| 797 |
{ |
| 798 |
\__mermap_supply_add_area_marker:n { #1 } |
| 799 |
}, |
| 800 |
flex~reference~scale .code:n = { |
| 801 |
\__mermap_set_flex_scale:nn {#1} {\l__mermap_supply_latitude_fp} |
| 802 |
}, |
| 803 |
flex~reference~scale .value_required:n = true, |
| 804 |
area~to~reference .code:n = { |
| 805 |
\fp_set:Nn \l__mermap_supply_longitude_fp { (\l__mermap_supply_west_fp+\l__mermap_supply_east_fp)/2 } |
| 806 |
\__mermap_mean_latitude:NN \l__mermap_supply_north_fp \l__mermap_supply_south_fp |
| 807 |
\fp_set_eq:NN \l__mermap_supply_latitude_fp \l__mermap_result_fp |
| 808 |
}, |
| 809 |
area~to~reference .value_forbidden:n = true, |
| 810 |
flex~area~scale .meta:nn = {mermap/supply}{area~to~reference,flex~reference~scale={#1}}, |
| 811 |
flex~area~scale .value_required:n = true, |
| 812 |
flex~area~fit .code:n = { |
| 813 |
\fp_compare:nNnF \l__mermap_tile_size_dim = \l__mermap_flex_tile_size_dim |
| 814 |
{ |
| 815 |
\fp_set:Nn \l__mermap_tmpa_fp { \l__mermap_tile_size_dim/\l__mermap_flex_tile_size_dim } |
| 816 |
\fp_set:Nn \l__mermap_supply_width_fp{\l__mermap_supply_width_fp*\l__mermap_tmpa_fp} |
| 817 |
\fp_set:Nn \l__mermap_supply_height_fp{\l__mermap_supply_height_fp*\l__mermap_tmpa_fp} |
| 818 |
} |
| 819 |
\fp_set:Nn \l__mermap_supply_width_fp{\l__mermap_supply_width_fp-(#1)/\l__mermap_flex_tile_size_dim} |
| 820 |
\fp_set:Nn \l__mermap_supply_height_fp{\l__mermap_supply_height_fp-(#1)/\l__mermap_flex_tile_size_dim} |
| 821 |
\fp_set:Nn \l__mermap_tmpa_fp { min ( 180*\l__mermap_supply_width_fp / (\l__mermap_supply_east_fp-\l__mermap_supply_west_fp) |
| 822 |
, pi*\l__mermap_supply_height_fp / ln( tand(\l__mermap_supply_north_fp/2+45) / tand(\l__mermap_supply_south_fp/2+45) ) ) } |
| 823 |
\fp_set:Nn \l__mermap_tmpb_fp { ln(\l__mermap_tmpa_fp)/ln(2) } |
| 824 |
\fp_set:Nn \l__mermap_tmpb_fp { round(\l__mermap_tmpb_fp)/\l__mermap_tmpb_fp } |
| 825 |
\fp_set:Nn \l__mermap_tmpb_fp { \l__mermap_tmpa_fp^(\l__mermap_tmpb_fp-1+0.0000001) } |
| 826 |
\dim_set:Nn \l__mermap_tile_size_dim { \fp_to_dim:n { \l__mermap_flex_tile_size_dim / \l__mermap_tmpb_fp }} |
| 827 |
\fp_set:Nn \l__mermap_supply_width_fp { \l__mermap_supply_width_fp * \l__mermap_tmpb_fp + (#1)/\l__mermap_tile_size_dim } |
| 828 |
\fp_set:Nn \l__mermap_supply_height_fp { \l__mermap_supply_height_fp * \l__mermap_tmpb_fp + (#1)/\l__mermap_tile_size_dim } |
| 829 |
}, |
| 830 |
flex~area~fit .default:n = 0pt, |
| 831 |
} |
| 832 |
|
| 833 |
|
| 834 |
\keys_set:nn { mermap/supply } |
| 835 |
{ |
| 836 |
zoom=9, |
| 837 |
north=50, |
| 838 |
south=48, |
| 839 |
west=11, |
| 840 |
east=13, |
| 841 |
latitude=49, |
| 842 |
longitude=12, |
| 843 |
width=4, |
| 844 |
height=4, |
| 845 |
align=center, |
| 846 |
basename=tiles/tile, |
| 847 |
url=, |
| 848 |
attribution=, |
| 849 |
attribution~print=, |
| 850 |
type=reference, |
| 851 |
pixel=256, |
| 852 |
target=tiles, |
| 853 |
} |
| 854 |
|
| 855 |
|
| 856 |
\keys_define:nn { mermap } |
| 857 |
{ |
| 858 |
definition~prefix .code:n = {\str_set:Nn\l__mermap_definition_prefix_str{#1}}, |
| 859 |
fail~on~missing~resource .bool_set:N = \l__mermap_fail_on_missing_resource_bool, |
| 860 |
python .code:n = { |
| 861 |
\tl_set:Nx \l__mermap_python_tl {#1~maptiles.texpy} |
| 862 |
}, |
| 863 |
} |
| 864 |
|
| 865 |
\keys_set:nn { mermap } |
| 866 |
{ |
| 867 |
definition~prefix = maps/, |
| 868 |
fail~on~missing~resource = true, |
| 869 |
python = python, |
| 870 |
} |
| 871 |
|
| 872 |
|
| 873 |
\msg_new:nnn { mercatormap }{ python-script } |
| 874 |
{ Python~script~'maptiles.texpy'~is~created~for~map~tile~download. } |
| 875 |
|
| 876 |
|
| 877 |
\NewDocumentCommand \mrcactivatescript {} |
| 878 |
{ |
| 879 |
\msg_info:nn { mercatormap }{ python-script } |
| 880 |
\file_input:n {\mrcpkgprefix mercatorpy.def} |
| 881 |
\bool_set_true:N \l__mermap_script_activated_bool |
| 882 |
} |
| 883 |
\@onlypreamble\mrcactivatescript |
| 884 |
|
| 885 |
|
| 886 |
\NewDocumentCommand \mrcsetapikey { mm } |
| 887 |
{ |
| 888 |
\prop_gput:Nnn \g__mermap_apikey_prop {#1}{#2} |
| 889 |
} |
| 890 |
|
| 891 |
|
| 892 |
\cs_new:Npn \__mermap_create_definition_id:n #1 |
| 893 |
{ |
| 894 |
\tl_set:Nx \l__mermap_tmpa_tl {#1} |
| 895 |
\tl_trim_spaces:N \l__mermap_tmpa_tl |
| 896 |
\str_set:Nx \l__mermap_definition_postfix_str {\tl_to_str:N \l__mermap_tmpa_tl} |
| 897 |
\str_concat:NNN \l__mermap_definition_id_str |
| 898 |
\l__mermap_definition_prefix_str \l__mermap_definition_postfix_str |
| 899 |
} |
| 900 |
|
| 901 |
\cs_new:Npn \__mermap_map:nn #1#2 |
| 902 |
{ |
| 903 |
\tl_set:Nx \l__mermap_tmpa_tl {#2} |
| 904 |
\tl_trim_spaces:N \l__mermap_tmpa_tl |
| 905 |
\tl_if_empty:NT \l__mermap_tmpa_tl |
| 906 |
{ |
| 907 |
\int_gincr:N \g__mermap_automap_int |
| 908 |
\tl_set:Nx \l__mermap_tmpa_tl |
| 909 |
{ |
| 910 |
automap- |
| 911 |
\int_compare:nNnTF \g__mermap_automap_int<{10} {000} |
| 912 |
{ |
| 913 |
\int_compare:nNnTF \g__mermap_automap_int<{100} {00} |
| 914 |
{ |
| 915 |
\int_compare:nNnTF \g__mermap_automap_int<{1000} {0} {} |
| 916 |
} |
| 917 |
} |
| 918 |
\int_use:N \g__mermap_automap_int |
| 919 |
} |
| 920 |
} |
| 921 |
\exp_args:NV \__mermap_create_definition_id:n \l__mermap_tmpa_tl |
| 922 |
%\str_set:Nx \l__mermap_definition_postfix_str {\tl_to_str:N \l__mermap_tmpa_tl} |
| 923 |
%\str_concat:NNN \l__mermap_definition_id_str |
| 924 |
% \l__mermap_definition_prefix_str \l__mermap_definition_postfix_str |
| 925 |
\__mermap_supplymap:n {#1} |
| 926 |
\__mermap_applymap: |
| 927 |
} |
| 928 |
|
| 929 |
\NewDocumentCommand \mrcmap { O{} m } |
| 930 |
{ |
| 931 |
\__mermap_map:nn {#1}{#2} |
| 932 |
} |
| 933 |
|
| 934 |
|
| 935 |
\msg_new:nnn{ mercatormap }{ definition-id-used } |
| 936 |
{ Map~definition~'#1'~already~existing } |
| 937 |
|
| 938 |
|
| 939 |
\cs_new:Npn \__mermap_supplymap:n #1 |
| 940 |
{ |
| 941 |
\group_begin: |
| 942 |
\keys_set:nn { mermap/supply } { #1 } |
| 943 |
\prop_if_in:NVT \g__mermap_definition_prop \l__mermap_definition_id_str |
| 944 |
{ |
| 945 |
\msg_warning:nnx { mercatormap }{ definition-id-used }{ \str_use:N \l__mermap_definition_id_str } |
| 946 |
} |
| 947 |
\prop_gput:NVn \g__mermap_definition_prop \l__mermap_definition_id_str {} |
| 948 |
\bool_if:NT \l__mermap_script_activated_bool |
| 949 |
{ |
| 950 |
\__mermap_supplymap_call: |
| 951 |
} |
| 952 |
\group_end: |
| 953 |
} |
| 954 |
|
| 955 |
\NewDocumentCommand \mrcsupplymap { O{} m } |
| 956 |
{ |
| 957 |
\__mermap_create_definition_id:n {#2} |
| 958 |
\__mermap_supplymap:n {#1} |
| 959 |
} |
| 960 |
|
| 961 |
|
| 962 |
\msg_new:nnnn { mercatormap }{ shell-escape } |
| 963 |
{ You~must~invoke~LaTeX~with~the~--shell-escape~flag~to~produce~map~'#1'. } |
| 964 |
{ The~--shell-escape~flag~is~needed,~because~a~Python~sript~has~to~be~called;~see~package~documentation. } |
| 965 |
|
| 966 |
\msg_new:nnnn { mercatormap }{ target-resource } |
| 967 |
{ Target~and~produced~resource~are~different~for~map~'#1'. } |
| 968 |
{ Your~target~was~'\l__mermap_supply_target_tl'.\\ |
| 969 |
The~produced~resource~is~'\l__mermap_tile_resource_tl'.\\ |
| 970 |
Check,~if~'\l__mermap_supply_target_tl'~is~available~via~'\str_use:N\l__mermap_supply_url_str'\\ |
| 971 |
or~if~the~zoom~value~is~too~large. |
| 972 |
} |
| 973 |
|
| 974 |
\msg_new:nnnn { mercatormap }{ definition-production } |
| 975 |
{ Map~definition~file~not~produced~for~map~'#1'. } |
| 976 |
{ **~The~failed~shell~command~was:\\ |
| 977 |
\l__mermap_supply_call_tl\\ |
| 978 |
**~Python~setup~correct? |
| 979 |
} |
| 980 |
|
| 981 |
\cs_new:Npn \__mermap_supplymap_call: |
| 982 |
{ |
| 983 |
\tl_set_eq:Nc \l__mermap_tmpa_tl { |
| 984 |
c__mermap_supply_call_\l__mermap_supply_type_tl _tl } |
| 985 |
\tl_set:Nx \l__mermap_supply_call_tl \l__mermap_tmpa_tl |
| 986 |
\tl_set:Nx \l__mermap_mdfivesum_tl { \str_mdfive_hash:e{\l__mermap_supply_call_tl} } |
| 987 |
\file_if_exist:nTF {\l__mermap_definition_id_str.def} |
| 988 |
{ |
| 989 |
\tl_clear:N \l__mermap_last_mdfivesum_tl |
| 990 |
\file_if_exist_input:n {\l__mermap_definition_id_str.md5} |
| 991 |
\str_if_eq:VVF \l__mermap_mdfivesum_tl \l__mermap_last_mdfivesum_tl |
| 992 |
{ |
| 993 |
\__mermap_supplymap_call_shell: |
| 994 |
} |
| 995 |
} |
| 996 |
{ |
| 997 |
\__mermap_supplymap_call_shell: |
| 998 |
} |
| 999 |
} |
| 1000 |
|
| 1001 |
\cs_new:Npn \__mermap_supplymap_call_shell: |
| 1002 |
{ |
| 1003 |
\sys_if_shell_unrestricted:TF |
| 1004 |
{ |
| 1005 |
\file_if_exist:nT {\l__mermap_definition_id_str.def} |
| 1006 |
{ |
| 1007 |
\iow_open:Nn \l__mermap_iow {\l__mermap_definition_id_str.def} |
| 1008 |
\iow_now:Nx \l__mermap_iow {\c_backslash_str def \c_backslash_str mrcdefinemap{} \c_percent_str} |
| 1009 |
\iow_close:N \l__mermap_iow |
| 1010 |
} |
| 1011 |
|
| 1012 |
\sys_shell_now:x {\l__mermap_supply_call_tl} |
| 1013 |
|
| 1014 |
\file_if_exist:nTF {\l__mermap_definition_id_str.def} |
| 1015 |
{ |
| 1016 |
\file_input:n {\l__mermap_definition_id_str.def} |
| 1017 |
\str_if_eq:VVTF \l__mermap_supply_target_tl \l__mermap_tile_resource_tl |
| 1018 |
{ |
| 1019 |
\__mermap_write_mdfive:n {\l__mermap_mdfivesum_tl} |
| 1020 |
} |
| 1021 |
{ |
| 1022 |
\__mermap_write_mdfive:n {false} |
| 1023 |
\bool_if:NTF \l__mermap_fail_on_missing_resource_bool |
| 1024 |
{ |
| 1025 |
\msg_error:nnx { mercatormap }{ target-resource }{ \l__mermap_definition_id_str } |
| 1026 |
} |
| 1027 |
{ |
| 1028 |
\msg_warning:nnx { mercatormap }{ target-resource }{ \l__mermap_definition_id_str } |
| 1029 |
} |
| 1030 |
} |
| 1031 |
} |
| 1032 |
{ |
| 1033 |
\msg_error:nnx { mercatormap }{ definition-production }{ \l__mermap_definition_id_str } |
| 1034 |
} |
| 1035 |
} |
| 1036 |
{ |
| 1037 |
\msg_error:nnx { mercatormap }{ shell-escape }{ \l__mermap_definition_id_str } |
| 1038 |
} |
| 1039 |
} |
| 1040 |
|
| 1041 |
\NewDocumentCommand \mermaplastfivesum { m } |
| 1042 |
{ |
| 1043 |
\tl_set:Nx \l__mermap_last_mdfivesum_tl { #1 } |
| 1044 |
} |
| 1045 |
|
| 1046 |
\cs_new:Npn \__mermap_write_mdfive:n #1 |
| 1047 |
{ |
| 1048 |
\iow_open:Nn \l__mermap_iow {\l__mermap_definition_id_str.md5} |
| 1049 |
\iow_now:Nx \l__mermap_iow {\c_backslash_str mermaplastfivesum{#1} \c_percent_str} |
| 1050 |
\iow_close:N \l__mermap_iow |
| 1051 |
} |
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
%---- map drawing -------------------------------------------------------------- |
| 1056 |
|
| 1057 |
|
| 1058 |
\dim_new:N \l__mermap_flex_tile_size_dim |
| 1059 |
\dim_new:N \l__mermap_tx_dim |
| 1060 |
\dim_new:N \l__mermap_ty_dim |
| 1061 |
|
| 1062 |
\int_new:N \l__mermap_tile_x_int |
| 1063 |
\int_new:N \l__mermap_tile_xmod_int |
| 1064 |
\int_new:N \l__mermap_tile_y_int |
| 1065 |
|
| 1066 |
\tl_new:N \l__mermap_current_map_tl |
| 1067 |
\tl_new:N \l__mermap_draw_map_tl |
| 1068 |
\tl_new:N \l__mermap_tikz_map_clip_tl |
| 1069 |
\tl_new:N \l__mermap_tile_filename_tl |
| 1070 |
|
| 1071 |
|
| 1072 |
\prg_new_conditional:Npnn \__mermap_if_inside_picture_environment: { p, TF, T } |
| 1073 |
{ |
| 1074 |
\cs_if_exist:NTF \pgfpictureid |
| 1075 |
{ |
| 1076 |
\prg_return_true: |
| 1077 |
} |
| 1078 |
{ |
| 1079 |
\prg_return_false: |
| 1080 |
} |
| 1081 |
} |
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
\cs_new_nopar:Npn \__mermap_set_flex_scale:nn #1#2 |
| 1086 |
{ |
| 1087 |
\fp_set:Nn \l__mermap_tmpa_fp { 1+ln(\c__mermap_mean_radius_fp/#1*cosd(#2)*pi/\l__mermap_flex_tile_size_dim)/ln(2) } |
| 1088 |
\keys_set:nn { mermap }{ flex~zoom=\l__mermap_tmpa_fp } |
| 1089 |
} |
| 1090 |
|
| 1091 |
\use:x |
| 1092 |
{ |
| 1093 |
\cs_new_nopar:Npn \exp_not:N\__mermap_set_flex_scale:w ##1 \c_colon_str ##2 \exp_not:N \q_stop |
| 1094 |
} |
| 1095 |
{ |
| 1096 |
\__mermap_set_flex_scale:nn {#1}{#2} |
| 1097 |
} |
| 1098 |
|
| 1099 |
\use:x |
| 1100 |
{ |
| 1101 |
\cs_new_nopar:Npn \exp_not:N\__mermap_set_named_flex_scale:w ##1 \c_colon_str ##2 \exp_not:N \q_stop |
| 1102 |
} |
| 1103 |
{ |
| 1104 |
\__mermap_set_flex_scale:nn {#1}{\mrcNPlat{#2}} |
| 1105 |
} |
| 1106 |
|
| 1107 |
|
| 1108 |
\keys_define:nn { mermap } |
| 1109 |
{ |
| 1110 |
tile~size .dim_set:N = \l__mermap_tile_size_dim, |
| 1111 |
flex~tile~size .dim_set:N = \l__mermap_flex_tile_size_dim, |
| 1112 |
flex~zoom .code:n = |
| 1113 |
{ |
| 1114 |
\int_set:Nn \l__mermap_supply_zoom_int {\fp_to_int:n{round(#1)}} |
| 1115 |
\dim_set:Nn \l__mermap_tile_size_dim {\fp_to_dim:n{\l__mermap_flex_tile_size_dim*2^(#1-\l__mermap_supply_zoom_int)}} |
| 1116 |
}, |
| 1117 |
flex~scale .code:n = {\__mermap_set_flex_scale:w #1 \q_stop}, |
| 1118 |
named~flex~scale .code:n = {\__mermap_set_named_flex_scale:w #1 \q_stop}, |
| 1119 |
map~clip .tl_set:N = \l__mermap_tikz_map_clip_tl, |
| 1120 |
map~scope .code:n = {\tikzset{mermap_scope_style/.style={#1}}}, |
| 1121 |
map~path .code:n = {\tikzset{mermap_path_style/.style={#1}}}, |
| 1122 |
draw .tl_set:N = \l__mermap_draw_map_tl, |
| 1123 |
} |
| 1124 |
|
| 1125 |
|
| 1126 |
\keys_set:nn { mermap } |
| 1127 |
{ |
| 1128 |
tile~size = 32.512mm, |
| 1129 |
flex~tile~size = 32.512mm, |
| 1130 |
map~clip=\mrcclipmap, |
| 1131 |
draw=auto, |
| 1132 |
map~scope=, |
| 1133 |
map~path={upper~left=green!50, upper~right=green!25, |
| 1134 |
lower~left=green!50!black!50, lower~right=green!25}, |
| 1135 |
} |
| 1136 |
|
| 1137 |
|
| 1138 |
\NewDocumentCommand \mrcclipmap {} |
| 1139 |
{\path[clip] (mrcmap.south~west) rectangle (mrcmap.north~east);} |
| 1140 |
|
| 1141 |
\NewDocumentCommand \mrcboundmap {} |
| 1142 |
{\path[use~as~bounding~box] (mrcmap.south~west) rectangle (mrcmap.north~east);} |
| 1143 |
|
| 1144 |
|
| 1145 |
\cs_new_nopar:Npn \__mermap_drawmap_path: |
| 1146 |
{ |
| 1147 |
\begin{scope}[ |
| 1148 |
xshift=\fp_to_dim:n{ (0.5-\l__mermap_tile_westoffset_fp)*\l__mermap_tile_size_dim }, |
| 1149 |
yshift=\fp_to_dim:n{ (0.5-\l__mermap_tile_southoffset_fp)*\l__mermap_tile_size_dim }, |
| 1150 |
mermap_scope_style] |
| 1151 |
\tl_use:N \l__mermap_tikz_map_clip_tl |
| 1152 |
\path[mermap_path_style] (mrcmap.south~west) rectangle (mrcmap.north~east); |
| 1153 |
\end{scope} |
| 1154 |
} |
| 1155 |
|
| 1156 |
|
| 1157 |
\cs_new_nopar:Npn \__mermap_drawtile: |
| 1158 |
{ |
| 1159 |
\tl_set:Nx \l__mermap_tile_filename_tl |
| 1160 |
{ |
| 1161 |
\exp_not:o\l__mermap_tile_basename_tl |
| 1162 |
_\int_use:N\l__mermap_tile_zoom_int |
| 1163 |
_\int_use:N\l__mermap_tile_xmod_int |
| 1164 |
_\int_use:N\l__mermap_tile_y_int |
| 1165 |
.png |
| 1166 |
} |
| 1167 |
\file_if_exist:nTF \l__mermap_tile_filename_tl |
| 1168 |
{ |
| 1169 |
\node[line~width=0mm,inner~sep=0mm,outer~sep=0mm,draw=none,fill=none,rectangle] |
| 1170 |
at (\l__mermap_tx_dim,\l__mermap_ty_dim) |
| 1171 |
{\includegraphics[width=\l__mermap_tile_size_dim]{\l__mermap_tile_filename_tl}}; |
| 1172 |
} |
| 1173 |
{ |
| 1174 |
\path[mermap_path_style] (\l__mermap_tx_dim,\l__mermap_ty_dim) |
| 1175 |
++(-\l__mermap_tile_size_dim/2,-\l__mermap_tile_size_dim/2) |
| 1176 |
rectangle +(\l__mermap_tile_size_dim,\l__mermap_tile_size_dim); |
| 1177 |
} |
| 1178 |
} |
| 1179 |
|
| 1180 |
|
| 1181 |
\cs_new_nopar:Npn \__mermap_drawmap_tiles: |
| 1182 |
{ |
| 1183 |
\begin{scope}[ |
| 1184 |
xshift=\fp_to_dim:n{ (0.5-\l__mermap_tile_westoffset_fp)*\l__mermap_tile_size_dim }, |
| 1185 |
yshift=\fp_to_dim:n{ (0.5-\l__mermap_tile_southoffset_fp)*\l__mermap_tile_size_dim }, |
| 1186 |
mermap_scope_style] |
| 1187 |
\tl_use:N \l__mermap_tikz_map_clip_tl |
| 1188 |
\int_set_eq:NN \l__mermap_tile_x_int \l__mermap_tile_xmin_int |
| 1189 |
\dim_set:Nn \l__mermap_tx_dim {0pt} |
| 1190 |
\int_until_do:nNnn \l__mermap_tile_x_int > \l__mermap_tile_xmax_int |
| 1191 |
{ |
| 1192 |
\dim_set:Nn \l__mermap_ty_dim {0pt} |
| 1193 |
\int_set:Nn \l__mermap_tile_xmod_int {\int_mod:nn{\l__mermap_tile_x_int}{\l__mermap_tile_number_int}} |
| 1194 |
\int_compare:nNnT \l__mermap_tile_xmod_int < 0 |
| 1195 |
{ |
| 1196 |
\int_add:Nn \l__mermap_tile_xmod_int \l__mermap_tile_number_int |
| 1197 |
} |
| 1198 |
\int_set_eq:NN \l__mermap_tile_y_int \l__mermap_tile_ymax_int |
| 1199 |
\int_until_do:nNnn \l__mermap_tile_y_int < \l__mermap_tile_ymin_int |
| 1200 |
{ |
| 1201 |
\int_compare:nNnF \l__mermap_tile_y_int < 0 |
| 1202 |
{ |
| 1203 |
\int_compare:nNnT \l__mermap_tile_y_int < \l__mermap_tile_number_int |
| 1204 |
{ |
| 1205 |
\__mermap_drawtile: |
| 1206 |
} |
| 1207 |
} |
| 1208 |
\dim_add:Nn \l__mermap_ty_dim \l__mermap_tile_size_dim |
| 1209 |
\int_decr:N \l__mermap_tile_y_int |
| 1210 |
} |
| 1211 |
\dim_add:Nn \l__mermap_tx_dim \l__mermap_tile_size_dim |
| 1212 |
\int_incr:N \l__mermap_tile_x_int |
| 1213 |
} |
| 1214 |
\end{scope} |
| 1215 |
} |
| 1216 |
|
| 1217 |
|
| 1218 |
\cs_new_nopar:Npn \__mermap_drawsinglemap: |
| 1219 |
{ |
| 1220 |
\begin{scope}[mermap_scope_style] |
| 1221 |
\tl_use:N \l__mermap_tikz_map_clip_tl |
| 1222 |
\node[above~right,line~width=0mm,inner~sep=0mm,outer~sep=0mm,draw=none,fill=none,rectangle] at (0,0) |
| 1223 |
{\includegraphics[width=\mrctexwidth,height=\mrctexheight]{\l__mermap_definition_id_str.png}}; |
| 1224 |
\end{scope} |
| 1225 |
} |
| 1226 |
|
| 1227 |
|
| 1228 |
\cs_new_nopar:Npn \__mermap_drawmap_mergedmap: |
| 1229 |
{ |
| 1230 |
\str_if_eq:VnTF \l__mermap_tile_resource_tl {mergedmap} |
| 1231 |
{ |
| 1232 |
\__mermap_drawsinglemap: |
| 1233 |
} |
| 1234 |
{ |
| 1235 |
\__mermap_drawmap_path: |
| 1236 |
} |
| 1237 |
} |
| 1238 |
|
| 1239 |
|
| 1240 |
\cs_new_nopar:Npn \__mermap_drawmap_wmsmap: |
| 1241 |
{ |
| 1242 |
\str_if_eq:VnTF \l__mermap_tile_resource_tl {wmsmap} |
| 1243 |
{ |
| 1244 |
\__mermap_drawsinglemap: |
| 1245 |
} |
| 1246 |
{ |
| 1247 |
\__mermap_drawmap_path: |
| 1248 |
} |
| 1249 |
} |
| 1250 |
|
| 1251 |
|
| 1252 |
\msg_new:nnn{ mercatormap }{ draw-auto } |
| 1253 |
{ 'draw=auto' -> 'draw=#1'~is~undefined. } |
| 1254 |
|
| 1255 |
|
| 1256 |
\cs_new_nopar:Npn \__mermap_drawmap_auto: |
| 1257 |
{ |
| 1258 |
\cs_if_exist:cTF {__mermap_drawmap_\l__mermap_tile_resource_tl :} |
| 1259 |
{ |
| 1260 |
\use:c {__mermap_drawmap_\l__mermap_tile_resource_tl :} |
| 1261 |
} |
| 1262 |
{ |
| 1263 |
\str_if_eq:VnTF \l__mermap_tile_resource_tl {none} |
| 1264 |
{ |
| 1265 |
\__mermap_drawmap_path: |
| 1266 |
} |
| 1267 |
{ |
| 1268 |
\msg_warning:nnx { mercatormap }{ draw-undefined }{ \tl_use:N \l__mermap_tile_resource_tl } |
| 1269 |
} |
| 1270 |
} |
| 1271 |
} |
| 1272 |
|
| 1273 |
|
| 1274 |
\msg_new:nnnn{ mercatormap }{ draw-undefined } |
| 1275 |
{ 'draw=#1'~is~undefined. } |
| 1276 |
{ |
| 1277 |
The~option~value~'#1'~is~not~known~for~'draw': |
| 1278 |
perhaps~it~is~spelled~incorrectly. |
| 1279 |
} |
| 1280 |
|
| 1281 |
\NewDocumentCommand \mrcdrawmap { o } |
| 1282 |
{ |
| 1283 |
\group_begin: |
| 1284 |
\IfNoValueF {#1} |
| 1285 |
{ \keys_set:nn { mermap } {#1} } |
| 1286 |
\cs_if_exist:cTF {__mermap_drawmap_\l__mermap_draw_map_tl :} |
| 1287 |
{ |
| 1288 |
\use:c {__mermap_drawmap_\l__mermap_draw_map_tl :} |
| 1289 |
} |
| 1290 |
{ |
| 1291 |
\msg_warning:nnx { mercatormap }{ draw-undefined }{ \tl_use:N \l__mermap_draw_map_tl } |
| 1292 |
} |
| 1293 |
\group_end: |
| 1294 |
} |
| 1295 |
|
| 1296 |
|
| 1297 |
\cs_new_nopar:Npn \__mermap_applymap: |
| 1298 |
{ |
| 1299 |
\file_input:n {\l__mermap_definition_id_str.def} |
| 1300 |
} |
| 1301 |
|
| 1302 |
|
| 1303 |
\NewDocumentCommand \mrcapplymap { m } |
| 1304 |
{ |
| 1305 |
\__mermap_create_definition_id:n {#1} |
| 1306 |
\__mermap_applymap: |
| 1307 |
} |
| 1308 |
|
| 1309 |
|
| 1310 |
\cs_new_nopar:Npn \__mermap_drawinfo: |
| 1311 |
{ |
| 1312 |
\begin{scope}[every~node/.style={fill=white,fill~opacity=0.8,text~opacity=1,font=\sffamily\footnotesize}] |
| 1313 |
\mrcclipmap |
| 1314 |
\tl_set:Nn \l__mermap_tile_basename_tl {_dummy_}% not existing file |
| 1315 |
\mermapset{map~path={draw=white,double=red}} |
| 1316 |
\tikzset{mermap_path_style/.style={draw=white,double=red}} |
| 1317 |
\__mermap_drawmap_tiles: |
| 1318 |
\node at (mrcmap.center) { |
| 1319 |
\begin{tabular}{ll} |
| 1320 |
scale & ca.~\mrcprettymapscale\\ |
| 1321 |
resolution & ca.~\mrcprettymapresolution\\ |
| 1322 |
\TeX\nobreakspace tile~size & ca.~\mrcprettytilesize\\ |
| 1323 |
width & ca.~\mrcprettymapwidth\\ |
| 1324 |
height & ca.~\mrcprettymapheight\\ |
| 1325 |
zoom & $z=\int_use:N \l__mermap_tile_zoom_int$\\ |
| 1326 |
horizontal & $x\in\{\int_use:N\l__mermap_tile_xmin_int,\ldots,\int_use:N\l__mermap_tile_xmax_int\}$\\ |
| 1327 |
vertical & $y\in\{\int_use:N\l__mermap_tile_ymin_int,\ldots,\int_use:N\l__mermap_tile_ymax_int\}$ |
| 1328 |
\end{tabular} |
| 1329 |
}; |
| 1330 |
\node[above] at (mrcmap.south) { |
| 1331 |
\mrcformlat[format~angle=decimal-4]{\mrcmapsouth}, |
| 1332 |
\SI[round-mode=figures,round-precision=6,detect-all]{\fp_to_decimal:n{ |
| 1333 |
\c__mermap_scale_radius_fp*(\mrcmapeast-\mrcmapwest)*cosd(\mrcmapsouth)}}{km} |
| 1334 |
}; |
| 1335 |
\node[below] at (mrcmap.north) { |
| 1336 |
\mrcformlat[format~angle=decimal-4]{\mrcmapnorth}, |
| 1337 |
\SI[round-mode=figures,round-precision=6,detect-all]{\fp_to_decimal:n{ |
| 1338 |
\c__mermap_scale_radius_fp*(\mrcmapeast-\mrcmapwest)*cosd(\mrcmapnorth)}}{km} |
| 1339 |
}; |
| 1340 |
\node[rotate=90] at ([xshift=3mm]mrcmap.west) { |
| 1341 |
\mrcformlon[format~angle=decimal-4]{\mrcmapwest}, |
| 1342 |
\SI[round-mode=figures,round-precision=6,detect-all]{\fp_to_decimal:n{ |
| 1343 |
\c__mermap_scale_radius_fp*(\mrcmapnorth-\mrcmapsouth)}}{km} |
| 1344 |
}; |
| 1345 |
\node[rotate=90] at ([xshift=-3mm]mrcmap.east) { |
| 1346 |
\mrcformlon[format~angle=decimal-4]{\mrcmapeast}, |
| 1347 |
\SI[round-mode=figures,round-precision=6,detect-all]{\fp_to_decimal:n{ |
| 1348 |
\c__mermap_scale_radius_fp*(\mrcmapnorth-\mrcmapsouth)}}{km} |
| 1349 |
}; |
| 1350 |
\end{scope}% |
| 1351 |
} |
| 1352 |
|
| 1353 |
\NewDocumentCommand{\mrcdrawinfo}{ }{ \__mermap_drawinfo: } |
| 1354 |
|
| 1355 |
|
| 1356 |
%---- geodetic network --------------------------------------------------------- |
| 1357 |
|
| 1358 |
|
| 1359 |
\dim_new:N \l__mermap_network_distance_dim |
| 1360 |
\int_new:N \l__mermap_network_pieces_int |
| 1361 |
\tl_new:N \l__mermap_network_font_tl |
| 1362 |
|
| 1363 |
\keys_define:nn { mermap } |
| 1364 |
{ |
| 1365 |
network~distance .dim_set:N = \l__mermap_network_distance_dim, |
| 1366 |
network~pieces .int_set:N = \l__mermap_network_pieces_int, |
| 1367 |
network~font .tl_set:N = \l__mermap_network_font_tl, |
| 1368 |
} |
| 1369 |
|
| 1370 |
\keys_set:nn { mermap } |
| 1371 |
{ |
| 1372 |
network~pieces = 8, |
| 1373 |
network~distance = 2cm, |
| 1374 |
network~font = \fontsize{4pt}{4pt}\sffamily, |
| 1375 |
} |
| 1376 |
|
| 1377 |
\cs_new_nopar:Npn \__mermap_compute_network_step:nn #1#2 |
| 1378 |
{ |
| 1379 |
\fp_set:Nn \l__mermap_tmpa_fp |
| 1380 |
{ |
| 1381 |
min ( \l__mermap_network_pieces_int, round((#1)/\l__mermap_network_distance_dim) ) |
| 1382 |
} |
| 1383 |
\fp_set:Nn \l__mermap_tmpb_fp { (#2)/\l__mermap_tmpa_fp } |
| 1384 |
\fp_set:Nn \l__mermap_tmpa_fp { floor(ln(\l__mermap_tmpb_fp)/ln(10)) } |
| 1385 |
\fp_compare:nNnTF {\l__mermap_tmpa_fp} < {0} |
| 1386 |
{ |
| 1387 |
\fp_compare:nNnTF {\l__mermap_tmpa_fp} > {-5} |
| 1388 |
{ |
| 1389 |
\use:x |
| 1390 |
{ |
| 1391 |
\exp_not:N\keys_set:nn { mermap }{ format~angle=decimal\fp_to_int:N\l__mermap_tmpa_fp} |
| 1392 |
} |
| 1393 |
} |
| 1394 |
{ |
| 1395 |
\keys_set:nn { mermap }{ format~angle=decimal } |
| 1396 |
} |
| 1397 |
} |
| 1398 |
{ |
| 1399 |
\keys_set:nn { mermap }{ format~angle=decimal-0 } |
| 1400 |
} |
| 1401 |
\fp_set:Nn \l__mermap_tmpa_fp { 10^\l__mermap_tmpa_fp } |
| 1402 |
\fp_set:Nn \l__mermap_tmpb_fp { \l__mermap_tmpb_fp/\l__mermap_tmpa_fp } |
| 1403 |
\fp_compare:nNnTF {abs(\l__mermap_tmpb_fp-1)} < {abs(\l__mermap_tmpb_fp-2)} |
| 1404 |
{ |
| 1405 |
\fp_compare:nNnTF {abs(\l__mermap_tmpb_fp-1)} < {abs(\l__mermap_tmpb_fp-5)} |
| 1406 |
{ |
| 1407 |
\fp_set:Nn \l__mermap_result_fp {\l__mermap_tmpa_fp} |
| 1408 |
} |
| 1409 |
{ |
| 1410 |
\fp_set:Nn \l__mermap_result_fp {5*\l__mermap_tmpa_fp} |
| 1411 |
} |
| 1412 |
} |
| 1413 |
{ |
| 1414 |
\fp_compare:nNnTF {abs(\l__mermap_tmpb_fp-2)} < {abs(\l__mermap_tmpb_fp-5)} |
| 1415 |
{ |
| 1416 |
\fp_set:Nn \l__mermap_result_fp {2*\l__mermap_tmpa_fp} |
| 1417 |
} |
| 1418 |
{ |
| 1419 |
\fp_set:Nn \l__mermap_result_fp {5*\l__mermap_tmpa_fp} |
| 1420 |
} |
| 1421 |
} |
| 1422 |
} |
| 1423 |
|
| 1424 |
|
| 1425 |
\NewDocumentCommand\mrcdrawnetwork { o } |
| 1426 |
{ |
| 1427 |
\begin{scope}[every~node/.style={inner~sep=0.5pt,black!50!gray, |
| 1428 |
font=\l__mermap_network_font_tl,fill=white,opacity=0.3,text~opacity=1}] |
| 1429 |
\IfNoValueF {#1} { \keys_set:nn { mermap } {#1} } |
| 1430 |
\tl_use:N \l__mermap_tikz_map_clip_tl |
| 1431 |
\__mermap_compute_network_step:nn {\l__mermap_tex_height_fp}{\l__mermap_mapnorth_fp-\l__mermap_mapsouth_fp} |
| 1432 |
\fp_set:Nn \l__mermap_tmpa_fp { ceil(\l__mermap_mapsouth_fp/\l__mermap_result_fp)*\l__mermap_result_fp} |
| 1433 |
\fp_compare:nNnT {\l__mermap_tmpa_fp-\l__mermap_mapsouth_fp} < {1e-10} |
| 1434 |
{ |
| 1435 |
\fp_add:Nn \l__mermap_tmpa_fp {\l__mermap_result_fp} |
| 1436 |
} |
| 1437 |
\fp_while_do:nNnn {\l__mermap_tmpa_fp} < {\l__mermap_mapnorth_fp} |
| 1438 |
{ |
| 1439 |
\tl_set:Nn \l__mermap_tmpa_tl {\fp_use:N\l__mermap_tmpa_fp} |
| 1440 |
\draw[gray,very~thin] (mrc~cs\c_colon_str lat=\l__mermap_tmpa_tl,lon=\mrcmapwest) |
| 1441 |
coordinate (mermap_temp) |
| 1442 |
node[right=1mm,inner~sep=0.5pt,black!50!gray,font=\l__mermap_network_font_tl, |
| 1443 |
fill=white,opacity=0.3,text~opacity=1, |
| 1444 |
]{\mrcformlat{\l__mermap_tmpa_tl}} |
| 1445 |
-- (mermap_temp -| mrcmap.east) |
| 1446 |
node[left=1mm,inner~sep=0.5pt,black!50!gray,font=\l__mermap_network_font_tl, |
| 1447 |
fill=white,opacity=0.3,text~opacity=1, |
| 1448 |
]{\mrcformlat{\l__mermap_tmpa_tl}} |
| 1449 |
; |
| 1450 |
\fp_add:Nn \l__mermap_tmpa_fp {\l__mermap_result_fp} |
| 1451 |
} |
| 1452 |
\__mermap_compute_network_step:nn {\l__mermap_tex_width_fp}{\l__mermap_mapeast_fp-\l__mermap_mapwest_fp} |
| 1453 |
\fp_set:Nn \l__mermap_tmpa_fp { ceil(\l__mermap_mapwest_fp/\l__mermap_result_fp)*\l__mermap_result_fp} |
| 1454 |
\fp_compare:nNnT {\l__mermap_tmpa_fp-\l__mermap_mapwest_fp} < {1e-10} |
| 1455 |
{ |
| 1456 |
\fp_add:Nn \l__mermap_tmpa_fp {\l__mermap_result_fp} |
| 1457 |
} |
| 1458 |
\fp_while_do:nNnn {\l__mermap_tmpa_fp} < {\l__mermap_mapeast_fp} |
| 1459 |
{ |
| 1460 |
\tl_set:Nn \l__mermap_tmpa_tl {\fp_use:N\l__mermap_tmpa_fp} |
| 1461 |
\draw[gray,very~thin] (mrc~cs\c_colon_str lon=\l__mermap_tmpa_tl,lat=\mrcmapsouth) |
| 1462 |
coordinate (mermap_temp) |
| 1463 |
node[above=1mm,inner~sep=0.5pt,black!50!gray,font=\l__mermap_network_font_tl, |
| 1464 |
fill=white,opacity=0.3,text~opacity=1, |
| 1465 |
]{\mrcformlon{\l__mermap_tmpa_tl}} |
| 1466 |
-- (mermap_temp |- mrcmap.north) |
| 1467 |
node[below=1mm,inner~sep=0.5pt,black!50!gray,font=\l__mermap_network_font_tl, |
| 1468 |
fill=white,opacity=0.3,text~opacity=1, |
| 1469 |
]{\mrcformlon{\l__mermap_tmpa_tl}} |
| 1470 |
; |
| 1471 |
\fp_add:Nn \l__mermap_tmpa_fp {\l__mermap_result_fp} |
| 1472 |
} |
| 1473 |
\end{scope} |
| 1474 |
} |
| 1475 |
|
| 1476 |
|
| 1477 |
%---- scaling and formatting --------------------------------------------------- |
| 1478 |
|
| 1479 |
\tl_new:N \l__mermap_temp_tl |
| 1480 |
|
| 1481 |
\keys_define:nn { mermap } |
| 1482 |
{ |
| 1483 |
format~south .cs_set:Np = \__mermap_format_south:n #1, |
| 1484 |
format~north .cs_set:Np = \__mermap_format_north:n #1, |
| 1485 |
format~east .cs_set:Np = \__mermap_format_east:n #1, |
| 1486 |
format~west .cs_set:Np = \__mermap_format_west:n #1, |
| 1487 |
__format_angle .cs_set:Np = \__mermap_format_angle:n #1, |
| 1488 |
format~angle .choice:, |
| 1489 |
format~angle .value_required:n = true, |
| 1490 |
format~angle / decimal .meta:nn = {mermap}{__format_angle=\ang{##1}}, |
| 1491 |
format~angle / decimal-0 .meta:nn = {mermap}{__format_angle={\ang[round-mode=places,round-precision=0]{##1}}}, |
| 1492 |
format~angle / decimal-1 .meta:nn = {mermap}{__format_angle={\ang[round-mode=places,round-precision=1]{##1}}}, |
| 1493 |
format~angle / decimal-2 .meta:nn = {mermap}{__format_angle={\ang[round-mode=places,round-precision=2]{##1}}}, |
| 1494 |
format~angle / decimal-3 .meta:nn = {mermap}{__format_angle={\ang[round-mode=places,round-precision=3]{##1}}}, |
| 1495 |
format~angle / decimal-4 .meta:nn = {mermap}{__format_angle={\ang[round-mode=places,round-precision=4]{##1}}}, |
| 1496 |
format~angle / degree .meta:nn = {mermap}{format~angle=decimal-0}, |
| 1497 |
format~angle / minute .meta:nn = {mermap}{__format_angle=\__mermap_format_angle_minute:n{##1}}, |
| 1498 |
format~angle / second .meta:nn = {mermap}{__format_angle=\__mermap_format_angle_second:n{##1}}, |
| 1499 |
format~NEWS~absolute .meta:nn = {mermap}{ |
| 1500 |
format~south = {##1}, format~north = {##1}, format~east = {##1}, format~west = {##1} }, |
| 1501 |
format~NEWS~numeric .meta:nn = {mermap}{ |
| 1502 |
format~south = {$-$##1}, format~north = {##1}, format~east = {##1}, format~west = {$-$##1} }, |
| 1503 |
} |
| 1504 |
|
| 1505 |
|
| 1506 |
\keys_set:nn { mermap } |
| 1507 |
{ |
| 1508 |
format~south = {#1\,S}, |
| 1509 |
format~north = {#1\,N}, |
| 1510 |
format~east = {#1\,E}, |
| 1511 |
format~west = {#1\,W}, |
| 1512 |
format~angle = decimal-4, |
| 1513 |
} |
| 1514 |
|
| 1515 |
|
| 1516 |
\NewExpandableDocumentCommand{\mrckmtotex}{ m } |
| 1517 |
{ |
| 1518 |
\fp_to_dim:n { (#1)/\l__mermap_scale_fp } |
| 1519 |
} |
| 1520 |
|
| 1521 |
\NewExpandableDocumentCommand{\mrcmiletotex}{ m } |
| 1522 |
{ |
| 1523 |
\fp_to_dim:n { (#1)*\c__mermap_mile_fp/\l__mermap_scale_fp } |
| 1524 |
} |
| 1525 |
|
| 1526 |
\NewExpandableDocumentCommand{\mrctextokm}{ m } |
| 1527 |
{ |
| 1528 |
\fp_to_decimal:n { (#1)*\l__mermap_scale_fp } |
| 1529 |
} |
| 1530 |
|
| 1531 |
\NewExpandableDocumentCommand{\mrctextomile}{ m } |
| 1532 |
{ |
| 1533 |
\fp_to_decimal:n { (#1)/\c__mermap_mile_fp*\l__mermap_scale_fp } |
| 1534 |
} |
| 1535 |
|
| 1536 |
\NewDocumentCommand{\mrcprettymapscale}{ } |
| 1537 |
{ |
| 1538 |
1\,\c_colon_str\,\num[round-mode=figures,round-precision=3,detect-all]{\fp_to_decimal:N \l__mermap_scale_denominator_fp} |
| 1539 |
} |
| 1540 |
|
| 1541 |
|
| 1542 |
\cs_new_nopar:Npn \__mermap_pretty_distance:n #1 |
| 1543 |
{ |
| 1544 |
\fp_set:Nn \l__mermap_tmpa_fp { #1 } |
| 1545 |
\fp_compare:nNnTF \l__mermap_tmpa_fp < 5 |
| 1546 |
{ |
| 1547 |
\SI[round-mode=figures,round-precision=3,detect-all]{\fp_to_decimal:n{1000*\l__mermap_tmpa_fp}}{\meter} |
| 1548 |
} |
| 1549 |
{ |
| 1550 |
\SI[round-mode=figures,round-precision=3,detect-all]{\fp_to_decimal:N \l__mermap_tmpa_fp}{\kilo\meter} |
| 1551 |
} |
| 1552 |
} |
| 1553 |
|
| 1554 |
|
| 1555 |
\cs_new_nopar:Npn \__mermap_pretty_length:n #1 |
| 1556 |
{ |
| 1557 |
\fp_set:Nn \l__mermap_tmpa_fp { (#1)*\l__mermap_scale_fp } |
| 1558 |
\fp_compare:nNnTF \l__mermap_tmpa_fp < 5 |
| 1559 |
{ |
| 1560 |
\SI[round-mode=figures,round-precision=3,detect-all]{\fp_to_decimal:n{1000*\l__mermap_tmpa_fp}}{\meter} |
| 1561 |
} |
| 1562 |
{ |
| 1563 |
\SI[round-mode=figures,round-precision=3,detect-all]{\fp_to_decimal:N \l__mermap_tmpa_fp}{\kilo\meter} |
| 1564 |
} |
| 1565 |
} |
| 1566 |
|
| 1567 |
|
| 1568 |
\NewDocumentCommand{\mrcprettymapwidth}{ } |
| 1569 |
{ |
| 1570 |
\__mermap_pretty_length:n {\mrctexwidth} |
| 1571 |
} |
| 1572 |
|
| 1573 |
\NewDocumentCommand{\mrcprettymapheight}{ } |
| 1574 |
{ |
| 1575 |
\__mermap_pretty_length:n {\mrctexheight} |
| 1576 |
} |
| 1577 |
|
| 1578 |
\NewDocumentCommand{\mrcprettymapresolution}{ } |
| 1579 |
{ |
| 1580 |
\SI[round-mode=places,round-precision=0,detect-all]{\fp_to_decimal:n{1in*\l__mermap_pixel_width_tl/\l__mermap_tex_width_fp}}{dpi} |
| 1581 |
} |
| 1582 |
|
| 1583 |
\NewDocumentCommand{\mrcprettytilesize}{ } |
| 1584 |
{ |
| 1585 |
\SI[round-mode=places,round-precision=3,detect-all]{\fp_to_decimal:n{\l__mermap_tile_size_dim/1mm}}{\milli\meter} |
| 1586 |
} |
| 1587 |
|
| 1588 |
|
| 1589 |
\cs_new_nopar:Npn \__mermap_format_angle_minute:n #1 |
| 1590 |
{ |
| 1591 |
\fp_set:Nn \l__mermap_tmpa_fp {floor(#1)} |
| 1592 |
\fp_set:Nn \l__mermap_tmpb_fp {round((#1-\l__mermap_tmpa_fp)*60)} |
| 1593 |
\ang[add-arc-degree-zero,add-arc-minute-zero] |
| 1594 |
{ |
| 1595 |
\fp_to_int:N \l__mermap_tmpa_fp ; |
| 1596 |
\fp_to_int:N \l__mermap_tmpb_fp ; |
| 1597 |
} |
| 1598 |
} |
| 1599 |
|
| 1600 |
|
| 1601 |
\cs_new_nopar:Npn \__mermap_format_angle_second:n #1 |
| 1602 |
{ |
| 1603 |
\fp_set:Nn \l__mermap_tmpa_fp {floor(#1)} |
| 1604 |
\fp_set:Nn \l__mermap_tmpb_fp {floor((#1-\l__mermap_tmpa_fp)*60)} |
| 1605 |
\ang[add-arc-degree-zero,add-arc-minute-zero] |
| 1606 |
{ |
| 1607 |
\fp_to_int:N \l__mermap_tmpa_fp ; |
| 1608 |
\fp_to_int:N \l__mermap_tmpb_fp ; |
| 1609 |
\fp_to_int:n {round(((#1-\l__mermap_tmpa_fp)*60-\l__mermap_tmpb_fp)*60)} |
| 1610 |
} |
| 1611 |
} |
| 1612 |
|
| 1613 |
\NewDocumentCommand{\mrcformlat}{ o m } |
| 1614 |
{ |
| 1615 |
\group_begin: |
| 1616 |
\IfNoValueF {#1} |
| 1617 |
{ \keys_set:nn { mermap } {#1} } |
| 1618 |
\fp_set:Nn \l__mermap_tmpa_fp {#2} |
| 1619 |
\fp_compare:nNnTF \l__mermap_tmpa_fp < 0 |
| 1620 |
{ |
| 1621 |
\tl_set:Nx \l__mermap_temp_tl {\fp_to_decimal:n{-\l__mermap_tmpa_fp}} |
| 1622 |
\__mermap_format_south:n {\__mermap_format_angle:n{\l__mermap_temp_tl}} |
| 1623 |
} |
| 1624 |
{ |
| 1625 |
\tl_set:Nx \l__mermap_temp_tl {\fp_to_decimal:N \l__mermap_tmpa_fp} |
| 1626 |
\__mermap_format_north:n {\__mermap_format_angle:n{\l__mermap_temp_tl}} |
| 1627 |
} |
| 1628 |
\group_end: |
| 1629 |
} |
| 1630 |
|
| 1631 |
\NewDocumentCommand{\mrcformlon}{ o m } |
| 1632 |
{ |
| 1633 |
\group_begin: |
| 1634 |
\IfNoValueF {#1} |
| 1635 |
{ \keys_set:nn { mermap } {#1} } |
| 1636 |
\fp_set:Nn \l__mermap_tmpa_fp {#2-360*floor((#2+180)/360)} |
| 1637 |
\fp_compare:nNnTF \l__mermap_tmpa_fp < 0 |
| 1638 |
{ |
| 1639 |
\tl_set:Nx \l__mermap_temp_tl {\fp_to_decimal:n{-\l__mermap_tmpa_fp}} |
| 1640 |
\__mermap_format_west:n{\__mermap_format_angle:n{\l__mermap_temp_tl}} |
| 1641 |
} |
| 1642 |
{ |
| 1643 |
\tl_set:Nx \l__mermap_temp_tl {\fp_to_decimal:N \l__mermap_tmpa_fp} |
| 1644 |
\__mermap_format_east:n {\__mermap_format_angle:n{\l__mermap_temp_tl}} |
| 1645 |
} |
| 1646 |
\group_end: |
| 1647 |
} |
| 1648 |
|
| 1649 |
|
| 1650 |
%---- scale bars --------------------------------------------------------------- |
| 1651 |
|
| 1652 |
\bool_new:N \l__mermap_scalebar_double_bool |
| 1653 |
\bool_new:N \l__mermap_scalebar_transparent_bool |
| 1654 |
\dim_new:N \l__mermap_scalebar_height_dim |
| 1655 |
\fp_new:N \l__mermap_scalebar_width_fp |
| 1656 |
\int_new:N \l__mermap_scalebar_partitions_int |
| 1657 |
\tl_new:N \l__mermap_scalebar_position_tl |
| 1658 |
|
| 1659 |
|
| 1660 |
\cs_new_nopar:Npn \__mermap_scalebar_positioning:w #1#2#3#4#5;#6;#7 \q_stop |
| 1661 |
{ |
| 1662 |
\tl_if_empty:nTF {#5} |
| 1663 |
{ |
| 1664 |
\fp_set:Nn \l__mermap_tmpa_fp {0} |
| 1665 |
\fp_set:Nn \l__mermap_tmpb_fp {0} |
| 1666 |
} |
| 1667 |
{ |
| 1668 |
\fp_set:Nn \l__mermap_tmpa_fp {#3*(#5)} |
| 1669 |
\tl_if_empty:nTF {#6} |
| 1670 |
{ |
| 1671 |
\fp_set:Nn \l__mermap_tmpb_fp {#4*(#5)} |
| 1672 |
} |
| 1673 |
{ |
| 1674 |
\fp_set:Nn \l__mermap_tmpb_fp {#4*(#6)} |
| 1675 |
} |
| 1676 |
} |
| 1677 |
\tl_set:Nx \l__mermap_scalebar_at_tl |
| 1678 |
{ |
| 1679 |
{([xshift=\fp_to_dim:N\l__mermap_tmpa_fp,yshift=\fp_to_dim:N\l__mermap_tmpb_fp]mrcmap.#1)} |
| 1680 |
} |
| 1681 |
\tl_set:Nn \l__mermap_scalebar_placement_tl {#2} |
| 1682 |
} |
| 1683 |
|
| 1684 |
\keys_define:nn { mermap/scalebar } |
| 1685 |
{ |
| 1686 |
width-in-km .fp_set:N = \l__mermap_scalebar_width_fp, |
| 1687 |
width-in-kilometer .meta:nn = { mermap/scalebar }{ width-in-km={#1} }, |
| 1688 |
width-in-meter .meta:nn = { mermap/scalebar }{ width-in-km={(#1)/1000} }, |
| 1689 |
width-in-mile .meta:nn = { mermap/scalebar }{ width-in-km={(#1)*\c__mermap_mile_fp} }, |
| 1690 |
width-in-yard .meta:nn = { mermap/scalebar }{ width-in-km={(#1)*0.0009144} }, |
| 1691 |
partitions .int_set:N = \l__mermap_scalebar_partitions_int, |
| 1692 |
height .dim_set:N = \l__mermap_scalebar_height_dim, |
| 1693 |
at .tl_set:N = \l__mermap_scalebar_at_tl, |
| 1694 |
placement .tl_set:N = \l__mermap_scalebar_placement_tl, |
| 1695 |
major~style .code:n = {\tikzset{mrcscalebarmajor/.style={#1}}}, |
| 1696 |
minor~style .code:n = {\tikzset{mrcscalebarminor/.style={#1}}}, |
| 1697 |
double .bool_set:N = \l__mermap_scalebar_double_bool, |
| 1698 |
single .bool_set_inverse:N = \l__mermap_scalebar_double_bool, |
| 1699 |
transparent .bool_set:N = \l__mermap_scalebar_transparent_bool, |
| 1700 |
solid .bool_set_inverse:N = \l__mermap_scalebar_transparent_bool, |
| 1701 |
scale .code:n = {\fp_set:Nn \l__mermap_scale_fp { #1 / (1cm*100000) }}, |
| 1702 |
south-east-inside .code:n = |
| 1703 |
{ \__mermap_scalebar_positioning:w {south~east}{above~left}{-1}{1}#1;;\q_stop }, |
| 1704 |
south-east-outside .code:n = |
| 1705 |
{ \__mermap_scalebar_positioning:w {south~east}{below~left}{-1}{-1}#1;;\q_stop }, |
| 1706 |
south-west-inside .code:n = |
| 1707 |
{ \__mermap_scalebar_positioning:w {south~west}{above~right}{1}{1}#1;;\q_stop }, |
| 1708 |
south-west-outside .code:n = |
| 1709 |
{ \__mermap_scalebar_positioning:w {south~west}{below~right}{1}{-1}#1;;\q_stop }, |
| 1710 |
north-west-inside .code:n = |
| 1711 |
{ \__mermap_scalebar_positioning:w {north~west}{below~right}{1}{-1}#1;;\q_stop }, |
| 1712 |
north-west-outside .code:n = |
| 1713 |
{ \__mermap_scalebar_positioning:w {north~west}{above~right}{1}{1}#1;;\q_stop }, |
| 1714 |
north-east-inside .code:n = |
| 1715 |
{ \__mermap_scalebar_positioning:w {north~east}{below~left}{-1}{-1}#1;;\q_stop }, |
| 1716 |
north-east-outside .code:n = |
| 1717 |
{ \__mermap_scalebar_positioning:w {north~east}{above~left}{-1}{1}#1;;\q_stop }, |
| 1718 |
} |
| 1719 |
|
| 1720 |
\keys_set:nn { mermap/scalebar } |
| 1721 |
{ |
| 1722 |
width-in-km = 0, |
| 1723 |
partitions = 5, |
| 1724 |
double = true, |
| 1725 |
transparent = true, |
| 1726 |
height = 2mm, |
| 1727 |
at = {(0,0)}, |
| 1728 |
placement =, |
| 1729 |
major~style =, |
| 1730 |
minor~style =, |
| 1731 |
} |
| 1732 |
|
| 1733 |
\cs_new_nopar:Npn \__mermap_drawscalebar: |
| 1734 |
{ |
| 1735 |
\use:x |
| 1736 |
{ |
| 1737 |
\exp_not:N\node[name=mrcscalebar, |
| 1738 |
at={\exp_not:V\l__mermap_scalebar_at_tl}, |
| 1739 |
\exp_not:V\l__mermap_scalebar_placement_tl, |
| 1740 |
line~width=0mm,inner~sep=0mm,outer~sep=0mm,draw=none,fill=none,rectangle, |
| 1741 |
minimum~width=\mrckmtotex{\l__mermap_scalebar_width_fp}, |
| 1742 |
minimum~height=\l__mermap_scalebar_height_dim]{}; |
| 1743 |
} |
| 1744 |
\begin{scope}[shift=(mrcscalebar.south~west)] |
| 1745 |
\__mermap_tikz_path_begin:n { fill=black, mrcscalebarmajor } |
| 1746 |
\pgfseteorule |
| 1747 |
\fp_set:Nn \l__mermap_tmpa_fp {\l__mermap_scalebar_width_fp/\l__mermap_scale_fp} % Breite |
| 1748 |
\pgfpathrectangle{\pgfpoint{0pt}{0pt}} |
| 1749 |
{\pgfpoint{\fp_to_dim:N\l__mermap_tmpa_fp}{\l__mermap_scalebar_height_dim}} |
| 1750 |
\bool_if:NF \l__mermap_scalebar_transparent_bool |
| 1751 |
{ |
| 1752 |
\__mermap_tikz_path_end: |
| 1753 |
\__mermap_tikz_path_begin:n { fill=white, mrcscalebarminor } |
| 1754 |
\fp_set:Nn \l__mermap_tmpa_fp {\l__mermap_scalebar_width_fp/\l__mermap_scale_fp} |
| 1755 |
} |
| 1756 |
\fp_set:Nn \l__mermap_tmpb_fp {\l__mermap_tmpa_fp/\l__mermap_scalebar_partitions_int} |
| 1757 |
\bool_if:NTF \l__mermap_scalebar_double_bool |
| 1758 |
{ |
| 1759 |
\dim_set:Nn \l__mermap_tmpb_dim {\l__mermap_scalebar_height_dim/2} |
| 1760 |
\dim_set:Nn \l__mermap_tmpa_dim {0.2pt-\l__mermap_tmpb_dim} |
| 1761 |
\int_compare:nNnTF \l__mermap_scalebar_partitions_int = 1 |
| 1762 |
{ |
| 1763 |
\pgfpathrectangle{\pgfpoint{0.2pt}{\l__mermap_tmpb_dim}} |
| 1764 |
{\pgfpoint{\fp_to_dim:n{\l__mermap_tmpb_fp-0.4pt}}{\l__mermap_tmpa_dim}} |
| 1765 |
} |
| 1766 |
{ |
| 1767 |
\pgfpathrectangle{\pgfpoint{0.2pt}{\l__mermap_tmpb_dim}} |
| 1768 |
{\pgfpoint{\fp_to_dim:n{\l__mermap_tmpb_fp-0.2pt}}{\l__mermap_tmpa_dim}} |
| 1769 |
} |
| 1770 |
\int_step_inline:nn { \l__mermap_scalebar_partitions_int-1 } |
| 1771 |
{ |
| 1772 |
\dim_set:Nn \l__mermap_tmpa_dim {-\l__mermap_tmpa_dim} |
| 1773 |
\int_compare:nNnTF {##1+1} = \l__mermap_scalebar_partitions_int |
| 1774 |
{ |
| 1775 |
\pgfpathrectangle{\pgfpoint{\fp_to_dim:n{##1*\l__mermap_tmpb_fp}}{\l__mermap_tmpb_dim}} |
| 1776 |
{\pgfpoint{\fp_to_dim:n{\l__mermap_tmpb_fp-0.2pt}}{\l__mermap_tmpa_dim}} |
| 1777 |
} |
| 1778 |
{ |
| 1779 |
\pgfpathrectangle{\pgfpoint{\fp_to_dim:n{##1*\l__mermap_tmpb_fp}}{\l__mermap_tmpb_dim}} |
| 1780 |
{\pgfpoint{\fp_to_dim:N\l__mermap_tmpb_fp}{\l__mermap_tmpa_dim}} |
| 1781 |
} |
| 1782 |
} |
| 1783 |
} |
| 1784 |
{ |
| 1785 |
\dim_set:Nn \l__mermap_tmpa_dim {\l__mermap_scalebar_height_dim-0.4pt} |
| 1786 |
\int_step_inline:nnnn { 1 }{ 2 }{ \l__mermap_scalebar_partitions_int-1 } |
| 1787 |
{ |
| 1788 |
\int_compare:nNnTF {##1+1} = \l__mermap_scalebar_partitions_int |
| 1789 |
{ |
| 1790 |
\pgfpathrectangle{\pgfpoint{\fp_to_dim:n{##1*\l__mermap_tmpb_fp}}{0.2pt}} |
| 1791 |
{\pgfpoint{\fp_to_dim:n{\l__mermap_tmpb_fp-0.2pt}}{\l__mermap_tmpa_dim}} |
| 1792 |
} |
| 1793 |
{ |
| 1794 |
\pgfpathrectangle{\pgfpoint{\fp_to_dim:n{##1*\l__mermap_tmpb_fp}}{0.2pt}} |
| 1795 |
{\pgfpoint{\fp_to_dim:N\l__mermap_tmpb_fp}{\l__mermap_tmpa_dim}} |
| 1796 |
} |
| 1797 |
} |
| 1798 |
} |
| 1799 |
\__mermap_tikz_path_end: |
| 1800 |
\end{scope} |
| 1801 |
} |
| 1802 |
|
| 1803 |
\msg_new:nnnn{ mercatormap }{ scalebar-too-large } |
| 1804 |
{ The~width~of~the~scale~bar~is~too~large:~#1. } |
| 1805 |
{ |
| 1806 |
You~should~provide~a~smaller~value~by~using~width-in-km~or~width-in-mile. |
| 1807 |
} |
| 1808 |
|
| 1809 |
\msg_new:nnnn{ mercatormap }{ scalebar-scale-unset } |
| 1810 |
{ The~map~scale~is~unknown. } |
| 1811 |
{ |
| 1812 |
Use~\token_to_str:N \mrcdrawscalebar \ with~a~defined~map~or~set~'scale'~ |
| 1813 |
explicitely. |
| 1814 |
} |
| 1815 |
|
| 1816 |
\NewDocumentCommand \mrcdrawscalebar { o } |
| 1817 |
{ |
| 1818 |
\group_begin: |
| 1819 |
\IfNoValueF {#1} { \keys_set:nn { mermap/scalebar } {#1} } |
| 1820 |
\fp_compare:nNnT \l__mermap_scale_fp = 0 |
| 1821 |
{ |
| 1822 |
\msg_error:nn{ mercatormap }{ scalebar-scale-unset } |
| 1823 |
} |
| 1824 |
\fp_compare:nNnT {\l__mermap_scalebar_width_fp/\l__mermap_scale_fp} > {575cm} |
| 1825 |
{ |
| 1826 |
\msg_error:nnx{ mercatormap }{ scalebar-too-large } |
| 1827 |
{ \fp_to_dim:n{\l__mermap_scalebar_width_fp/\l__mermap_scale_fp} } |
| 1828 |
} |
| 1829 |
\__mermap_drawscalebar: |
| 1830 |
\group_end: |
| 1831 |
} |
| 1832 |
|
| 1833 |
%---- markers ------------------------------------------------------------------ |
| 1834 |
|
| 1835 |
\bool_new:N \l__mermap_marker_show_bool |
| 1836 |
\bool_new:N \l__mermap_marker_use_links |
| 1837 |
\bool_new:N \l__mermap_marker_use_urls |
| 1838 |
|
| 1839 |
\fp_new:N \l__mermap_marker_angle_fp |
| 1840 |
\fp_new:N \l__mermap_marker_distance_fp |
| 1841 |
\fp_new:N \l__mermap_marker_inner_radius_fp |
| 1842 |
\fp_new:N \l__mermap_marker_latitude_fp |
| 1843 |
\fp_new:N \l__mermap_marker_longitude_fp |
| 1844 |
\fp_new:N \l__mermap_marker_radius_fp |
| 1845 |
\fp_new:N \l__mermap_marker_shift_fp |
| 1846 |
|
| 1847 |
\tl_new:N \l__mermap_every_marker_first_tl |
| 1848 |
\tl_new:N \l__mermap_every_marker_last_tl |
| 1849 |
\tl_new:N \l__mermap_marker_alias_tl |
| 1850 |
\tl_new:N \l__mermap_marker_category_tl |
| 1851 |
\tl_new:N \l__mermap_marker_contents_tl |
| 1852 |
\tl_new:N \l__mermap_marker_font_tl |
| 1853 |
\tl_new:N \l_mermap_marker_generic_tl |
| 1854 |
\tl_new:N \l__mermap_marker_link_tl |
| 1855 |
\tl_new:N \l__mermap_marker_pictocontents_tl |
| 1856 |
\tl_new:N \l__mermap_marker_type_tl |
| 1857 |
\tl_new:N \l__mermap_marker_url_tl |
| 1858 |
\tl_new:N \l_mermap_marker_uuid_tl |
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
\use:x |
| 1864 |
{ |
| 1865 |
\cs_new_nopar:Npn \exp_not:N\__mermap_marker_position:w ##1 \c_colon_str ##2 \exp_not:N \q_stop |
| 1866 |
} |
| 1867 |
{ |
| 1868 |
\fp_set:Nn \l__mermap_marker_latitude_fp {#1} |
| 1869 |
\fp_set:Nn \l__mermap_marker_longitude_fp {#2} |
| 1870 |
} |
| 1871 |
|
| 1872 |
|
| 1873 |
\keys_define:nn { mermap/marker } |
| 1874 |
{ |
| 1875 |
latitude .fp_set:N = \l__mermap_marker_latitude_fp, |
| 1876 |
lat .fp_set:N = \l__mermap_marker_latitude_fp, |
| 1877 |
longitude .fp_set:N = \l__mermap_marker_longitude_fp, |
| 1878 |
lon .fp_set:N = \l__mermap_marker_longitude_fp, |
| 1879 |
position .code:n = {\__mermap_marker_position:w #1 \q_stop}, |
| 1880 |
named~position .meta:nn = {mermap/marker}{latitude=\mrcNPlat{#1},longitude=\mrcNPlon{#1}}, |
| 1881 |
use~inside .choice: =, |
| 1882 |
use~inside .value_required:n = true, |
| 1883 |
use~inside/map .code:n = { \cs_set_eq:NN \__mermap_if_marker_inside:nnTF \__mermap_if_in_map:nnTF }, |
| 1884 |
use~inside/vicinity .code:n = { \cs_set_eq:NN \__mermap_if_marker_inside:nnTF \__mermap_if_in_vicinity:nnTF }, |
| 1885 |
alias .tl_set:N = \l__mermap_marker_alias_tl, |
| 1886 |
contents .tl_set:N = \l__mermap_marker_contents_tl, |
| 1887 |
pictocontents .tl_set:N = \l__mermap_marker_pictocontents_tl, |
| 1888 |
uuid .tl_set:N = \l_mermap_marker_uuid_tl, |
| 1889 |
generic .tl_set:N = \l_mermap_marker_generic_tl, |
| 1890 |
url .tl_set:N = \l__mermap_marker_url_tl, |
| 1891 |
link .tl_set:N = \l__mermap_marker_link_tl, |
| 1892 |
category .tl_set:N = \l__mermap_marker_category_tl, |
| 1893 |
type .tl_set:N = \l__mermap_marker_type_tl, |
| 1894 |
angle .fp_set:N = \l__mermap_marker_angle_fp, |
| 1895 |
shift .fp_set:N = \l__mermap_marker_shift_fp, |
| 1896 |
distance .fp_set:N = \l__mermap_marker_distance_fp, |
| 1897 |
draw .code:n = \colorlet{mrcmarkerdraw}{#1}, |
| 1898 |
fill .code:n = \colorlet{mrcmarkerfill}{#1}, |
| 1899 |
text .code:n = \colorlet{mrcmarkertext}{#1}, |
| 1900 |
font .tl_set:N = \l__mermap_marker_font_tl, |
| 1901 |
radius .fp_set:N = \l__mermap_marker_radius_fp, |
| 1902 |
inner~radius .fp_set:N = \l__mermap_marker_inner_radius_fp, |
| 1903 |
path~style .code:n = {\tikzset{mrcpathstyle/.style={#1}}}, |
| 1904 |
node~style .code:n = {\tikzset{mrcnodestyle/.style={#1}}}, |
| 1905 |
show .bool_set:N = \l__mermap_marker_show_bool, |
| 1906 |
hide .bool_set_inverse:N = \l__mermap_marker_show_bool, |
| 1907 |
show~category .code:n = |
| 1908 |
{ \str_if_eq:VnT \l__mermap_marker_category_tl {#1} {\bool_set_true:N \l__mermap_marker_show_bool} }, |
| 1909 |
show~all~but~category .code:n = |
| 1910 |
{ \str_if_eq:VnF \l__mermap_marker_category_tl {#1} {\bool_set_true:N \l__mermap_marker_show_bool} }, |
| 1911 |
hide~category .code:n = |
| 1912 |
{ \str_if_eq:VnT \l__mermap_marker_category_tl {#1} {\bool_set_false:N \l__mermap_marker_show_bool} }, |
| 1913 |
hide~all~but~category .code:n = |
| 1914 |
{ \str_if_eq:VnF \l__mermap_marker_category_tl {#1} {\bool_set_false:N \l__mermap_marker_show_bool} }, |
| 1915 |
use~links .bool_set:N = \l__mermap_marker_use_links, |
| 1916 |
ignore~links .bool_set_inverse:N = \l__mermap_marker_use_links, |
| 1917 |
use~urls .bool_set:N = \l__mermap_marker_use_urls, |
| 1918 |
ignore~urls .bool_set_inverse:N = \l__mermap_marker_use_urls, |
| 1919 |
first~options .tl_set:N = \l__mermap_every_marker_first_tl, |
| 1920 |
last~options .tl_set:N = \l__mermap_every_marker_last_tl, |
| 1921 |
style .choice: =, |
| 1922 |
style .value_required:n = true, |
| 1923 |
} |
| 1924 |
|
| 1925 |
|
| 1926 |
\keys_set:nn { mermap/marker } |
| 1927 |
{ |
| 1928 |
latitude = 12, |
| 1929 |
longitude = 49, |
| 1930 |
use~inside = map, |
| 1931 |
contents =, |
| 1932 |
alias = noname, |
| 1933 |
pictocontents =, |
| 1934 |
angle = 90, |
| 1935 |
shift = 0pt, |
| 1936 |
distance = 5mm, |
| 1937 |
fill = gray!20, |
| 1938 |
draw = gray, |
| 1939 |
text = black, |
| 1940 |
radius = 3mm, |
| 1941 |
inner~radius = 2.25mm, |
| 1942 |
path~style =, |
| 1943 |
node~style =, |
| 1944 |
font = \sffamily\small, |
| 1945 |
type = classic, |
| 1946 |
uuid =, |
| 1947 |
generic =, |
| 1948 |
url =, |
| 1949 |
link =, |
| 1950 |
category =, |
| 1951 |
show = true, |
| 1952 |
use~links = true, |
| 1953 |
use~urls = true, |
| 1954 |
} |
| 1955 |
|
| 1956 |
|
| 1957 |
\NewExpandableDocumentCommand\mrcmarkerlatitude{}{\fp_to_decimal:N \l__mermap_marker_latitude_fp} |
| 1958 |
\NewExpandableDocumentCommand\mrcmarkerlongitude{}{\fp_to_decimal:N \l__mermap_marker_longitude_fp} |
| 1959 |
\NewDocumentCommand\mrcmarkercontents{}{\tl_use:N \l__mermap_marker_contents_tl} |
| 1960 |
\NewDocumentCommand\mrcmarkerpictocontents{}{\tl_use:N \l__mermap_marker_pictocontents_tl} |
| 1961 |
\NewExpandableDocumentCommand\mrcmarkeruuid{}{\tl_use:N \l_mermap_marker_uuid_tl} |
| 1962 |
\NewDocumentCommand\mrcmarkergeneric{}{\tl_use:N \l_mermap_marker_generic_tl} |
| 1963 |
\NewExpandableDocumentCommand\mrcmarkercategory{}{\tl_use:N \l__mermap_marker_category_tl} |
| 1964 |
\NewDocumentCommand\mrcmarkerfont{}{\tl_use:N \l__mermap_marker_font_tl} |
| 1965 |
\NewExpandableDocumentCommand\mrcmarkerangle{}{\fp_to_decimal:N \l__mermap_marker_angle_fp} |
| 1966 |
\NewExpandableDocumentCommand\mrcmarkershift{}{\fp_to_dim:N \l__mermap_marker_shift_fp} |
| 1967 |
\NewExpandableDocumentCommand\mrcmarkerdistance{}{\fp_to_dim:N \l__mermap_marker_distance_fp} |
| 1968 |
\NewExpandableDocumentCommand\mrcmarkerradius{}{\fp_to_dim:N \l__mermap_marker_radius_fp} |
| 1969 |
\NewExpandableDocumentCommand\mrcmarkerinnerradius{}{\fp_to_dim:N \l__mermap_marker_inner_radius_fp} |
| 1970 |
|
| 1971 |
|
| 1972 |
\NewDocumentCommand \mrcnewmarkerstyle { m +m } |
| 1973 |
{ |
| 1974 |
\keys_define:nn { mermap/marker/style } |
| 1975 |
{ |
| 1976 |
#1 .meta:nn = {mermap/marker}{#2} |
| 1977 |
} |
| 1978 |
} |
| 1979 |
|
| 1980 |
|
| 1981 |
\msg_new:nnnn{ mercatormap }{ markertype-undefined } |
| 1982 |
{ Marker~type~'#1'~is~unknown. } |
| 1983 |
{ |
| 1984 |
I~guess~'type=#1'~for~setting~a~marker~type~contains~a~spelling~error. |
| 1985 |
} |
| 1986 |
|
| 1987 |
|
| 1988 |
\cs_new_nopar:Npn \__mermap_hyper_path:n #1 |
| 1989 |
{ |
| 1990 |
\pgfpointanchor{path~picture~bounding~box}{south~west} |
| 1991 |
\pgf@xb-\pgf@x |
| 1992 |
\pgf@yb-\pgf@y |
| 1993 |
\pgfpointanchor{path~picture~bounding~box}{north~east} |
| 1994 |
\advance\pgf@xb\pgf@x |
| 1995 |
\advance\pgf@yb\pgf@y |
| 1996 |
\advance\pgf@x-1bp |
| 1997 |
\advance\pgf@y-1bp |
| 1998 |
\advance\pgf@xb-2bp |
| 1999 |
\advance\pgf@yb-2bp |
| 2000 |
\pgftext[at={\pgfqpoint{\pgf@x}{\pgf@y}},right,top] |
| 2001 |
{ |
| 2002 |
\hypersetup{pdfborder=0~0~0} |
| 2003 |
#1{\vrule height\pgf@yb depth0ptwidth0pt\vrule height0ptdepth0ptwidth\pgf@xb} |
| 2004 |
} |
| 2005 |
} |
| 2006 |
|
| 2007 |
|
| 2008 |
\cs_new_nopar:Npn \__mermap_hyper_path_insert: |
| 2009 |
{ |
| 2010 |
\cs_if_exist:NT \hypersetup |
| 2011 |
{ |
| 2012 |
\bool_if:NT \l__mermap_marker_use_urls |
| 2013 |
{ |
| 2014 |
\tl_if_empty:NF \l__mermap_marker_url_tl |
| 2015 |
{ |
| 2016 |
\__mermap_hyper_path:n {\href{\l__mermap_marker_url_tl}} |
| 2017 |
} |
| 2018 |
} |
| 2019 |
\bool_if:NT \l__mermap_marker_use_links |
| 2020 |
{ |
| 2021 |
\tl_if_empty:NF \l__mermap_marker_link_tl |
| 2022 |
{ |
| 2023 |
\__mermap_hyper_path:n {\hyperlink{\l__mermap_marker_link_tl}} |
| 2024 |
} |
| 2025 |
} |
| 2026 |
} |
| 2027 |
} |
| 2028 |
|
| 2029 |
|
| 2030 |
\tikzset |
| 2031 |
{ |
| 2032 |
mrchyperpath/.style = |
| 2033 |
{ |
| 2034 |
path~picture = {\__mermap_hyper_path_insert:} |
| 2035 |
} |
| 2036 |
} |
| 2037 |
|
| 2038 |
\NewDocumentCommand \mrcmarker { m } |
| 2039 |
{ |
| 2040 |
\group_begin: |
| 2041 |
\keys_set:nV { mermap/marker } \l__mermap_every_marker_first_tl |
| 2042 |
\keys_set:nn { mermap/marker } { #1 } |
| 2043 |
\keys_set:nV { mermap/marker } \l__mermap_every_marker_last_tl |
| 2044 |
\__mermap_if_marker_inside:nnTF {\l__mermap_marker_latitude_fp} {\l__mermap_marker_longitude_fp} |
| 2045 |
{ |
| 2046 |
\bool_if:NT \l__mermap_marker_show_bool |
| 2047 |
{ |
| 2048 |
\pgfnodealias{\l__mermap_marker_alias_tl}{mrcpos} |
| 2049 |
\begin{scope}[shift=(mrcpos)] |
| 2050 |
\cs_if_exist_use:cF{__mermap_drawmarker_\l__mermap_marker_type_tl} |
| 2051 |
{ |
| 2052 |
\msg_error:nnx{ mercatormap }{ markertype-undefined }{ \l__mermap_marker_type_tl } |
| 2053 |
} |
| 2054 |
\end{scope} |
| 2055 |
} |
| 2056 |
} |
| 2057 |
{} |
| 2058 |
\group_end: |
| 2059 |
} |
| 2060 |
|
| 2061 |
|
| 2062 |
\cs_new:Npn \__mermap_new_marker_type:nn #1 |
| 2063 |
{ |
| 2064 |
\cs_new:cpn {__mermap_drawmarker_#1} |
| 2065 |
} |
| 2066 |
|
| 2067 |
|
| 2068 |
\NewDocumentCommand \mrcnewmarkertype { m } |
| 2069 |
{ |
| 2070 |
\__mermap_new_marker_type:nn {#1} |
| 2071 |
} |
| 2072 |
|
| 2073 |
|
| 2074 |
\__mermap_new_marker_type:nn {classic} |
| 2075 |
{ |
| 2076 |
\node[circle,fill=black,inner~sep=0pt,minimum~width=4pt, |
| 2077 |
pin={[text=mrcmarkertext,font=\mrcmarkerfont, |
| 2078 |
pin~distance=\mrcmarkerradius, |
| 2079 |
pin~position=\mrcmarkerangle,mrcnodestyle,mrchyperpath]\mrcmarkercontents}] {}; |
| 2080 |
} |
| 2081 |
|
| 2082 |
\__mermap_new_marker_type:nn {pin} |
| 2083 |
{ |
| 2084 |
\tl_set:Nx \l__mermap_tmpa_tl {\fp_to_dim:N \l__mermap_marker_distance_fp} |
| 2085 |
\path[fill=mrcmarkerfill,draw=none,fill~opacity=0.7] |
| 2086 |
(0,0) -- (0.1,\l__mermap_tmpa_tl) -- (-0.1,\l__mermap_tmpa_tl) -- cycle; |
| 2087 |
\node[fill=white,draw=none,text=mrcmarkertext, |
| 2088 |
above,font=\mrcmarkerfont,inner~sep=0.5mm,align=center, |
| 2089 |
line~width=0mm,xshift=\mrcmarkershift, |
| 2090 |
fill~opacity=0.7,text~opacity=1,xshift=0mm,mrcnodestyle,mrchyperpath] |
| 2091 |
(pin_node) at (0,\l__mermap_tmpa_tl) {\mrcmarkercontents}; |
| 2092 |
\path[draw=mrcmarkerdraw,fill=none,line~join=round,mrcpathstyle] |
| 2093 |
(0,0) -- (0.1,\l__mermap_tmpa_tl) -- (pin_node.south~east) -- (pin_node.north~east) |
| 2094 |
-- (pin_node.north~west) -- (pin_node.south~west) |
| 2095 |
-- (-0.1,\l__mermap_tmpa_tl) [line~join=bevel] -- cycle; |
| 2096 |
} |
| 2097 |
|
| 2098 |
\__mermap_new_marker_type:nn {pinflip} |
| 2099 |
{ |
| 2100 |
\tl_set:Nx \l__mermap_tmpa_tl {\fp_to_dim:N \l__mermap_marker_distance_fp} |
| 2101 |
\path[fill=mrcmarkerfill,draw=none,fill~opacity=0.7] |
| 2102 |
(0,0) -- (-0.1,-\l__mermap_tmpa_tl) -- (0.1,-\l__mermap_tmpa_tl) -- cycle; |
| 2103 |
\node[fill=white,draw=none,text=mrcmarkertext, |
| 2104 |
below,font=\mrcmarkerfont,inner~sep=0.5mm,align=center, |
| 2105 |
line~width=0mm,xshift=\mrcmarkershift, |
| 2106 |
fill~opacity=0.7,text~opacity=1,xshift=0mm,mrcnodestyle,mrchyperpath] |
| 2107 |
(pin_node) at (0,-\l__mermap_tmpa_tl) {\mrcmarkercontents}; |
| 2108 |
\path[draw=mrcmarkerdraw,fill=none,line~join=round,mrcpathstyle] |
| 2109 |
(0,0) -- (-0.1,-\l__mermap_tmpa_tl) -- (pin_node.north~west) -- (pin_node.south~west) |
| 2110 |
-- (pin_node.south~east) -- (pin_node.north~east) |
| 2111 |
-- (0.1,-\l__mermap_tmpa_tl) [line~join=bevel] -- cycle; |
| 2112 |
} |
| 2113 |
|
| 2114 |
|
| 2115 |
\cs_new_nopar:Npn \__mermap_tikz_drop_path:n #1 |
| 2116 |
{ |
| 2117 |
\tl_set:Nn \l__mermap_tmpa_tl {\fp_to_dim:N\l__mermap_marker_radius_fp} |
| 2118 |
\tl_set:Nn \l__mermap_tmpb_tl {\fp_to_dim:n{\l__mermap_marker_radius_fp*0.552}} |
| 2119 |
\__mermap_tikz_path_begin:n |
| 2120 |
{ |
| 2121 |
line~join=bevel,draw=mrcmarkerdraw,fill=mrcmarkerfill,mrcpathstyle,mrchyperpath |
| 2122 |
} |
| 2123 |
\pgfpathmoveto{\pgfpoint{0pt}{\fp_to_dim:n{-2*\l__mermap_marker_radius_fp-\l__mermap_marker_shift_fp}}} |
| 2124 |
\pgfpathcurveto{\pgfpoint{\l__mermap_tmpb_tl}{-\l__mermap_tmpa_tl}}{\pgfpoint{\l__mermap_tmpa_tl}{-\l__mermap_tmpb_tl}} |
| 2125 |
{\pgfpoint{\l__mermap_tmpa_tl}{0pt}} |
| 2126 |
\pgfpathcurveto{\pgfpoint{\l__mermap_tmpa_tl}{\l__mermap_tmpb_tl}}{\pgfpoint{\l__mermap_tmpb_tl}{\l__mermap_tmpa_tl}} |
| 2127 |
{\pgfpoint{0pt}{\l__mermap_tmpa_tl}} |
| 2128 |
\pgfpathcurveto{\pgfpoint{-\l__mermap_tmpb_tl}{\l__mermap_tmpa_tl}}{\pgfpoint{-\l__mermap_tmpa_tl}{\l__mermap_tmpb_tl}} |
| 2129 |
{\pgfpoint{-\l__mermap_tmpa_tl}{0pt}} |
| 2130 |
\pgfpathcurveto{\pgfpoint{-\l__mermap_tmpa_tl}{-\l__mermap_tmpb_tl}}{\pgfpoint{-\l__mermap_tmpb_tl}{-\l__mermap_tmpa_tl}} |
| 2131 |
{\pgfpoint{0pt}{\fp_to_dim:n{-2*\l__mermap_marker_radius_fp-\l__mermap_marker_shift_fp}}} |
| 2132 |
\pgfpathclose |
| 2133 |
#1 |
| 2134 |
\__mermap_tikz_path_end: |
| 2135 |
} |
| 2136 |
|
| 2137 |
\cs_new_nopar:Npn \__mermap_tikz_circle_node: |
| 2138 |
{ |
| 2139 |
\node[circle,inner~sep=0pt,font=\mrcmarkerfont,text=mrcmarkertext,mrcnodestyle] |
| 2140 |
{ |
| 2141 |
\hbox_set:Nn \l__mermap_tmpa_box {\mrcmarkercontents} |
| 2142 |
\fp_compare:nNnT {\box_wd:N \l__mermap_tmpa_box} > {1.5*\l__mermap_marker_radius_fp} |
| 2143 |
{ |
| 2144 |
\box_resize_to_wd_and_ht:Nnn \l__mermap_tmpa_box |
| 2145 |
{\fp_to_dim:n {1.5*\l__mermap_marker_radius_fp}} |
| 2146 |
{\box_ht:N \l__mermap_tmpa_box} |
| 2147 |
} |
| 2148 |
\box_use_drop:N \l__mermap_tmpa_box |
| 2149 |
}; |
| 2150 |
} |
| 2151 |
|
| 2152 |
\__mermap_new_marker_type:nn {drop} |
| 2153 |
{ |
| 2154 |
\begin{scope}[yshift=\fp_to_dim:n{2*\l__mermap_marker_radius_fp+\l__mermap_marker_shift_fp}] |
| 2155 |
\__mermap_tikz_drop_path:n {} |
| 2156 |
\__mermap_tikz_circle_node: |
| 2157 |
\end{scope} |
| 2158 |
} |
| 2159 |
|
| 2160 |
\__mermap_new_marker_type:nn {pictodrop} |
| 2161 |
{ |
| 2162 |
\begin{scope}[yshift=\fp_to_dim:n{2*\l__mermap_marker_radius_fp+\l__mermap_marker_shift_fp}] |
| 2163 |
\__mermap_tikz_drop_path:n {} |
| 2164 |
\tl_use:N \l__mermap_marker_pictocontents_tl |
| 2165 |
\end{scope} |
| 2166 |
} |
| 2167 |
|
| 2168 |
\__mermap_new_marker_type:nn {pictodropring} |
| 2169 |
{ |
| 2170 |
\begin{scope}[yshift=\fp_to_dim:n{2*\l__mermap_marker_radius_fp+\l__mermap_marker_shift_fp}] |
| 2171 |
\group_begin: |
| 2172 |
\pgfseteorule |
| 2173 |
\__mermap_tikz_drop_path:n { |
| 2174 |
\pgfpathcircle{\pgfpoint{0pt}{0pt}}{\fp_to_dim:N\l__mermap_marker_inner_radius_fp} |
| 2175 |
} |
| 2176 |
\group_end: |
| 2177 |
\tl_use:N \l__mermap_marker_pictocontents_tl |
| 2178 |
\end{scope} |
| 2179 |
} |
| 2180 |
|
| 2181 |
\__mermap_new_marker_type:nn {knob} |
| 2182 |
{ |
| 2183 |
\path[draw=mrcmarkerdraw,fill=mrcmarkerfill,mrcpathstyle,mrchyperpath] |
| 2184 |
circle (\fp_to_dim:N\l__mermap_marker_radius_fp); |
| 2185 |
\__mermap_tikz_circle_node: |
| 2186 |
} |
| 2187 |
|
| 2188 |
\__mermap_new_marker_type:nn {pictoknob} |
| 2189 |
{ |
| 2190 |
\path[draw=mrcmarkerdraw,fill=mrcmarkerfill,mrcpathstyle,mrchyperpath] |
| 2191 |
circle (\fp_to_dim:N\l__mermap_marker_radius_fp); |
| 2192 |
\tl_use:N \l__mermap_marker_pictocontents_tl |
| 2193 |
} |
| 2194 |
|
| 2195 |
\__mermap_new_marker_type:nn {pictoknobring} |
| 2196 |
{ |
| 2197 |
\path[draw=mrcmarkerdraw,fill=mrcmarkerfill,mrcpathstyle,mrchyperpath,even~odd~rule] |
| 2198 |
circle (\fp_to_dim:N\l__mermap_marker_radius_fp) |
| 2199 |
circle (\fp_to_dim:N\l__mermap_marker_inner_radius_fp); |
| 2200 |
\tl_use:N \l__mermap_marker_pictocontents_tl |
| 2201 |
} |
| 2202 |
|
| 2203 |
\__mermap_new_marker_type:nn {ringx} |
| 2204 |
{ |
| 2205 |
\tl_set:Nn \l__mermap_tmpa_tl {\fp_to_dim:N\l__mermap_marker_radius_fp} |
| 2206 |
\path[draw=mrcmarkerdraw,very~thin] |
| 2207 |
(45 \c_colon_str \l__mermap_tmpa_tl)--(225\c_colon_str \l__mermap_tmpa_tl) |
| 2208 |
(135\c_colon_str \l__mermap_tmpa_tl)--(315\c_colon_str \l__mermap_tmpa_tl); |
| 2209 |
\path[draw=mrcmarkerdraw,fill=mrcmarkerfill,mrcpathstyle,mrchyperpath,even~odd~rule] |
| 2210 |
circle (\l__mermap_tmpa_tl) circle (\fp_to_dim:N\l__mermap_marker_inner_radius_fp); |
| 2211 |
} |
| 2212 |
|
| 2213 |
\__mermap_new_marker_type:nn {markx} |
| 2214 |
{ |
| 2215 |
\tl_set:Nn \l__mermap_tmpa_tl {\fp_to_dim:N\l__mermap_marker_radius_fp} |
| 2216 |
\path[line~join=bevel,draw=mrcmarkerdraw,fill=mrcmarkerfill,mrcpathstyle,mrchyperpath] |
| 2217 |
(0,0) -- (35 \c_colon_str \l__mermap_tmpa_tl) -- (55 \c_colon_str \l__mermap_tmpa_tl) -- cycle |
| 2218 |
(0,0) -- (125 \c_colon_str \l__mermap_tmpa_tl) -- (145 \c_colon_str \l__mermap_tmpa_tl) -- cycle |
| 2219 |
(0,0) -- (215 \c_colon_str \l__mermap_tmpa_tl) -- (235 \c_colon_str \l__mermap_tmpa_tl) -- cycle |
| 2220 |
(0,0) -- (305 \c_colon_str \l__mermap_tmpa_tl) -- (325 \c_colon_str \l__mermap_tmpa_tl) -- cycle; |
| 2221 |
} |
| 2222 |
|
| 2223 |
|
| 2224 |
%---- paths and routes --------------------------------------------------------- |
| 2225 |
|
| 2226 |
|
| 2227 |
\bool_new:N \l__mermap_path_first_point_bool |
| 2228 |
|
| 2229 |
|
| 2230 |
\keys_define:nn { mermap } |
| 2231 |
{ |
| 2232 |
every~route .code:n = { \tikzset{ mermap_every_route/.style={#1} } } |
| 2233 |
} |
| 2234 |
|
| 2235 |
\keys_set:nn { mermap } |
| 2236 |
{ |
| 2237 |
every~route =, |
| 2238 |
} |
| 2239 |
|
| 2240 |
|
| 2241 |
\cs_new:Npn \__mermap_tikz_path_begin:n #1 |
| 2242 |
{ |
| 2243 |
\path[#1] \pgfextra |
| 2244 |
} |
| 2245 |
|
| 2246 |
\cs_new:Npn \__mermap_tikz_path_end: |
| 2247 |
{ |
| 2248 |
\endpgfextra; |
| 2249 |
} |
| 2250 |
|
| 2251 |
\cs_new_nopar:Npn \__mermap_pgf_moveto_point:nn #1#2 |
| 2252 |
{ |
| 2253 |
\pgfpathmoveto{\__mermap_pgfpoint:nn {#1}{#2}} |
| 2254 |
} |
| 2255 |
|
| 2256 |
\cs_new_nopar:Npn \__mermap_pgf_lineto_point:nn #1#2 |
| 2257 |
{ |
| 2258 |
\pgfpathlineto{\__mermap_pgfpoint:nn {#1}{#2}} |
| 2259 |
} |
| 2260 |
|
| 2261 |
\cs_new_nopar:Npn \__mermap_route_point #1#2 |
| 2262 |
{ |
| 2263 |
\bool_if:NTF \l__mermap_path_first_point_bool |
| 2264 |
{ |
| 2265 |
\__mermap_pgf_moveto_point:nn {#1}{#2} |
| 2266 |
\bool_set_false:N \l__mermap_path_first_point_bool |
| 2267 |
} |
| 2268 |
{ |
| 2269 |
\__mermap_pgf_lineto_point:nn {#1}{#2} |
| 2270 |
} |
| 2271 |
} |
| 2272 |
|
| 2273 |
\cs_new_nopar:Npn \__mermap_route_begin:n #1 |
| 2274 |
{ |
| 2275 |
\__mermap_tikz_path_begin:n |
| 2276 |
{ |
| 2277 |
draw,mermap_every_route,#1 |
| 2278 |
} |
| 2279 |
\cs_set_eq:NN \mrcpoint \__mermap_route_point |
| 2280 |
\bool_set_true:N \l__mermap_path_first_point_bool |
| 2281 |
} |
| 2282 |
|
| 2283 |
\NewDocumentEnvironment {mrcroute} { O{} } |
| 2284 |
{ |
| 2285 |
\__mermap_route_begin:n {#1} |
| 2286 |
} |
| 2287 |
{ |
| 2288 |
\__mermap_tikz_path_end: |
| 2289 |
} |
| 2290 |
|
| 2291 |
\NewDocumentEnvironment {mrcroute*} { O{} } |
| 2292 |
{ |
| 2293 |
\__mermap_route_begin:n {#1} |
| 2294 |
} |
| 2295 |
{ |
| 2296 |
\pgfpathclose |
| 2297 |
\__mermap_tikz_path_end: |
| 2298 |
} |
| 2299 |
|
| 2300 |
\NewDocumentCommand \mrcrouteinput { s O{} m } |
| 2301 |
{ |
| 2302 |
\__mermap_route_begin:n {#2} |
| 2303 |
\file_input:n {#3} |
| 2304 |
\IfBooleanT {#1} |
| 2305 |
{ |
| 2306 |
\pgfpathclose |
| 2307 |
} |
| 2308 |
\__mermap_tikz_path_end: |
| 2309 |
} |
| 2310 |
|
| 2311 |
|
| 2312 |
%---- orthodromes and loxodromes ----------------------------------------------- |
| 2313 |
|
| 2314 |
|
| 2315 |
\fp_new:N \l__mermap_a_x_fp |
| 2316 |
\fp_new:N \l__mermap_a_y_fp |
| 2317 |
\fp_new:N \l__mermap_a_z_fp |
| 2318 |
\fp_new:N \l__mermap_b_x_fp |
| 2319 |
\fp_new:N \l__mermap_b_y_fp |
| 2320 |
\fp_new:N \l__mermap_b_z_fp |
| 2321 |
\fp_new:N \l__mermap_alpha_fp |
| 2322 |
\fp_new:N \l__mermap_delta_lambda_fp |
| 2323 |
\fp_new:N \l__mermap_delta_phi_fp |
| 2324 |
\fp_new:N \l__mermap_n_x_fp |
| 2325 |
\fp_new:N \l__mermap_n_y_fp |
| 2326 |
\fp_new:N \l__mermap_n_z_fp |
| 2327 |
\fp_new:N \l__mermap_psi_fp |
| 2328 |
\fp_new:N \l__mermap_sin_psi_fp |
| 2329 |
\fp_new:N \l__mermap_t_fp |
| 2330 |
\fp_new:N \l__mermap_t_psi_fp |
| 2331 |
\fp_new:N \l__mermap_t_x_fp |
| 2332 |
\fp_new:N \l__mermap_t_y_fp |
| 2333 |
\fp_new:N \l__mermap_t_z_fp |
| 2334 |
\fp_const:Nn \c__mermap_linearization_threshold_fp { 10e-9 } |
| 2335 |
\bool_new:N \l__mermap_linearization_bool |
| 2336 |
|
| 2337 |
\int_new:N \l__mermap_samples_int |
| 2338 |
|
| 2339 |
\keys_define:nn { mermap } |
| 2340 |
{ |
| 2341 |
samples .int_set:N = \l__mermap_samples_int, |
| 2342 |
} |
| 2343 |
|
| 2344 |
\keys_set:nn { mermap } |
| 2345 |
{ |
| 2346 |
samples = 100, |
| 2347 |
} |
| 2348 |
|
| 2349 |
\tikzset{ |
| 2350 |
mermap~samples/.code={\mermapset{samples=#1}} |
| 2351 |
} |
| 2352 |
|
| 2353 |
|
| 2354 |
\cs_new_nopar:Npn \__mermap_sphere_point:nnn #1#2#3 % {x}{y}{z} |
| 2355 |
{ |
| 2356 |
\fp_set:Nn \l__mermap_cs_lat_fp { asind(#3/sqrt((#1)^2+(#2)^2+(#3)^2)) } |
| 2357 |
\fp_set:Nn \l__mermap_cs_lon_fp { sign(#2)*acosd(#1/sqrt((#1)^2+(#2)^2)) } |
| 2358 |
\__mermap_pgfpoint:nn {\l__mermap_cs_lat_fp}{\l__mermap_cs_lon_fp} |
| 2359 |
} |
| 2360 |
|
| 2361 |
|
| 2362 |
\cs_new_nopar:Npn \__mermap_unit_sphere_point:nnn #1#2#3 % {x}{y}{z} radius 1 |
| 2363 |
{ |
| 2364 |
\fp_set:Nn \l__mermap_cs_lat_fp { asind(#3) } |
| 2365 |
\fp_set:Nn \l__mermap_cs_lon_fp { sign(#2)*acosd(#1/sqrt((#1)^2+(#2)^2)) } |
| 2366 |
\__mermap_pgfpoint:nn {\l__mermap_cs_lat_fp}{\l__mermap_cs_lon_fp} |
| 2367 |
} |
| 2368 |
|
| 2369 |
|
| 2370 |
\cs_new_protected:Npn \__mermap_draw_orthodrome:nnnnn #1#2#3#4#5 |
| 2371 |
{ |
| 2372 |
\__mermap_tikz_path_begin:n { draw,mermap_every_route,#1 } |
| 2373 |
\__mermap_setup_orthodrome:nnnn { #2 }{ #3 }{ #4 }{ #5 } |
| 2374 |
\__mermap_pgf_moveto_point:nn { #2 }{ #3 } |
| 2375 |
\int_step_inline:nn { \l__mermap_samples_int } |
| 2376 |
{ |
| 2377 |
\__mermap_point_on_orthodrome:n { ##1/\l__mermap_samples_int } |
| 2378 |
\__mermap_pgf_lineto_point:nn{ \l__mermap_cs_lat_fp }{ \l__mermap_cs_lon_fp } |
| 2379 |
} |
| 2380 |
\__mermap_tikz_path_end: |
| 2381 |
} |
| 2382 |
|
| 2383 |
|
| 2384 |
\cs_new_protected:Npn \__mermap_setup_orthodrome:nnnn #1#2#3#4 |
| 2385 |
{ |
| 2386 |
\fp_set:Nn \l__mermap_a_x_fp { cosd(#2)*cosd(#1) } |
| 2387 |
\fp_set:Nn \l__mermap_a_y_fp { sind(#2)*cosd(#1) } |
| 2388 |
\fp_set:Nn \l__mermap_a_z_fp { sind(#1) } |
| 2389 |
|
| 2390 |
\fp_set:Nn \l__mermap_b_x_fp { cosd(#4)*cosd(#3) } |
| 2391 |
\fp_set:Nn \l__mermap_b_y_fp { sind(#4)*cosd(#3) } |
| 2392 |
\fp_set:Nn \l__mermap_b_z_fp { sind(#3) } |
| 2393 |
|
| 2394 |
\fp_set:Nn \l__mermap_psi_fp { acosd( sind(#1)*sind(#3) + cosd(#1)*cosd(#3)*cosd(#4-(#2)) ) } |
| 2395 |
\fp_set:Nn \l__mermap_sin_psi_fp { sind(\l__mermap_psi_fp) } |
| 2396 |
|
| 2397 |
\bool_set:Nn \l__mermap_linearization_bool { \fp_compare_p:nNn \l__mermap_psi_fp < \c__mermap_linearization_threshold_fp } |
| 2398 |
} |
| 2399 |
|
| 2400 |
|
| 2401 |
\cs_new_protected:Npn \__mermap_point_on_orthodrome:n #1 |
| 2402 |
{ |
| 2403 |
\fp_set:Nn \l__mermap_t_fp { #1 } |
| 2404 |
|
| 2405 |
\bool_if:NTF \l__mermap_linearization_bool |
| 2406 |
{ |
| 2407 |
\fp_set:Nn \l__mermap_tmpa_fp { 1 - \l__mermap_t_fp } |
| 2408 |
\fp_set_eq:NN \l__mermap_tmpb_fp \l__mermap_t_fp |
| 2409 |
} |
| 2410 |
{ |
| 2411 |
\fp_set:Nn \l__mermap_t_psi_fp { \l__mermap_t_fp * \l__mermap_psi_fp } |
| 2412 |
\fp_set:Nn \l__mermap_tmpa_fp { sind( \l__mermap_psi_fp - \l__mermap_t_psi_fp ) / \l__mermap_sin_psi_fp } |
| 2413 |
\fp_set:Nn \l__mermap_tmpb_fp { sind( \l__mermap_t_psi_fp ) / \l__mermap_sin_psi_fp } |
| 2414 |
} |
| 2415 |
|
| 2416 |
\fp_set:Nn \l__mermap_t_x_fp { \l__mermap_tmpa_fp*\l__mermap_a_x_fp + \l__mermap_tmpb_fp*\l__mermap_b_x_fp } |
| 2417 |
\fp_set:Nn \l__mermap_t_y_fp { \l__mermap_tmpa_fp*\l__mermap_a_y_fp + \l__mermap_tmpb_fp*\l__mermap_b_y_fp } |
| 2418 |
\fp_set:Nn \l__mermap_t_z_fp { \l__mermap_tmpa_fp*\l__mermap_a_z_fp + \l__mermap_tmpb_fp*\l__mermap_b_z_fp } |
| 2419 |
|
| 2420 |
\fp_set:Nn \l__mermap_cs_lat_fp { asind(\l__mermap_t_z_fp) } |
| 2421 |
\fp_set:Nn \l__mermap_cs_lon_fp { sign(\l__mermap_t_y_fp)*acosd(\l__mermap_t_x_fp/sqrt(\l__mermap_t_x_fp^2+\l__mermap_t_y_fp^2)) } |
| 2422 |
} |
| 2423 |
|
| 2424 |
|
| 2425 |
\cs_new_protected:Npn \__mermap_angle_at_orthodrome: |
| 2426 |
{ |
| 2427 |
\bool_if:NTF \l__mermap_linearization_bool |
| 2428 |
{ |
| 2429 |
\fp_set:Nn \l__mermap_alpha_fp { 90 } |
| 2430 |
} |
| 2431 |
{ |
| 2432 |
\fp_set:Nn \l__mermap_tmpa_fp { cosd( \l__mermap_psi_fp - \l__mermap_t_psi_fp ) } |
| 2433 |
\fp_set:Nn \l__mermap_tmpb_fp { cosd( \l__mermap_t_psi_fp ) } |
| 2434 |
\fp_set:Nn \l__mermap_n_x_fp { \l__mermap_tmpb_fp*\l__mermap_b_x_fp - \l__mermap_tmpa_fp*\l__mermap_a_x_fp } |
| 2435 |
\fp_set:Nn \l__mermap_n_y_fp { \l__mermap_tmpb_fp*\l__mermap_b_y_fp - \l__mermap_tmpa_fp*\l__mermap_a_y_fp } |
| 2436 |
\fp_set:Nn \l__mermap_n_z_fp { \l__mermap_tmpb_fp*\l__mermap_b_z_fp - \l__mermap_tmpa_fp*\l__mermap_a_z_fp } |
| 2437 |
\fp_set:Nn \l__mermap_tmpa_fp { sqrt( \l__mermap_n_x_fp^2 + \l__mermap_n_y_fp^2 + \l__mermap_n_z_fp^2 ) } |
| 2438 |
\fp_set:Nn \l__mermap_n_x_fp { \l__mermap_n_x_fp / \l__mermap_tmpa_fp } |
| 2439 |
\fp_set:Nn \l__mermap_n_y_fp { \l__mermap_n_y_fp / \l__mermap_tmpa_fp } |
| 2440 |
\fp_set:Nn \l__mermap_n_z_fp { \l__mermap_n_z_fp / \l__mermap_tmpa_fp } |
| 2441 |
\fp_set:Nn \l__mermap_alpha_fp { acosd( \l__mermap_n_y_fp*cosd(\l__mermap_cs_lon_fp) - \l__mermap_n_x_fp*sind(\l__mermap_cs_lon_fp) ) } |
| 2442 |
\fp_compare:nNnT \l__mermap_n_z_fp < 0 |
| 2443 |
{ |
| 2444 |
\fp_set:Nn \l__mermap_alpha_fp { 360 - \l__mermap_alpha_fp } |
| 2445 |
} |
| 2446 |
} |
| 2447 |
} |
| 2448 |
|
| 2449 |
|
| 2450 |
\NewDocumentCommand \mrcdraworthodrome { O{} mmmm } |
| 2451 |
{ |
| 2452 |
\__mermap_draw_orthodrome:nnnnn {#1}{#2}{#3}{#4}{#5} |
| 2453 |
} |
| 2454 |
|
| 2455 |
|
| 2456 |
\NewDocumentCommand \mrcNPdraworthodrome { O{} mm } |
| 2457 |
{ |
| 2458 |
\__mermap_draw_orthodrome:nnnnn {#1}{\mrcNPlat{#2}}{\mrcNPlon{#2}}{\mrcNPlat{#3}}{\mrcNPlon{#3}} |
| 2459 |
} |
| 2460 |
|
| 2461 |
|
| 2462 |
\cs_new_nopar:Npn \__mermap_ortho_distance:nnnn #1#2#3#4 |
| 2463 |
{ |
| 2464 |
\fp_set:Nn \l__mermap_result_fp |
| 2465 |
{ |
| 2466 |
\c__mermap_scale_radius_fp * |
| 2467 |
acosd( sind(#1)*sind(#3) + cosd(#1)*cosd(#3)*cosd(#4-(#2)) ) |
| 2468 |
} |
| 2469 |
} |
| 2470 |
|
| 2471 |
|
| 2472 |
\NewDocumentCommand \mrcstoreorthodistance { mmmmm } |
| 2473 |
{ |
| 2474 |
\__mermap_ortho_distance:nnnn {#2}{#3}{#4}{#5} |
| 2475 |
\cs_set_nopar:Npx #1 { \fp_to_decimal:N \l__mermap_result_fp } |
| 2476 |
} |
| 2477 |
|
| 2478 |
|
| 2479 |
\NewDocumentCommand \mrcprettyorthodistance { mmmm } |
| 2480 |
{ |
| 2481 |
\__mermap_ortho_distance:nnnn {#1}{#2}{#3}{#4} |
| 2482 |
\__mermap_pretty_distance:n { \l__mermap_result_fp } |
| 2483 |
} |
| 2484 |
|
| 2485 |
\NewDocumentCommand \mrcNPprettyorthodistance { mm } |
| 2486 |
{ |
| 2487 |
\__mermap_ortho_distance:nnnn {\mrcNPlat{#1}}{\mrcNPlon{#1}}{\mrcNPlat{#2}}{\mrcNPlon{#2}} |
| 2488 |
\__mermap_pretty_distance:n { \l__mermap_result_fp } |
| 2489 |
} |
| 2490 |
|
| 2491 |
|
| 2492 |
\cs_new_nopar:Npn \__mermap_loxo_distance:nnnn #1#2#3#4 |
| 2493 |
{ |
| 2494 |
\fp_set:Nn \l__mermap_delta_phi_fp {(#3-(#1))/180*pi} |
| 2495 |
\fp_set:Nn \l__mermap_delta_lambda_fp {(#4-(#2))/180*pi} |
| 2496 |
\fp_compare:nNnTF {abs(\l__mermap_delta_phi_fp)} < {1e-5} |
| 2497 |
{ |
| 2498 |
\fp_set:Nn \l__mermap_tmpa_fp { tand(#1) } |
| 2499 |
\fp_set:Nn \l__mermap_tmpb_fp { \l__mermap_delta_lambda_fp*cosd(#1) |
| 2500 |
/( 1 + (\l__mermap_tmpa_fp + (1+2*\l__mermap_tmpa_fp*\l__mermap_tmpa_fp)*\l__mermap_delta_phi_fp/3)*\l__mermap_delta_phi_fp/2 ) } |
| 2501 |
\fp_set:Nn \l__mermap_result_fp { |
| 2502 |
sqrt( \l__mermap_delta_phi_fp*\l__mermap_delta_phi_fp + \l__mermap_tmpb_fp*\l__mermap_tmpb_fp ) } |
| 2503 |
} |
| 2504 |
{ |
| 2505 |
\fp_set:Nn \l__mermap_result_fp { abs(\l__mermap_delta_phi_fp) |
| 2506 |
*sqrt( 1+ (\l__mermap_delta_lambda_fp/( ln(tand(#3/2+45)) - ln(tand(#1/2+45)) ) )^2 ) } |
| 2507 |
} |
| 2508 |
\fp_set:Nn \l__mermap_result_fp { \c__mermap_scale_radius_fp*180/pi * \l__mermap_result_fp } |
| 2509 |
} |
| 2510 |
|
| 2511 |
|
| 2512 |
\NewDocumentCommand \mrcstoreloxodistance { mmmmm } |
| 2513 |
{ |
| 2514 |
\__mermap_loxo_distance:nnnn {#2}{#3}{#4}{#5} |
| 2515 |
\cs_set_nopar:Npx #1 { \fp_to_decimal:N \l__mermap_result_fp } |
| 2516 |
} |
| 2517 |
|
| 2518 |
|
| 2519 |
\NewDocumentCommand \mrcprettyloxodistance { mmmm } |
| 2520 |
{ |
| 2521 |
\__mermap_loxo_distance:nnnn {#1}{#2}{#3}{#4} |
| 2522 |
\__mermap_pretty_distance:n { \l__mermap_result_fp } |
| 2523 |
} |
| 2524 |
|
| 2525 |
|
| 2526 |
\NewDocumentCommand \mrcNPprettyloxodistance { mm } |
| 2527 |
{ |
| 2528 |
\__mermap_loxo_distance:nnnn { \mrcNPlat{#1} }{ \mrcNPlon{#1} }{ \mrcNPlat{#2} }{ \mrcNPlon{#2} } |
| 2529 |
\__mermap_pretty_distance:n { \l__mermap_result_fp } |
| 2530 |
} |
| 2531 |
|
| 2532 |
|
| 2533 |
\cs_new_protected:Npn \__mermap_orthodrome_point:nnn #1#2#3 |
| 2534 |
{ |
| 2535 |
\__mermap_point_on_orthodrome:n { #3 } |
| 2536 |
\__mermap_set_named_position { #1 }{ \l__mermap_cs_lat_fp }{ \l__mermap_cs_lon_fp } |
| 2537 |
\IfNoValueF { #2 } |
| 2538 |
{ |
| 2539 |
\__mermap_angle_at_orthodrome: |
| 2540 |
\cs_set:Npe #2 { \fp_to_decimal:N \l__mermap_alpha_fp } |
| 2541 |
} |
| 2542 |
} |
| 2543 |
|
| 2544 |
\NewDocumentCommand \mrcNPfromOrthoFraction { mo mm mm m } |
| 2545 |
{ |
| 2546 |
\__mermap_setup_orthodrome:nnnn { #3 }{ #4 }{ #5 }{ #6 } |
| 2547 |
\__mermap_orthodrome_point:nnn { #1 }{ #2 }{ #7 } |
| 2548 |
} |
| 2549 |
|
| 2550 |
\NewDocumentCommand \mrcNPfromOrthoFractionNamed { mo m m m } |
| 2551 |
{ |
| 2552 |
\__mermap_setup_orthodrome:nnnn { \mrcNPlat{#3} }{ \mrcNPlon{#3} }{ \mrcNPlat{#4} }{ \mrcNPlon{#4} } |
| 2553 |
\__mermap_orthodrome_point:nnn { #1 }{ #2 }{ #5 } |
| 2554 |
} |
| 2555 |
|
| 2556 |
\NewDocumentCommand \mrcNPfromOrthoDistance { mo mm mm m } |
| 2557 |
{ |
| 2558 |
\__mermap_ortho_distance:nnnn { #3 }{ #4 }{ #5 }{ #6 } |
| 2559 |
\fp_compare:nNnTF \l__mermap_result_fp > { 0.001 } |
| 2560 |
{ |
| 2561 |
\__mermap_setup_orthodrome:nnnn { #3 }{ #4 }{ #5 }{ #6 } |
| 2562 |
\__mermap_orthodrome_point:nnn { #1 }{ #2 }{ #7 / \l__mermap_result_fp } |
| 2563 |
} |
| 2564 |
{ |
| 2565 |
\__mermap_set_named_position { #1 }{ #3 }{ #4 } |
| 2566 |
\IfNoValueF { #2 } |
| 2567 |
{ |
| 2568 |
\cs_set:Npn #2 { 90 } |
| 2569 |
} |
| 2570 |
} |
| 2571 |
} |
| 2572 |
|
| 2573 |
\NewDocumentCommand \mrcNPfromOrthoDistanceNamed { mo m m m } |
| 2574 |
{ |
| 2575 |
\__mermap_ortho_distance:nnnn { \mrcNPlat{#3} }{ \mrcNPlon{#3} }{ \mrcNPlat{#4} }{ \mrcNPlon{#4} } |
| 2576 |
\fp_compare:nNnTF \l__mermap_result_fp > { 0.001 } |
| 2577 |
{ |
| 2578 |
\__mermap_setup_orthodrome:nnnn { \mrcNPlat{#3} }{ \mrcNPlon{#3} }{ \mrcNPlat{#4} }{ \mrcNPlon{#4} } |
| 2579 |
\__mermap_orthodrome_point:nnn { #1 }{ #2 }{ #5 / \l__mermap_result_fp } |
| 2580 |
} |
| 2581 |
{ |
| 2582 |
\__mermap_set_named_position { #1 }{ \mrcNPlat{#3} }{ \mrcNPlon{#3} } |
| 2583 |
\IfNoValueF { #2 } |
| 2584 |
{ |
| 2585 |
\cs_set:Npn #2 { 90 } |
| 2586 |
} |
| 2587 |
} |
| 2588 |
} |
| 2589 |
|
| 2590 |
|
| 2591 |
%---- animations --------------------------------------------------------------- |
| 2592 |
|
| 2593 |
\bool_new:N \l__mermap_anim_drop_first_frame_bool |
| 2594 |
\bool_new:N \l__mermap_anim_drop_last_frame_bool |
| 2595 |
|
| 2596 |
\fp_new:N \l__mermap_anim_a_lat_fp |
| 2597 |
\fp_new:N \l__mermap_anim_a_lon_fp |
| 2598 |
\fp_new:N \l__mermap_anim_a_scaledenom_fp |
| 2599 |
\fp_new:N \l__mermap_anim_a_time_fp |
| 2600 |
\fp_new:N \l__mermap_anim_b_lat_fp |
| 2601 |
\fp_new:N \l__mermap_anim_b_lon_fp |
| 2602 |
\fp_new:N \l__mermap_anim_b_scaledenom_fp |
| 2603 |
\fp_new:N \l__mermap_anim_b_time_fp |
| 2604 |
\fp_new:N \l_mermap_anim_angle_fp |
| 2605 |
\fp_new:N \l_mermap_anim_lat_fp |
| 2606 |
\fp_new:N \l_mermap_anim_lon_fp |
| 2607 |
\fp_new:N \l_mermap_anim_scaledenom_fp |
| 2608 |
\fp_new:N \l_mermap_anim_time_fp |
| 2609 |
|
| 2610 |
\int_new:N \l__mermap_anim_final_frame_int |
| 2611 |
\int_new:N \l__mermap_anim_frames_int |
| 2612 |
\int_new:N \l__mermap_anim_start_frame_int |
| 2613 |
\int_new:N \l_mermap_anim_frame_int |
| 2614 |
|
| 2615 |
\seq_new:N \l__mermap_anim_scaledenom_seq |
| 2616 |
|
| 2617 |
\tl_new:N \l__mermap_anim_timescale_tl |
| 2618 |
\tl_new:N \l__mermap_anim_timewarp_tl |
| 2619 |
|
| 2620 |
|
| 2621 |
\NewExpandableDocumentCommand \mrcTimewarpIdentity { m } |
| 2622 |
{ |
| 2623 |
#1 |
| 2624 |
} |
| 2625 |
|
| 2626 |
\NewExpandableDocumentCommand \mrcTimewarpSlowStart { m m } |
| 2627 |
{ |
| 2628 |
(#2)^(#1) |
| 2629 |
} |
| 2630 |
|
| 2631 |
\NewExpandableDocumentCommand \mrcTimewarpSlowFinal { m m } |
| 2632 |
{ |
| 2633 |
1 - (1-#2)^(#1) |
| 2634 |
} |
| 2635 |
|
| 2636 |
\NewExpandableDocumentCommand \mrcTimewarpSlowStartFinal { m m } |
| 2637 |
{ |
| 2638 |
%1 - (1-#2)^(#1) |
| 2639 |
#2 <= 0.5 |
| 2640 |
? (2*(#2))^(#1) / 2 |
| 2641 |
: 1 - (2-2*(#2))^(#1) / 2 |
| 2642 |
} |
| 2643 |
|
| 2644 |
|
| 2645 |
\NewDocumentEnvironment { mrcAnimation }{ m +b } |
| 2646 |
{ |
| 2647 |
\keys_set:nn { mermap/anim }{ #1 } |
| 2648 |
|
| 2649 |
\__mermap_anim_autocorrect_scaledenom_seq: |
| 2650 |
\int_compare:nNnT \l__mermap_anim_frames_int < 2 |
| 2651 |
{ |
| 2652 |
\int_set:Nn \l__mermap_anim_frames_int { 2 } |
| 2653 |
} |
| 2654 |
\bool_if:NTF \l__mermap_anim_drop_first_frame_bool |
| 2655 |
{ |
| 2656 |
\int_set:Nn \l__mermap_anim_start_frame_int { 2 } |
| 2657 |
} |
| 2658 |
{ |
| 2659 |
\int_set:Nn \l__mermap_anim_start_frame_int { 1 } |
| 2660 |
} |
| 2661 |
\bool_if:NTF \l__mermap_anim_drop_last_frame_bool |
| 2662 |
{ |
| 2663 |
\int_set:Nn \l__mermap_anim_final_frame_int { \l__mermap_anim_frames_int-1 } |
| 2664 |
} |
| 2665 |
{ |
| 2666 |
\int_set:Nn \l__mermap_anim_final_frame_int { \l__mermap_anim_frames_int } |
| 2667 |
} |
| 2668 |
|
| 2669 |
\__mermap_setup_orthodrome:nnnn { \l__mermap_anim_a_lat_fp }{ \l__mermap_anim_a_lon_fp } |
| 2670 |
{ \l__mermap_anim_b_lat_fp }{ \l__mermap_anim_b_lon_fp } |
| 2671 |
|
| 2672 |
\__mermap_anim_pop_time_scale:NN \l__mermap_anim_a_time_fp \l__mermap_anim_a_scaledenom_fp |
| 2673 |
\__mermap_anim_pop_time_scale:NN \l__mermap_anim_b_time_fp \l__mermap_anim_b_scaledenom_fp |
| 2674 |
|
| 2675 |
\int_step_variable:nnNn { \l__mermap_anim_start_frame_int }{ \l__mermap_anim_final_frame_int } \l_mermap_anim_frame_int |
| 2676 |
{ |
| 2677 |
\fp_set:Nn \l_mermap_anim_time_fp { (\l_mermap_anim_frame_int-1)/(\l__mermap_anim_frames_int-1) } |
| 2678 |
\fp_set:Nn \l_mermap_anim_time_fp { \l__mermap_anim_timewarp_tl { \l_mermap_anim_time_fp } } |
| 2679 |
|
| 2680 |
\__mermap_point_on_orthodrome:n { \l_mermap_anim_time_fp } |
| 2681 |
\fp_set_eq:NN \l_mermap_anim_lat_fp \l__mermap_cs_lat_fp |
| 2682 |
\fp_set_eq:NN \l_mermap_anim_lon_fp \l__mermap_cs_lon_fp |
| 2683 |
\__mermap_set_named_position{ AnimNP }{ \l_mermap_anim_lat_fp }{ \l_mermap_anim_lon_fp } |
| 2684 |
|
| 2685 |
\__mermap_angle_at_orthodrome: |
| 2686 |
\fp_set_eq:NN \l_mermap_anim_angle_fp \l__mermap_alpha_fp |
| 2687 |
|
| 2688 |
\fp_while_do:nNnn \l_mermap_anim_time_fp > \l__mermap_anim_b_time_fp |
| 2689 |
{ |
| 2690 |
\fp_set_eq:NN \l__mermap_anim_a_time_fp \l__mermap_anim_b_time_fp |
| 2691 |
\fp_set_eq:NN \l__mermap_anim_a_scaledenom_fp \l__mermap_anim_b_scaledenom_fp |
| 2692 |
\__mermap_anim_pop_time_scale:NN \l__mermap_anim_b_time_fp \l__mermap_anim_b_scaledenom_fp |
| 2693 |
} |
| 2694 |
\fp_set:Nn \l_mermap_anim_scaledenom_fp |
| 2695 |
{ |
| 2696 |
round ( exp ( |
| 2697 |
ln(\l__mermap_anim_a_scaledenom_fp) + |
| 2698 |
( ln(\l__mermap_anim_b_scaledenom_fp)-ln(\l__mermap_anim_a_scaledenom_fp) ) * |
| 2699 |
( \l_mermap_anim_time_fp-\l__mermap_anim_a_time_fp ) / ( \l__mermap_anim_b_time_fp-\l__mermap_anim_a_time_fp ) |
| 2700 |
) ) |
| 2701 |
} |
| 2702 |
|
| 2703 |
#2 |
| 2704 |
} |
| 2705 |
}{} |
| 2706 |
|
| 2707 |
|
| 2708 |
\cs_new_protected:Npn \__mermap_anim_autocorrect_scaledenom_seq: |
| 2709 |
{ |
| 2710 |
\seq_get_left:NN \l__mermap_anim_scaledenom_seq \l__mermap_anim_timescale_tl |
| 2711 |
\bool_lazy_any:nTF |
| 2712 |
{ |
| 2713 |
{ \seq_if_empty_p:N \l__mermap_anim_scaledenom_seq } |
| 2714 |
{ \tl_if_empty_p:N \l__mermap_anim_timescale_tl } |
| 2715 |
{ \quark_if_no_value_p:N \l__mermap_anim_timescale_tl } |
| 2716 |
} |
| 2717 |
{ |
| 2718 |
\seq_set_split:Nnn \l__mermap_anim_scaledenom_seq { - }{ 0/25000 - 1/25000 }, |
| 2719 |
} |
| 2720 |
{ |
| 2721 |
\fp_compare:nNnF { \__mermap_anim_use_time:o \l__mermap_anim_timescale_tl } = 0 |
| 2722 |
{ |
| 2723 |
\seq_put_left:Ne \l__mermap_anim_scaledenom_seq { 0 / \__mermap_anim_use_scale:o \l__mermap_anim_timescale_tl } |
| 2724 |
} |
| 2725 |
} |
| 2726 |
\seq_get_right:NNF \l__mermap_anim_scaledenom_seq \l__mermap_anim_timescale_tl |
| 2727 |
{ |
| 2728 |
\msg_error:nn{ mercatormap }{ anim-scaledenom-invalid } |
| 2729 |
} |
| 2730 |
\fp_compare:nNnF { \__mermap_anim_use_time:o \l__mermap_anim_timescale_tl } = 1 |
| 2731 |
{ |
| 2732 |
\seq_put_right:Ne \l__mermap_anim_scaledenom_seq { 1 / \__mermap_anim_use_scale:o \l__mermap_anim_timescale_tl } |
| 2733 |
} |
| 2734 |
\fp_set:Nn \l__mermap_anim_a_time_fp { -1 } |
| 2735 |
\seq_map_inline:Nn \l__mermap_anim_scaledenom_seq |
| 2736 |
{ |
| 2737 |
\fp_set:Nn \l__mermap_anim_b_time_fp { \__mermap_anim_use_time:n { ##1 } } |
| 2738 |
\fp_compare:nNnTF \l__mermap_anim_a_time_fp < \l__mermap_anim_b_time_fp |
| 2739 |
{ |
| 2740 |
\fp_set_eq:NN \l__mermap_anim_a_time_fp \l__mermap_anim_b_time_fp |
| 2741 |
} |
| 2742 |
{ |
| 2743 |
\msg_error:nn{ mercatormap }{ anim-scaledenom-invalid } |
| 2744 |
} |
| 2745 |
} |
| 2746 |
} |
| 2747 |
|
| 2748 |
\cs_new_protected:Npn \__mermap_anim_pop_time_scale:NN #1#2 |
| 2749 |
{ |
| 2750 |
\seq_pop_left:NN \l__mermap_anim_scaledenom_seq \l__mermap_anim_timescale_tl |
| 2751 |
\fp_set:Nn #1 { \__mermap_anim_use_time:o \l__mermap_anim_timescale_tl } |
| 2752 |
\fp_set:Nn #2 { \__mermap_anim_use_scale:o \l__mermap_anim_timescale_tl } |
| 2753 |
} |
| 2754 |
|
| 2755 |
\msg_new:nnnn{ mercatormap }{ anim-scaledenom-invalid } |
| 2756 |
{ The~animation~scale~denominator~sequence~is~invalid. } |
| 2757 |
{ |
| 2758 |
Check~\seq_use:Nn \l__mermap_anim_scaledenom_seq { ~-~ }~with~the~documentation.~ |
| 2759 |
Time~values~are~not~strictly~monotonically~increasing. |
| 2760 |
} |
| 2761 |
|
| 2762 |
\cs_new_protected_nopar:Npn \__mermap_anim_set_position:w #1 #2 / #3 \q_stop |
| 2763 |
{ |
| 2764 |
\fp_set:cn { l__mermap_anim_#1_lat_fp }{ #2 } |
| 2765 |
\fp_set:cn { l__mermap_anim_#1_lon_fp }{ #3 } |
| 2766 |
} |
| 2767 |
|
| 2768 |
\cs_new_nopar:Npn \__mermap_anim_use_time:w #1 / #2 \q_stop |
| 2769 |
{ |
| 2770 |
#1 |
| 2771 |
} |
| 2772 |
\cs_new_nopar:Npn \__mermap_anim_use_time:n #1 |
| 2773 |
{ |
| 2774 |
\__mermap_anim_use_time:w #1 \q_stop |
| 2775 |
} |
| 2776 |
\cs_generate_variant:Nn \__mermap_anim_use_time:n { o } |
| 2777 |
|
| 2778 |
\cs_new_nopar:Npn \__mermap_anim_use_scale:w #1 / #2 \q_stop |
| 2779 |
{ |
| 2780 |
#2 |
| 2781 |
} |
| 2782 |
\cs_new_nopar:Npn \__mermap_anim_use_scale:n #1 |
| 2783 |
{ |
| 2784 |
\__mermap_anim_use_scale:w #1 \q_stop |
| 2785 |
} |
| 2786 |
\cs_generate_variant:Nn \__mermap_anim_use_scale:n { o } |
| 2787 |
|
| 2788 |
\keys_define:nn { mermap/anim } |
| 2789 |
{ |
| 2790 |
start-position .code:n = \__mermap_anim_set_position:w { a } #1 \q_stop, |
| 2791 |
final-position .code:n = \__mermap_anim_set_position:w { b } #1 \q_stop, |
| 2792 |
position .meta:n = { start-position = #1, final-position = #1 }, |
| 2793 |
named-start-position .code:n = |
| 2794 |
{ |
| 2795 |
\fp_set:Nn \l__mermap_anim_a_lat_fp { \mrcNPlat{ #1 } } |
| 2796 |
\fp_set:Nn \l__mermap_anim_a_lon_fp { \mrcNPlon{ #1 } } |
| 2797 |
}, |
| 2798 |
named-final-position .code:n = |
| 2799 |
{ |
| 2800 |
\fp_set:Nn \l__mermap_anim_b_lat_fp { \mrcNPlat{ #1 } } |
| 2801 |
\fp_set:Nn \l__mermap_anim_b_lon_fp { \mrcNPlon{ #1 } } |
| 2802 |
}, |
| 2803 |
named-position .meta:n = { named-start-position = #1, named-final-position = #1 }, |
| 2804 |
frames .int_set:N = \l__mermap_anim_frames_int, |
| 2805 |
drop-first-frame .bool_set:N = \l__mermap_anim_drop_first_frame_bool, |
| 2806 |
drop-last-frame .bool_set:N = \l__mermap_anim_drop_last_frame_bool, |
| 2807 |
drop-no-frame .meta:n = { drop-first-frame=false, drop-last-frame=false }, |
| 2808 |
scale-denominators .code:n = \seq_set_split:Nnn \l__mermap_anim_scaledenom_seq { - }{ #1 }, |
| 2809 |
common-scale-denominator .meta:n = { scale-denominators = 0/#1 - 1/#1 }, |
| 2810 |
timewarp .tl_set:N = \l__mermap_anim_timewarp_tl, |
| 2811 |
timewarp-identity .meta:n = { timewarp = \mrcTimewarpIdentity }, |
| 2812 |
timewarp-slow-start .meta:n = { timewarp = \mrcTimewarpSlowStart{#1} }, |
| 2813 |
timewarp-slow-start .default:n = 2, |
| 2814 |
timewarp-slow-final .meta:n = { timewarp = \mrcTimewarpSlowFinal{#1} }, |
| 2815 |
timewarp-slow-final .default:n = 2, |
| 2816 |
timewarp-slow-start-final .meta:n = { timewarp = \mrcTimewarpSlowStartFinal{#1} }, |
| 2817 |
timewarp-slow-start-final .default:n = 2, |
| 2818 |
} |
| 2819 |
|
| 2820 |
\keys_set:nn { mermap/anim } |
| 2821 |
{ |
| 2822 |
position = 51.4779 / 0, |
| 2823 |
frames = 20, |
| 2824 |
drop-no-frame, |
| 2825 |
common-scale-denominator = 25000, |
| 2826 |
timewarp-identity, |
| 2827 |
} |
| 2828 |
|
| 2829 |
\NewExpandableDocumentCommand\mrcAnimFrame{}{\int_to_arabic:n \l_mermap_anim_frame_int} |
| 2830 |
\NewExpandableDocumentCommand\mrcAnimTime{}{\fp_to_decimal:N \l_mermap_anim_time_fp} |
| 2831 |
\NewExpandableDocumentCommand\mrcAnimScaleDenom{}{\fp_to_decimal:N \l_mermap_anim_scaledenom_fp} |
| 2832 |
\NewExpandableDocumentCommand\mrcAnimLatitude{}{\fp_to_decimal:N \l_mermap_anim_lat_fp} |
| 2833 |
\NewExpandableDocumentCommand\mrcAnimLongitude{}{\fp_to_decimal:N \l_mermap_anim_lon_fp} |
| 2834 |
\NewExpandableDocumentCommand\mrcAnimAngle{}{\fp_to_decimal:N \l_mermap_anim_angle_fp} |
| 2835 |
|
| 2836 |
|
| 2837 |
%---- supplier ----------------------------------------------------------------- |
| 2838 |
|
| 2839 |
\file_input:n { \mrcpkgprefix mercatorsupplier.def } |