Skip to content

Commit 2fe153f

Browse files
committed
Make HEALPix/MOC support optional
1 parent e679906 commit 2fe153f

6 files changed

+147
-65
lines changed

Makefile

+75-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
PGSPHERE_VERSION = 1.2.2
2+
EXTENSION = pg_sphere
3+
RELEASE_SQL = $(EXTENSION)--$(PGSPHERE_VERSION).sql
4+
USE_PGXS = 1
5+
USE_HEALPIX =? 1
26

37
# the base dir name may be changed depending on git clone command
48
SRC_DIR = $(shell basename $(shell pwd))
@@ -7,11 +11,13 @@ MODULE_big = pg_sphere
711
OBJS = src/sscan.o src/sparse.o src/sbuffer.o src/vector3d.o src/point.o \
812
src/euler.o src/circle.o src/line.o src/ellipse.o src/polygon.o \
913
src/path.o src/box.o src/output.o src/gq_cache.o src/gist.o \
10-
src/key.o src/gnomo.o src/healpix.o src/moc.o src/process_moc.o \
11-
healpix_bare/healpix_bare.o src/epochprop.o
14+
src/key.o src/gnomo.o src/epochprop.o
15+
16+
ifneq ($(USE_HEALPIX),0)
17+
OBJS += src/healpix.o src/moc.o src/process_moc.o \
18+
healpix_bare/healpix_bare.o
19+
endif
1220

13-
EXTENSION = pg_sphere
14-
RELEASE_SQL = $(EXTENSION)--$(PGSPHERE_VERSION).sql
1521
DATA_built = $(RELEASE_SQL) \
1622
pg_sphere--unpackaged--1.1.5beta0gavo.sql \
1723
pg_sphere--1.0--1.0_gavo.sql \
@@ -24,14 +30,24 @@ DATA_built = $(RELEASE_SQL) \
2430

2531
DOCS = README.pg_sphere COPYRIGHT.pg_sphere
2632
REGRESS = init tables points euler circle line ellipse poly path box index \
27-
contains_ops contains_ops_compat bounding_box_gist gnomo healpix \
28-
moc mocautocast epochprop
33+
contains_ops contains_ops_compat bounding_box_gist gnomo
34+
35+
ifneq ($(USE_HEALPIX),0)
36+
REGRESS += healpix moc mocautocast
37+
endif
38+
39+
REGRESS += epochprop
2940

3041
REGRESS_9_5 = index_9.5 # experimental for spoint3
3142

32-
TESTS = init_test tables points euler circle line ellipse poly path box index \
33-
contains_ops contains_ops_compat bounding_box_gist gnomo healpix \
34-
moc mocautocast epochprop
43+
TESTS = init_test tables points euler circle line ellipse poly path box \
44+
index contains_ops contains_ops_compat bounding_box_gist gnomo
45+
46+
ifneq ($(USE_HEALPIX),0)
47+
TESTS += healpix moc mocautocast
48+
endif
49+
50+
TESTS += epochprop
3551

3652
PG_CFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)
3753
PG_CPPFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)
@@ -48,14 +64,25 @@ CRUSH_TESTS = init_extended circle_extended
4864

4965
# order of sql files is important
5066
PGS_SQL = pgs_types.sql pgs_point.sql pgs_euler.sql pgs_circle.sql \
51-
pgs_line.sql pgs_ellipse.sql pgs_polygon.sql pgs_path.sql \
52-
pgs_box.sql pgs_contains_ops.sql pgs_contains_ops_compat.sql \
53-
pgs_gist.sql gnomo.sql \
54-
healpix.sql pgs_gist_spoint3.sql pgs_moc_type.sql pgs_moc_compat.sql pgs_moc_ops.sql \
55-
pgs_moc_geo_casts.sql pgs_epochprop.sql
67+
pgs_line.sql pgs_ellipse.sql pgs_polygon.sql pgs_path.sql \
68+
pgs_box.sql pgs_contains_ops.sql pgs_contains_ops_compat.sql \
69+
pgs_gist.sql gnomo.sql
70+
71+
ifneq ($(USE_HEALPIX),0)
72+
PGS_SQL += healpix.sql
73+
endif
74+
75+
PGS_SQL += pgs_gist_spoint3.sql
76+
77+
ifneq ($(USE_HEALPIX),0)
78+
PGS_SQL += pgs_moc_type.sql pgs_moc_compat.sql pgs_moc_ops.sql \
79+
pgs_moc_geo_casts.sql
80+
endif
81+
82+
PGS_SQL += pgs_epochprop.sql
83+
5684
PGS_SQL_9_5 = pgs_9.5.sql # experimental for spoint3
5785

