[postgis-users] Extent Generation

Humberto Cereser Ibanez humberto at pastoraldacrianca.org.br
Mon Jan 22 07:39:01 PST 2007


De: "Leonardo Mateo" <leonardomateo at gmail.com>
Data: Mon, 22 Jan 2007 11:58:14 -0300
Para: postgis-users at postgis.refractions.net
Assunto: [postgis-users] Extent Generation

Hi guys, I'm pretty new with all this GIS thing. I'm gonna need some help.
I need to generate map files dynamically for different spatial
datasets (mostly points) and I don't know how to find out the extent
for each one of these data sets.

For testing, I've been doing this with the help of external tools such
as Quantum Gis or Udig but now I need to do this inside the
application wich will be a PHP web application.

How can I do it?

Thanx a lot in advance.

-- 
Leonardo Mateo.

Mateo,

in my application I write the following code in PHP:

<?
function calcula_extent($base, $tabela_shp, $tabela_setor)
{
 $extent = array();
 $conexao = pg_connect("host=localhost dbname=$base user=postgres");
 $result_sql = pg_query
                ($conexao,
                        "select
                                xmin(extent(the_geom)),
                                ymin(extent(the_geom)),
                                xmax(extent(the_geom)),
                                ymax(extent(the_geom))
                        from $tabela_shp where id_ in (select * from $tabela_setor);" // tabela_shp and tabela_setor has the id_ column as the identifier.  
                );
 $extent[0] = pg_result($result_sql, 0, 0);
 $extent[1] = pg_result($result_sql, 0, 1);
 $extent[2] = pg_result($result_sql, 0, 2);
 $extent[3] = pg_result($result_sql, 0, 3);
 return $extent;
}
?>

$extensao = calcula_extent($base, "brasil", $nome_tabela_setor);

I hope this code help you,

Humberto Cereser Ibanez
Pastoral da Criança
Curitiba - PR



More information about the postgis-users mailing list