-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy_wfs.php
38 lines (31 loc) · 1.02 KB
/
proxy_wfs.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
<?php
session_start(['read_and_close' => true]);
require('admin/incl/const.php');
require('admin/class/database.php');
# Redirect MapProxy requests with SERVICE=WFS to proxy_qgis.php
$database = new Database(DB_HOST, DB_NAME, DB_USER, DB_PASS, DB_PORT, DB_SCMA);
$l = null;
if(!empty($_GET['layers'])){
$l = $_GET['layers'];
}else if(!empty($_GET['LAYERS'])){
$l = $_GET['LAYERS'];
}else{
http_response_code(400); // Bad Request
exit(0);
}
# if layer name contains a dot, its an exposed layer (neighbourhoods.ways)
if(str_contains( $l, '.')){
$l = explode('.', $l)[0]; # use only app layer name
}
$row = $database->get('public.layer', 'name=\''.$l.'\'');
if(!$row){
http_response_code(404); // Not Found
exit(0);
}
// change $_GET['LAYERS'] from MapProxy to QGIS names
require('layers/'.$row['id'].'/env.php');
$_GET['QUERY_LAYERS'] = $_GET['LAYERS'] = implode(',', QGIS_LAYERS);
header('Location: /layers/'.$row['id'].'/proxy_qgis.php?'.http_build_query($_GET));
#chdir('layers/'.$row['id']);
#include('proxy_qgis.php');
?>