58-
USE_PGXS = 1
5986
ifdef USE_PGXS
6087
ifndef PG_CONFIG
6188
PG_CONFIG := pg_config
@@ -70,11 +97,13 @@ else
7097
include $(top_srcdir)/contrib/contrib-global.mk
7198
endif
7299

100+
ifneq ($(USE_HEALPIX),0)
73101
# compiler settings
74102
PKG_CONFIG = pkg-config
75103
override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags healpix_cxx)
76104
SHLIB_LINK += $(shell $(PKG_CONFIG) --libs healpix_cxx)
77105
LINK.shared = g++ -shared
106+
endif
78107

79108
# healpix_bare.c isn't ours so we refrain from fixing the warnings in there
80109
healpix_bare/healpix_bare.o : healpix_bare/healpix_bare.c
@@ -96,9 +125,11 @@ has_explain_summary = $(if $(filter-out 9.%,$(pg_version)),y,n)
96125
crushtest: REGRESS += $(CRUSH_TESTS)
97126
crushtest: installcheck
98127

128+
ifneq ($(USE_HEALPIX),0)
99129
ifeq ($(has_explain_summary),y)
100130
REGRESS += moc1 moc100
101131
endif
132+
endif
102133

103134
ifeq ($(pg_version_9_5_plus),y)
104135
PGS_TMP_DIR = --temp-instance=tmp_check
@@ -159,12 +190,17 @@ else
159190
endif
160191

161192
# local stuff follows here
162-
163-
AUGMENT_GAVO_111 = $(AUGMENT_UNP_111) healpix.sql # for vanilla 1.1.1 users
193+
AUGMENT_GAVO_111 = $(AUGMENT_UNP_111) # for vanilla 1.1.1 users
194+
ifneq ($(USE_HEALPIX),0)
195+
AUGMENT_GAVO_111 += healpix.sql
196+
endif
164197
UPGRADE_GAVO_111 = $(UPGRADE_UNP_COMMON)
165198

166-
# add new Healpix functions and experimental spoint3
167-
AUGMENT_FROM_GAVO = healpix.sql pgs_gist_spoint3.sql
199+
# add new HEALPix functions and experimental spoint3
200+
ifneq ($(USE_HEALPIX),0)
201+
AUGMENT_FROM_GAVO = healpix.sql
202+
endif
203+
AUGMENT_FROM_GAVO += pgs_gist_spoint3.sql
168204

169205
AUGMENT_UNP_115B0G = $(AUGMENT_UNP_111) $(AUGMENT_FROM_GAVO)
170206
UPGRADE_UNP_115B0G = $(UPGRADE_UNP_COMMON)
@@ -188,20 +224,37 @@ pg_sphere--1.0_gavo--1.1.5beta0gavo.sql: $(addsuffix .in, \
188224
$(addprefix upgrade_scripts/, $(UPGRADE_1_0_115B0G)))
189225
cat upgrade_scripts/$@.in $^ > $@
190226

227+
ifneq ($(USE_HEALPIX),0)
191228
pg_sphere--1.1.5beta0gavo--1.1.5beta2gavo.sql: pgs_moc_type.sql.in
192229
cat upgrade_scripts/$@.in $^ > $@
193230

