Re: How to calculate length of path data without diagonals?

From: Stephen Cook <sclists(at)gmail(dot)com>
To: Romain Billoir <billoirr(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to calculate length of path data without diagonals?
Date: 2010-12-24 00:28:46
Message-ID: 4D13E93E.9040903@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/23/2010 1:25 PM, Romain Billoir wrote:
> Hi, i need to calculate some length of path without diagonal. Some
examples:
> length((5,5),(6,6))) returns 1.41. I need 2: 5,5 to 5,6 + 5,6 to 6,6.
>
> Is that possible?

You could write a function to get the Manhattan distance between two
points, it is the sum of the absolute values of subtracting each part of
the coordinate. e.g. ABS(x2 - x1) + ABS(y2 - y1)

-- Stephen

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2010-12-24 02:27:13 Re: Understanding Schema's
Previous Message Adrian Klaver 2010-12-23 19:46:09 Re: Data backup to local duplicate without resetting permissions