mappe per georeferenziazione
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

46 righe
1.5 KiB

2 anni fa
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once 'dbconfig.php';
header("Access-Control-Allow-Origin: *");
$geojson = array(
'type' => 'FeatureCollection',
'features' => array()
);
try {
$dbcon = new PDO("pgsql:host=".$dbconfig['_pgsql_db_host_'].";port=".$dbconfig['_pgsql_db_port_'].";dbname=".$dbconfig['_pgsql_db_name_'].";user=".$dbconfig['_pgsql_db_user_'].";password=".$dbconfig['_pgsql_db_pass_']."");
$dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbcon->prepare("SELECT id, notes, ST_AsGeoJSON(geom, 4326, 1) AS geojson FROM interventi_polygon WHERE idpratica = ".$_SESSION['IDPRATICA']."");
if($stmt->execute()){
$id_count = 0;
while($rowset = $stmt->fetch(PDO::FETCH_ASSOC)){
$properties = $rowset;
unset($properties['geojson']);
unset($properties['geom']);
$feature = array(
'type' => 'Feature',
'id' => $id_count,
'properties' => $properties,
'geometry' => json_decode($rowset['geojson'], true)
);
array_push($geojson['features'], $feature);
$id_count++;
}
header('Content-Type: application/json');
echo json_encode($geojson, JSON_NUMERIC_CHECK);
$dbcon = null;
exit;
} else {
header('Content-Type: application/json');
echo json_encode($geojson, JSON_NUMERIC_CHECK);
$dbcon = null;
exit;
}
} catch (PDOException $e) {
header('Content-Type: application/json');
echo json_encode($geojson, JSON_NUMERIC_CHECK);
$dbcon = null;
exit;
}
?>