";*/ }
$output = ''; $rowOutput = '';
while ($row = pg_fetch_assoc($rs_polygon)) {
$rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {';
$props = '';
$id = '';
foreach ($row as $key => $val) {
if ($key != "geojson") {
$props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"';
}
if ($key == "id") { $id .= ',"id":"' . escapeJsonString($val) . '"'; }
}
$rowOutput .= $props . '}, "geometry": ' . $row['geojson'] . '';
$rowOutput .= $id;
$rowOutput .= '}';
$output .= $rowOutput;
}
$_SESSION['INT_POLYGON'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }';
// ####### LINE ####### //
$sql_line = "SELECT id, notes, ST_AsGeoJSON(geom, 4326, 1) AS geojson FROM interventi_line WHERE idpratica = ".$_SESSION['IDPRATICA']."";
$rs_line = pg_query($conn, $sql_line);
if (!$rs_line) {echo "ERROR - LINE.\n"; } else { /*echo "QUERY OKKEY
";*/ }
$output = ''; $rowOutput = '';
while ($row = pg_fetch_assoc($rs_line)) {
$rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {';
$props = '';
$id = '';
foreach ($row as $key => $val) {
if ($key != "geojson") {
$props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"';
}
if ($key == "id") { $id .= ',"id":"' . escapeJsonString($val) . '"'; }
}
$rowOutput .= $props . '}, "geometry": ' . $row['geojson'] . '';
$rowOutput .= $id;
$rowOutput .= '}';
$output .= $rowOutput;
}
$_SESSION['INT_LINE'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }';
// ####### POINT ####### //
$sql_point = "SELECT id, notes, ST_AsGeoJSON(geom, 4326, 1) AS geojson FROM interventi_point WHERE idpratica = ".$_SESSION['IDPRATICA']."";
$rs_point = pg_query($conn, $sql_point);
if (!$rs_point) {echo "ERROR - POINT.\n"; } else { /*echo "QUERY OKKEY
";*/ }
$output = ''; $rowOutput = '';
while ($row = pg_fetch_assoc($rs_point)) {
$rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {';
$props = '';
$id = '';
foreach ($row as $key => $val) {
if ($key != "geojson") {
$props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"';
}
if ($key == "id") { $id .= ',"id":"' . escapeJsonString($val) . '"'; }
}
$rowOutput .= $props . '}, "geometry": ' . $row['geojson'] . '';
$rowOutput .= $id;
$rowOutput .= '}';
$output .= $rowOutput;
}
$_SESSION['INT_POINT'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }';
?>