[postgis-users] Extent Generation

Rodrigo Martín LÓPEZ GREGORIO rodrigomlg at yahoo.com.ar
Mon Jan 22 08:49:11 PST 2007


Hi Leonardo. I think that maybe if you want to get the extent of a entire
Postgis table you may use the Postgis function:

estimated_extent([schema], table, geocolumn)

You can read the documentation at section " 6.2.8 Misc" on Postgis docs
page:

http://postgis.refractions.net/docs/ch06.html#id2840629

I think it must be faster cause it is based on the statistics generated by
Postgres at Vacuum process. The documentation says that for Postgres >=
8.0.0 the resulting extent will be about 95% of the real one. With your
solution the extent may be more accurated but for large datasets could be
slower I guess. Maybe someone in the list with advanced knowledge on
Postgres/Postgis can tell us if this method really improves considerably the
response time.

On 1/22/07, Humberto Cereser Ibanez <humberto at pastoraldacrianca.org.br>
wrote:
>
> 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
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070122/76161496/attachment.html>


More information about the postgis-users mailing list