";
//echo "QUERY=".$_SESSION['QUERY_CDU']."
";
//echo "PROV=".strtolower($_SESSION['COMUNE_PROV'])."
";
if ($_GET['mode'] == "new") {
$_SESSION['QUERY_CDU'] = "";
$_SESSION['PARTICELLE'] = "";
$_SESSION['CATA_TABLE'] = "";
$_SESSION['cataparticella'] = "";
}
if (!empty($_SESSION['cataparticella'])) {
//$arraycata[] = $_SESSION['cataparticella'];
$arraycata = explode(";", $_SESSION['cataparticella']);
}
if (!empty($_POST['mappale'])) {
$arraycata = $_POST['mappale'];
}
$valorecata = count($arraycata);
// INIZIO PROCEDURA DI RICERCA PROVENIENTE DA FORM QUESTA PAGINA
//if($_POST['mappale']) {
if($valorecata > 0) {
echo "
Dati catastali inseriti:";
foreach( $arraycata as $index => $mappale ) {
if(strlen($valorecata) > 0) { //CALCOLA LA LUNGHEZZA DELLA STRINGA ARRAY
$arr = explode("-", $mappale);
echo '» Foglio:
'.$arr[0].' Particella:
'.$arr[1].'';
$query = "SELECT id FROM ".strtolower($_SESSION['COMUNE_PROV']).".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND mappale ='".trim($mappale)."'";
$result_query = pg_query($conn, $query) or die('ERROR query_mappale: ');
$numrec = pg_numrows($result_query);
//echo "REC = ". $numrec ."
";
if ($numrec > 0) {
while($rowparticelle = pg_fetch_assoc($result_query)) { $gidquery[] = $rowparticelle['id']; }
echo "
";
$_SESSION['CATA_TABLE'] = strtolower($_SESSION['COMUNE_PROV']).".particelle";
} elseif ($numrec == 0) {
$query = "SELECT id FROM public.particelle_modificate WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND mappale ='".$mappale."'";
$result_query = pg_query($conn, $query) or die('ERROR query_mappale_modificato: ');
while($rowparticelle = pg_fetch_assoc($result_query)) { $gidquery[] = $rowparticelle['id']; }
echo "
";
$_SESSION['CATA_TABLE'] = "public.particelle_modificate";
} else { echo "
".$foglioparticella." » particella non trovata
";}
}
}
$valorearray = count($gidquery);
$stringa = implode(' OR id=', $gidquery);
$_SESSION['QUERY_CDU'] = $stringa;
//echo '
STRINGA: '.$_SESSION['QUERY_CDU'];
if ($stringa != "") {
// INIZIO CALCOLO GEOMETRIE E ZOOM
if(!$strcoordinate = @pg_query("SELECT ST_X(ST_Transform(ST_Centroid(ST_Union(geom)),4326)) as long, ST_Y(ST_Transform(ST_Centroid(ST_union(geom)),4326)) as lat FROM ".$_SESSION['CATA_TABLE']." WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";"))
die("Errore CENTRO PARTICELLA: " . pg_last_error($conn));
while($rowcoord = pg_fetch_assoc($strcoordinate)) {
$_SESSION['CENTER'] = $rowcoord['lat'] .", ".$rowcoord['long'];
}
function escapeJsonString($value) { # list from www.json.org: (\b backspace, \f formfeed)
$escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");
$replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");
$result = str_replace($escapers, $replacements, $value);
return $result;
}
// CALCOLA GEOMETRIA PARTICELLA
//$sql_catasto = "SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) AS cata_geojson, round(ST_Area(geom)::numeric,2) as area
$sql_catasto = "SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) AS cata_geojson FROM ".$_SESSION['CATA_TABLE']." WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU']."";
$rs = pg_query($conn, $sql_catasto);
if (!$rs) {
echo "ERROR GEOM PARTICELLE.\n";
} else {
// echo "QUERY OKKEY
";
}
$output = ''; $rowOutput = '';
while ($row = pg_fetch_assoc($rs)) {
$rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {';
$props = '';
$id = '';
foreach ($row as $key => $val) {
if ($key != "cata_geojson") {
$props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"';
}
if ($key == "id") {
$id .= ',"id":"' . escapeJsonString($val) . '"';
}
}
$rowOutput .= $props . '}, "geometry": ' . $row['cata_geojson'] . '';
$rowOutput .= $id;
$rowOutput .= '}';
$output .= $rowOutput;
}
$_SESSION['SELECT_PARTICELLA'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }';
$_SESSION['ZOOM'] = 16;
// FINE CALCOLO GEOMETRIE E ZOOM
echo "";
?>
Verificare con esattezza i dati catastali.รจ possibile che sia presente un frazionamento recente o un'area riservata;
contattare il supporto.";
}
}
?>
Verifica regime vincolistico:
Foglio-Particella, es: 15-234