Mercurial > hg > batmud > gmap2
comparison tools/makegmaps.php @ 307:0c370efd753b gmap2
Use modern PHP array syntax.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 11 Sep 2017 13:37:05 +0300 |
parents | 695d01a321ec |
children | 63eb4661d13c |
comparison
equal
deleted
inserted
replaced
306:2f472f65d80a | 307:0c370efd753b |
---|---|
10 | 10 |
11 $gmapsConfig = "config.php"; | 11 $gmapsConfig = "config.php"; |
12 | 12 |
13 | 13 |
14 // Paths and files | 14 // Paths and files |
15 $cfgDefaults = array( | 15 $cfgDefaults = [ |
16 "binConvert" => array(1, "convert", "Path of 'convert' binary from ImageMagick or GraphicsMagick."), | 16 "binConvert" => [1, "convert", "Path of 'convert' binary from ImageMagick or GraphicsMagick."], |
17 "binMercurial" => array(1, "hg", "Path of 'hg' binary of Mercurial DVCS."), | 17 "binMercurial" => [1, "hg", "Path of 'hg' binary of Mercurial DVCS."], |
18 "binMake" => array(1, "make", "Path of 'make', preferably GNU make."), | 18 "binMake" => [1, "make", "Path of 'make', preferably GNU make."], |
19 | 19 |
20 "pathMapUtils" => array(2, "maputils/", "Path for maputils directory tree."), | 20 "pathMapUtils" => [2, "maputils/", "Path for maputils directory tree."], |
21 "pathImageCache" => array(2, "cache/", "Image cache directory."), | 21 "pathImageCache" => [2, "cache/", "Image cache directory."], |
22 "pathGMap" => array(2, "../", "Path to map main directory and marker data files."), | 22 "pathGMap" => [2, "../", "Path to map main directory and marker data files."], |
23 "pathTileData" => array(2, "../tiles/", "Path to map tiles directory structure."), | 23 "pathTileData" => [2, "../tiles/", "Path to map tiles directory structure."], |
24 | 24 |
25 "pathRawMaps" => array(3, FALSE, "Path to the raw ASCII maps."), | 25 "pathRawMaps" => [3, FALSE, "Path to the raw ASCII maps."], |
26 "pathLocFiles" => array(3, FALSE, "Path to the location data LOC files."), | 26 "pathLocFiles" => [3, FALSE, "Path to the location data LOC files."], |
27 "worldConfig" => array(3, FALSE, "Path of the world configuration file 'world.inc.php' from MapUtils."), | 27 "worldConfig" => [3, FALSE, "Path of the world configuration file 'world.inc.php' from MapUtils."], |
28 ); | 28 ]; |
29 | 29 |
30 | 30 |
31 $fontFile = "./lucon.ttf"; | 31 $fontFile = "./lucon.ttf"; |
32 | 32 |
33 | 33 |
36 | 36 |
37 $minZoom = 1; | 37 $minZoom = 1; |
38 $maxZoom = 10; | 38 $maxZoom = 10; |
39 | 39 |
40 // Font sizes | 40 // Font sizes |
41 $fontSize = array(); | 41 $fontSize = []; |
42 $fontSize[ 8] = 7; | 42 $fontSize[ 8] = 7; |
43 $fontSize[16] = 13; | 43 $fontSize[16] = 13; |
44 $fontSize[32] = 26; | 44 $fontSize[32] = 26; |
45 | 45 |
46 $modes = array( | 46 $modes = [ |
47 "xml" => array("batclient.xml" , 0, 0), | 47 "xml" => ["batclient.xml" , 0, 0], |
48 "json" => array("markers.json" , 0, 0), | 48 "json" => ["markers.json" , 0, 0], |
49 ); | 49 ]; |
50 | 50 |
51 $mapPalette = array(); | 51 $mapPalette = []; |
52 $mapPalette["!"] = array(204,255,255); | 52 $mapPalette["!"] = [ 204, 255, 255]; |
53 $mapPalette["%"] = array( 0,170,170); | 53 $mapPalette["%"] = [ 0, 170, 170]; |
54 $mapPalette["-"] = array( 51, 51, 51); | 54 $mapPalette["-"] = [ 51, 51, 51]; |
55 $mapPalette["|"] = array( 51, 51, 51); | 55 $mapPalette["|"] = [ 51, 51, 51]; |
56 $mapPalette["/"] = array( 51, 51, 51); | 56 $mapPalette["/"] = [ 51, 51, 51]; |
57 $mapPalette["+"] = array( 51, 51, 51); | 57 $mapPalette["+"] = [ 51, 51, 51]; |
58 $mapPalette["\\"] = array( 51, 51, 51); | 58 $mapPalette["\\"] = [ 51, 51, 51]; |
59 $mapPalette["="] = array( 72, 67, 57); | 59 $mapPalette["="] = [ 72, 67, 57]; |
60 $mapPalette["@"] = array(255,107, 0); | 60 $mapPalette["@"] = [ 255, 107, 0]; |
61 $mapPalette["F"] = array( 0,136, 0); | 61 $mapPalette["F"] = [ 0, 136, 0]; |
62 $mapPalette["L"] = array(255, 80, 0); | 62 $mapPalette["L"] = [ 255, 80, 0]; |
63 $mapPalette["S"] = array( 68,204,204); | 63 $mapPalette["S"] = [ 68, 204, 204]; |
64 $mapPalette["^"] = array(113,130,146); | 64 $mapPalette["^"] = [ 113, 130, 146]; |
65 $mapPalette["c"] = array( 95, 86, 85); | 65 $mapPalette["c"] = [ 95, 86, 85]; |
66 $mapPalette["f"] = array( 0,182, 0); | 66 $mapPalette["f"] = [ 0, 182, 0]; |
67 $mapPalette["i"] = array(255,255,255); | 67 $mapPalette["i"] = [ 255, 255, 255]; |
68 $mapPalette["l"] = array(100,100,255); | 68 $mapPalette["l"] = [ 100, 100, 255]; |
69 $mapPalette["s"] = array(157,168, 10); | 69 $mapPalette["s"] = [ 157, 168, 10]; |
70 $mapPalette["v"] = array( 34,221, 34); | 70 $mapPalette["v"] = [ 34, 221, 34]; |
71 $mapPalette["x"] = array(138,131, 96); | 71 $mapPalette["x"] = [ 138, 131, 96]; |
72 $mapPalette["z"] = array(177,164,133); | 72 $mapPalette["z"] = [ 177, 164, 133]; |
73 $mapPalette["#"] = array( 79, 54, 69); | 73 $mapPalette["#"] = [ 79, 54, 69]; |
74 $mapPalette["."] = array( 85,146, 0); | 74 $mapPalette["."] = [ 85, 146, 0]; |
75 $mapPalette[","] = array(140, 87, 56); | 75 $mapPalette[","] = [ 140, 87, 56]; |
76 $mapPalette["?"] = array(255,255, 0); | 76 $mapPalette["?"] = [ 255, 255, 0]; |
77 $mapPalette["C"] = array(153,153, 0); | 77 $mapPalette["C"] = [ 153, 153, 0]; |
78 $mapPalette["H"] = array(102, 63, 0); | 78 $mapPalette["H"] = [ 102, 63, 0]; |
79 $mapPalette["R"] = array( 51,102,255); | 79 $mapPalette["R"] = [ 51, 102, 255]; |
80 $mapPalette["V"] = array(255, 51, 0); | 80 $mapPalette["V"] = [ 255, 51, 0]; |
81 $mapPalette["b"] = array(207,196,165); | 81 $mapPalette["b"] = [ 207, 196, 165]; |
82 $mapPalette["d"] = array(238,187, 34); | 82 $mapPalette["d"] = [ 238, 187, 34]; |
83 $mapPalette["h"] = array(153,102, 0); | 83 $mapPalette["h"] = [ 153, 102, 0]; |
84 $mapPalette["j"] = array( 19,150, 54); | 84 $mapPalette["j"] = [ 19, 150, 54]; |
85 $mapPalette["r"] = array(102,153,255); | 85 $mapPalette["r"] = [ 102, 153, 255]; |
86 $mapPalette["t"] = array( 97,195,162); | 86 $mapPalette["t"] = [ 97, 195, 162]; |
87 $mapPalette["w"] = array(119,170,255); | 87 $mapPalette["w"] = [ 119, 170, 255]; |
88 $mapPalette["y"] = array(167,204, 20); | 88 $mapPalette["y"] = [ 167, 204, 20]; |
89 $mapPalette["~"] = array( 51, 51,170); | 89 $mapPalette["~"] = [ 51, 51, 170]; |
90 $mapPalette["1"] = array(255,102, 16); | 90 $mapPalette["1"] = [ 255, 102, 16]; |
91 $mapPalette[3] = array(0,0, 0); | 91 $mapPalette[3] = [ 0, 0, 0]; |
92 | 92 |
93 | 93 |
94 // | 94 // |
95 // Helper functions | 95 // Helper functions |
96 // | 96 // |
321 $binMkLoc = $cfg["pathMapUtils"].$tgtMkLoc; | 321 $binMkLoc = $cfg["pathMapUtils"].$tgtMkLoc; |
322 $rawSuffix = ".new"; | 322 $rawSuffix = ".new"; |
323 $rawAltSuffix = ".map"; | 323 $rawAltSuffix = ".map"; |
324 | 324 |
325 /* | 325 /* |
326 foreach (array("." => 0600, $cfg["pathMapUtils"] => 0600) as $spath => $sperm) | 326 foreach (["." => 0600, $cfg["pathMapUtils"] => 0600] as $spath => $sperm) |
327 { | 327 { |
328 if (chmod($spath, $sperm) === FALSE) | 328 if (chmod($spath, $sperm) === FALSE) |
329 echo "Could not set permissions for '".$spath."'.\n"); | 329 echo "Could not set permissions for '".$spath."'.\n"); |
330 } | 330 } |
331 */ | 331 */ |
448 if (!isset($tradelanePoints)) | 448 if (!isset($tradelanePoints)) |
449 die("PHP array \$tradelanePoints not set, '".$cfg["worldConfig"]."' is old or incompatible.\n"); | 449 die("PHP array \$tradelanePoints not set, '".$cfg["worldConfig"]."' is old or incompatible.\n"); |
450 | 450 |
451 echo "\nCreating tradelane waypoint data '".$tradelaneOut."' ...\n"; | 451 echo "\nCreating tradelane waypoint data '".$tradelaneOut."' ...\n"; |
452 | 452 |
453 $qdata = array(); | 453 $qdata = []; |
454 | 454 |
455 foreach ($tradelanePoints as $name => $data) | 455 foreach ($tradelanePoints as $name => $data) |
456 { | 456 { |
457 $html = "<b>TRADELANE WPT</b><br>".htmlentities($name); | 457 $html = "<b>TRADELANE WPT</b><br>".htmlentities($name); |
458 | 458 |
459 if (!stGetWorldCoords($data[0], $data[1], $data[2], $xc, $yc)) | 459 if (!stGetWorldCoords($data[0], $data[1], $data[2], $xc, $yc)) |
460 die("Invalid tradelane waypoint '".$name."', continent '".$data[0]."' not defined.\n"); | 460 die("Invalid tradelane waypoint '".$name."', continent '".$data[0]."' not defined.\n"); |
461 | 461 |
462 $qdata[] = array( | 462 $qdata[] = [ |
463 "x" => $xc, | 463 "x" => $xc, |
464 "y" => $yc, | 464 "y" => $yc, |
465 "name" => $name, | 465 "name" => $name, |
466 "html" => $html, | 466 "html" => $html, |
467 "continent" => "", | 467 "continent" => "", |
468 "type" => "tradelane", | 468 "type" => "tradelane", |
469 "flags" => 0, | 469 "flags" => 0, |
470 ); | 470 ]; |
471 } | 471 } |
472 | 472 |
473 stOutputToJSONFile($tradelaneOut, $qdata); | 473 stOutputToJSONFile($tradelaneOut, $qdata); |
474 | 474 |
475 | 475 |
478 // | 478 // |
479 echo "\nCreating tradelane polyline data '".$tradelaneOverlay."' ...\n"; | 479 echo "\nCreating tradelane polyline data '".$tradelaneOverlay."' ...\n"; |
480 if (!isset($tradelaneDefs)) | 480 if (!isset($tradelaneDefs)) |
481 die("PHP array \$tradelaneDefs not set, '".$cfg["worldConfig"]."' is old or incompatible.\n"); | 481 die("PHP array \$tradelaneDefs not set, '".$cfg["worldConfig"]."' is old or incompatible.\n"); |
482 | 482 |
483 $qdata = array(); | 483 $qdata = []; |
484 foreach ($tradelaneDefs as $index => $points) | 484 foreach ($tradelaneDefs as $index => $points) |
485 { | 485 { |
486 $qline = array(); | 486 $qline = []; |
487 | 487 |
488 foreach ($points as $point) | 488 foreach ($points as $point) |
489 { | 489 { |
490 if (!stGetWaypointCoords($point, $xc, $yc)) | 490 if (!stGetWaypointCoords($point, $xc, $yc)) |
491 die("Invalid tradelane definition #$index: waypoint '".$point."' not defined.\n"); | 491 die("Invalid tradelane definition #$index: waypoint '".$point."' not defined.\n"); |
492 | 492 |
493 $qline[] = array( | 493 $qline[] = [ |
494 "x" => $xc, | 494 "x" => $xc, |
495 "y" => $yc | 495 "y" => $yc |
496 ); | 496 ]; |
497 } | 497 } |
498 | 498 |
499 $qdata[] = $qline; | 499 $qdata[] = $qline; |
500 } | 500 } |
501 | 501 |
612 | 612 |
613 /* | 613 /* |
614 * Generate small versions | 614 * Generate small versions |
615 */ | 615 */ |
616 echo "\nGenerating scaled small map data...\n"; | 616 echo "\nGenerating scaled small map data...\n"; |
617 $mapScales = array("50", "25", "12.5", "6.25", "3.125"); | 617 $mapScales = ["50", "25", "12.5", "6.25", "3.125"]; |
618 foreach ($continentList as $name => $data) | 618 foreach ($continentList as $name => $data) |
619 if ($data[4] && $data[7]) | 619 if ($data[4] && $data[7]) |
620 { | 620 { |
621 $n = count($mapScales); | 621 $n = count($mapScales); |
622 $inFilename = $cfg["pathImageCache"].$name."_".$n.".png"; | 622 $inFilename = $cfg["pathImageCache"].$name."_".$n.".png"; |
760 } | 760 } |
761 | 761 |
762 | 762 |
763 echo "\nBuilding tiles data for all zoom levels ...\n"; | 763 echo "\nBuilding tiles data for all zoom levels ...\n"; |
764 | 764 |
765 $mapData = array(); | 765 $mapData = []; |
766 | 766 |
767 for ($zoom = $minZoom; $zoom <= $maxZoom; $zoom++) | 767 for ($zoom = $minZoom; $zoom <= $maxZoom; $zoom++) |
768 { | 768 { |
769 $zoom2 = $zoom - 1; | 769 $zoom2 = $zoom - 1; |
770 $scale = pow(2, $zoom2 - 5); | 770 $scale = pow(2, $zoom2 - 5); |