diff options
| author | Bruce Momjian <bruce@momjian.us> | 2000-06-15 18:55:34 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2000-06-15 18:55:34 +0000 |
| commit | f7f177d372750e4f766ccefdf20e1b30d66cba0a (patch) | |
| tree | d4e2a148640ba36d9a1e8cbf8557faa606ce5ba1 /contrib/earthdistance | |
| parent | 82c4733116813ff862dade1984b6fb74149f4124 (diff) | |
| download | postgresql-f7f177d372750e4f766ccefdf20e1b30d66cba0a.tar.gz | |
/contrib patch from Karel.
Diffstat (limited to 'contrib/earthdistance')
| -rw-r--r-- | contrib/earthdistance/Makefile | 58 | ||||
| -rw-r--r-- | contrib/earthdistance/earthdistance.c | 7 | ||||
| -rw-r--r-- | contrib/earthdistance/earthdistance.sql | 23 |
3 files changed, 53 insertions, 35 deletions
diff --git a/contrib/earthdistance/Makefile b/contrib/earthdistance/Makefile index 0cdaaac5a6..37bfb5df31 100644 --- a/contrib/earthdistance/Makefile +++ b/contrib/earthdistance/Makefile @@ -1,15 +1,53 @@ -# PGLIB is probably /usr/local/pgsql/lib +# +# $Header: /cvsroot/pgsql/contrib/earthdistance/Makefile,v 1.2 2000/06/15 18:54:46 momjian Exp $ +# -PGINCLUDE=${PGLIB}/../include -CFLAGS+=-I${PGINCLUDE} +TOPDIR=../.. -install-earthdistance: ${PGLIB}/earthdistance.so +include ../Makefile.global -${PGLIB}/earthdistance.so: earthdistance.so - sudo install -C -g bin -o bin earthdistance.so ${PGLIB} +NAME = earthdistance -earthdistance.so: earthdistance.o - $(LD) -o $@ -Bshareable $< +PROGRAM = +OBJS = $(NAME).o +DOCS = $(NAME).doc +SQLS = $(NAME).sql +BINS = +EXAMPLES= +MODS = $(NAME)$(DLSUFFIX) -earthdistance.o: earthdistance.c - $(CC) -o $@ -c $(CFLAGS) $< +CFLAGS += -I. $(CFLAGS_SL) + +OTHER_CLEAN = $(SQLS) + +all: $(MODS) $(SQLS) + +%.sql: %.sql.in + $(SED) "s|MODULE_PATHNAME|$(CONTRIB_MODDIR)/$@|" < $< > $@ + +install: install_doc install_sql install_mod + +install_doc: + for inst_file in $(DOCS); do \ + $(INSTALL) $(INSTL_LIB_OPTS) $$inst_file $(CONTRIB_DOCDIR); \ + done + +install_sql: + for inst_file in $(SQLS); do \ + $(INSTALL) $(INSTL_LIB_OPTS) $$inst_file $(CONTRIB_SQLDIR); \ + done + +install_mod: + for inst_file in $(MODS); do \ + $(INSTALL) $(INSTL_SHLIB_OPTS) $$inst_file $(CONTRIB_MODDIR); \ + done + +depend dep: + $(CC) -MM -MG $(CFLAGS) *.c > depend + +clean: + $(RM) *~ $(OBJS) $(MODS) $(PROGRAM) depend $(OTHER_CLEAN) core log + +ifeq (depend,$(wildcard depend)) +include depend +endif diff --git a/contrib/earthdistance/earthdistance.c b/contrib/earthdistance/earthdistance.c index 8dbef7295c..7f2826a35b 100644 --- a/contrib/earthdistance/earthdistance.c +++ b/contrib/earthdistance/earthdistance.c @@ -7,8 +7,11 @@ #include <utils/palloc.h> /* for palloc */ /* Earth's radius is in statute miles. */ -const EARTH_RADIUS = 3958.747716; -const TWO_PI = 2.0 * M_PI; +const int EARTH_RADIUS = 3958.747716; +const int TWO_PI = 2.0 * M_PI; + +double *geo_distance(Point *pt1, Point *pt2); + /****************************************************** * diff --git a/contrib/earthdistance/earthdistance.sql b/contrib/earthdistance/earthdistance.sql index 174d565085..e69de29bb2 100644 --- a/contrib/earthdistance/earthdistance.sql +++ b/contrib/earthdistance/earthdistance.sql @@ -1,23 +0,0 @@ - ---------------- geo_distance - -DROP FUNCTION geo_distance (point, point); -CREATE FUNCTION geo_distance (point, point) RETURNS float8 - AS '/usr/local/pgsql/lib/earthdistance.so' LANGUAGE 'c'; - -SELECT geo_distance ('(1,2)'::point, '(3,4)'::point); - ---------------- geo_distance as operator <@> - -DROP OPERATOR <@> (point, point); -CREATE OPERATOR <@> ( - leftarg = point, - rightarg = point, - procedure = geo_distance, - commutator = <@> -); - --- ( 87.6, 41.8) is in Chicago --- (106.7, 35.1) is in Albuquerque --- The cities are about 1100 miles apart -SELECT '(87.6,41.8)'::point <@> '(106.7,35.1)'::point; |
