[postgis-users] Problem with pgsql function

Bruce Rindahl rindahl at lrcwe.com
Fri Sep 22 17:58:54 PDT 2006


You will have to use a case statement if the point crosses the 180° line
just like you did in your shift_point function.  I thought it might be
faster to use the translate function instead of splitting the point and then
recreating the new one.

Enjoy!

Bruce

 

  _____  

From: Jeremy Palmer [mailto:palmerj at xtra.co.nz] 
Sent: Friday, September 22, 2006 6:52 PM
To: rindahl at lrcwe.com
Cc: postgis-users at postgis.refractions.net
Subject: RE: [postgis-users] Problem with pgsql function

 

He is an example of why translate (unless I wrap a case statement around it
to deal with points that cross the 180° line) will not work even with a
point.

 

Example query:

 

SELECT COO.value1,

       COO.value2,

       ASTEXT(NOD.shape) AS ORGINAL,

       ASTEXT(shift_point(NOD.shape, true)) AS SHIFT,

       ASTEXT(translate(NOD.shape, 160, 0)) AS TRANSLATE

FROM   crs_mark_name MKN,

       crs_mark MRK,

       crs_coordinate COO,

       crs_node NOD

WHERE  MRK.id = MKN.mrk_id

AND    COO.nod_id = MRK.nod_id

AND    NOD.id = MRK.nod_id

AND    MKN.name = 'CHAT'

AND    MKN.type = 'CODE'

AND    NOD.status = 'AUTH'

AND    COO.status = 'AUTH'

AND    COO.cos_id = 109;

 

Real latitude:                 -43.955786822800

Real latitude:                 -176.565839634400

Stored geometry:           POINT(23.4341603667 -43.9557868167)

shift_point function:        POINT(-176.5658396333 -43.9557868167)

Translate:                      POINT(183.4341603667 -43.9557868167)

 

Notice that the shift_point function will return the point ‘west’ of
Grenwich, not ‘east’ like translate

 

Cheers

Jeremy

 

  _____  

From: Bruce Rindahl [mailto:rindahl at lrcwe.com] 
Sent: Saturday, 23 September 2006 10:02 a.m.
To: 'Jeremy Palmer'; postgis-users at postgis.refractions.ne
Subject: RE: [postgis-users] Problem with pgsql function

 

It will definitely work for points which was your example.  Do you have a
valid polygon geometry that crosses 180?  I mean do you have a polygon with
corners at -179,-31 179,-29 and have that stored as a 2 degree box or is it
2 degrees high and 358 degrees wide ?

Bruce

 

  _____  

From: Jeremy Palmer [mailto:palmerj at xtra.co.nz] 
Sent: Friday, September 22, 2006 3:57 PM
To: postgis-users at postgis.refractions.ne
Cc: rindahl at lrcwe.com
Subject: RE: [postgis-users] Problem with pgsql function

 

Thanks for the tip, but the translate function (which uses the affine
transform function) will not work on geometries that cross the 180°
longitude line will it? Otherwise your right, I should use it.

 

Cheers

Jeremy

 

<< "Bruce Rindahl" rindahl at lrcwe.com

 

<< Have you considered using the translate() function?  I would do exactly
what

<< you are coding and it will work on all geometries.

<< Bruce Rindahl

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060922/7fd2debb/attachment.html>


More information about the postgis-users mailing list