[postgis-users] Mapserver extent question

strk at refractions.net strk at refractions.net
Tue Sep 20 14:17:58 PDT 2005


On Tue, Sep 20, 2005 at 03:17:44PM -0500, David Niergarth wrote:
> 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?> ;

Whatever can cast to a geometry:
	- a BOX2D [ 'BOX(xmin ymin, xmax ymax)'::box2d ]
	- a BOX3D [ 'BOX3D(xmin ymin zmin, xmax ymax zmax)'::box3d ]
	- a geometry [ 'LINESTRING(xmin ymin, xmax ymax)'::geometry ]

I think examples in manual page use BOX3D, the only thing you need
to take care of is setting the SRID of the geometry resulting from
the automatic cast:

	SetSRID(<my_thing>::geometry, <SRID>)


> 
> 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)

That's a BOX2D type. extent3d(the_geom) would give you BOX3D type.

> It doesn't appear to be a WKT format. Is there a way to use BOX like you 
> would with other WKT formats?

I have no informations about a WKT formats for a box.
OGC specifications don't include the BOX type (please prove me
wrong if you can).

0.x PostGIS releases accepted box-only geometries, but it was a
PostGIS extension, obsoleted in 1.x releases.
If you mean the BOX3D(.....) format see above, it's the BOX3D type's
canonical ASCII form.

--strk;



More information about the postgis-users mailing list