194231
pg_sphere--1.1.5beta2gavo--1.1.5beta4gavo.sql: pgs_moc_compat.sql.in
195232
cat upgrade_scripts/$@.in $^ > $@
196233

197234
pg_sphere--1.1.5beta4gavo--1.2.0.sql: pgs_moc_ops.sql.in
198-
cat $^ > $@
235+
cat upgrade_scripts/$@.in $^ > $@
199236

200237
pg_sphere--1.2.0--1.2.1.sql: pgs_moc_geo_casts.sql.in pgs_epochprop.sql.in
201238
cat $^ > $@
202239

203-
pg_sphere--1.2.1--1.2.2.sql: upgrade_scripts/pg_sphere--1.2.1--1.2.2.sql.in
204-
cat $^ > $@
240+
pg_sphere--1.2.1--1.2.2.sql: upgrade_scripts/pg_sphere--1.2.1--1.2.2-healpix.sql.in
241+
cat upgrade_scripts/$@.in $^ > $@
242+
else
243+
pg_sphere--1.1.5beta0gavo--1.1.5beta2gavo.sql:
244+
cat upgrade_scripts/$@.in > $@
245+
246+
pg_sphere--1.1.5beta2gavo--1.1.5beta4gavo.sql:
247+
cat upgrade_scripts/$@.in > $@
248+
249+
pg_sphere--1.1.5beta4gavo--1.2.0.sql:
250+
cat upgrade_scripts/$@.in > $@
251+
252+
pg_sphere--1.2.0--1.2.1.sql: pgs_epochprop.sql.in
253+
cat upgrade_scripts/$@.in $^ > $@
254+
255+
pg_sphere--1.2.1--1.2.2.sql:
256+
cat upgrade_scripts/$@.in > $@
257+
endif
205258

206259
# end of local stuff
207260

README.pg_sphere

+36-11
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,53 @@ like spherical points and spherical circles with
1414
useful functions and operators.
1515

1616
NOTICE:
17-
This version will work only with postgresql version 9.1 and above.
17+
This version will work only with PostgreSQL version 9.5 and above.
1818

1919
INSTALLATION:
2020

21-
-- build and install
22-
gmake USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config
23-
gmake USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config install
24-
-- load extension
21+
-- Build and install
22+
23+
gmake
24+
gmake install
25+
26+
-- HEALPix/MOC support is included by default. If your platform does not
27+
-- have the required libhealpix_cxx dependency, you can optionally build
28+
-- pgSphere without HEALPix/MOC support, like so:
29+
30+
gmake USE_HEALPIX=0
31+
gmake USE_HEALPIX=0 install
32+
33+
-- Load extension
34+
2535
psql -c "CREATE EXTENSION pg_sphere;" <database>
2636

27-
REGRESSION TEST (as the same user as the currently running postgresql server):
37+
UPDATING AN EXISTING INSTALLATION:
38+
39+
-- If you are updating from a previous version of pgSphere, perform the
40+
-- same make and make install steps as above, but, instead of the CREATE
41+
-- EXTENSION step, you need to do:
2842

29-
make USE_PGXS=1 installcheck
43+
psql -c "ALTER EXTENSION q3c UPDATE TO 'A.B.C';" <database>
44+
45+
-- where A.B.C is a placeholder for the current version.
46+
-- You also may want to check what version of pgSphere is installed using
47+
either of following commands:
48+
49+
psql -c "select pg_sphere_version();" <database>
50+
psql -c "SELECT * FROM pg_available_extension_versions WHERE name = 'pg_sphere';"
51+
52+
REGRESSION TESTS (as the same user as the currently running PostgreSQL server):
53+
54+
make installcheck
55+
make test
3056

3157
LONG REGRESSION TEST:
3258

33-
make USE_PGXS=1 crushtest
59+
make crushtest
3460

3561
The 'make' program must be compatible with GNU make.
3662

