-
Notifications
You must be signed in to change notification settings - Fork 0
/
tilemap.php
54 lines (48 loc) · 1.74 KB
/
tilemap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*PhpDoc:
name: tilemap.php
title: tilemap.php - génération de la carte pour tile.php (PERIME)
doc: |
journal: |
1/3/2022:
remplacement de genmap.php en utilisant llmap
*/
require_once __DIR__.'/config.inc.php';
require_once __DIR__.'/llmap.inc.php';
use Symfony\Component\Yaml\Yaml;
$config = config();
$layers = $config['layers'];
$gpkey = array_keys($config['gpkeys'])[0];
$map = Yaml::parseFile(__DIR__.'/tilemap.yaml');
$map['body']['baseLayers'] = [];
$map['body']['overlays'] = [];
$map['body']['defaultBaseLayer'] = null;
foreach ($_GET as $k => $v) {
// outre action, $_GET contient une entrée par id de couche avec pour valeur off, base ou overlay
if (($k<>'action') && ($v<>'off')) {
$layer = $layers[$k];
$protocole = (($_SERVER['HTTPS'] ?? null ) == 'on') ? 'https' : 'http';
$tilepath = ($_SERVER['SERVER_NAME']=='localhost' ?
$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME'])
: 'igngp.geoapi.fr');
$tilepath .= '/tile.php';
$key = isset($layer['gpkey']) ? '' : "/$gpkey";
$kindLayer = ($v == 'base') ? 'baseLayers' : 'overlays';
$map['body'][$kindLayer][$layer['title']] = [
'type'=> 'L.TileLayer',
'params'=> [
"$protocole://$tilepath/$k$key/{z}/{x}/{y}.$layer[format]",
[
'format'=> ($layer['format']=='png' ? 'image/png' : 'image/jpeg'),
'minZoom'=> $layer['minZoom'],
'maxZoom'=> $layer['maxZoom'],
'detectRetina'=> !isset($layer['detectRetina']),
'attribution'=> $layer['attribution'] ?? "© <a href='http://www.ign.fr'>IGN</a>",
],
]
];
if (!$map['body']['defaultBaseLayer'] && ($v=='base'))
$map['body']['defaultBaseLayer'] = $layer['title'];
}
}
LLMap::genPhp($map);