-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsources.php
More file actions
105 lines (93 loc) · 3.3 KB
/
sources.php
File metadata and controls
105 lines (93 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
// Abrir archivo de sources
$sources = file_get_contents('https://raw.githubusercontent.com/idera/mapa/master/sources.js');
// Responder peticion plana (cron)
if ($_GET['format']=='plain') {
$jSources=str_replace("var sources = ","",$sources);
$plano = json_decode($jSources,true);
foreach ($plano as $nombre=>$datos){
if (($datos['ptype']=='gxp_wmssource') || ($datos['ptype']=='gxp_wmscsource'))
echo $nombre . "," . $datos['url'] . (($datos['ptype']=='gxp_wmscsource')? "&TILED=true," : ",");
}
}
//Responder peticion HTML
else if ($_GET['format']=='html'){
$jSources=str_replace("var sources = ","",$sources);
$aSources = json_decode($jSources,true);
?>
<html>
<body>
<h1>Listado de servicios WMS</h1>
<ul>
<?php
foreach ($aSources as $nombre=>$datos){
if (($datos['ptype']=='gxp_wmssource') or ($datos['ptype']=='gxp_wmscsource'))
echo "<li><h3>".htmlentities($datos['title'])."</h3><a href=".$datos['url'].">".htmlentities($datos['url'])."</a></li>";
}
?>
</ul>
</body>
</html>
<?php
}
// Responder capabilities cacheados (.xml)
else if ($_GET['format']=='xml') {
//paso a json para usar array
$jSources=str_replace("var sources = ","",$sources);
$aSources = json_decode($jSources,true);
//recorro array
foreach ($aSources as $nombre=>$datos){
//genero nombre del archivo
$filename = 'ogc/'.$nombre.'.xml';
//modifico solo si es wms
if (($datos['ptype']=='gxp_wmssource') || ($datos['ptype']=='gxp_wmscsource')) {
if (file_exists($filename)) {
//reemplazo url con path al xml
$aSources[$nombre]['url'] = $filename;
} else {
//quito source
unset($aSources[$nombre]);
}
}
}
//vuelta al formato original
$jSources = json_encode($aSources, JSON_UNESCAPED_UNICODE);
echo "var sources = ".stripslashes($jSources);
}
//Solo responder servicios WMS (app estado servicios wms)
else if ($_GET['format']=='wms') {
//paso a json para usar array
$jSources=str_replace("var sources = ","",$sources);
$aSources = json_decode($jSources,true);
//recorro array
foreach ($aSources as $nombre=>$datos){
//modifico solo si es wms
if (!(($datos['ptype']=='gxp_wmssource') || ($datos['ptype']=='gxp_wmscsource'))) {
//quito source
unset($aSources[$nombre]);
}
}
//vuelta al formato original
$jSources = json_encode($aSources, JSON_UNESCAPED_UNICODE);
echo "var sources = ".stripslashes($jSources);
}
else if ($_GET['format']=='qgis') {
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="qgis.xml"');
header('Content-Type: charset=utf-8');
$jSources=str_replace("var sources = ","",$sources);
$plano = json_decode($jSources,true);
$cadena = "<wms ignoreGetMapURI='false' smoothPixmapTransform='false' dpiMode='7' password='' ignoreGetFeatureInfoURI='false' referer='' username='' invertAxisOrientation='false' ignoreAxisOrientation='false'";
echo "<qgsWMSConnections version='1.0'>";
foreach ($plano as $nombre=>$datos){
if (($datos['ptype']=='gxp_wmssource') || ($datos['ptype']=='gxp_wmscsource')){
$cadena2 = $cadena. " url='" .htmlentities($datos['url'])."' name='IDERA_". $datos['title']. "'/>";
}
echo $cadena2;
}
echo "</qgsWMSConnections>";
}
else {
echo $sources;
}
?>