37-
For more information, have a look at http://pgsphere.projects.postgresql.org
38-
and https://github.com/akorotkov/pgsphere
63+
For more information or to report issues or to help with development, please
64+
refer to https://github.com/postgrespro/pgsphere/
3965

4066
Have a lot of fun!
41-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- complain if this upgrade script is run via psql
2+
\echo Use "ALTER EXTENSION pg_sphere UPDATE TO '1.2.0'" to load this file. \quit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- complain if this upgrade script is run via psql
2+
\echo Use "ALTER EXTENSION pg_sphere UPDATE TO '1.2.1'" to load this file. \quit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- healpix
2+
ALTER FUNCTION nest2ring(integer, bigint) PARALLEL SAFE;
3+
ALTER FUNCTION ring2nest(integer, bigint) PARALLEL SAFE;
4+
ALTER FUNCTION healpix_convert_nest(integer, integer, bigint) PARALLEL SAFE;
5+
ALTER FUNCTION healpix_convert_ring(integer, integer, bigint) PARALLEL SAFE;
6+
ALTER FUNCTION nside2order(bigint) PARALLEL SAFE;
7+
ALTER FUNCTION order2nside(integer) PARALLEL SAFE;
8+
ALTER FUNCTION nside2npix(bigint) PARALLEL SAFE;
9+
ALTER FUNCTION npix2nside(bigint) PARALLEL SAFE;
10+
ALTER FUNCTION healpix_nest(integer, spoint) PARALLEL SAFE;
11+
ALTER FUNCTION healpix_ring(integer, spoint) PARALLEL SAFE;
12+
ALTER FUNCTION centre_of_healpix_nest(integer, bigint) PARALLEL SAFE;
13+
ALTER FUNCTION centre_of_healpix_ring(integer, bigint) PARALLEL SAFE;
14+
ALTER FUNCTION center_of_healpix_nest(integer, bigint) PARALLEL SAFE;
15+
ALTER FUNCTION center_of_healpix_ring(integer, bigint) PARALLEL SAFE;
16+
17+
-- moc_type
18+
ALTER FUNCTION smoc_in(cstring) PARALLEL SAFE;
19+
ALTER FUNCTION smoc_out(smoc) PARALLEL SAFE;
20+
ALTER FUNCTION moc_debug() PARALLEL SAFE;
21+
ALTER FUNCTION set_smoc_output_type(integer) PARALLEL SAFE;
22+
ALTER FUNCTION max_order(smoc) PARALLEL SAFE;
23+
ALTER FUNCTION healpix_subset_smoc(bigint, smoc) PARALLEL SAFE;
24+
ALTER FUNCTION healpix_not_subset_smoc(bigint, smoc) PARALLEL SAFE;
25+
ALTER FUNCTION smoc_superset_healpix(smoc, bigint) PARALLEL SAFE;
26+
ALTER FUNCTION smoc_not_superset_healpix(smoc, bigint) PARALLEL SAFE;
27+
ALTER FUNCTION spoint_subset_smoc(spoint, smoc) PARALLEL SAFE;
28+
ALTER FUNCTION spoint_not_subset_smoc(spoint, smoc) PARALLEL SAFE;
29+
ALTER FUNCTION smoc_superset_spoint(smoc, spoint) PARALLEL SAFE;
30+
ALTER FUNCTION smoc_not_superset_spoint(smoc, spoint) PARALLEL SAFE;

upgrade_scripts/pg_sphere--1.2.1--1.2.2.sql.in

+2-32
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22
ALTER FUNCTION gnomonic_proj(spoint, spoint) PARALLEL SAFE;
33
ALTER FUNCTION gnomonic_inv(point, spoint) PARALLEL SAFE;
44

