[postgis-users] Mapserver extent question
Nicolas Ribot
nicky666 at gmail.com
Tue Sep 20 14:17:11 PDT 2005
> Hello,
>
> I have an extent from mapserver (e.g., "-121.682485 38.408966
> -121.231440 38.763359") that I want to feed back into a PostGIS query.
>
> How do I express this extent in my query?
>
> I want to write a query something like
>
> select recid from tbl_points
> where the_geom && <what goes here?> ;
>
>
> A related question... What's a BOX (see following query):
>
> select extent(the_geom) from tbl_points ;
> extent
>
> ----------------------------------------------------------------------------
> BOX(-124.278755187988 32.5427703857422,-73.5306396484375 46.1519355773926)
> (1 row)
>
> It doesn't appear to be a WKT format. Is there a way to use BOX like you
> would with other WKT formats?
>
> Thanks for any suggestions.
>
Hello David.
To perform a spatial query involving an extent, you can use the
box2d() function to build the extent:
select recid from tbl_points where the_geom && box2D('BOX(-121.682485
38.408966, -121.231440 38.763359)');
Related question: a box is the lower-left, upper-right coordinates of
a geometry or a group of geometries.
Nicolas
More information about the postgis-users
mailing list