-
Notifications
You must be signed in to change notification settings - Fork 0
/
consulta_capaNueva.php
52 lines (46 loc) · 1.2 KB
/
consulta_capaNueva.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
$conexion=pg_connect("host=localhost dbname=GIS user=postgres password=root");
$wkt=$_GET['wkt'];
$geometria=$_GET['condicion'];
if ($conexion)
{
if ($geometria==2)
{
$query=<<<EOD
SELECT ST_AsText(geom),provincia,responsable FROM "nueva_capa" WHERE ST_intersects(st_geomfromtext('$wkt',4326),geom)
EOD;
$consulta=pg_query($conexion,$query);
$json=array();
while($resul=pg_fetch_row($consulta))
{
$json[]=array(
'geom'=>$resul[0],
'campo_1'=>$resul[1],
'campo_2'=>$resul[2],
);
}
$jsonString=json_encode($json);
echo $jsonString;
}else
{
$resolucion=$_GET['resolucion'];
$resolucion=$resolucion*3;
$query=<<<EOD
SELECT ST_AsText(geom),provincia,responsable FROM "nueva_capa"
WHERE st_dwithin(st_geomfromtext('$wkt',4326),geom,$resolucion)
EOD;
$resultado=pg_query($conexion, $query);
$json=array();
while ($resul=pg_fetch_row($resultado))
{
$json[] =array(
'geom'=>$resul[0],
'campo_1'=>$resul[1],
'campo_2'=>$resul[2],
);
}
$jsonString=json_encode($json);
echo $jsonString;
}
}
?>