From: | Stephen Davies <scldad(at)sdc(dot)com(dot)au> |
---|---|
To: | "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu> |
Cc: | dgross(at)lri(dot)fr, Postgres Interfaces Mailing List <pgsql-interfaces(at)postgreSQL(dot)org> |
Subject: | Re: [INTERFACES] postgres for spatial data |
Date: | 1998-07-12 04:53:21 |
Message-ID: | 199807120453.OAA19842@mustang.sdc.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
> > I'm looking for a graphical interface that can display the
> > geometric types like polygon,...
>
> Don't know about pre-built utilities for graphical display of geometric
> objects. Let us know what you discover.
>
> > I'm also looking for SQL extension in order to make
> > spatial queries (for example, a function that tells if a point
> > belongs to the interior of a polygon)
>
> There are already some operators available; for example, the "@"
> operator is for "on or inside":
>
> postgres=> select '(0,0)'::point
> postgres-> @ '((0,1),(1,0),(0,-1),(-1,0))'::polygon;
> ?column?
> --------
> t
> (1 row)
>
> Look in the hardcopy or html doc set which is included in v6.3.x. You
> need to do a "make install" from the doc directory to get them unpacked.
> Good luck...
>
> - Tom
The "point in poly" code in the release package looks rather complicated and
uses lots of calls. The fastest PinP that I have found is the following (coded
here in basic but readily translatable to anything else).
(The underlying algorithms are the same - just the coding differs).
Cheers,
Stephen.
Function TestPoly(X As Double, Y As Double) As Boolean
' check if point X,Y is inside a polygon. Return true if ins%<>0
'
' Polygon coordinates are in global arrays PX and PY.
' The number of coordinates is in global nP.
'
Dim X1 As Double, X2 As Double, Y1 As Double, Y2 As Double
Dim ins As Boolean
ins = False
j% = nP - 1
For i% = 0 To nP - 1
X1 = PX(j%)
X2 = PX(i%)
Y1 = PY(j%)
Y2 = PY(i%)
If X1 < X And X <= X2 Then
If (Y - Y1) * (X2 - X1) < (Y2 - Y1) * (X - X1) Then
ins = Not ins
End If
ElseIf X2 < X And X <= X1 Then
If (Y - Y2) * (X1 - X2) < (Y1 - Y2) * (X - X2) Then
ins = Not ins
End If
End If
j% = i%
Next i%
TestPoly = ins
End Function
========================================================================
Stephen Davies Consulting scldad(at)sdc(dot)com(dot)au
Adelaide, South Australia. Voice: 61-8-82728863
Computing & Network solutions. Fax: 61-8-82741015
From | Date | Subject | |
---|---|---|---|
Next Message | Goran Thyni | 1998-07-12 13:34:03 | db/dbm-emulation |
Previous Message | Thomas G. Lockhart | 1998-07-11 14:09:16 | Re: [INTERFACES] postgres for spatial data |