[postgis-users] reverse function

Ralph Mason ralph.mason at telogis.com
Wed Apr 14 18:48:35 PDT 2004


John Hagstrand wrote:

>Hello,
>
>Is there a function to reverse the order of points in a line or polygon?
>
>Thanks
>John Hagstrand
>
>
>_______________________________________________
>postgis-users mailing list
>postgis-users at postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
>  
>
It's probably not what you would expect but for linestrings I use

create function reverse_ls(wkb) returns wkb
as '
    wkb = args[0]
    return wkb[0..17]+wkb[18..-1].split(/(.{32})/).reverse.join
'
language 'plruby'

You could make another version for polygons (why would one want to 
reverse the points in a polygon?)

Ralph




More information about the postgis-users mailing list