Re: Point inside/outside area constructed by an expanded path

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: "Josi Perez (3T Systems)" <josiperez3t(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Point inside/outside area constructed by an expanded path
Date: 2010-10-15 11:08:38
Message-ID: AANLkTim+jSR3uQ-tORcV-Lm54t1eQJ56_o-_b3MJT0HY@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 14, 2010 at 3:00 PM, Josi Perez (3T Systems)
<josiperez3t(at)gmail(dot)com> wrote:
> Hi,
>
> I use postgreSQL.8.4.2 and don't have postGIS installed.
> I have a geometric type polygon and I know that it is possible to determine
> if a point it is inside or not of this polygon, using anything like that:
> select
> polygon('(-23.5672,-46.6510),(-23.5670,-46.65095),(-23.5672,-46.6508),(-23.5672,-46.6510)')
> @> point('-23.567534,-46.64942')
>
> The question:
> Anyone knows an algorithm or have ideas how to determine if a point it is
> inside an area constructed by geometric type path expanded for a known
> distance?
> Graphically:
>
> the path
>             x=========x=======x
>
> the path expanded by a distance
>
>             |         | A     |
>             |         |       |
>      -------x=========x=======x-------  C
>             |         |       |
>         B   |         |       |
>
> the points A and B are inside and the point C are outside .

hm -- if the number of points in the path aren't terribly large, you
can bust this down to a a smaller number of components using available
tools in postgres. For *each* path segment, construct a rectangle and
two circles at the end points:

CRRRRC

If the point is inside the rectangle or either circle (both of those
operations can be solved conventionally in postgres), it's in your
area. If there are a lot of points or you are working with big data,
you should be looking at geometric library to do the work for you.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Haas 2010-10-15 13:24:31 Re: [GENERAL] pg_filedump binary for CentOS
Previous Message Bob Pawley 2010-10-15 10:34:20 Re: How to determine failed connection attempt due to invalid authorization (libpq)?