[postgis-users] intersection() box2d

strk at refractions.net strk at refractions.net
Fri Jun 3 16:14:24 PDT 2005


On Fri, Jun 03, 2005 at 01:05:26PM +0200, Nicolas Ribot wrote:
> > Hi Users!
> > 
> > Is it possible to use BOX2D within the 'intersection'-command?
> > 
> > e.g.: select intersection(GeometryFromText('BOX2D(2578271
> > 5622034,2579725 5623110)'), GeometryFromText('LINESTRING(2578664.06
> > 5623016.69,2583790.06 5624136.29)'))
> > 
> > 
> > With BOX3D it seems not to work. But perhaps with BOX2D...
> > 
> > 
> Hi,
> You should try to cast your box2d into a valid geometry.
> On postgis 1.0, this is something like:
> 
> select intersection(
> setSRID('BOX(2578271 5622034,2579725 5623110)'::box2d, -1), 
> GeometryFromText('LINESTRING(2578664.06 5623016.69,2583790.06 5624136.29)', -1)
> )
> 
> setSRID transforms box2d into a geometry.
> I don't know exactly how to do that on 0.9, as geometric textual
> representations have changed a bit, i think.

The setSRID just expects a geometry, and postgresql automatically
casts the box2d into one, anyway your example should fail as
you never tell postgresql that string is a box2d type, you
could use 'BOX2D(...)'::box2d::geometry for an explicit cast, or
just 'BOX2D(...)'::box2d and let pgsql automatically cast it
to geometry to fit into intersection() args list.

--strk;

> 
> Nicolas
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list