Skip to content

Commit 5815523

Browse files
committed
Add FAQ_CVS.
1 parent b4672e2 commit 5815523

File tree

6 files changed

+222
-1
lines changed

6 files changed

+222
-1
lines changed

contrib/earthdistance/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# PGLIB is probably /usr/local/pgsql/lib
2+
3+
PGINCLUDE=${PGLIB}/../include
4+
CFLAGS+=-I${PGINCLUDE}
5+
6+
install-earthdistance: ${PGLIB}/earthdistance.so
7+
8+
${PGLIB}/earthdistance.so: earthdistance.so
9+
sudo install -C -g bin -o bin earthdistance.so ${PGLIB}
10+
11+
earthdistance.so: earthdistance.o
12+
$(LD) -o $@ -Bshareable $<
13+
14+
earthdistance.o: earthdistance.c
15+
$(CC) -o $@ -c $(CFLAGS) $<

contrib/earthdistance/README

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Date: Wed, 1 Apr 1998 15:19:32 -0600 (CST)
2+
From: Hal Snyder <hal@vailsys.com>
3+
To: vmehr@ctp.com
4+
Subject: [QUESTIONS] Re: Spatial data, R-Trees
5+
6+
> From: Vivek Mehra <vmehr@ctp.com>
7+
> Date: Wed, 1 Apr 1998 10:06:50 -0500
8+
9+
> Am just starting out with PostgreSQL and would like to learn more about
10+
> the spatial data handling ablilities of postgreSQL - in terms of using
11+
> R-tree indexes, user defined types, operators and functions.
12+
>
13+
> Would you be able to suggest where I could find some code and SQL to
14+
> look at to create these?
15+
16+
Here's the setup for adding an operator '<@>' to give distance in
17+
statute miles between two points on the earth's surface. Coordinates
18+
are in degrees. Points are taken as (longitude, latitude) and not vice
19+
versa as longitude is closer to the intuitive idea of x-axis and
20+
latitude to y-axis.
21+
22+
There's C source, Makefile for FreeBSD, and SQL for installing and
23+
testing the function.
24+
25+
Let me know if anything looks fishy!
26+
27+
A note on testing C extensions - it seems not enough to drop a function
28+
and re-create it - if I change a function, I have to stop and restart
29+
the backend for the new version to be seen. I guess it would be too
30+
messy to track which functions are added from a .so and do a dlclose
31+
when the last one is dropped.

