Received: from mustang.sdc.com.au (mustang.sdc.com.au [203.2.199.1]) by hub.org (8.8.8/8.7.5) with ESMTP id AAA27484 for ; Sun, 12 Jul 1998 00:54:17 -0400 (EDT) Received: from mustang.sdc.com.au (localhost [127.0.0.1]) by mustang.sdc.com.au (8.8.8/8.6.12) with ESMTP id OAA19842; Sun, 12 Jul 1998 14:23:21 +0930 Message-Id: <199807120453.OAA19842@mustang.sdc.com.au> X-Mailer: exmh version 2.0.2 24/2/98 To: "Thomas G. Lockhart" cc: dgross@lri.fr, Postgres Interfaces Mailing List Subject: Re: [INTERFACES] postgres for spatial data In-reply-to: Your message of "Sat, 11 Jul 1998 14:09:16 GMT." <35A7720C.B254F09@alumni.caltech.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 12 Jul 1998 14:23:21 +0930 From: Stephen Davies > > 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@sdc.com.au Adelaide, South Australia. Voice: 61-8-82728863 Computing & Network solutions. Fax: 61-8-82741015