[postgis-users] Re: PG 8.0 and PostGIS 1.0 RC1onWindows2003overlap

strk at refractions.net strk at refractions.net
Thu Jan 27 09:57:06 PST 2005


On Thu, Jan 27, 2005 at 10:42:40AM -0700, Randy George wrote:
> Hi,
> 
> 	This is interesting:
> select AsEWKT(transform(SetSRID('BOX3D(284519.3 3769952.1,496251.69999999995
> 3596407.1)'::box3d, 26712),4269));
> returns: "SRID=26712;POLYGON((-113.293160109785
> 32.4857520041516,-113.334429907594 34.0498920281307,-111.040622350418
> 34.0720603897317,-111.039903423973 32.5066459734368,-113.293160109785
> 32.4857520041516))"
> I guess the transform doesn't reset the SRID even though it correctly
> transforms the geometry?

Thanks, you found a bug ;)
Here's the patch:

----8<-----------------------------------------------------------------

diff -U2 -r1.12 lwgeom_transform.c
--- lwgeom_transform.c  25 Jan 2005 09:47:32 -0000      1.12
+++ lwgeom_transform.c  27 Jan 2005 18:03:45 -0000
@@ -316,4 +316,5 @@
                lwgeom_dropBBOX(lwgeom);
                lwgeom->bbox = lwgeom_compute_bbox(lwgeom);
+               lwgeom->SRID = result_srid;
                result = pglwgeom_serialize(lwgeom);
        }

----8<-----------------------------------------------------------------

> Is there any efficiency savings by using Box3d casting?

In respect to what ?
The most efficient way would be using a diagonal linestring, but
I don't think you'll never see the difference in performance.

--strk;

> 
> Thanks
> Randy
> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> strk at refractions.net
> Sent: Thursday, January 27, 2005 10:31 AM
> To: 'PostGIS Users Discussion'
> Subject: Re: [postgis-users] Re: PG 8.0 and PostGIS 1.0
> RC1onWindows2003overlap
> 
> On Thu, Jan 27, 2005 at 10:12:49AM -0700, Randy George wrote:
> > Hi 
> > 
> > 	I just installed  PG 8.0 and PostGIS 1.0 RC2 on a Windows 2003
> > server
> > 
> > 	When attempting the old query on my test data:
> > 
> > select id, type as name, AsText(the_geom) from ibus where type='SOR' and
> > the_geom && transform(GeometryFromText('BOX3D(284519.3
> > 3769952.1,496251.69999999995 3596407.1)'::box3d,26712),4269);
> > 
> > I get: ERROR:  function geometryfromtext(box3d, integer) does not exist
> > 
> > Replacing Box3D with LineString:
> > 
> > select id, type as name, AsText(the_geom) from ibus where type='SOR' and
> > the_geom && transform(GeometryFromText('LineString(284519.3
> > 3769952.1,496251.69999999995 3596407.1)',26712),4269);
> > 
> > Since the bounding box is the same as the BOX3D but Linestring is a text
> > this gives the correct result.
> > 
> > 
> > I was looking through the docs for some more information on Box3D but I'm
> > not clear when/how use of Box3D would be appropriate?
> > 
> > Is 'BOX3D(284519.3 3769952.1,496251.69999999995 3596407.1)'::box3d a
> > shortcut for creating a bounding box geometry only when SRID is not an
> > issue? Or is there a way to transform a Box3D to a new SRID?
> > It is used in the examples Re: 4.6.1 in new docs
> 
> A BOX3D has no SRID. When using the && operator your box is being
> transformed to a GEOMETRY by an implicit cast. If you need to 
> specify a SRID other then -1 you must use the SetSRID(geometry, int)
> function. Again, you will rely on an implicit cast doing:
> 
> 	SetSRID('BOX3D(...)'::box3d, 4326)
> 
> I hope this wasn't too confusing.
> 
> --strk;
> 
> 
> > 
> > Thanks
> > randy
> > 
> > 
> > 
> > -----Original Message-----
> > From: postgis-users-bounces at postgis.refractions.net
> > [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Mark
> > Cave-Ayland
> > Sent: Tuesday, January 25, 2005 3:04 AM
> > To: 'PostGIS Users Discussion'
> > Subject: RE: [postgis-users] Re: PG 8.0 and PostGIS 1.0
> > RC1onWindows2003overlap
> > 
> > Hi strk,
> > 
> > > -----Original Message-----
> > > From: postgis-users-bounces at postgis.refractions.net 
> > > [mailto:postgis-users-bounces at postgis.refractions.net] On 
> > > Behalf Of strk at refractions.net
> > > Sent: 25 January 2005 09:25
> > > To: Mark Cave-Ayland
> > > Cc: 'PostGIS Users Discussion'
> > > Subject: Re: [postgis-users] Re: PG 8.0 and PostGIS 1.0 
> > > RC1onWindows2003overlap
> > > 
> > > 
> > > Mmm.. I wouldn't use GeometryFromText with a BOX3D argument.
> > > I think it should only accept 'text' as it has been done with 
> > > GeomFromWKB only accepting bytea.
> > 
> > No complaints here. We do a lot of queries like "the_geom && BOX3D('1 2 3,
> 4
> > 5 6')" (and I believe the Mapserver connector uses a similar query) so as
> > long as these still work, I can live without accepting BOX3D as part of
> > GeometryFromText().
> > 
> > > Beside this, you can use asEWKT(geometry) to see Extended WKT.
> > 
> > That's the function I couldn't remember then :)
> > 
> > > .. And .. I've found the bug.
> > > The transform() functoin is failing to transform/recompute an 
> > > already cached bbox.
> > > 
> > > I'm working on it.
> > 
> > Just got your patch, but having Windows/Linux conversion problems ;) Will
> > try and find a moment to test it at this end later.....
> > 
> > 
> > Kind regards,
> > 
> > Mark.
> > 
> > ------------------------
> > WebBased Ltd
> > South West Technology Centre
> > Tamar Science Park
> > Plymouth
> > PL6 8BT 
> > 
> > T: +44 (0)1752 791021
> > F: +44 (0)1752 791023
> > W: http://www.webbased.co.uk
> > 
> > 
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> _______________________________________________
> 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