5-
-- healpix
6-
ALTER FUNCTION nest2ring(integer, bigint) PARALLEL SAFE;
7-
ALTER FUNCTION ring2nest(integer, bigint) PARALLEL SAFE;
8-
ALTER FUNCTION healpix_convert_nest(integer, integer, bigint) PARALLEL SAFE;
9-
ALTER FUNCTION healpix_convert_ring(integer, integer, bigint) PARALLEL SAFE;
10-
ALTER FUNCTION nside2order(bigint) PARALLEL SAFE;
11-
ALTER FUNCTION order2nside(integer) PARALLEL SAFE;
12-
ALTER FUNCTION nside2npix(bigint) PARALLEL SAFE;
13-
ALTER FUNCTION npix2nside(bigint) PARALLEL SAFE;
14-
ALTER FUNCTION healpix_nest(integer, spoint) PARALLEL SAFE;
15-
ALTER FUNCTION healpix_ring(integer, spoint) PARALLEL SAFE;
16-
ALTER FUNCTION centre_of_healpix_nest(integer, bigint) PARALLEL SAFE;
17-
ALTER FUNCTION centre_of_healpix_ring(integer, bigint) PARALLEL SAFE;
18-
ALTER FUNCTION center_of_healpix_nest(integer, bigint) PARALLEL SAFE;
19-
ALTER FUNCTION center_of_healpix_ring(integer, bigint) PARALLEL SAFE;
20-
215
-- sbox
226
ALTER FUNCTION sbox(spoint, spoint) PARALLEL SAFE;
237
ALTER FUNCTION sw(sbox) PARALLEL SAFE;
@@ -215,21 +199,6 @@ ALTER FUNCTION scircle_contains_line_com(sline, scircle) PARALLEL SAFE;
215199
ALTER FUNCTION scircle_contains_line_neg(scircle, sline) PARALLEL SAFE;
216200
ALTER FUNCTION scircle_contains_line_com_neg(sline, scircle) PARALLEL SAFE;
217201

218-
-- moc_type
219-
ALTER FUNCTION smoc_in(cstring) PARALLEL SAFE;
220-
ALTER FUNCTION smoc_out(smoc) PARALLEL SAFE;
221-
ALTER FUNCTION moc_debug() PARALLEL SAFE;
222-
ALTER FUNCTION set_smoc_output_type(integer) PARALLEL SAFE;
223-
ALTER FUNCTION max_order(smoc) PARALLEL SAFE;
224-
ALTER FUNCTION healpix_subset_smoc(bigint, smoc) PARALLEL SAFE;
225-
ALTER FUNCTION healpix_not_subset_smoc(bigint, smoc) PARALLEL SAFE;
226-
ALTER FUNCTION smoc_superset_healpix(smoc, bigint) PARALLEL SAFE;
227-
ALTER FUNCTION smoc_not_superset_healpix(smoc, bigint) PARALLEL SAFE;
228-
ALTER FUNCTION spoint_subset_smoc(spoint, smoc) PARALLEL SAFE;
229-
ALTER FUNCTION spoint_not_subset_smoc(spoint, smoc) PARALLEL SAFE;
230-
ALTER FUNCTION smoc_superset_spoint(smoc, spoint) PARALLEL SAFE;
231-
ALTER FUNCTION smoc_not_superset_spoint(smoc, spoint) PARALLEL SAFE;
232-
233202
-- spath
234203
ALTER FUNCTION npoints(spath) PARALLEL SAFE;
235204
ALTER FUNCTION spoint(spath, int4) PARALLEL SAFE;
@@ -344,4 +313,5 @@ ALTER FUNCTION spoly_add_points_fin_aggr(spoly) PARALLEL SAFE;
344313

345314
-- gist_spoint3
346315
ALTER FUNCTION g_spoint3_penalty(internal, internal, internal) PARALLEL SAFE;
347-
ALTER FUNCTION g_spoint3_fetch(internal, internal, internal) PARALLEL SAFE;
316+
ALTER FUNCTION g_spoint3_fetch(internal) PARALLEL SAFE;
317+

0 commit comments

Comments
 (0)