contrib/earthdistance/earthdistance.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <math.h>
2+
#include <stdio.h>
3+
#include <string.h>
4+
5+
#include <postgres.h>
6+
#include <utils/geo_decls.h> /* for Pt */
7+
#include <utils/palloc.h> /* for palloc */
8+
9+
/* Earth's radius is in statute miles. */
10+
const EARTH_RADIUS = 3958.747716;
11+
const TWO_PI = 2.0 * M_PI;
12+
13+
/******************************************************
14+
*
15+
* degtorad - convert degrees to radians
16+
*
17+
* arg: double, angle in degrees
18+
*
19+
* returns: double, same angle in radians
20+
******************************************************/
21+
22+
static double
23+
degtorad (double degrees) {
24+
return (degrees / 360.0) * TWO_PI;
25+
}
26+
27+
28+
/******************************************************
29+
*
30+
* geo_distance - distance between points
31+
*
32+
* args:
33+
* a pair of points - for each point,
34+
* x-coordinate is longitude in degrees west of Greenwich
35+
* y-coordinate is latitude in degrees above equator
36+
*
37+
* returns: double
38+
* distance between the points in miles on earth's surface
39+
******************************************************/
40+
41+
double *
42+
geo_distance (Point *pt1, Point *pt2) {
43+
44+
double long1, lat1, long2, lat2;
45+
double longdiff;
46+
double * resultp = palloc (sizeof(double));
47+
48+
/* convert degrees to radians */
49+
50+
long1 = degtorad (pt1->x);
51+
lat1 = degtorad (pt1->y);
52+
53+
long2 = degtorad (pt2->x);
54+
lat2 = degtorad (pt2->y);
55+
56+
/* compute difference in longitudes - want < 180 degrees */
57+
longdiff = fabs (long1 - long2);
58+
if (longdiff > M_PI)
59+
longdiff = TWO_PI - longdiff;
60+
61+
* resultp = EARTH_RADIUS * acos
62+
(sin (lat1) * sin (lat2) + cos (lat1) * cos (lat2) * cos (longdiff));
63+
64+
return resultp;
65+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
--------------- geo_distance
3+
4+
DROP FUNCTION geo_distance (point, point);
5+
CREATE FUNCTION geo_distance (point, point) RETURNS float8
6+
AS '/usr/local/pgsql/lib/earthdistance.so' LANGUAGE 'c';
7+
8+
SELECT geo_distance ('(1,2)'::point, '(3,4)'::point);
9+
10+
--------------- geo_distance as operator <@>
11+
12+
DROP OPERATOR <@> (point, point);
13+
CREATE OPERATOR <@> (
14+
leftarg = point,
15+
rightarg = point,
16+
procedure = geo_distance,
17+
commutator = <@>
18+
);
19+
20+
-- ( 87.6, 41.8) is in Chicago
21+
-- (106.7, 35.1) is in Albuquerque
22+
-- The cities are about 1100 miles apart
23+
SELECT '(87.6,41.8)'::point <@> '(106.7,35.1)'::point;

doc/FAQ_CVS

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<html>
2+
<head>
3+
<title>PostgreSQL: Getting the source via CVS</title>
4+
</head>
5+
<body bgcolor=white text=black link=blue vlink=purple>
6+
7+
<font size="+3">Getting the source via CVS</font>
8+
9+
<p>If you would like to keep up with the current sources on a regular
10+
basis, you can fetch them from our CVS server and then use CVS to
11+
retrieve updates from time to time.
12+
13+
<P>To do this you first need a local copy of CVS (Concurrent Version Control
14+
System), which you can get from
15+
<A HREF="http://www.cyclic.com/">http://www.cyclic.com/</A> or
16+
any GNU software archive site. Currently we recommend version 1.9.
17+
18+
<P>Once you have installed the CVS software, do this:
19+
<PRE>
20+
cvs -d :pserver:anoncvs@postgresql.org:/usr/local/cvsroot login
21+
</PRE>
22+
You will be prompted for a password; enter '<tt>postgresql</tt>'.
23+
You should only need to do this once, since the password will be
24+
saved in <tt>.cvspass</tt> in your home directory.
25+
26+
<P>Having logged in, you are ready to fetch the PostgreSQL sources.
27+
Do this:
28+
<PRE>
29+
cvs -z3 -d :pserver:anoncvs@postgresql.org:/usr/local/cvsroot co -P pgsql
30+
</PRE>
31+
which will install the PostgreSQL sources into a subdirectory <tt>pgsql</tt>
32+
of the directory you are currently in.
33+
34+
<P>(If you have a fast link to the Internet, you may not need <tt>-z3</tt>,
35+
which instructs CVS to use gzip compression for transferred data. But
36+
on a modem-speed link, it's a very substantial win.)
37+
38+
<P>This initial checkout is a little slower than simply downloading
39+
a <tt>tar.gz</tt> file; expect it to take 40 minutes or so if you
40+
have a 28.8K modem. The advantage of CVS doesn't show up until you
41+
want to update the file set later on.
42+
43+
<P>Whenever you want to update to the latest CVS sources, <tt>cd</tt> into
44+
the <tt>pgsql</tt> subdirectory, and issue
45+
<PRE>
46+
cvs -z3 update -d -P
47+
</PRE>
48+
This will fetch only the changes since the last time you updated.
49+
You can update in just a couple of minutes, typically, even over
50+
a modem-speed line.
51+
52+
<P>You can save yourself some typing by making a file <tt>.cvsrc</tt>
53+
in your home directory that contains
54+
55+
<PRE>
56+
cvs -z3
57+
update -d -P
58+
</PRE>
59+
60+
This supplies the <tt>-z3</tt> option to all cvs commands, and the
61+
<tt>-d</tt> and <tt>-P</tt> options to cvs update. Then you just have
62+
to say
63+
<PRE>
64+
cvs update
65+
</PRE>
66+
to update your files.
67+
68+
<P><strong>CAUTION:</strong> some versions of CVS have a bug that
69+
causes all checked-out files to be stored world-writable in your
70+
directory. If you see that this has happened, you can do something like
71+
<PRE>
72+
chmod -R go-w pgsql
73+
</PRE>
74+
to set the permissions properly. This bug is allegedly fixed in the
75+
latest beta version of CVS, 1.9.28 ... but it may have other, less
76+
predictable bugs.
77+
78+
<P>CVS can do a lot of other things, such as fetching prior revisions
79+
of the PostgreSQL sources rather than the latest development version.
80+
For more info consult the manual that comes with CVS, or see the online
81+
documentation at <A HREF="http://www.cyclic.com/">http://www.cyclic.com/</A>.
82+
83+
</body>
84+
</html>

doc/FAQ_DEV

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ existing code doing similar things is helpful.
113113

114114
There are several ways to obtain the source tree. Occasional developers can
115115
just get the most recent source tree snapshot from ftp.postgresql.org. For
116-
regular developers, you can get CVSup, which is available from
116+
regular developers, you can use CVSup, which is available from
117117
ftp.postgresql.org too. CVSup allows you to download the source tree, then
118118
occasionally update your copy of the source tree with any new changes. Using
119119
CVSup, you don't have to download the entire source each time, only the
120120
changed files. CVSup does not allow developers to update the source tree.
121121

122+
Anonymous CVS is available too. See the doc/FAQ_CVS file for more
123+
information.
124+
122125
To update the source tree, there are two ways. You can generate a patch
123126
against your current source tree, perhaps using the make_diff tools
124127
mentioned above, and send them to the patches list. They will be reviewed,

0 commit comments

Comments
 (0)