diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..993a1d11 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*.{c,cpp,h,l,y,pl,pm}] +indent_style = tab +indent_size = tab +tab_width = 4 + +[*.{sgml,xml}] +indent_style = space +indent_size = 1 + +[*.xsl] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/build-and-check-windows-latest.yml b/.github/workflows/build-and-check-windows-latest.yml new file mode 100644 index 00000000..e2d7b274 --- /dev/null +++ b/.github/workflows/build-and-check-windows-latest.yml @@ -0,0 +1,95 @@ +name: Build and Check (windows-latest) + +on: + push: + pull_request: + workflow_dispatch: + schedule: + - cron: '0 0 * * 5' + +jobs: + build_and_test: + + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + pg_version: [10, 11, 12, 13, 14, 15, 16, 17] + use_healpix: [0] + + name: PostgreSQL ${{ matrix.pg_version }} - USE_HEALPIX=${{ matrix.use_healpix }} (windows-latest) + + defaults: + run: + shell: msys2 {0} + + steps: + + - name: Install MSYS2 + uses: msys2/setup-msys2@v2 + with: + update: true + msystem: mingw64 + install: >- + base-devel + curl + git + make + perl + flex + bison + diffutils + mingw-w64-x86_64-zlib + mingw-w64-x86_64-icu + mingw-w64-x86_64-gcc + + - name: Install PostgreSQL + run: | + echo "Workspace: ${GITHUB_WORKSPACE}" + git clone --single-branch -b "REL_${{ matrix.pg_version }}_STABLE" git://git.postgresql.org/git/postgresql.git + cd ${GITHUB_WORKSPACE}/postgresql + ./configure --enable-cassert --without-icu + make -j$(nproc) + make install + + - name: Clone pgSphere + uses: actions/checkout@v4 + + - name: Build pgSphere + run: | + make --keep-going -j$(nproc) PROFILE='-Werror -Wall' USE_HEALPIX=0 + make USE_HEALPIX=0 install + + - name: Test pgSphere (installcheck) + run: | + initdb -D pgdata -U postgres + pg_ctl -D pgdata -l postgres_installcheck.log start + make USE_HEALPIX=0 installcheck + pg_ctl -D pgdata stop + rm -rf pgdata + + - name: Show installcheck regression.diffs + if: ${{ failure() }} + run: cat regression.diffs + + - name: Test pgSphere (crushtest) + run: | + initdb -D pgdata -U postgres + pg_ctl -D pgdata -l postgres_crushtest.log start + make USE_HEALPIX=0 crushtest + pg_ctl -D pgdata stop + + - name: Show crushtest regression.diffs + if: ${{ failure() }} + run: cat regression.diffs + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: ${{ env.GITHUB_REF_SLUG_URL }}-pg${{ matrix.pg_version }}-use-healpix-${{ matrix.use_healpix }}-${{ github.run_id }} + if-no-files-found: ignore + path: | + ./**/*.log + ./**/*.diffs diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml new file mode 100644 index 00000000..b89bdba0 --- /dev/null +++ b/.github/workflows/build-and-check.yml @@ -0,0 +1,85 @@ +name: Build and Check + +on: + push: + pull_request: + workflow_dispatch: + schedule: + - cron: '0 0 * * 5' + +jobs: + build_and_test: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + pg_version: [10, 11, 12, 13, 14, 15, 16, 17] + use_healpix: [0, 1] + + name: PostgreSQL ${{ matrix.pg_version }} - USE_HEALPIX=${{ matrix.use_healpix }} + + steps: + - name: Install dependencies + run: | + sudo apt update && sudo apt install -y \ + postgresql-common \ + libhealpix-cxx-dev \ + docbook-xml \ + docbook-xsl \ + libxml2-utils \ + xsltproc \ + fop + + - name: Install PostgreSQL + run: sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -p -v ${{ matrix.pg_version }} -i + + - name: Clone pgSphere + uses: actions/checkout@v4 + + - name: Set MAKE_CMD variable + run: echo "MAKE_CMD=make --keep-going -j$(nproc) -l$(nproc) -O" >> $GITHUB_ENV + + - name: Build pgSphere + run: ${MAKE_CMD} PROFILE="-Werror -Wall" USE_HEALPIX=${{ matrix.use_healpix }} + + - name: make test + run: pg_virtualenv ${MAKE_CMD} USE_HEALPIX=${{ matrix.use_healpix }} test + + - name: Show test regression.diffs + if: ${{ failure() }} + run: cat regression.diffs + + - name: Install pgSphere + run: sudo ${MAKE_CMD} USE_HEALPIX=${{ matrix.use_healpix }} install + + - name: make installcheck + run: pg_virtualenv ${MAKE_CMD} USE_HEALPIX=${{ matrix.use_healpix }} installcheck + + - name: Show installcheck regression.diffs + if: ${{ failure() }} + run: cat regression.diffs + + - name: make crushtest + run: pg_virtualenv ${MAKE_CMD} USE_HEALPIX=${{ matrix.use_healpix }} crushtest + + - name: Show crushtest regression.diffs + if: ${{ failure() }} + run: cat regression.diffs + + - name: Build docs + run: ${MAKE_CMD} -C doc + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: ${{ env.GITHUB_REF_SLUG_URL }}-pg${{ matrix.pg_version }}-use-healpix-${{ matrix.use_healpix }}-${{ github.run_id }} + if-no-files-found: ignore + path: | + ./**/*.log + ./**/*.diffs diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..2047a36c --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,51 @@ +name: Build and Deploy Docs + +# Deploy docs only for master +on: + push: + branches: + - "master" + +# Allow deployment to GitHub Pages +permissions: + pages: write + id-token: write + +jobs: + deploy-docs: + + name: Deploy Docs + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + + steps: + - name: Install dependencies + run: | + sudo apt update && sudo apt install -y \ + docbook-xml \ + docbook-xsl \ + libxml2-utils \ + xsltproc \ + fop + + - name: Clone pgSphere + uses: actions/checkout@v4 + + - name: Build docs + run: make -C doc + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: 'doc/html' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.gitignore b/.gitignore index ff5e881e..f7267631 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,17 @@ *.so /*.sql /doc/html/ +/doc/pg_sphere*.fo +/doc/pg_sphere-*.html +/doc/pg_sphere-*.pdf +/doc/pg_sphere-full.xml /doc/pg_sphere.dsl +/doc/version.xml +/log /results/ regression.out regression.diffs tags +/tmp_check buildpod .deps diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4df87d58..00000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -# run the testsuite on travis-ci.com ---- -# versions to run on -env: - - PG_SUPPORTED_VERSIONS=10 - - PG_SUPPORTED_VERSIONS=11 - - PG_SUPPORTED_VERSIONS=12 - - PG_SUPPORTED_VERSIONS=13 - - PG_SUPPORTED_VERSIONS=14 - - PG_SUPPORTED_VERSIONS=15 - - PG_SUPPORTED_VERSIONS=16 - -language: C -dist: focal - -before_install: - # extra apt.pg.o.sh options added in version 204, travis currently has 199 (2019-11-27) - - sudo apt-get -qq update - - sudo apt-get -y install postgresql-common libhealpix-cxx-dev docbook-dsssl docbook-xml openjade - -install: - - sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -p -v $PG_SUPPORTED_VERSIONS -i - -script: - - make PROFILE="-Werror" - - sudo make install - - pg_virtualenv make installcheck - - if test -s regression.diffs; then cat regression.diffs; exit 1; fi - - pg_virtualenv make test - - if test -s regression.diffs; then cat regression.diffs; exit 1; fi - - pg_virtualenv make crushtest - - if test -s regression.diffs; then cat regression.diffs; exit 1; fi - - make clean - - make PROFILE="-Werror" USE_HEALPIX=0 - - sudo make USE_HEALPIX=0 install - - pg_virtualenv make USE_HEALPIX=0 installcheck - - if test -s regression.diffs; then cat regression.diffs; exit 1; fi - - pg_virtualenv make USE_HEALPIX=0 test - - if test -s regression.diffs; then cat regression.diffs; exit 1; fi - - pg_virtualenv make USE_HEALPIX=0 crushtest - - if test -s regression.diffs; then cat regression.diffs; exit 1; fi - - make -C doc - - sudo make -C doc install diff --git a/COPYRIGHT.pg_sphere b/COPYRIGHT.pg_sphere index 61a2e1f7..77532605 100644 --- a/COPYRIGHT.pg_sphere +++ b/COPYRIGHT.pg_sphere @@ -1,4 +1,4 @@ -Copyright (c) 2003-2017, pgSphere development team +Copyright (c) 2003-2023, pgSphere development team All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,4 +24,3 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/Makefile b/Makefile index c8287aed..782961cd 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,19 @@ -PGSPHERE_VERSION = 1.3.1 -EXTENSION = pg_sphere + +include Makefile.common.mk + RELEASE_SQL = $(EXTENSION)--$(PGSPHERE_VERSION).sql USE_PGXS = 1 -USE_HEALPIX =? 1 +USE_HEALPIX ?= 1 +PGINDENT ?= pgindent +PGBSDINDENT ?= pg_bsd_indent # the base dir name may be changed depending on git clone command SRC_DIR = $(shell basename $(shell pwd)) MODULE_big = pg_sphere OBJS = src/sscan.o src/sparse.o src/sbuffer.o src/vector3d.o src/point.o \ - src/euler.o src/circle.o src/line.o src/ellipse.o src/polygon.o \ - src/path.o src/box.o src/output.o src/gq_cache.o src/gist.o \ + src/euler.o src/circle.o src/circle_sel.o src/line.o src/ellipse.o src/polygon.o \ + src/path.o src/box.o src/output.o src/gq_cache.o src/gist.o src/gist_support.o \ src/key.o src/gnomo.o src/epochprop.o src/brin.o ifneq ($(USE_HEALPIX),0) @@ -19,7 +22,6 @@ OBJS += src/healpix.o src/moc.o src/process_moc.o \ endif DATA_built = $(RELEASE_SQL) \ - pg_sphere--unpackaged--1.1.5beta0gavo.sql \ pg_sphere--1.0--1.0_gavo.sql \ pg_sphere--1.0_gavo--1.1.5beta0gavo.sql \ pg_sphere--1.1.5beta0gavo--1.1.5beta2gavo.sql \ @@ -29,26 +31,19 @@ DATA_built = $(RELEASE_SQL) \ pg_sphere--1.2.1--1.2.2.sql \ pg_sphere--1.2.2--1.2.3.sql \ pg_sphere--1.2.3--1.3.0.sql \ - pg_sphere--1.3.0--1.3.1.sql + pg_sphere--1.3.0--1.3.1.sql \ + pg_sphere--1.3.1--1.4.0.sql \ + pg_sphere--1.4.0--1.4.1.sql \ + pg_sphere--1.4.1--1.4.2.sql \ + pg_sphere--1.4.2--1.5.0.sql \ + pg_sphere--1.5.0--1.5.1.sql DOCS = README.pg_sphere COPYRIGHT.pg_sphere -REGRESS = init tables points euler circle line ellipse poly path box index \ - contains_ops contains_ops_compat bounding_box_gist gnomo epochprop \ - contains overlaps spoint_brin sbox_brin - -ifneq ($(USE_HEALPIX),0) -REGRESS += healpix moc mocautocast -endif - -REGRESS_9_5 = index_9.5 # experimental for spoint3 - -TESTS = init_test tables points euler circle line ellipse poly path box \ +TESTS = version tables points euler circle line ellipse poly path box \ index contains_ops contains_ops_compat bounding_box_gist gnomo \ - epochprop contains overlaps spoint_brin sbox_brin - -ifneq ($(USE_HEALPIX),0) -TESTS += healpix moc mocautocast -endif + epochprop contains overlaps spoint_brin sbox_brin selectivity \ + knn output_precision +REGRESS = init $(TESTS) PG_CFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION) PG_CPPFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION) @@ -67,23 +62,22 @@ CRUSH_TESTS = init_extended circle_extended PGS_SQL = pgs_types.sql pgs_point.sql pgs_euler.sql pgs_circle.sql \ pgs_line.sql pgs_ellipse.sql pgs_polygon.sql pgs_path.sql \ pgs_box.sql pgs_contains_ops.sql pgs_contains_ops_compat.sql \ - pgs_gist.sql gnomo.sql pgs_brin.sql + pgs_gist.sql gnomo.sql pgs_brin.sql pgs_circle_sel.sql pgs_hash.sql ifneq ($(USE_HEALPIX),0) +TESTS += healpix moc moc1 moc100 mocautocast PGS_SQL += healpix.sql endif PGS_SQL += pgs_gist_spoint3.sql ifneq ($(USE_HEALPIX),0) -PGS_SQL += pgs_moc_type.sql pgs_moc_compat.sql pgs_moc_ops.sql \ +PGS_SQL += pgs_moc_type.sql pgs_moc_ops.sql \ pgs_moc_geo_casts.sql endif PGS_SQL += pgs_epochprop.sql -PGS_SQL_9_5 = pgs_9.5.sql # experimental for spoint3 - ifdef USE_PGXS ifndef PG_CONFIG PG_CONFIG = pg_config @@ -110,69 +104,35 @@ endif healpix_bare/healpix_bare.o : healpix_bare/healpix_bare.c $(COMPILE.c) -Wno-declaration-after-statement -o $@ $^ -# experimental for spoint3 pg_version := $(word 2,$(shell $(PG_CONFIG) --version)) -pg_version_9_5_plus = $(if $(filter-out 9.1% 9.2% 9.3% 9.4%,$(pg_version)),y,n) -has_explain_summary = $(if $(filter-out 9.%,$(pg_version)),y,n) - -## the use of spoint 3 is too experimental and preliminary: -#ifeq ($(pg_version_9_5_plus),y) -# REGRESS += $(REGRESS_9_5) -# TESTS += $(REGRESS_9_5) -# PGS_SQL += $(PGS_SQL_9_5) -#endif +has_support_functions = $(if $(filter-out 9.% 10.% 11.%,$(pg_version)),y,n) +has_index_options = $(if $(filter-out 9.% 10.% 11.% 12.%,$(pg_version)),y,n) -crushtest: REGRESS += $(CRUSH_TESTS) +crushtest: TESTS += $(CRUSH_TESTS) crushtest: installcheck -ifneq ($(USE_HEALPIX),0) -ifeq ($(has_explain_summary),y) - REGRESS += moc1 moc100 -endif -endif - -ifeq ($(pg_version_9_5_plus),y) - PGS_TMP_DIR = --temp-instance=tmp_check -else - PGS_TMP_DIR = --temp-install=tmp_check --top-builddir=test_top_build_dir +ifeq ($(has_support_functions),y) +PGS_SQL += pgs_gist_support.sql +TESTS += gist_support endif -test: pg_sphere.test.sql sql/init_test.sql - cp expected/init_test.out.in expected/init_test.out ifneq ($(USE_HEALPIX),0) - cat expected/init_test_healpix.out.in >> expected/init_test.out +ifeq ($(has_index_options),y) +PGS_SQL += pgs_moc_options.sql +TESTS += moc_options endif - $(pg_regress_installcheck) $(PGS_TMP_DIR) $(REGRESS_OPTS) $(TESTS) +endif + +# "make test" uses a special initialization file that doesn't rely on "create extension" +test: pg_sphere.test.sql + $(pg_regress_installcheck) --temp-instance=tmp_check $(REGRESS_OPTS) init_test $(TESTS) pg_sphere.test.sql: $(RELEASE_SQL) $(shlib) tail -n+3 $< | sed 's,MODULE_PATHNAME,$(realpath $(shlib)),g' >$@ - -$(RELEASE_SQL): $(addsuffix .in, $(RELEASE_SQL) $(PGS_SQL)) +$(RELEASE_SQL): pg_sphere_head.sql.in $(addsuffix .in, $(PGS_SQL)) cat $^ > $@ -# for "create extension from unpacked*": - -UPGRADE_UNP_COMMON = pgs_types.sql pgs_point.sql pgs_euler.sql pgs_circle.sql \ - pgs_line.sql pgs_ellipse.sql pgs_polygon.sql pgs_path.sql \ - pgs_box.sql pgs_contains_ops_compat.sql pgs_gist.sql \ - pgs_gist_contains_ops.sql contains-ops-fixes-1.sql - -AUGMENT_UNP_COMMON = upgrade_scripts/pgs_pre111.sql pgs_contains_ops.sql \ - gnomo.sql -# for vanilla 1.1.1 users: -AUGMENT_UNP_111 = $(AUGMENT_UNP_COMMON) pgs_gist_pointkey.sql - -# for 1.1.2+ users: 'from unpacked_1.1.2plus' -AUGMENT_UNP_FOR_112plus = $(AUGMENT_UNP_COMMON) -UPGRADE_UNP_FOR_112plus = pgs_gist_pointkey.sql pgs_gist_drop_spoint2.sql.in - -# for "alter extension": - -# TODO: add dynamic pl/pgsql to do perform an additional -# "ALTER EXTENSION pg_sphere UPDATE TO '1.1.5_from_before_2016-02-07';" -# if required. -# # default 1.0 (after 2016-02-07) -> 1.1.5 UPGRADE_1_0_PRE_xxxxxx = contains-ops-fixes-2.sql # '1.1.5_from_2015-08-31' @@ -180,46 +140,15 @@ AUGMENT_1_0_PRE_AAF2D5 = pgs_contains_ops.sql gnomo.sql UPGRADE_1_0_PRE_AAF2D5 = contains-ops-fixes-1.sql pgs_gist_drop_spoint2.sql.in \ pgs_gist_contains_ops.sql -# vanilla 'create from unpackaged' must assume 1.1.1 -# ... - -# create "create extension from unpacked*" files - -# create "alter extension" files - - -ifeq ($(pg_version_9_5_plus),y) -# 1.1.1.5 -> 1.1.5.1 for Postgres 9.5+ features -else -endif - -# local stuff follows here -AUGMENT_GAVO_111 = $(AUGMENT_UNP_111) # for vanilla 1.1.1 users -ifneq ($(USE_HEALPIX),0) -AUGMENT_GAVO_111 += healpix.sql -endif -UPGRADE_GAVO_111 = $(UPGRADE_UNP_COMMON) - # add new HEALPix functions and experimental spoint3 ifneq ($(USE_HEALPIX),0) AUGMENT_FROM_GAVO = healpix.sql endif AUGMENT_FROM_GAVO += pgs_gist_spoint3.sql -AUGMENT_UNP_115B0G = $(AUGMENT_UNP_111) $(AUGMENT_FROM_GAVO) -UPGRADE_UNP_115B0G = $(UPGRADE_UNP_COMMON) - AUGMENT_1_0_115B0G = $(AUGMENT_FROM_GAVO) UPGRADE_1_0_115B0G = contains-ops-fixes-2.sql pgs_gist_drop_spoint2.sql -# test installation 0 -pg_sphere--unpackaged--1.1.5beta0gavo.sql: $(addsuffix .in, \ - $(AUGMENT_GAVO_111) \ - $(addprefix upgrade_scripts/, $(UPGRADE_GAVO_111))) - cat upgrade_scripts/$@.in $^ > $@ - -# (The upgrade of test installation A has been completed.) - # test installation B (generic) pg_sphere--1.0--1.0_gavo.sql: # dummy upgrade to allow for descriptive names cat upgrade_scripts/$@.in > $@ @@ -232,7 +161,7 @@ ifneq ($(USE_HEALPIX),0) pg_sphere--1.1.5beta0gavo--1.1.5beta2gavo.sql: pgs_moc_type.sql.in cat upgrade_scripts/$@.in $^ > $@ -pg_sphere--1.1.5beta2gavo--1.1.5beta4gavo.sql: pgs_moc_compat.sql.in +pg_sphere--1.1.5beta2gavo--1.1.5beta4gavo.sql: cat upgrade_scripts/$@.in $^ > $@ pg_sphere--1.1.5beta4gavo--1.2.0.sql: pgs_moc_ops.sql.in @@ -269,6 +198,29 @@ pg_sphere--1.2.3--1.3.0.sql: pgs_brin.sql.in pg_sphere--1.3.0--1.3.1.sql: cat upgrade_scripts/$@.in > $@ +ifeq ($(has_support_functions),y) +pg_sphere--1.3.1--1.4.0.sql: pgs_gist_support.sql.in +endif +ifneq ($(USE_HEALPIX),0) +ifeq ($(has_index_options),y) +pg_sphere--1.3.1--1.4.0.sql: pgs_moc_options.sql.in +endif +endif +pg_sphere--1.3.1--1.4.0.sql: pgs_circle_sel.sql.in pgs_hash.sql.in + cat upgrade_scripts/$@.in $^ > $@ + +pg_sphere--1.4.0--1.4.1.sql pg_sphere--1.4.1--1.4.2.sql: + @echo "-- Nothing to upgrade in the schema" > $@ + +pg_sphere--1.4.2--1.5.0.sql: + cat upgrade_scripts/$@.in $^ > $@ + +pg_sphere--1.5.0--1.5.1.sql: + cat upgrade_scripts/$@.in $^ > $@ + +pg_sphere--1.5.1--1.5.2.sql: + cat upgrade_scripts/$@.in $^ > $@ + # end of local stuff src/sscan.o : src/sparse.c @@ -287,6 +239,37 @@ else @$(missing) flex $< $@ endif -dist : clean sparse.c sscan.c +dist : clean find . -name '*~' -type f -exec rm {} \; cd .. && tar --transform s/$(SRC_DIR)/pgsphere-$(PGSPHERE_VERSION)/ --exclude CVS --exclude .git -czf pgsphere-$(PGSPHERE_VERSION).tar.gz $(SRC_DIR) && cd - + +# To use pgindent, set the PATH environment variable to include the directories +# containing the binaries pgindent and pg_bsd_indent. It is important to +# utilize a specific version of pg_bsd_indent, which sources can be found +# in the /src/tools/pg_bsd_indent directory, where +# is the root directory of the PostgreSQL project source tree. +# +# The sources of the utilities can be found in the following directories: +# - /src/tools/pgindent +# - /src/tools/pg_bsd_indent +# +# pgindent-typedefs.list should be updated every time after implementing +# new types and introducing new typedefs in the code. For details how +# to update pgindent-typedefs.list and for other information about pgindent, +# please, read the doc: /src/tools/pgindent/README. +# +# pgindent-excludes.list is used to specify files to be ignored. +# +pgindent: + $(PGINDENT) \ + --typedefs=pgindent-typedefs.list \ + --excludes=pgindent-excludes.list \ + --indent=${PGBSDINDENT} \ + src + +pgindent-headers: + $(PGINDENT) \ + --typedefs=pgindent-typedefs.list \ + --excludes=pgindent-excludes.list \ + --indent=${PGBSDINDENT} \ + src/*.h diff --git a/Makefile.common.mk b/Makefile.common.mk new file mode 100644 index 00000000..89632277 --- /dev/null +++ b/Makefile.common.mk @@ -0,0 +1,8 @@ +#---------------------------------------------------------------------------- +# +# pgSphere common definitions +# +#---------------------------------------------------------------------------- + +EXTENSION := pg_sphere +PGSPHERE_VERSION := 1.5.2 diff --git a/README.pg_sphere b/README.pg_sphere index 95a2563a..be6b40fb 100644 --- a/README.pg_sphere +++ b/README.pg_sphere @@ -54,7 +54,7 @@ UPDATING AN EXISTING INSTALLATION: -- same make and make install steps as above, but, instead of the CREATE -- EXTENSION step, you need to do: - psql -c "ALTER EXTENSION q3c UPDATE TO 'A.B.C';" + psql -c "ALTER EXTENSION pg_sphere UPDATE TO 'A.B.C';" -- where A.B.C is a placeholder for the current version. -- You also may want to check what version of pgSphere is installed using diff --git a/doc/Makefile b/doc/Makefile index a607103a..11894ff5 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,90 +1,103 @@ #---------------------------------------------------------------------------- # -# pgSphere documentation makefile +# pgSphere documentation generation # #---------------------------------------------------------------------------- -USE_PGXS = 1 -ifdef USE_PGXS -PG_CONFIG = pg_config -PGXS := $(shell $(PG_CONFIG) --pgxs) -include $(PGXS) -else -subdir = contrib/pg_sphere/doc -top_builddir = ../../.. -include $(top_builddir)/src/Makefile.global -include $(top_srcdir)/contrib/contrib-global.mk +ifndef PGSPHERE_VERSION +include ../Makefile.common.mk +ifndef PGSPHERE_VERSION +$(error PGSPHERE_VERSION is not set) +endif endif -.SECONDARY: -.NOTPARALLEL: +ifndef FOP +FOP = fop +endif -ifndef COLLATEINDEX -COLLATEINDEX = $(DOCBOOKSTYLE)/bin/collateindex.pl +ifdef XMLLINT +XMLLINT := $(XMLLINT) --nonet +else +XMLLINT = xmllint --nonet endif -ifndef JADE -JADE = openjade +ifdef XSLTPROC +XSLTPROC := $(XSLTPROC) --nonet +else +XSLTPROC = xsltproc --nonet endif -SGMLINCLUDE = -D $(srcdir) -ALLSGML := $(wildcard $(srcdir)/*.sgm) +override XSLTPROCFLAGS += \ + --path stylesheets --path img --path . \ + --stringparam pg_sphere.version '$(PGSPHERE_VERSION)' \ + --stringparam pg.version '$(PGSPHERE_VERSION)' -ifdef DOCBOOKSTYLE -CATALOG = -c $(DOCBOOKSTYLE)/catalog -endif +XMLINCLUDE = --path . +ALLSGML := $(wildcard *.sgm) +ALLIMAGES := $(wildcard img/*.jpg) -COLLATEINDEX := $(PERL) $(COLLATEINDEX) -f -g +all: html pdf +.PHONY: all html pdf clean -all : html +# This line fixes the error like: +# No rule to make target 'pg_sphere.control' +.PHONY: pg_sphere.control -.PHONY: html pdf ps +version.xml: + @echo $(PGSPHERE_VERSION) > version.xml -XMLDCL = declaration/xml.dcl +pg_sphere-full.xml: version.xml +pg_sphere-full.xml: pg_sphere.xml $(ALLSGML) + $(XMLLINT) $(XMLINCLUDE) --output $@ --noent --valid $< -html : pg_sphere.xml $(ALLSGML) pg_sphere.dsl - @rm -f *.html - @rm -rf html - mkdir html - mkdir html/img - cp img/*.jpg img/*.png html/img - cp pg_sphere.css html - $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -b UTF-8 -d pg_sphere.dsl -i html -t sgml $(XMLDCL) $< - mv *.html html +#------------------------------------------------------------------------------ +# HTML +#------------------------------------------------------------------------------ -pg_sphere.tex : pg_sphere.xml $(ALLSGML) pg_sphere.dsl - $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d pg_sphere.dsl -i print -t tex -o $@ $(XMLDCL) $< +XSLTPROC_HTML_MULTIPAGE_FLAGS := --stringparam img.src.path '' +XSLTPROC_HTML_SINGLEPAGE_FLAGS := --stringparam img.src.path '' -pdf : jadetex.cfg pg_sphere.pdf +html: html-singlepage html-multipage -pg_sphere.pdf: pg_sphere.tex - @rm -f $*.aux $*.log $*.out - pdfjadetex $< - pdfjadetex $< - pdfjadetex $< +html-multipage: stylesheets/stylesheet.xsl pg_sphere-full.xml version.xml $(ALLIMAGES) + $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_MULTIPAGE_FLAGS) $(wordlist 1,2,$^) + mkdir -p html/img + cp $(ALLIMAGES) html/img -ps : pg_sphere.ps +html-singlepage: pg_sphere-$(PGSPHERE_VERSION).html -pg_sphere.ps: pg_sphere.pdf - pdftops $< $@ +pg_sphere-$(PGSPHERE_VERSION).html: stylesheets/stylesheet-html-nochunk.xsl pg_sphere-full.xml version.xml $(ALLIMAGES) + $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_SINGLEPAGE_FLAGS) -o $@ $(wordlist 1,2,$^) -pg_sphere.dsl : pg_sphere.dsl-dist - cp $< $@ +#------------------------------------------------------------------------------ +# PDF +#------------------------------------------------------------------------------ -jadetex.cfg : jadetex.cfg-dist - cp $< $@ +pdf: pg_sphere-${PGSPHERE_VERSION}-A4.pdf pg_sphere-${PGSPHERE_VERSION}-US.pdf +pg_sphere-$(PGSPHERE_VERSION)-A4.pdf: pg_sphere.A4.fo + $(FOP) -v -fo $< -pdf $@ +pg_sphere-$(PGSPHERE_VERSION)-US.pdf: pg_sphere.US.fo + $(FOP) -v -fo $< -pdf $@ -## -## Clean -## +pg_sphere.A4.fo: stylesheets/stylesheet-fo.xsl pg_sphere-full.xml version.xml $(ALLIMAGES) + $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_FO_FLAGS) --stringparam paper.type A4 -o $@ stylesheets/stylesheet-fo.xsl pg_sphere-full.xml -clean distclean maintainer-clean: -# HTML - rm -rf html pg_sphere.dsl -# print - rm -f *.rtf *.tex *.dvi *.aux *.log *.ps *.pdf *.out *.fot jadetex.cfg -# img - make clean -C img +pg_sphere.US.fo: stylesheets/stylesheet-fo.xsl pg_sphere-full.xml version.xml $(ALLIMAGES) + $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_FO_FLAGS) --stringparam paper.type USLetter -o $@ stylesheets/stylesheet-fo.xsl pg_sphere-full.xml + +#------------------------------------------------------------------------------ +# Cleanup +#------------------------------------------------------------------------------ + +clean distclean: + rm -rf ./html + rm -f version.xml + rm -f pg_sphere-full.xml + rm -f pg_sphere.A4.fo + rm -f pg_sphere.US.fo + rm -f pg_sphere-$(PGSPHERE_VERSION).html + rm -f pg_sphere-$(PGSPHERE_VERSION)-A4.pdf + rm -f pg_sphere-$(PGSPHERE_VERSION)-US.pdf diff --git a/doc/appendixes.sgm b/doc/appendixes.sgm index 46b87cc2..5bd221ea 100644 --- a/doc/appendixes.sgm +++ b/doc/appendixes.sgm @@ -19,7 +19,7 @@ - This version is compatible to PostgreSQL 8.4 + This version is compatible to PostgreSQL 8.4 @@ -66,5 +66,5 @@ - + diff --git a/doc/constructors.sgm b/doc/constructors.sgm index 5fefff7b..4f876513 100644 --- a/doc/constructors.sgm +++ b/doc/constructors.sgm @@ -1,7 +1,6 @@ - - Codestin Search App + + Codestin Search App + Constructors within pgSphere are functions needed to create spherical data types from other data @@ -14,7 +13,7 @@ mentioned here. - + Codestin Search App @@ -44,9 +43,9 @@ - + - + Codestin Search App @@ -90,9 +89,9 @@ - + - + Codestin Search App @@ -110,7 +109,7 @@ returns a spherical circle with center at center and a radius radius in radians. The circle radius has - to be larger than or equal to zero but less or equal to 90°. + to be larger than or equal to zero but less or equal to 90°. Otherwise, this function returns an error. @@ -134,18 +133,18 @@ - + - + Codestin Search App The input of spherical lines using Euler transformation and - length is quite circumstantial (see ). + length is quite circumstantial (see ). For short lines it is easier to input a line specifying the beginning and the end of the line. - + sline @@ -155,13 +154,13 @@ If the distance between begin and - end is 180° (&pgr;), this function - returns an error because the location of the line is undefined. + end is 180° (&pg_pgr;), this function + returns an error because the location of the line is undefined. However, if longitudes of begin and end are equal, pgSphere assumes a meridian and returns the corresponding spherical line. - + Codestin Search App @@ -212,9 +211,9 @@ - + - + Codestin Search App @@ -238,7 +237,7 @@ radii of the ellipse in radians. If the major radius is smaller than minor radius, pgSphere swaps the values automatically. The last parameter - incl is the inclination angle in radians. + incl is the inclination angle in radians. For more informations about ellipses, see . @@ -263,28 +262,51 @@ - + - + Codestin Search App + - The aggregate function + The functions spoly and spoly_deg + can be used to create spherical polygons. Function spoly + is overloaded and can accept arrays of float8 or spoint elements. + There are the same restrictions as for using the input function of + spherical polygon (see ). - - - spoly - spoint edge - - + - can be used to create a polygon from a set of spherical points. - There are the same restrictions as for using the input function of - spherical polygon (see ). The function - returns - NULL, if the polygon couldn't be created. + Create a spherical polygon from an array of pair-consecutive + numbers (lng, lat). The coordinates are specified in radians. + + SELECT spoly(ARRAY[0, 0, 0, 0.5, 0.5, 0.5, 0.5, 0])]]> + + + + Create a spherical polygon from an array of spoint elements. + + SELECT spoly(ARRAY[spoint(0, 0), spoint(0, 0.5), spoint(0.5, 0.5), spoint(0.5, 0)])]]> + + + + + Create a spherical polygon from an array of pair-consecutive + numbers (lng, lat). The coordinates are specified in degrees. + + SELECT spoly_deg(ARRAY[0, 0, 0, 10, 10, 10, 10, 0])]]> + + + + + The aggregate function spoly can be used to + create a polygon from a set of spherical points. The function + returns NULL, if the polygon could not be + created. + + Codestin Search App @@ -371,9 +393,9 @@ - + - + Codestin Search App @@ -403,9 +425,9 @@ SELECT sbox ( spoint '(0d,0d),(10d,10d)' );]]> - + - + Codestin Search App @@ -449,6 +471,6 @@ creates an smoc of the given order covering the spoly - + - + diff --git a/doc/examples.sgm b/doc/examples.sgm index 08866919..1590b43c 100644 --- a/doc/examples.sgm +++ b/doc/examples.sgm @@ -1,37 +1,18 @@ - - Codestin Search App - - Codestin Search App - - tbw - - - - - Codestin Search App - - tbw - - - - + + Codestin Search App + + Codestin Search App - + Codestin Search App A commonly used task is a coordinate transformation. With the parameters of a new coordinate system (plane) relative to an old one, - + @@ -39,7 +20,7 @@ - &OHgr; + &pg_OHgr; longitude of the ascending node @@ -51,7 +32,7 @@ - &ohgr; + &pg_ohgr; argument of pericenter @@ -79,22 +60,22 @@ object from an old into a new coordinate system using: - object - strans '&ohgr;, i, &OHgr;' + object - strans '&pg_ohgr;, i, &pg_OHgr;' or - object - strans (&ohgr;, i, &OHgr;) + object - strans (&pg_ohgr;, i, &pg_OHgr;) Otherwise, for a transformation of an object object from the new into the old coordinate system, use the operator +: - object + strans '&ohgr;, i, &OHgr;' + object + strans '&pg_ohgr;, i, &pg_OHgr;' or - object + strans (&ohgr;, i, &OHgr;) + object + strans (&pg_ohgr;, i, &pg_OHgr;) Codestin Search App We are assuming the orbital elements of a comet are - &OHgr;=30°, i=60° and &ohgr;=90°. We get the + &pg_OHgr;=30°, i=60° and &pg_ohgr;=90°. We get the spherical position of perihelion and aphelion with: @@ -117,6 +98,7 @@ - - - + + + + diff --git a/doc/functions.sgm b/doc/functions.sgm index d5bb457d..047b7f11 100644 --- a/doc/functions.sgm +++ b/doc/functions.sgm @@ -1,30 +1,37 @@ - - Codestin Search App + + Codestin Search App + The functions described below are implemented without having an operator. If you are missing some functions, see and use the operators. - + + Codestin Search App The area function returns the area of a spherical object in square radians. Supported data types are: - scircle, spolygon (if the polygon - is convex), sbox, and smoc. + scircle, spolygon, sbox, + smoc. The polygon should be convex, otherwise the + behaviour is undefined. - Codestin Search App + Codestin Search App SELECT area( scircle '<(0d,90d),60d>' ) / pi() AS area;]]> + + + + + Codestin Search App + SELECT area(smoc '0/1-3');]]> @@ -32,14 +39,14 @@ - + - + Codestin Search App - + Codestin Search App @@ -76,9 +83,9 @@ - + - + Codestin Search App @@ -140,16 +147,51 @@ - + - - - + + Codestin Search App + + The function + + + + spoint_dwithin + spoint p1 + spoint p2 + float8 radius + + + + returns a boolean value that signifies whether the points + p1 and p2 + lie within distance radius (in radians) of each other, i.e. + it computes the boolean expression p1 <-> p2 <= radius. + On PostgreSQL 12 and later, the function has GiST + support and the PostgreSQL optimizer will transform it to either + p1 <@ scircle(p2, radius) or + p2 <@ scircle(p1, radius) where appropriate. + + + Codestin Search App + + SELECT * FROM stars1 JOIN stars2 WHERE spoint_dwithin(stars1.s, stars2.s, 1e-5);]]> + + + + + + + Codestin Search App - + Codestin Search App @@ -169,9 +211,9 @@ SELECT strans_zxz ( strans '20d, -270d, 70.5d, XZY' );]]> - + - + Codestin Search App @@ -249,12 +291,12 @@ - + - + - + Codestin Search App @@ -275,9 +317,9 @@ - + - + Codestin Search App @@ -338,10 +380,10 @@ - To get the ellipse center, you can use the + To get the ellipse center, you can use the operator @@ () instead of using the function - center(sellipse). + center(sellipse). Codestin Search App @@ -355,14 +397,14 @@ - - - + + + Codestin Search App - + Codestin Search App @@ -386,9 +428,9 @@ SELECT sl_beg( sline '(10d, 90d, 270d, ZXZ ), 20d';]]> - + - + Codestin Search App @@ -423,14 +465,14 @@ - - - - + + + + Codestin Search App - + Codestin Search App @@ -455,10 +497,10 @@ - - - - + + + + Codestin Search App @@ -532,19 +574,19 @@ - - - - + + + + Codestin Search App - + Codestin Search App - Similar to an spath (), + Similar to an spath (), you can get the count of edges of a spherical polygon using the function: @@ -565,8 +607,8 @@ - - + + Codestin Search App @@ -617,9 +659,9 @@ - + - + Codestin Search App @@ -643,11 +685,11 @@ - + - + - + Codestin Search App @@ -683,9 +725,9 @@ SELECT sw ( sbox '( (0d,0d), (90d,0d) )' ) ;]]> - + - + Codestin Search App @@ -778,14 +820,14 @@ - + - + Codestin Search App - + Codestin Search App @@ -804,15 +846,15 @@ applies proper motion to positions) - Following both pg_sphere and, where missing, astronomical + Following both pg_sphere and, where missing, astronomical conventions makes units somewhat eclectic here; pm_long and pm_lat - need to be in rad/yr, whereas parallax is in mas, and - radial_velocity in km/s. The time difference must be in + need to be in rad/yr, whereas parallax is in mas, and + radial_velocity in km/s. The time difference must be in (Julian) years. - This function returns a 6-array of [long, lat, parallax, + This function returns a 6-array of [long, lat, parallax, pm_long, pm_lat, radial_velocity] of the corresponding values delta_t years after the reference epoch for the original position. As in the function arguments, long and lat are in rad, pm_lon and @@ -825,9 +867,12 @@ It is an error to have either pos or delta_t NULL. For all other arguments, NULLs are turned into 0s, except for parallax, - where some very small default is put in. In that case, - both parallax and radial_velocity will be NULL in the output - array. + where some very small default is put in. Whatever is NULL + on the input is NULL on the output. In addition, we null + out a non-NULL input on one component of the proper motion + if the other component is NULL, and we null out the radial + velocity if the parallax is missing, as it would be horribly + off with the propagation algorithm we use here. @@ -839,7 +884,7 @@ Codestin Search App - - + + Codestin Search App @@ -890,7 +935,7 @@ FROM ( - As with epoch_prop itself, missing values (except for pos and + As with epoch_prop itself, missing values (except for pos and delta_t) are substituted by 0 (or a very small value in the case of parallax). @@ -898,14 +943,15 @@ FROM ( Codestin Search App - - - + + + + diff --git a/doc/indices.sgm b/doc/indices.sgm index 11940c2f..6b874b02 100644 --- a/doc/indices.sgm +++ b/doc/indices.sgm @@ -1,8 +1,7 @@ - - Codestin Search App - + + Codestin Search App + + Codestin Search App @@ -27,7 +26,7 @@ linkend="op.over">&&, #, =, and !=. + linkend="op.equal">!=. You can create a GiST index with the following spherical data types: @@ -69,6 +68,11 @@ + + A GiST index can be also used for quickly finding the points closest to the given one + when ordering by an expression with the <-> operator, + as shown in an example below. + BRIN indexing supports just spherical points (spoint) and spherical coordinates range (sbox) at the moment. @@ -84,7 +88,14 @@ - BRIN index can be created through the following syntax: + To find the points closest to a given spherical position, use the <-> operator: + + + spoint (0.2, 0.3) LIMIT 10 ]]> + + + + BRIN index can be created through the following syntax: @@ -102,9 +113,9 @@ - + - + Codestin Search App @@ -122,14 +133,20 @@ The index works by casting all contained smocs to a fixed level, and for each pixel at that level, storing which smocs overlap with that pixel. This is especially beneficial for "overlaps" queries using - the && operator. Two levels of granularity - are provided: the default opclass smoc_gin_ops - works on level 5 with a resolution of 12288 pixels, while the - opclass smoc_gin_ops_fine works on level 8 with - 786432 pixels. The downside of that approach is that storing large + the && operator. + The downside of that approach is that storing large smocs like "all sky" (0/0-11) produces a large number of index entries. + + The default opclass smoc_gin_ops defaults to + working on level 5 with a resolution of 12288 pixels (12 * 4^5). + An alternative granularity can be selected by setting the + order parameter on the opclass (integer value + between 0 and 12; option only available on PG 13 and later). + The alternative smoc_gin_ops_fine opclass works + on level 8 with 786432 pixels. + Codestin Search App @@ -137,12 +154,40 @@ + - + + + - + + + + Codestin Search App + + Values of type spoint can be indexed using a + HASH index, supporting the + = operator. + The spoint_hash_ops operator class also enables + DISTINCT queries on spoint. + + + Codestin Search App + + + + + + + + + + + - + diff --git a/doc/install.sgm b/doc/install.sgm index 39ebaf93..ded78fa9 100644 --- a/doc/install.sgm +++ b/doc/install.sgm @@ -1,124 +1,100 @@ - - Codestin Search App - - Codestin Search App - - pgSphere is not part of the PostgreSQL software. - You can download it from the pgSphere homepage - https://github.com/akorotkov/pgsphere - - + + Codestin Search App - - Codestin Search App - - You will need PostgreSQL - 9.1 or above. We assume that you have - PostgreSQL already compiled and - installed. Please note: Depending on your system configuration mostly you have to be logged in as the system - superuser. - - - There are two ways to compile pgSphere. - The first is to copy the sources into the contribution directory of - PostgreSQL's source tree - (POSTGRESQL_SRC/src/contrib). - Then, change into POSTGRESQL_SRC/src/contrib. - If the sources are not yet installed and the directory - pg_sphere does not exist, take the - gzipped pgSphere sources ( e. g., - pg_sphere_xxx.tgz ) and run: - - - tar -xzf path/to/pg_sphere_xxx.tgz]]> - - - Now, change into the pg_sphere - directory and run : - - + + Codestin Search App + + + &pgsphere; is not the part of the &postgresql; software. You can download + the latest release from the + &pgsphere; Releases page. + The source code can also be downloaded by cloning the repository with the + appropriate release tag. The master branch is intended for development + use and may contain the code in a transitional state. It is not recommended + for use in production. + + + + + Codestin Search App + + It is assumed that &postgresql; is already installed. Depending on the + system configuration, superuser (root) access rights may be required to + complete the installation. + + + + The installation script uses &pg_config; utility. Make sure that the + environment variable PATH includes path to &pg_config; utility. The path + to &pg_config; can be also specified in make command: + + make PG_CONFIG=/path/to/pgconfig ...]]> + + + + Unpack the downloaded archive and enter the directory: + + tar -xzf path/to/pgsphere-X.X.X.tgz]]> + cd pgsphere-X.X.X]]> + + + + Compile the code. By default, &pgsphere; is compiled with &healpix; support. + + make]]> - - - and to install pgSphere : - - + + or compile without &healpix; support: + + make USE_HEALPIX=0]]> + + + + Run regression tests optionally. If &pgsphere; was compiled without &healpix; + support, USE_HEALPIX=0 should be specified in make command line. + + + make test]]> + + + + Install &pgsphere; files to the installation directories. The installation + directories are defined by &pg_config; utility. Superuser (root) access + rights may be required. If &pgsphere; was compiled without &healpix; support, + USE_HEALPIX=0 should be added after make. + + make install]]> - - - The second way does not require the PostgreSQL sources but - the configuration tool pg_config. - - - First unpack the pgSphere sources: - - - tar -xzf path_to_pg_sphere_xxx.tgz]]> - - - Now, change into the pg_sphere - directory and run: - - - make USE_PGXS=1 PG_CONFIG=/path/to/pg_config]]> - - - To install pgSphere you have to run : - - - make USE_PGXS=1 PG_CONFIG=/path/to/pg_config install]]> - - - To check the installation change into the pg_sphere source - directory again and run: - - - make installcheck]]> - - - The check status will be displayed. Please note, the check gives different results with - different PostgreSQL-versions. Currently, the check should - run without errors with PostgreSQL-version 8.4. Otherwise check - the file regression.diff. - - - - - - Codestin Search App - - We assume you have already created a database - datab, where datab - is the name of any database. - Presupposing the name of your - PostgreSQL's superuser is - postgres, type: - - - psql -U postgres -c 'CREATE EXTENSION pg_sphere;' datab]]> - - - Depending on your system, it may be necessary to give more - psql options like port or host name. - Please have a look at the - PostgreSQL documentation for more - details. - - - To get the version of installed pgSphere software, simply - call: - - + + + + + + Codestin Search App + + + We assume you have already created a database userdb, + where userdb is the name of any database. Assume that + the name of &postgresql;'s superuser is postgres. + + + psql -U postgres -c 'CREATE EXTENSION pg_sphere' userdb]]> + + + + It may be necessary to give more psql options, like port + or host name, depending on your system configuration. Please, take a look at + the psql user manual for details. The psql user manual for the latest + &postgresql; version can be found at + + &postgresql; site + . + + + To get the version of installed &pgsphere; software: + SELECT pg_sphere_version();]]> - - - - + + + + diff --git a/doc/jadetex.cfg-dist b/doc/jadetex.cfg-dist deleted file mode 100644 index d7917b9f..00000000 --- a/doc/jadetex.cfg-dist +++ /dev/null @@ -1,14 +0,0 @@ -\hypersetup{ - pdftitle={pgSphere}, - pdfsubject={user guide}, - pdfauthor={pgSphere developer team}, - pdfkeywords={spherical PostgreSQL SQL}, - bookmarksopen=true, - bookmarksopenlevel=2, - colorlinks=true, - linkcolor=blue, - pdfpagemode=UseOutlines, - pdfstartview=FitH -} -\usepackage{url} -\tolerance=2000 diff --git a/doc/operators.sgm b/doc/operators.sgm index 73ebb835..c2d89026 100644 --- a/doc/operators.sgm +++ b/doc/operators.sgm @@ -1,8 +1,7 @@ - - Codestin Search App - + + Codestin Search App + + Codestin Search App @@ -120,9 +119,9 @@ - - - + + + Codestin Search App @@ -144,9 +143,9 @@ - - - + + + Codestin Search App @@ -156,7 +155,7 @@ a contained by object b? or Does object a overlap object - b? + b? pgSphere supports such queries using binary operators returning true or false: @@ -298,9 +297,9 @@ - + - + Codestin Search App @@ -320,9 +319,9 @@ - - - + + + Codestin Search App @@ -358,9 +357,9 @@ - - - + + + Codestin Search App @@ -395,9 +394,9 @@ - + - + Codestin Search App @@ -415,9 +414,9 @@ SELECT @@ scircle '<(0d,20d),30d>';]]> - + - + Codestin Search App @@ -433,15 +432,15 @@ SELECT - sline (spoint '(0d,0d)', spoint '(10d,0d)');]]> - + - + Codestin Search App The unary operator ! turns the - path of sline objects, but preserves + path of sline objects, but preserves begin and end of the spherical line. The length of returned line will be 360° minus the line length of operator's argument. @@ -450,7 +449,7 @@ The operator ! returns NULL, if the length of sline argument is 0, because the path of returned sline - is undefined. + is undefined. Codestin Search App @@ -490,9 +489,9 @@ - + - + Codestin Search App @@ -561,9 +560,9 @@ - + - + Codestin Search App @@ -590,6 +589,6 @@ - + - + diff --git a/doc/pg_sphere.css b/doc/pg_sphere.css deleted file mode 100644 index 2b7c85d8..00000000 --- a/doc/pg_sphere.css +++ /dev/null @@ -1,182 +0,0 @@ -/* similar to PostgreSQL.org Documentation Style */ - -body { - margin: 1em; - padding: 1em; - font-size: 85%; - font-family: verdana, sans-serif; - color: #000; - background-color: #fff; -} - -h1 { - font-size: 1.4em; - font-weight: bold; - margin-top: 0em; - margin-bottom: 0em; -} - -h2 { - font-size: 1.2em; - margin: 1.2em 0em 1.2em 0em; - font-weight: bold; -} - -h3 { - font-size: 1.0em; - margin: 1.2em 0em 1.2em 0em; - font-weight: bold; -} - -h4 { - font-size: 0.95em; - margin: 1.2em 0em 1.2em 0em; - font-weight: normal; -} - -h5 { - font-size: 0.9em; - margin: 1.2em 0em 1.2em 0em; - font-weight: normal; -} - -h6 { - font-size: 0.85em; - margin: 1.2em 0em 1.2em 0em; - font-weight: normal; -} - -img { - border: 0; -} - -ol, ul, li { - font-size: 1.0em; - line-height: 1.2em; - margin-top: 0.2em; - margin-bottom: 0.1em; -} - -p { - font-size: 1.0em; - line-height: 1.2em; - margin: 1.2em 0em 1.2em 0em; -} - -li > p { - margin-top: 0.2em; -} - -pre { - font-family: monospace; - font-size: 1.2em; - margin: 0em; -} - -strong, b { - font-weight: bold; -} - -h1 { - font-weight: bold; - color: #EC5800; - font-size: 1.4em; -} - -h2 { - font-weight: bold; - color: #666; - font-size: 1.2em; -} - -h3 { - font-weight: bold; - color: #666; - font-size: 1.1em; -} - -h4 { - color: #666; -} - -/* Text Styles */ - -.txtCurrentLocation { - font-weight: bold; -} - -p, ol, ul, li { - line-height: 1.5em; -} - -table.CALSTABLE { - width: 50%; -} - -table.CALSTABLE td { - vertical-align : top; -} - -/* Link Styles */ - -a:link { color:#0066A2; text-decoration: underline; } -a:visited { color:#004E66; text-decoration: underline; } -a:active { color:#0066A2; text-decoration: underline; } -a:hover { color:#000000; text-decoration: underline; } - - -pre.programlisting, -blockquote.note, -blockquote.tip -{ - -moz-border-radius: 8px 8px 8px 8px; - -moz-box-shadow: 3px 3px 5px #DFDFDF; - color: black; - margin: 1ex 0ex 1ex 1ex; - padding: 1ex; - border-style: solid; - border-width: 1px; -} - - -/* Programlisting */ -pre.programlisting { - background-color: #F7F7F7; - border-color: #CFCFCF; - font-family: monospace; - text-align: left; -} - -div.note { - margin-top: 4ex; -} - -blockquote.note, -blockquote.tip -{ - padding-top: 0ex; - background-color: #FDFDEE; - border-color: #DBDBCC; -} - - -.literal, -.parameter, -.funcsynopsis, -.function -{ - font-size: 130%; -} - -div.table table tr td { - padding: 0.5ex; -} - -div.example p b { - font-size : 70%; - font-style: italic; -} - -div.NAVFOOTER { - margin-top: 5ex; -} \ No newline at end of file diff --git a/doc/pg_sphere.dsl-dist b/doc/pg_sphere.dsl-dist deleted file mode 100644 index a658c789..00000000 --- a/doc/pg_sphere.dsl-dist +++ /dev/null @@ -1,330 +0,0 @@ - - - - - -]]> - - -]]> - -]> - - - - - - -;; PAPER - - - - -string (time) #t))) - '("META" ("HTTP-EQUIV" "Content-Type") ("CONTENT" "text/html; charset=utf-8")) - ) -) - -(define %stylesheet% "pg_sphere.css") - -(define %generate-article-titlepage% - ;; produce a title page for articles - #t) - -(define (chunk-skip-first-element-list) - ;; forces the Table of Contents on separate page - '()) - -(define (list-element-list) - ;; fixes bug in Table of Contents generation - '()) - -(define %root-filename% - ;; The filename of the root HTML document (e.g, "index"). - "index") - -(define ($shade-verbatim-attr$) - ;; REFENTRY shade-verbatim-attr - ;; PURP Attributes used to create a shaded verbatim environment. - ;; DESC - ;; See '%shade-verbatim%' - ;; /DESC - ;; AUTHOR N/A - ;; /REFENTRY - (list - (list "BORDER" "0") - (list "BGCOLOR" "#F7F7F7") - (list "WIDTH" ($table-width$)))) - -;; ...but we need to do some extra work to make the above apply to PRE -;; as well. (mostly pasted from dbverb.dsl) -(define ($verbatim-display$ indent line-numbers?) - (let ((content (make element gi: "PRE" - attributes: (list - (list "CLASS" (gi))) - (if (or indent line-numbers?) - ($verbatim-line-by-line$ indent line-numbers?) - (process-children))))) - (if %shade-verbatim% - (make element gi: "TABLE" - attributes: ($shade-verbatim-attr$) - (make element gi: "TR" - (make element gi: "TD" - content))) - (make sequence - (para-check) - content - (para-check 'restart))))) - -(define %shade-verbatim% - ;; verbatim sections will be shaded if t(rue) - #f) - -(define %use-id-as-filename% - ;; Use ID attributes as name for component HTML files? - #t) - -(define %graphic-extensions% - ;; graphic extensions allowed - '("jpg" "jpeg" "png")) - -(define %graphic-default-extension% - "jpg") - -(define %section-autolabel% - ;; For enumerated sections (1.1, 1.1.1, 1.2, etc.) - #t) - -(define (toc-depth nd) - ;; more depth (3 levels) to toc; instead of flat hierarchy - 2) - -(element emphasis - ;; make role=strong equate to bold for emphasis tag - (if (equal? (attribute-string "role") "strong") - (make element gi: "STRONG" (process-children)) - (make element gi: "EM" (process-children)))) - -(define (article-titlepage-recto-elements) - ;; elements on an article's titlepage - (list (normalize "title") - (normalize "subtitle") - (normalize "authorgroup") - (normalize "author") - (normalize "othercredit") - (normalize "releaseinfo") - (normalize "copyright") - (normalize "pubdate") - (normalize "revhistory") - (normalize "abstract") - (normalize "legalnotice"))) - -(define (article-title nd) - (let* ((artchild (children nd)) - (artheader (select-elements artchild (normalize "artheader"))) - (artinfo (select-elements artchild (normalize "articleinfo"))) - (ahdr (if (node-list-empty? artheader) - artinfo - artheader)) - (ahtitles (select-elements (children ahdr) - (normalize "title"))) - (artitles (select-elements artchild (normalize "title"))) - (titles (if (node-list-empty? artitles) - ahtitles - artitles))) - (if (node-list-empty? titles) - "" - (node-list-first titles)))) - -(mode subtitle-mode - ;; do not print subtitle on subsequent pages - (element subtitle (empty-sosofo))) - -;; notes. -(element note - (make sequence - (para-check) - ($admonition$) - (para-check 'restart))) - -]]> - - - - - - - diff --git a/doc/pg_sphere.xml b/doc/pg_sphere.xml index 950a5309..62cd79df 100644 --- a/doc/pg_sphere.xml +++ b/doc/pg_sphere.xml @@ -1,7 +1,7 @@ - @@ -11,8 +11,6 @@ - - @@ -25,50 +23,34 @@ +&ohgr;"> +&OHgr;"> +&pgr;"> +HEALPix"> +pgSphere"> +PostgreSQL"> +pg_config"> + + + ]> + + + + Codestin Search App + pgSphere Development Team + pgSphere + &pg_sphere_version; + -
- - Codestin Search App - - pgSphere development team - - - - - - - - - - - pgSphere provides spherical data - types, functions, and operators for - PostgreSQL. - - - The project is hosted at - https://github.com/postgrespro/pgsphere - - - - This document - describes installation and usage of this module. - - - - &capWhatis; - &capInstall; - &capTypes; - &capConstr; - &capOperators; - &capFunctions; - &capIndices; - &capExamples; - &capFaq; - &capAppendixes; + &capWhatis; + &capInstall; + &capTypes; + &capConstr; + &capOperators; + &capFunctions; + &capIndices; + &capExamples; -
+
diff --git a/doc/stylesheets/stylesheet-common.xsl b/doc/stylesheets/stylesheet-common.xsl new file mode 100644 index 00000000..c739f038 --- /dev/null +++ b/doc/stylesheets/stylesheet-common.xsl @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + 1 + 0 + + + + +yes +2 + + + + + + + + + +1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ? + + ? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/stylesheets/stylesheet-fo.xsl b/doc/stylesheets/stylesheet-fo.xsl new file mode 100644 index 00000000..19f368fa --- /dev/null +++ b/doc/stylesheets/stylesheet-fo.xsl @@ -0,0 +1,147 @@ + + + + + + + + +3 + + + +1.5em + + + wrap + + + + solid + 1pt + black + 12pt + 12pt + 6pt + 6pt + + + + center + + + + + left + + + + + 1em + 0.8em + 1.2em + + + + + + + + + + + + , + + + + + + + + ISBN + + + + + + + + + + + + + + + + -3.5em + + + + + + + + + + -3.5em + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/stylesheets/stylesheet-html-common.xsl b/doc/stylesheets/stylesheet-html-common.xsl new file mode 100644 index 00000000..a368e0e1 --- /dev/null +++ b/doc/stylesheets/stylesheet-html-common.xsl @@ -0,0 +1,439 @@ + + +%common.entities; +]> + + + + + + + + +pgsql-docs@lists.postgresql.org +2 + + + stylesheet.css.xml + + + https://www.postgresql.org/media/css/docs-complete.css + + + + + + docContent + container-fluid col-10 + + + + + + + + + + + + + + , + + + + + + + + + + ISBN + + + + + + + + + +appendix toc,title +article/appendix nop +article toc,title +book toc,title +chapter toc,title +part toc,title +preface toc,title +qandadiv toc +qandaset toc +reference toc,title +sect1 toc +sect2 toc +sect3 toc +sect4 toc +sect5 toc +section toc +set toc,title + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+

+ + + +

+
+ + + + + + + +
+
+
+ + + + + +
+

+ + + +

+
+ + + + + + + +
+
+
+
+
+ + + + + + + + +
+
+ + + + + + + + + +
+ + + + + + +

+ +

+
+
+ + + + + + + +
+
+
+
+ + + + + + + + + + + + | + + + + + + + + + + + + + + + + + + + + + + + + + + id- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + + + + + + + + + + clear: both + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # + + + + + + id_link + + # + + + + + + + ERROR: id attribute missing on < + + > element under + + / + + + [@ + + = ' + + '] + + + + + + + + +
diff --git a/doc/stylesheets/stylesheet-html-nochunk.xsl b/doc/stylesheets/stylesheet-html-nochunk.xsl new file mode 100644 index 00000000..5a0bb4ea --- /dev/null +++ b/doc/stylesheets/stylesheet-html-nochunk.xsl @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/stylesheets/stylesheet-man.xsl b/doc/stylesheets/stylesheet-man.xsl new file mode 100644 index 00000000..fcb485c2 --- /dev/null +++ b/doc/stylesheets/stylesheet-man.xsl @@ -0,0 +1,226 @@ + + + + + + + + + +0 +0 +0 + + + +32 +40 + + + + + + + + + + + + + + < + + > + + + + + + ^ + + + + + + + + + + + + + + + + ( + + + + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + Note: + + + + + + + + + + + + + + + + + + + + + + + + + Note: + (soelim stub) + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/stylesheets/stylesheet-speedup-common.xsl b/doc/stylesheets/stylesheet-speedup-common.xsl new file mode 100644 index 00000000..e3fb582a --- /dev/null +++ b/doc/stylesheets/stylesheet-speedup-common.xsl @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +en + + diff --git a/doc/stylesheets/stylesheet-speedup-xhtml.xsl b/doc/stylesheets/stylesheet-speedup-xhtml.xsl new file mode 100644 index 00000000..da0f2b5a --- /dev/null +++ b/doc/stylesheets/stylesheet-speedup-xhtml.xsl @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: If you change $chunk.section.depth, then you must update the performance-optimized chunk-all-sections-template. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/stylesheets/stylesheet-text.xsl b/doc/stylesheets/stylesheet-text.xsl new file mode 100644 index 00000000..529cc9ec --- /dev/null +++ b/doc/stylesheets/stylesheet-text.xsl @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + +
  • + + + + +
  • +
    + + + + + * + + * + + + + + + + + + + + + + + +
    + + + + + + +

    + + + : + +

    +
    + + +
    +
    + + + + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    diff --git a/doc/stylesheets/stylesheet.css b/doc/stylesheets/stylesheet.css new file mode 100644 index 00000000..86a8edb9 --- /dev/null +++ b/doc/stylesheets/stylesheet.css @@ -0,0 +1,182 @@ +/* doc/src/sgml/stylesheet.css */ + +/* color scheme similar to www.postgresql.org */ + +body { + color: #000000; + background: #FFFFFF; + font-family: verdana, sans-serif; +} + +a:link { color:#0066A2; } +a:visited { color:#004E66; } +a:active { color:#0066A2; } +a:hover { color:#000000; } + +h1 { + font-size: 1.4em; + font-weight: bold; + margin-top: 0em; + margin-bottom: 0em; + color: #EC5800; +} + +h2 { + font-size: 1.2em; + margin: 1.2em 0em 1.2em 0em; + font-weight: bold; + color: #666; +} + +.titlepage h2.title, +.refnamediv h2 { + color: #EC5800; +} + +h3 { + font-size: 1.1em; + margin: 1.2em 0em 1.2em 0em; + font-weight: bold; + color: #666; +} + +h4 { + font-size: 0.95em; + margin: 1.2em 0em 1.2em 0em; + font-weight: normal; + color: #666; +} + +h5 { + font-size: 0.9em; + margin: 1.2em 0em 1.2em 0em; + font-weight: normal; +} + +h6 { + font-size: 0.85em; + margin: 1.2em 0em 1.2em 0em; + font-weight: normal; +} + +/* center some titles */ + +.book .title, .book .corpauthor, .book .copyright { + text-align: center; +} + +/* decoration for formal examples */ + +div.example { + padding-left: 15px; + border-style: solid; + border-width: 0px; + border-left-width: 2px; + border-color: black; + margin: 0.5ex; +} + +/* Additional formatting for "simplelist" structures */ +table.simplelist td { + padding-left: 2em; + padding-right: 2em; +} + +/* formatting for entries in tables of functions: indent all but first line */ + +th.func_table_entry p, +td.func_table_entry p { + margin-top: 0.1em; + margin-bottom: 0.1em; + padding-left: 4em; + text-align: left; +} + +p.func_signature { + text-indent: -3.5em; +} + +td.func_table_entry pre.programlisting { + margin-top: 0.1em; + margin-bottom: 0.1em; + padding-left: 4em; +} + +/* formatting for entries in tables of catalog/view columns */ + +th.catalog_table_entry p, +td.catalog_table_entry p { + margin-top: 0.1em; + margin-bottom: 0.1em; + padding-left: 4em; + text-align: left; +} + +th.catalog_table_entry p.column_definition { + text-indent: -3.5em; + word-spacing: 0.25em; +} + +td.catalog_table_entry p.column_definition { + text-indent: -3.5em; +} + +p.column_definition code.type { + padding-left: 0.25em; + padding-right: 0.25em; +} + +td.catalog_table_entry pre.programlisting { + margin-top: 0.1em; + margin-bottom: 0.1em; + padding-left: 4em; +} + +/* Put these here instead of inside the HTML (see unsetting of + admon.style in XSL) so that the web site stylesheet can set its own + style. */ + +.tip, +.note, +.important, +.caution, +.warning { + margin-left: 0.5in; + margin-right: 0.5in; +} + +/* miscellaneous */ + +pre.literallayout, .screen, .synopsis, .programlisting { + margin-left: 4ex; +} + +ul.itemizedlist { + margin-left: 2.5rem; +} + +.comment { color: red; } + +var { font-family: monospace; font-style: italic; } +/* Konqueror's standard style for ACRONYM is italic. */ +acronym { font-style: inherit; } + +.option { white-space: nowrap; } + +/* make images not too wide on larger screens */ +@media (min-width: 800px) { + .mediaobject { + width: 75%; + } +} + +/* links to ids of headers and definition terms */ + +a.id_link { + color: inherit; + visibility: hidden; +} + +*:hover > a.id_link { + visibility: visible; +} diff --git a/doc/stylesheets/stylesheet.css.xml b/doc/stylesheets/stylesheet.css.xml new file mode 100644 index 00000000..a21fcca5 --- /dev/null +++ b/doc/stylesheets/stylesheet.css.xml @@ -0,0 +1,8 @@ + + +]> + diff --git a/doc/stylesheets/stylesheet.xsl b/doc/stylesheets/stylesheet.xsl new file mode 100644 index 00000000..6b39d918 --- /dev/null +++ b/doc/stylesheets/stylesheet.xsl @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/types.sgm b/doc/types.sgm index 557c1441..acb3c549 100644 --- a/doc/types.sgm +++ b/doc/types.sgm @@ -1,8 +1,7 @@ - - Codestin Search App - + + Codestin Search App + + Codestin Search App @@ -100,9 +99,9 @@ - - - + + + Codestin Search App @@ -118,28 +117,28 @@ - sites on earth + sites on earth - star positions on the sky sphere + star positions on the sky sphere - spherical positions on planets + spherical positions on planets - + A spherical point (or position) is given by two values: longitude and latitude. Longitude is a floating point value between 0 and - 2&pgr;. Latitude is a floating point - value, too, but between -&pgr;/2 and - &pgr;/2. It is possible to give a + 2&pg_pgr;. Latitude is a floating point + value, too, but between -&pg_pgr;/2 and + &pg_pgr;/2. It is possible to give a spherical position in degrees (DEG) or with a triple value of degrees, minutes and seconds (DMS). Degrees and minutes are integer @@ -189,10 +188,10 @@ longitude and latitude. The value pairs are always enclosed within braces. Spaces are optional. - - - + + + Codestin Search App @@ -210,12 +209,12 @@ - spherical object transformations + spherical object transformations - spherical coordinates transformations + spherical coordinates transformations @@ -226,7 +225,7 @@ where axes is an optional 3 letter code with letters : X, Y, or - Z. Default is ZXZ. + Z. Default is ZXZ. angleN is any valid angle with the input format RAD, DEG, or DMS. @@ -263,9 +262,9 @@ SELECT strans '2d 20m, 10d, 0';]]> - - - + + + Codestin Search App @@ -289,12 +288,12 @@ - round cluster or nebula on sky sphere + round cluster or nebula on sky sphere - a position with an undirected position error + a position with an undirected position error @@ -318,9 +317,9 @@ SELECT scircle '< (0d, 90d), 5d >';]]> - + - + Codestin Search App @@ -336,12 +335,12 @@ - direct connection of two points + direct connection of two points - meteors on the sky sphere + meteors on the sky sphere @@ -395,9 +394,9 @@ i syntax is a somewhat complex. SELECT sline '( -90d, -20d, 200d, XYZ ), 30d ';]]> - - - + + + Codestin Search App @@ -432,7 +431,7 @@ i syntax is a somewhat complex. - to describe a position error + to describe a position error @@ -442,12 +441,12 @@ i syntax is a somewhat complex. - a major radius rad_1 + a major radius rad_1 - a minor radius rad_2 + a minor radius rad_2 @@ -505,9 +504,9 @@ i syntax is a somewhat complex. SELECT sellipse '< { 10d, 5d } , ( 20d, 0d ), 90d >';]]> - + - + Codestin Search App @@ -523,7 +522,7 @@ i syntax is a somewhat complex. - rivers on earth + rivers on earth @@ -548,7 +547,7 @@ i syntax is a somewhat complex. - At least 2 positions are required. + At least 2 positions are required. @@ -565,9 +564,9 @@ i syntax is a somewhat complex. SELECT spath '{ (10d,0d),(45d,15d),(80d,30d) } ';]]> - + - + Codestin Search App @@ -582,7 +581,7 @@ i syntax is a somewhat complex. A spherical polygon is a closed spherical path where line segments cannot be crossed. One main use case are areas on the earth and sky sphere. - Polygons within pgSphere + Polygons within pgSphere have the same input syntax as paths: {pos1,pos2,pos3[,pos4[,... ]]} @@ -598,7 +597,7 @@ i syntax is a somewhat complex. - The line segments can not be crossed. + The line segments can not be crossed. @@ -621,9 +620,9 @@ i syntax is a somewhat complex. SELECT spoly '{ (270d,-10d), (270d,30d), (290d,10d) } ';]]> - + - + Codestin Search App @@ -689,9 +688,9 @@ i syntax is a somewhat complex. SELECT sbox '( (350d,-10d), (10d,+10d) )';]]> - + - + Codestin Search App @@ -750,5 +749,6 @@ i syntax is a somewhat complex. SELECT smoc '0/4 1/0 2 12-13 34-35 45 47 2/4 6 12 14 56-57 60-61 88 90-91 116-117 119 130-131 134-135 177 179 185 187';]]> - - + + + diff --git a/doc/whatis.sgm b/doc/whatis.sgm index 6af690bb..eb12bf1d 100644 --- a/doc/whatis.sgm +++ b/doc/whatis.sgm @@ -1,4 +1,7 @@ - + + Codestin Search App + + Codestin Search App @@ -15,7 +18,7 @@ - containing, overlapping, and other operators + containing, overlapping, and other operators @@ -30,17 +33,17 @@ - spherical transformation + spherical transformation - indexing of spherical data types + indexing of spherical data types - several input and output formats + several input and output formats @@ -48,17 +51,19 @@ Hence, you can do a fast search and analysis for objects with spherical attributes as used in geographical, astronomical, or - other applications using PostgreSQL. + other applications using PostgreSQL. For instance, you can manage data of geographical objects around the world and astronomical data like star and other catalogs conveniently using an SQL interface. - The aim of pgSphere is to provide + The aim of pgSphere is to provide uniform access to spherical data. Because PostgreSQL itself supports a lot of software interfaces, you can now use the same database with different utilities and applications. - + + + diff --git a/expected/bounding_box_gist.out b/expected/bounding_box_gist.out index 6307ac1a..ef424748 100644 --- a/expected/bounding_box_gist.out +++ b/expected/bounding_box_gist.out @@ -1,3 +1,4 @@ +SET extra_float_digits = 2; SET enable_seqscan=true; CREATE TABLE bbox_ellipse (e sellipse not null); INSERT INTO bbox_ellipse VALUES ('<{10d, 0.1d}, (0d,0d), 0d>'); @@ -20,19 +21,19 @@ SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' @ e; - QUERY PLAN ----------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------ Aggregate -> Seq Scan on bbox_ellipse - Filter: ('(0.0872664625997165 , 0)'::spoint @ e) + Filter: ('(0.087266462599716474 , 0)'::spoint @ e) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; - QUERY PLAN ------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------- Aggregate -> Seq Scan on bbox_ellipse - Filter: ('(0.0872664625997165 , 0)'::spoint <@ e) + Filter: ('(0.087266462599716474 , 0)'::spoint <@ e) (3 rows) -- The ellipse has semi-major axis length of 10 degrees along the equator, @@ -53,19 +54,19 @@ SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' @ e; - QUERY PLAN --------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------- Aggregate -> Index Scan using idx_bbox_ellipse on bbox_ellipse - Index Cond: ('(0.0872664625997165 , 0)'::spoint @ e) + Index Cond: ('(0.087266462599716474 , 0)'::spoint @ e) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; - QUERY PLAN ---------------------------------------------------------------- + QUERY PLAN +----------------------------------------------------------------- Aggregate -> Index Scan using idx_bbox_ellipse on bbox_ellipse - Index Cond: ('(0.0872664625997165 , 0)'::spoint <@ e) + Index Cond: ('(0.087266462599716474 , 0)'::spoint <@ e) (3 rows) SET enable_seqscan=true; @@ -170,11 +171,11 @@ SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' <@ p; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE sline(spoint '(0d, -10d)', spoint '(0d, 10d)') && p; - QUERY PLAN --------------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Aggregate -> Seq Scan on bbox_path - Filter: ('( 6.10865238198015, 1.5707963267949, 0, ZXZ ), 0.349065850398866'::sline && p) + Filter: ('( 6.1086523819801535, 1.5707963267948966, 0, ZXZ ), 0.34906585039886584'::sline && p) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' @ p; @@ -215,11 +216,11 @@ SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' <@ p; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE sline(spoint '(0d, -10d)', spoint '(0d, 10d)') && p; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------- Aggregate -> Index Scan using idx_bbox_path on bbox_path - Index Cond: ('( 6.10865238198015, 1.5707963267949, 0, ZXZ ), 0.349065850398866'::sline && p) + Index Cond: ('( 6.1086523819801535, 1.5707963267948966, 0, ZXZ ), 0.34906585039886584'::sline && p) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' @ p; diff --git a/expected/bounding_box_gist_1.out b/expected/bounding_box_gist_1.out index 8c089360..48d4ff30 100644 --- a/expected/bounding_box_gist_1.out +++ b/expected/bounding_box_gist_1.out @@ -1,3 +1,4 @@ +SET extra_float_digits = 2; SET enable_seqscan=true; CREATE TABLE bbox_ellipse (e sellipse not null); INSERT INTO bbox_ellipse VALUES ('<{10d, 0.1d}, (0d,0d), 0d>'); @@ -20,19 +21,19 @@ SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' @ e; - QUERY PLAN ----------------------------------------------------------- + QUERY PLAN +----------------------------------------------------------- Aggregate -> Seq Scan on bbox_ellipse - Filter: ('(0.0872664625997165 , 0)'::spoint @ e) + Filter: ('(0.08726646259971647 , 0)'::spoint @ e) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; - QUERY PLAN ------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------ Aggregate -> Seq Scan on bbox_ellipse - Filter: ('(0.0872664625997165 , 0)'::spoint <@ e) + Filter: ('(0.08726646259971647 , 0)'::spoint <@ e) (3 rows) -- The ellipse has semi-major axis length of 10 degrees along the equator, @@ -53,19 +54,19 @@ SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' @ e; - QUERY PLAN --------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------- Aggregate -> Index Scan using idx_bbox_ellipse on bbox_ellipse - Index Cond: (e ~ '(0.0872664625997165 , 0)'::spoint) + Index Cond: (e ~ '(0.08726646259971647 , 0)'::spoint) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_ellipse WHERE spoint '(5d, 0d)' <@ e; - QUERY PLAN ---------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------- Aggregate -> Index Scan using idx_bbox_ellipse on bbox_ellipse - Index Cond: (e @> '(0.0872664625997165 , 0)'::spoint) + Index Cond: (e @> '(0.08726646259971647 , 0)'::spoint) (3 rows) SET enable_seqscan=true; @@ -170,11 +171,11 @@ SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' <@ p; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE sline(spoint '(0d, -10d)', spoint '(0d, 10d)') && p; - QUERY PLAN --------------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------- Aggregate -> Seq Scan on bbox_path - Filter: ('( 6.10865238198015, 1.5707963267949, 0, ZXZ ), 0.349065850398866'::sline && p) + Filter: ('( 6.1086523819801535, 1.5707963267948966, 0, ZXZ ), 0.34906585039886584'::sline && p) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' @ p; @@ -215,11 +216,11 @@ SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' <@ p; (1 row) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE sline(spoint '(0d, -10d)', spoint '(0d, 10d)') && p; - QUERY PLAN ------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------- Aggregate -> Index Scan using idx_bbox_path on bbox_path - Index Cond: (p && '( 6.10865238198015, 1.5707963267949, 0, ZXZ ), 0.349065850398866'::sline) + Index Cond: (p && '( 6.1086523819801535, 1.5707963267948966, 0, ZXZ ), 0.34906585039886584'::sline) (3 rows) EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM bbox_path WHERE spoint '(0d, 0d)' @ p; diff --git a/expected/epochprop.out b/expected/epochprop.out index 8541601e..1111f1a7 100644 --- a/expected/epochprop.out +++ b/expected/epochprop.out @@ -1,4 +1,5 @@ -SELECT +SET extra_float_digits = 1; +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -6,7 +7,7 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 546.9759, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; @@ -15,7 +16,7 @@ FROM ( 269.4742714391 | 4.4072939987 | 543.624 | -791.442 | 10235.412 | -110.450 (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -23,16 +24,16 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 0, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+---------+----------+------------+--------- - 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+----------+------------+---------- + 269.4744079540 | 4.4055337210 | .000 | -801.210 | 10361.762 | -110.000 (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -40,16 +41,16 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), NULL, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+---------+----------+------------+--------- - 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+---------+----------+------------+---------- + 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | -110.000 (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -57,16 +58,16 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), NULL, 20) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+----------+----------+------------+---------- - 269.4476085384 | 4.7509315989 | 23.000 | -801.617 | 10361.984 | 2.159 + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+----------+------------+--------- + 269.4476085384 | 4.7509315989 | 23.000 | -801.617 | 10361.984 | (1 row) -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -74,13 +75,13 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, NULL, RADIANS(10362/3.6e6), -110, 120) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+----------+----------+------------+---------- - 269.4520769500 | 5.0388680565 | 23.007 | -.000 | 10368.061 | -97.120 + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+---------+---------+---------- + 269.4520769500 | 4.6933649660 | 23.007 | | | -110.000 (1 row) SELECT epoch_prop(NULL, @@ -88,20 +89,20 @@ SELECT epoch_prop(NULL, 0.01 , RADIANS(10362/3.6e6), -110, 120); ERROR: NULL position not supported in epoch propagation -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, 20) AS tp; - tp ------------------------------------------ - (4.70274792658313 , 0.0829194509345993) + tp +------------------------------------------- + (4.702747926583129 , 0.08291945093459933) (1 row) -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), 20) AS tp; - tp ------------------------------------------ - (4.70274793061952 , 0.0829193989380876) + tp +------------------------------------------- + (4.702747930619516 , 0.08291939893808763) (1 row) diff --git a/expected/epochprop_1.out b/expected/epochprop_1.out new file mode 100644 index 00000000..08317fcd --- /dev/null +++ b/expected/epochprop_1.out @@ -0,0 +1,108 @@ +SET extra_float_digits = 2; +SELECT + to_char(DEGREES(tp[1]), '999D9999999999'), + to_char(DEGREES(tp[2]), '999D9999999999'), + to_char(tp[3], '999D999'), + to_char(DEGREES(tp[4])*3.6e6, '999D999'), + to_char(DEGREES(tp[5])*3.6e6, '99999D999'), + to_char(tp[6], '999D999') +FROM ( + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + 546.9759, + RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, + -100) AS tp) AS q; + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+----------+------------+---------- + 269.4742714391 | 4.4072939987 | 543.624 | -791.442 | 10235.412 | -110.450 +(1 row) + +SELECT + to_char(DEGREES(tp[1]), '999D9999999999'), + to_char(DEGREES(tp[2]), '999D9999999999'), + to_char(tp[3], '999D999'), + to_char(DEGREES(tp[4])*3.6e6, '999D999'), + to_char(DEGREES(tp[5])*3.6e6, '99999D999'), + to_char(tp[6], '999D999') +FROM ( + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + 0, + RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, + -100) AS tp) AS q; + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+---------+----------+------------+--------- + 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | +(1 row) + +SELECT + to_char(DEGREES(tp[1]), '999D9999999999'), + to_char(DEGREES(tp[2]), '999D9999999999'), + to_char(tp[3], '999D999'), + to_char(DEGREES(tp[4])*3.6e6, '999D999'), + to_char(DEGREES(tp[5])*3.6e6, '99999D999'), + to_char(tp[6], '999D999') +FROM ( + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + NULL, + RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, + -100) AS tp) AS q; + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+---------+----------+------------+--------- + 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | +(1 row) + +SELECT + to_char(DEGREES(tp[1]), '999D9999999999'), + to_char(DEGREES(tp[2]), '999D9999999999'), + to_char(tp[3], '999D999'), + to_char(DEGREES(tp[4])*3.6e6, '999D999'), + to_char(DEGREES(tp[5])*3.6e6, '99999D999'), + to_char(tp[6], '999D999') +FROM ( + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + 23, + RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), NULL, + 20) AS tp) AS q; + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+----------+------------+---------- + 269.4476085384 | 4.7509315989 | 23.000 | -801.617 | 10361.984 | 2.159 +(1 row) + +SELECT + to_char(DEGREES(tp[1]), '999D9999999999'), + to_char(DEGREES(tp[2]), '999D9999999999'), + to_char(tp[3], '999D999'), + to_char(DEGREES(tp[4])*3.6e6, '999D999'), + to_char(DEGREES(tp[5])*3.6e6, '99999D999'), + to_char(tp[6], '999D999') +FROM ( + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + 23, + NULL, RADIANS(10362/3.6e6), -110, + 120) AS tp) AS q; + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+----------+----------+------------+---------- + 269.4520769500 | 5.0388680565 | 23.007 | -.000 | 10368.061 | -97.120 +(1 row) + +SELECT epoch_prop(NULL, + 23, + 0.01 , RADIANS(10362/3.6e6), -110, + 120); +ERROR: NULL position not supported in epoch propagation +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), + 23, + RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, + 20) AS tp; + tp +------------------------------------------- + (4.702747926583129 , 0.08291945093459933) +(1 row) + +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), + RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), + 20) AS tp; + tp +------------------------------------------- + (4.702747930619516 , 0.08291939893808763) +(1 row) + diff --git a/expected/gist_support.out b/expected/gist_support.out new file mode 100644 index 00000000..dead655f --- /dev/null +++ b/expected/gist_support.out @@ -0,0 +1,155 @@ +-- spoint_dwithin function selectivity +set jit = off; -- suppress extra planning output +select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), 1)'); + explain +----------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) + Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '1'::double precision) + Rows Removed by Filter: 1560 + Heap Blocks: exact=55 + -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) + Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .1)'); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) + Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) + Rows Removed by Filter: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .01)'); + explain +--------------------------------------------------------------------------------------------- + Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) +(2 rows) + +select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, 1)'); + explain +----------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) + Filter: spoint_dwithin('(1 , 1)'::spoint, star, '1'::double precision) + Rows Removed by Filter: 1560 + Heap Blocks: exact=55 + -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) + Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .1)'); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) + Filter: spoint_dwithin('(1 , 1)'::spoint, star, '0.1'::double precision) + Rows Removed by Filter: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .01)'); + explain +--------------------------------------------------------------------------------------------- + Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) +(2 rows) + +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, 1)', do_analyze := 'false'); + explain +--------------------------------------------------------------------------------------- + Nested Loop (rows=22984885 width=32) + -> Seq Scan on spoint10k a (rows=10000 width=16) + -> Index Scan using spoint10k_star_idx on spoint10k b (rows=2298 width=16) + Index Cond: (star OPERATOR(public.<@) scircle(a.star, '1'::double precision)) +(4 rows) + +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .1)'); + explain +----------------------------------------------------------------------------------------------------------- + Nested Loop (rows=249792 width=32) (actual rows=505342 loops=1) + -> Seq Scan on spoint10k a (rows=10000 width=16) (actual rows=10000 loops=1) + -> Index Scan using spoint10k_star_idx on spoint10k b (rows=25 width=16) (actual rows=51 loops=10000) + Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.1'::double precision)) + Rows Removed by Index Recheck: 31 +(5 rows) + +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01)'); + explain +--------------------------------------------------------------------------------------------------------- + Nested Loop (rows=2500 width=32) (actual rows=17614 loops=1) + -> Seq Scan on spoint10k a (rows=10000 width=16) (actual rows=10000 loops=1) + -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=2 loops=10000) + Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) + Rows Removed by Index Recheck: 1 +(5 rows) + +-- spoint_dwithin is symmetric in the first two arguments +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .1)'); + explain +------------------------------------------------------------------------------------------------------ + Nested Loop (rows=6 width=32) (actual rows=33 loops=1) + -> Bitmap Heap Scan on spoint10k a (rows=25 width=16) (actual rows=29 loops=1) + Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) + Rows Removed by Filter: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) + -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=29) + Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) + Rows Removed by Index Recheck: 0 +(10 rows) + +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(b.star, a.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .1)'); + explain +------------------------------------------------------------------------------------------------------ + Nested Loop (rows=6 width=32) (actual rows=33 loops=1) + -> Bitmap Heap Scan on spoint10k a (rows=25 width=16) (actual rows=29 loops=1) + Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) + Rows Removed by Filter: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) + -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=29) + Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) + Rows Removed by Index Recheck: 0 +(10 rows) + +-- both sides indexable, check if the planner figures out the better choice +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .1) and spoint_dwithin(b.star, spoint(1,1), .05)'); + explain +------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (rows=1 width=32) (actual rows=16 loops=1) + -> Bitmap Heap Scan on spoint10k b (rows=6 width=16) (actual rows=12 loops=1) + Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.05'::double precision) + Rows Removed by Filter: 4 + Heap Blocks: exact=14 + -> Bitmap Index Scan on spoint10k_star_idx (rows=6 width=0) (actual rows=16 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.05>'::scircle) + -> Index Scan using spoint10k_star_idx on spoint10k a (rows=1 width=16) (actual rows=1 loops=12) + Index Cond: ((star OPERATOR(public.<@) scircle(b.star, '0.01'::double precision)) AND (star <@ '<(1 , 1) , 0.1>'::scircle)) + Rows Removed by Index Recheck: 0 +(10 rows) + +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .05) and spoint_dwithin(b.star, spoint(1,1), .1)'); + explain +------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (rows=1 width=32) (actual rows=16 loops=1) + -> Bitmap Heap Scan on spoint10k a (rows=6 width=16) (actual rows=12 loops=1) + Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.05'::double precision) + Rows Removed by Filter: 4 + Heap Blocks: exact=14 + -> Bitmap Index Scan on spoint10k_star_idx (rows=6 width=0) (actual rows=16 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.05>'::scircle) + -> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=12) + Index Cond: ((star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) AND (star <@ '<(1 , 1) , 0.1>'::scircle)) + Rows Removed by Index Recheck: 0 +(10 rows) + diff --git a/expected/index.out b/expected/index.out index a639dabf..f63cff80 100644 --- a/expected/index.out +++ b/expected/index.out @@ -55,6 +55,7 @@ SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>'; -- create idx CREATE TABLE spheretmp1b AS TABLE spheretmp1; +ANALYZE spheretmp1; CREATE INDEX aaaidx ON spheretmp1 USING gist ( p ); CREATE INDEX spoint3_idx ON spheretmp1b USING gist (p spoint3); CREATE INDEX bbbidx ON spheretmp2 USING gist ( c ); @@ -134,3 +135,99 @@ SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>' ; 40 (1 row) +-- test spoint3 operator class with and without index-only scan +SET enable_bitmapscan = OFF; +SET enable_indexonlyscan = ON; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + QUERY PLAN +-------------------------------------------------------- + Aggregate + -> Index Only Scan using spoint3_idx on spheretmp1b + Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + count +------- + 32 +(1 row) + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + QUERY PLAN +-------------------------------------------------------- + Aggregate + -> Index Only Scan using spoint3_idx on spheretmp1b + Index Cond: (p = '(3.09 , 1.25)'::spoint) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + count +------- + 4 +(1 row) + +SET enable_indexonlyscan = OFF; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + QUERY PLAN +------------------------------------------------------- + Aggregate + -> Index Scan using spoint3_idx on spheretmp1b + Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + count +------- + 32 +(1 row) + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + QUERY PLAN +--------------------------------------------------- + Aggregate + -> Index Scan using spoint3_idx on spheretmp1b + Index Cond: (p = '(3.09 , 1.25)'::spoint) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + count +------- + 4 +(1 row) + +-- test hash opclass +CREATE TABLE spheretmp1c AS TABLE spheretmp1; +SELECT p FROM spheretmp1c WHERE p <@ scircle '<(1,1),0.2>' ORDER BY p::text; + p +--------------- + (0.67 , 0.97) + (0.67 , 0.97) + (0.67 , 0.97) + (0.67 , 0.97) + (1.07 , 1.09) + (1.07 , 1.09) + (1.07 , 1.09) + (1.07 , 1.09) + (1.24 , 0.95) + (1.24 , 0.95) + (1.24 , 0.95) + (1.24 , 0.95) +(12 rows) + +WITH points AS (SELECT DISTINCT p FROM spheretmp1c WHERE p <@ scircle '<(1,1),0.2>') + SELECT p FROM points ORDER BY p::text; + p +--------------- + (0.67 , 0.97) + (1.07 , 1.09) + (1.24 , 0.95) +(3 rows) + +CREATE INDEX spheretmp1c_hash_idx ON spheretmp1c USING hash(p); +EXPLAIN (COSTS OFF) SELECT * FROM spheretmp1c WHERE p = '(0.67 , 0.97)'; + QUERY PLAN +------------------------------------------------------ + Index Scan using spheretmp1c_hash_idx on spheretmp1c + Index Cond: (p = '(0.67 , 0.97)'::spoint) +(2 rows) + diff --git a/expected/index_9.5.out b/expected/index_9.5.out deleted file mode 100644 index 99995f08..00000000 --- a/expected/index_9.5.out +++ /dev/null @@ -1,62 +0,0 @@ --- test spoint3 operator class with and without index-only scan -SET enable_seqscan = OFF; -SET enable_bitmapscan = OFF; -SET enable_indexonlyscan = ON; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - QUERY PLAN --------------------------------------------------------- - Aggregate - -> Index Only Scan using spoint3_idx on spheretmp1b - Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - count -------- - 32 -(1 row) - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - QUERY PLAN --------------------------------------------------------- - Aggregate - -> Index Only Scan using spoint3_idx on spheretmp1b - Index Cond: (p = '(3.09 , 1.25)'::spoint) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - count -------- - 4 -(1 row) - -SET enable_bitmapscan = ON; -SET enable_indexonlyscan = OFF; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - QUERY PLAN -------------------------------------------------------- - Aggregate - -> Index Scan using spoint3_idx on spheretmp1b - Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - count -------- - 32 -(1 row) - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - QUERY PLAN ---------------------------------------------------- - Aggregate - -> Index Scan using spoint3_idx on spheretmp1b - Index Cond: (p = '(3.09 , 1.25)'::spoint) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - count -------- - 4 -(1 row) - diff --git a/expected/init.out b/expected/init.out index fb864883..374e2a35 100644 --- a/expected/init.out +++ b/expected/init.out @@ -1,11 +1,4 @@ -- --- first, define the datatype. Turn off echoing so that expected file --- does not depend on contents of pg_sphere.sql. +-- Initialize the extension. -- CREATE EXTENSION pg_sphere; -select pg_sphere_version(); - pg_sphere_version -------------------- - 1.3.1 -(1 row) - diff --git a/expected/init_extended.out b/expected/init_extended.out index 382a0dcb..adeaa8d8 100644 --- a/expected/init_extended.out +++ b/expected/init_extended.out @@ -1,18 +1,18 @@ -- indexed operations..... -- spoint_data and scircle_data tables have to be created and indexed using -\! testsuite/gen_point.pl 1 > results/gen_point_1.sql +\! perl testsuite/gen_point.pl 1 > results/gen_point_1.sql \i results/gen_point_1.sql CREATE TABLE spoint_data (sp spoint); COPY spoint_data (sp) FROM stdin; CREATE INDEX sp_idx ON spoint_data USING gist (sp); -- and -\! testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql +\! perl testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql \i results/gen_circle_1_0.1.sql CREATE TABLE scircle_data (sc scircle); COPY scircle_data (sc) FROM stdin; CREATE INDEX sc_idx ON scircle_data USING gist (sc); -- -\! testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql +\! perl testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql \i results/gen_poly_1_0.1_4.sql CREATE TABLE spoly_data (sp spoly); COPY spoly_data (sp) FROM stdin; diff --git a/expected/init_test.out b/expected/init_test.out new file mode 100644 index 00000000..da0e94be --- /dev/null +++ b/expected/init_test.out @@ -0,0 +1,2 @@ +SET client_min_messages TO WARNING; +\set ECHO none diff --git a/expected/init_test.out.in b/expected/init_test.out.in deleted file mode 100644 index 6fbd06bd..00000000 --- a/expected/init_test.out.in +++ /dev/null @@ -1,35 +0,0 @@ -SET client_min_messages TO NOTICE; -\set ECHO none -psql:pg_sphere.test.sql:9: NOTICE: type "spoint" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:16: NOTICE: argument type spoint is only a shell -psql:pg_sphere.test.sql:32: NOTICE: type "strans" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:39: NOTICE: argument type strans is only a shell -psql:pg_sphere.test.sql:55: NOTICE: type "scircle" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:62: NOTICE: argument type scircle is only a shell -psql:pg_sphere.test.sql:78: NOTICE: type "sline" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:85: NOTICE: argument type sline is only a shell -psql:pg_sphere.test.sql:101: NOTICE: type "sellipse" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:108: NOTICE: argument type sellipse is only a shell -psql:pg_sphere.test.sql:126: NOTICE: type "spoly" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:133: NOTICE: argument type spoly is only a shell -psql:pg_sphere.test.sql:151: NOTICE: type "spath" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:158: NOTICE: argument type spath is only a shell -psql:pg_sphere.test.sql:177: NOTICE: type "sbox" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:184: NOTICE: argument type sbox is only a shell -psql:pg_sphere.test.sql:8658: NOTICE: type "spherekey" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:8665: NOTICE: argument type spherekey is only a shell -psql:pg_sphere.test.sql:8679: NOTICE: type "pointkey" is not yet defined -DETAIL: Creating a shell type definition. -psql:pg_sphere.test.sql:8686: NOTICE: argument type pointkey is only a shell -psql:pg_sphere.test.sql:8692: NOTICE: argument type pointkey is only a shell -psql:pg_sphere.test.sql:8698: NOTICE: argument type pointkey is only a shell -psql:pg_sphere.test.sql:8704: NOTICE: argument type pointkey is only a shell diff --git a/expected/init_test_healpix.out.in b/expected/init_test_healpix.out.in deleted file mode 100644 index b87a70df..00000000 --- a/expected/init_test_healpix.out.in +++ /dev/null @@ -1,2 +0,0 @@ -psql:pg_sphere.test.sql:9684: NOTICE: return type smoc is only a shell -psql:pg_sphere.test.sql:9690: NOTICE: argument type smoc is only a shell diff --git a/expected/knn.out b/expected/knn.out new file mode 100644 index 00000000..49c89031 --- /dev/null +++ b/expected/knn.out @@ -0,0 +1,122 @@ +CREATE TABLE points (id int, p spoint, pos int); +INSERT INTO points (id, p) SELECT x, spoint(random()*6.28, (2*random()-1)*1.57) FROM generate_series(1,314159) x; +CREATE INDEX i ON points USING gist (p); +SET enable_indexscan = true; +EXPLAIN (costs off) SELECT p <-> spoint (0.2, 0.3) FROM points ORDER BY 1 LIMIT 100; + QUERY PLAN +------------------------------------------------- + Limit + -> Index Scan using i on points + Order By: (p <-> '(0.2 , 0.3)'::spoint) +(3 rows) + +UPDATE points SET pos = n FROM + (SELECT id, row_number() OVER (ORDER BY p <-> spoint (0.2, 0.3)) n FROM points ORDER BY p <-> spoint (0.2, 0.3) LIMIT 100) sel + WHERE points.id = sel.id; +SET enable_indexscan = false; +SELECT pos, row_number() OVER (ORDER BY p <-> spoint (0.2, 0.3)) n FROM points ORDER BY p <-> spoint (0.2, 0.3) LIMIT 100; + pos | n +-----+----- + 1 | 1 + 2 | 2 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 10 | 10 + 11 | 11 + 12 | 12 + 13 | 13 + 14 | 14 + 15 | 15 + 16 | 16 + 17 | 17 + 18 | 18 + 19 | 19 + 20 | 20 + 21 | 21 + 22 | 22 + 23 | 23 + 24 | 24 + 25 | 25 + 26 | 26 + 27 | 27 + 28 | 28 + 29 | 29 + 30 | 30 + 31 | 31 + 32 | 32 + 33 | 33 + 34 | 34 + 35 | 35 + 36 | 36 + 37 | 37 + 38 | 38 + 39 | 39 + 40 | 40 + 41 | 41 + 42 | 42 + 43 | 43 + 44 | 44 + 45 | 45 + 46 | 46 + 47 | 47 + 48 | 48 + 49 | 49 + 50 | 50 + 51 | 51 + 52 | 52 + 53 | 53 + 54 | 54 + 55 | 55 + 56 | 56 + 57 | 57 + 58 | 58 + 59 | 59 + 60 | 60 + 61 | 61 + 62 | 62 + 63 | 63 + 64 | 64 + 65 | 65 + 66 | 66 + 67 | 67 + 68 | 68 + 69 | 69 + 70 | 70 + 71 | 71 + 72 | 72 + 73 | 73 + 74 | 74 + 75 | 75 + 76 | 76 + 77 | 77 + 78 | 78 + 79 | 79 + 80 | 80 + 81 | 81 + 82 | 82 + 83 | 83 + 84 | 84 + 85 | 85 + 86 | 86 + 87 | 87 + 88 | 88 + 89 | 89 + 90 | 90 + 91 | 91 + 92 | 92 + 93 | 93 + 94 | 94 + 95 | 95 + 96 | 96 + 97 | 97 + 98 | 98 + 99 | 99 + 100 | 100 +(100 rows) + +DROP TABLE points; diff --git a/expected/moc100.out b/expected/moc100.out index 51d668b9..c74fb6ed 100644 --- a/expected/moc100.out +++ b/expected/moc100.out @@ -1,20 +1,10 @@ -\set ECHO none - outputfile_for_majorversion ------------------------------ - 10, 11, 12 -(1 row) - - outputfile_for_arch_bits --------------------------- - 64-bit -(1 row) - CREATE TABLE moc100 ( ivoid text, coverage smoc, ref_system_name text ); COPY moc100 FROM STDIN; +ANALYZE moc100; CREATE INDEX ON moc100 USING GIN (coverage); SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; ivoid @@ -56,208 +46,175 @@ SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; ivo://vopdc.obspm/luth/hess (35 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '0/'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=0.00..4.01 rows=1 width=96) (actual rows=0 loops=1) +-- PG 10 does not have JIT, ignore errors on SET +DO $$ + begin + set jit = off; + exception + when undefined_object then null; + when others then raise; + end; +$$; +SELECT explain ($$SELECT * FROM moc100 WHERE coverage && '0/'$$); + explain +------------------------------------------------------------------------------------------ + Bitmap Heap Scan on moc100 (rows=1 width=341) (actual rows=0 loops=1) Recheck Cond: (coverage && '0/'::smoc) - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..0.00 rows=1 width=0) (actual rows=0 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=1 width=0) (actual rows=0 loops=1) Index Cond: (coverage && '0/'::smoc) (4 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=35 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage && '4/0'$$); + explain +----------------------------------------------------------------- + Seq Scan on moc100 (rows=1 width=341) (actual rows=35 loops=1) Filter: (coverage && '4/0'::smoc) Rows Removed by Filter: 66 - Buffers: shared hit=114 -(4 rows) +(3 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=23 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/0-11'$$); + explain +----------------------------------------------------------------- + Seq Scan on moc100 (rows=1 width=341) (actual rows=23 loops=1) Filter: (coverage = '0/0-11'::smoc) Rows Removed by Filter: 78 - Buffers: shared hit=59 -(4 rows) +(3 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '6/43225,43227'$$); + explain +---------------------------------------------------------------- + Seq Scan on moc100 (rows=1 width=341) (actual rows=1 loops=1) Filter: (coverage = '6/43225 43227'::smoc) Rows Removed by Filter: 100 - Buffers: shared hit=59 -(4 rows) +(3 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/'$$); + explain +---------------------------------------------------------------- + Seq Scan on moc100 (rows=1 width=341) (actual rows=1 loops=1) Filter: (coverage = '0/'::smoc) Rows Removed by Filter: 100 - Buffers: shared hit=59 -(4 rows) +(3 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=78 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/0-11'$$); + explain +------------------------------------------------------------------- + Seq Scan on moc100 (rows=100 width=341) (actual rows=78 loops=1) Filter: (coverage <> '0/0-11'::smoc) Rows Removed by Filter: 23 - Buffers: shared hit=59 -(4 rows) +(3 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'$$); + explain +-------------------------------------------------------------------- + Seq Scan on moc100 (rows=100 width=341) (actual rows=100 loops=1) Filter: (coverage <> '6/43225 43227'::smoc) Rows Removed by Filter: 1 - Buffers: shared hit=59 -(4 rows) +(3 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/'$$); + explain +-------------------------------------------------------------------- + Seq Scan on moc100 (rows=100 width=341) (actual rows=100 loops=1) Filter: (coverage <> '0/'::smoc) Rows Removed by Filter: 1 - Buffers: shared hit=59 -(4 rows) +(3 rows) SET enable_seqscan = off; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=35 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage && '4/0'$$); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=1 width=341) (actual rows=35 loops=1) Recheck Cond: (coverage && '4/0'::smoc) Heap Blocks: exact=5 - Buffers: shared hit=85 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=35 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=1 width=0) (actual rows=35 loops=1) Index Cond: (coverage && '4/0'::smoc) - Buffers: shared hit=9 -(7 rows) +(5 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <@ '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=44.00..48.01 rows=1 width=96) (actual rows=1 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <@ '4/0'$$); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=1 width=341) (actual rows=1 loops=1) Recheck Cond: (coverage <@ '4/0'::smoc) Rows Removed by Index Recheck: 35 Heap Blocks: exact=5 - Buffers: shared hit=33 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..44.00 rows=1 width=0) (actual rows=36 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=1 width=0) (actual rows=36 loops=1) Index Cond: (coverage <@ '4/0'::smoc) - Buffers: shared hit=12 -(8 rows) +(6 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage @> '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=28 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage @> '4/0'$$); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=1 width=341) (actual rows=28 loops=1) Recheck Cond: (coverage @> '4/0'::smoc) Rows Removed by Index Recheck: 1 Heap Blocks: exact=4 - Buffers: shared hit=36 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=29 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=1 width=0) (actual rows=29 loops=1) Index Cond: (coverage @> '4/0'::smoc) - Buffers: shared hit=9 -(8 rows) +(6 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN ---------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98308.01..98312.02 rows=1 width=96) (actual rows=23 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/0-11'$$); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=1 width=341) (actual rows=23 loops=1) Recheck Cond: (coverage = '0/0-11'::smoc) Rows Removed by Index Recheck: 1 Heap Blocks: exact=2 - Buffers: shared hit=24581 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98308.01 rows=1 width=0) (actual rows=24 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=1 width=0) (actual rows=24 loops=1) Index Cond: (coverage = '0/0-11'::smoc) - Buffers: shared hit=24577 -(8 rows) +(6 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '6/43225,43227'$$); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=1 width=341) (actual rows=1 loops=1) Recheck Cond: (coverage = '6/43225 43227'::smoc) Rows Removed by Index Recheck: 28 Heap Blocks: exact=3 - Buffers: shared hit=12 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=29 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=1 width=0) (actual rows=29 loops=1) Index Cond: (coverage = '6/43225 43227'::smoc) - Buffers: shared hit=3 -(8 rows) +(6 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------ - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/'$$); + explain +------------------------------------------------------------------------------------------ + Bitmap Heap Scan on moc100 (rows=1 width=341) (actual rows=1 loops=1) Recheck Cond: (coverage = '0/'::smoc) Heap Blocks: exact=1 - Buffers: shared hit=5 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=1 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=1 width=0) (actual rows=1 loops=1) Index Cond: (coverage = '0/'::smoc) - Buffers: shared hit=4 -(7 rows) +(5 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=78 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/0-11'$$); + explain +---------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=100 width=341) (actual rows=78 loops=1) Recheck Cond: (coverage <> '0/0-11'::smoc) Rows Removed by Index Recheck: 23 Heap Blocks: exact=5 - Buffers: shared hit=24821 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=100 width=0) (actual rows=101 loops=1) Index Cond: (coverage <> '0/0-11'::smoc) - Buffers: shared hit=24762 -(8 rows) +(6 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'$$); + explain +---------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=100 width=341) (actual rows=100 loops=1) Recheck Cond: (coverage <> '6/43225 43227'::smoc) Rows Removed by Index Recheck: 1 Heap Blocks: exact=5 - Buffers: shared hit=247 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=100 width=0) (actual rows=101 loops=1) Index Cond: (coverage <> '6/43225 43227'::smoc) - Buffers: shared hit=188 -(8 rows) +(6 rows) -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/'$$); + explain +---------------------------------------------------------------------------------------------- + Bitmap Heap Scan on moc100 (rows=100 width=341) (actual rows=100 loops=1) Recheck Cond: (coverage <> '0/'::smoc) Rows Removed by Index Recheck: 1 Heap Blocks: exact=5 - Buffers: shared hit=245 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) + -> Bitmap Index Scan on moc100_coverage_idx (rows=100 width=0) (actual rows=101 loops=1) Index Cond: (coverage <> '0/'::smoc) - Buffers: shared hit=186 -(8 rows) +(6 rows) diff --git a/expected/moc100_1.out b/expected/moc100_1.out deleted file mode 100644 index c7d62557..00000000 --- a/expected/moc100_1.out +++ /dev/null @@ -1,263 +0,0 @@ -\set ECHO none - outputfile_for_majorversion ------------------------------ - 10, 11, 12 -(1 row) - - outputfile_for_arch_bits --------------------------- - 32-bit -(1 row) - -CREATE TABLE moc100 ( - ivoid text, - coverage smoc, - ref_system_name text -); -COPY moc100 FROM STDIN; -CREATE INDEX ON moc100 USING GIN (coverage); -SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; - ivoid ------------------------------------------- - ivo://byu.arvo/dfbsspec/q/getssa - ivo://cadc.nrc.ca/archive/cfht - ivo://cadc.nrc.ca/archive/hst - ivo://cds.vizier/b/assocdata - ivo://cds.vizier/b/swift - ivo://cds.vizier/i/241 - ivo://cds.vizier/iv/12 - ivo://cds.vizier/ix/13 - ivo://cds.vizier/j/a+a/316/147 - ivo://cds.vizier/j/a+as/105/311 - ivo://cds.vizier/j/a+as/122/235 - ivo://chivo/gaia/q/dr1 - ivo://chivo/openngc/q/data - ivo://cxc.harvard.edu/csc - ivo://irsa.ipac/2mass/catalog/psc - ivo://irsa.ipac/2mass/catalog/xsc - ivo://irsa.ipac/2mass/images/asky-ql - ivo://irsa.ipac/cosmos/images - ivo://irsa.ipac/iras/images/issa - ivo://irsa.ipac/mast/scrapbook - ivo://irsa.ipac/spitzer/images/swire - ivo://mssl.ucl.ac.uk/xmmsuss_dsa/xmmsuss - ivo://ned.ipac/sia - ivo://ned.ipac/tap - ivo://svo.cab/cat/gbs - ivo://svo.cab/cat/uves - ivo://svo.cab/cat/xshooter - ivo://vopdc.iap/fss - ivo://vopdc.obspm/imcce/m4ast - ivo://vopdc.obspm/imcce/miriade - ivo://vopdc.obspm/imcce/skybot - ivo://vopdc.obspm/lesia/bestars/besc - ivo://vopdc.obspm/lesia/bestars/bess - ivo://vopdc.obspm/luth/exoplanet - ivo://vopdc.obspm/luth/hess -(35 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '0/'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=0.00..4.01 rows=1 width=96) (actual rows=0 loops=1) - Recheck Cond: (coverage && '0/'::smoc) - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..0.00 rows=1 width=0) (actual rows=0 loops=1) - Index Cond: (coverage && '0/'::smoc) -(4 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=35 loops=1) - Filter: (coverage && '4/0'::smoc) - Rows Removed by Filter: 66 - Buffers: shared hit=115 -(4 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=23 loops=1) - Filter: (coverage = '0/0-11'::smoc) - Rows Removed by Filter: 78 - Buffers: shared hit=59 -(4 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '6/43225 43227'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 -(4 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '0/'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 -(4 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=78 loops=1) - Filter: (coverage <> '0/0-11'::smoc) - Rows Removed by Filter: 23 - Buffers: shared hit=59 -(4 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 -(4 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '0/'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 -(4 rows) - -SET enable_seqscan = off; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=35 loops=1) - Recheck Cond: (coverage && '4/0'::smoc) - Heap Blocks: exact=5 - Buffers: shared hit=86 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=35 loops=1) - Index Cond: (coverage && '4/0'::smoc) - Buffers: shared hit=9 -(7 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <@ '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=44.00..48.01 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage <@ '4/0'::smoc) - Rows Removed by Index Recheck: 35 - Heap Blocks: exact=5 - Buffers: shared hit=33 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..44.00 rows=1 width=0) (actual rows=36 loops=1) - Index Cond: (coverage <@ '4/0'::smoc) - Buffers: shared hit=12 -(8 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage @> '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=28 loops=1) - Recheck Cond: (coverage @> '4/0'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=4 - Buffers: shared hit=36 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage @> '4/0'::smoc) - Buffers: shared hit=9 -(8 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN ---------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98308.01..98312.02 rows=1 width=96) (actual rows=23 loops=1) - Recheck Cond: (coverage = '0/0-11'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=2 - Buffers: shared hit=24581 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98308.01 rows=1 width=0) (actual rows=24 loops=1) - Index Cond: (coverage = '0/0-11'::smoc) - Buffers: shared hit=24577 -(8 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 28 - Heap Blocks: exact=3 - Buffers: shared hit=12 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage = '6/43225 43227'::smoc) - Buffers: shared hit=3 -(8 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------ - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '0/'::smoc) - Heap Blocks: exact=1 - Buffers: shared hit=5 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=1 loops=1) - Index Cond: (coverage = '0/'::smoc) - Buffers: shared hit=4 -(7 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=78 loops=1) - Recheck Cond: (coverage <> '0/0-11'::smoc) - Rows Removed by Index Recheck: 23 - Heap Blocks: exact=5 - Buffers: shared hit=24804 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/0-11'::smoc) - Buffers: shared hit=24745 -(8 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=230 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '6/43225 43227'::smoc) - Buffers: shared hit=171 -(8 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '0/'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=228 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/'::smoc) - Buffers: shared hit=169 -(8 rows) - diff --git a/expected/moc100_2.out b/expected/moc100_2.out deleted file mode 100644 index 0f511a85..00000000 --- a/expected/moc100_2.out +++ /dev/null @@ -1,297 +0,0 @@ -\set ECHO none - outputfile_for_majorversion ------------------------------ - 13, 14, 15 -(1 row) - - outputfile_for_arch_bits --------------------------- - 64-bit -(1 row) - -CREATE TABLE moc100 ( - ivoid text, - coverage smoc, - ref_system_name text -); -COPY moc100 FROM STDIN; -CREATE INDEX ON moc100 USING GIN (coverage); -SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; - ivoid ------------------------------------------- - ivo://byu.arvo/dfbsspec/q/getssa - ivo://cadc.nrc.ca/archive/cfht - ivo://cadc.nrc.ca/archive/hst - ivo://cds.vizier/b/assocdata - ivo://cds.vizier/b/swift - ivo://cds.vizier/i/241 - ivo://cds.vizier/iv/12 - ivo://cds.vizier/ix/13 - ivo://cds.vizier/j/a+a/316/147 - ivo://cds.vizier/j/a+as/105/311 - ivo://cds.vizier/j/a+as/122/235 - ivo://chivo/gaia/q/dr1 - ivo://chivo/openngc/q/data - ivo://cxc.harvard.edu/csc - ivo://irsa.ipac/2mass/catalog/psc - ivo://irsa.ipac/2mass/catalog/xsc - ivo://irsa.ipac/2mass/images/asky-ql - ivo://irsa.ipac/cosmos/images - ivo://irsa.ipac/iras/images/issa - ivo://irsa.ipac/mast/scrapbook - ivo://irsa.ipac/spitzer/images/swire - ivo://mssl.ucl.ac.uk/xmmsuss_dsa/xmmsuss - ivo://ned.ipac/sia - ivo://ned.ipac/tap - ivo://svo.cab/cat/gbs - ivo://svo.cab/cat/uves - ivo://svo.cab/cat/xshooter - ivo://vopdc.iap/fss - ivo://vopdc.obspm/imcce/m4ast - ivo://vopdc.obspm/imcce/miriade - ivo://vopdc.obspm/imcce/skybot - ivo://vopdc.obspm/lesia/bestars/besc - ivo://vopdc.obspm/lesia/bestars/bess - ivo://vopdc.obspm/luth/exoplanet - ivo://vopdc.obspm/luth/hess -(35 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '0/'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=0.00..4.01 rows=1 width=96) (actual rows=0 loops=1) - Recheck Cond: (coverage && '0/'::smoc) - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..0.00 rows=1 width=0) (actual rows=0 loops=1) - Index Cond: (coverage && '0/'::smoc) - Planning: - Buffers: shared hit=5 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=35 loops=1) - Filter: (coverage && '4/0'::smoc) - Rows Removed by Filter: 66 - Buffers: shared hit=114 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=23 loops=1) - Filter: (coverage = '0/0-11'::smoc) - Rows Removed by Filter: 78 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '6/43225 43227'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '0/'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=78 loops=1) - Filter: (coverage <> '0/0-11'::smoc) - Rows Removed by Filter: 23 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '0/'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -SET enable_seqscan = off; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=35 loops=1) - Recheck Cond: (coverage && '4/0'::smoc) - Heap Blocks: exact=5 - Buffers: shared hit=85 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=35 loops=1) - Index Cond: (coverage && '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <@ '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=44.00..48.01 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage <@ '4/0'::smoc) - Rows Removed by Index Recheck: 35 - Heap Blocks: exact=5 - Buffers: shared hit=33 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..44.00 rows=1 width=0) (actual rows=36 loops=1) - Index Cond: (coverage <@ '4/0'::smoc) - Buffers: shared hit=12 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage @> '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=28 loops=1) - Recheck Cond: (coverage @> '4/0'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=4 - Buffers: shared hit=36 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage @> '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN ---------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98308.01..98312.02 rows=1 width=96) (actual rows=23 loops=1) - Recheck Cond: (coverage = '0/0-11'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=2 - Buffers: shared hit=24581 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98308.01 rows=1 width=0) (actual rows=24 loops=1) - Index Cond: (coverage = '0/0-11'::smoc) - Buffers: shared hit=24577 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 28 - Heap Blocks: exact=3 - Buffers: shared hit=12 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage = '6/43225 43227'::smoc) - Buffers: shared hit=3 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------ - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '0/'::smoc) - Heap Blocks: exact=1 - Buffers: shared hit=5 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=1 loops=1) - Index Cond: (coverage = '0/'::smoc) - Buffers: shared hit=4 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=78 loops=1) - Recheck Cond: (coverage <> '0/0-11'::smoc) - Rows Removed by Index Recheck: 23 - Heap Blocks: exact=5 - Buffers: shared hit=24821 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/0-11'::smoc) - Buffers: shared hit=24762 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=247 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '6/43225 43227'::smoc) - Buffers: shared hit=188 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '0/'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=245 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/'::smoc) - Buffers: shared hit=186 - Planning: - Buffers: shared hit=1 -(10 rows) - diff --git a/expected/moc100_3.out b/expected/moc100_3.out deleted file mode 100644 index c650501b..00000000 --- a/expected/moc100_3.out +++ /dev/null @@ -1,297 +0,0 @@ -\set ECHO none - outputfile_for_majorversion ------------------------------ - 13, 14, 15 -(1 row) - - outputfile_for_arch_bits --------------------------- - 32-bit -(1 row) - -CREATE TABLE moc100 ( - ivoid text, - coverage smoc, - ref_system_name text -); -COPY moc100 FROM STDIN; -CREATE INDEX ON moc100 USING GIN (coverage); -SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; - ivoid ------------------------------------------- - ivo://byu.arvo/dfbsspec/q/getssa - ivo://cadc.nrc.ca/archive/cfht - ivo://cadc.nrc.ca/archive/hst - ivo://cds.vizier/b/assocdata - ivo://cds.vizier/b/swift - ivo://cds.vizier/i/241 - ivo://cds.vizier/iv/12 - ivo://cds.vizier/ix/13 - ivo://cds.vizier/j/a+a/316/147 - ivo://cds.vizier/j/a+as/105/311 - ivo://cds.vizier/j/a+as/122/235 - ivo://chivo/gaia/q/dr1 - ivo://chivo/openngc/q/data - ivo://cxc.harvard.edu/csc - ivo://irsa.ipac/2mass/catalog/psc - ivo://irsa.ipac/2mass/catalog/xsc - ivo://irsa.ipac/2mass/images/asky-ql - ivo://irsa.ipac/cosmos/images - ivo://irsa.ipac/iras/images/issa - ivo://irsa.ipac/mast/scrapbook - ivo://irsa.ipac/spitzer/images/swire - ivo://mssl.ucl.ac.uk/xmmsuss_dsa/xmmsuss - ivo://ned.ipac/sia - ivo://ned.ipac/tap - ivo://svo.cab/cat/gbs - ivo://svo.cab/cat/uves - ivo://svo.cab/cat/xshooter - ivo://vopdc.iap/fss - ivo://vopdc.obspm/imcce/m4ast - ivo://vopdc.obspm/imcce/miriade - ivo://vopdc.obspm/imcce/skybot - ivo://vopdc.obspm/lesia/bestars/besc - ivo://vopdc.obspm/lesia/bestars/bess - ivo://vopdc.obspm/luth/exoplanet - ivo://vopdc.obspm/luth/hess -(35 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '0/'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=0.00..4.01 rows=1 width=96) (actual rows=0 loops=1) - Recheck Cond: (coverage && '0/'::smoc) - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..0.00 rows=1 width=0) (actual rows=0 loops=1) - Index Cond: (coverage && '0/'::smoc) - Planning: - Buffers: shared hit=5 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=35 loops=1) - Filter: (coverage && '4/0'::smoc) - Rows Removed by Filter: 66 - Buffers: shared hit=115 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=23 loops=1) - Filter: (coverage = '0/0-11'::smoc) - Rows Removed by Filter: 78 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '6/43225 43227'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '0/'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=78 loops=1) - Filter: (coverage <> '0/0-11'::smoc) - Rows Removed by Filter: 23 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '0/'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -SET enable_seqscan = off; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=35 loops=1) - Recheck Cond: (coverage && '4/0'::smoc) - Heap Blocks: exact=5 - Buffers: shared hit=86 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=35 loops=1) - Index Cond: (coverage && '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <@ '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=44.00..48.01 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage <@ '4/0'::smoc) - Rows Removed by Index Recheck: 35 - Heap Blocks: exact=5 - Buffers: shared hit=33 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..44.00 rows=1 width=0) (actual rows=36 loops=1) - Index Cond: (coverage <@ '4/0'::smoc) - Buffers: shared hit=12 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage @> '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=36.00..40.01 rows=1 width=96) (actual rows=28 loops=1) - Recheck Cond: (coverage @> '4/0'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=4 - Buffers: shared hit=36 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..36.00 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage @> '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN ---------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98308.01..98312.02 rows=1 width=96) (actual rows=23 loops=1) - Recheck Cond: (coverage = '0/0-11'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=2 - Buffers: shared hit=24581 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98308.01 rows=1 width=0) (actual rows=24 loops=1) - Index Cond: (coverage = '0/0-11'::smoc) - Buffers: shared hit=24577 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 28 - Heap Blocks: exact=3 - Buffers: shared hit=12 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage = '6/43225 43227'::smoc) - Buffers: shared hit=3 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------ - Bitmap Heap Scan on moc100 (cost=12.01..16.02 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '0/'::smoc) - Heap Blocks: exact=1 - Buffers: shared hit=5 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.01 rows=1 width=0) (actual rows=1 loops=1) - Index Cond: (coverage = '0/'::smoc) - Buffers: shared hit=4 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=78 loops=1) - Recheck Cond: (coverage <> '0/0-11'::smoc) - Rows Removed by Index Recheck: 23 - Heap Blocks: exact=5 - Buffers: shared hit=24804 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/0-11'::smoc) - Buffers: shared hit=24745 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=230 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '6/43225 43227'::smoc) - Buffers: shared hit=171 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '0/'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=228 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/'::smoc) - Buffers: shared hit=169 - Planning: - Buffers: shared hit=1 -(10 rows) - diff --git a/expected/moc100_4.out b/expected/moc100_4.out deleted file mode 100644 index 0dc26bd4..00000000 --- a/expected/moc100_4.out +++ /dev/null @@ -1,309 +0,0 @@ -\set ECHO none - outputfile_for_majorversion ------------------------------ - 16+ -(1 row) - - outputfile_for_arch_bits --------------------------- - 64-bit -(1 row) - -CREATE TABLE moc100 ( - ivoid text, - coverage smoc, - ref_system_name text -); -COPY moc100 FROM STDIN; -CREATE INDEX ON moc100 USING GIN (coverage); -SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; - ivoid ------------------------------------------- - ivo://byu.arvo/dfbsspec/q/getssa - ivo://cadc.nrc.ca/archive/cfht - ivo://cadc.nrc.ca/archive/hst - ivo://cds.vizier/b/assocdata - ivo://cds.vizier/b/swift - ivo://cds.vizier/i/241 - ivo://cds.vizier/iv/12 - ivo://cds.vizier/ix/13 - ivo://cds.vizier/j/a+a/316/147 - ivo://cds.vizier/j/a+as/105/311 - ivo://cds.vizier/j/a+as/122/235 - ivo://chivo/gaia/q/dr1 - ivo://chivo/openngc/q/data - ivo://cxc.harvard.edu/csc - ivo://irsa.ipac/2mass/catalog/psc - ivo://irsa.ipac/2mass/catalog/xsc - ivo://irsa.ipac/2mass/images/asky-ql - ivo://irsa.ipac/cosmos/images - ivo://irsa.ipac/iras/images/issa - ivo://irsa.ipac/mast/scrapbook - ivo://irsa.ipac/spitzer/images/swire - ivo://mssl.ucl.ac.uk/xmmsuss_dsa/xmmsuss - ivo://ned.ipac/sia - ivo://ned.ipac/tap - ivo://svo.cab/cat/gbs - ivo://svo.cab/cat/uves - ivo://svo.cab/cat/xshooter - ivo://vopdc.iap/fss - ivo://vopdc.obspm/imcce/m4ast - ivo://vopdc.obspm/imcce/miriade - ivo://vopdc.obspm/imcce/skybot - ivo://vopdc.obspm/lesia/bestars/besc - ivo://vopdc.obspm/lesia/bestars/bess - ivo://vopdc.obspm/luth/exoplanet - ivo://vopdc.obspm/luth/hess -(35 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '0/'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=0.00..4.01 rows=1 width=96) (actual rows=0 loops=1) - Recheck Cond: (coverage && '0/'::smoc) - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..0.00 rows=1 width=0) (actual rows=0 loops=1) - Index Cond: (coverage && '0/'::smoc) - Planning: - Buffers: shared hit=5 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..7.26 rows=1 width=96) (actual rows=35 loops=1) - Filter: (coverage && '4/0'::smoc) - Rows Removed by Filter: 66 - Buffers: shared hit=115 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..7.26 rows=1 width=96) (actual rows=23 loops=1) - Filter: (coverage = '0/0-11'::smoc) - Rows Removed by Filter: 78 - Buffers: shared hit=60 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..7.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '6/43225 43227'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=60 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..7.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '0/'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=60 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..7.26 rows=100 width=96) (actual rows=78 loops=1) - Filter: (coverage <> '0/0-11'::smoc) - Rows Removed by Filter: 23 - Buffers: shared hit=60 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..7.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=60 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..7.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '0/'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=60 - Planning: - Buffers: shared hit=1 -(6 rows) - -SET enable_seqscan = off; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=38.92..42.93 rows=1 width=96) (actual rows=35 loops=1) - Recheck Cond: (coverage && '4/0'::smoc) - Heap Blocks: exact=5 - Buffers: shared hit=85 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..38.92 rows=1 width=0) (actual rows=35 loops=1) - Index Cond: (coverage && '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <@ '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=47.61..51.63 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage <@ '4/0'::smoc) - Rows Removed by Index Recheck: 35 - Heap Blocks: exact=5 - Buffers: shared hit=33 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..47.61 rows=1 width=0) (actual rows=36 loops=1) - Index Cond: (coverage <@ '4/0'::smoc) - Buffers: shared hit=12 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage @> '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=38.92..42.93 rows=1 width=96) (actual rows=28 loops=1) - Recheck Cond: (coverage @> '4/0'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=4 - Buffers: shared hit=36 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..38.92 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage @> '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106879.01..106883.02 rows=1 width=96) (actual rows=23 loops=1) - Recheck Cond: (coverage = '0/0-11'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=2 - Buffers: shared hit=24581 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106879.01 rows=1 width=0) (actual rows=24 loops=1) - Index Cond: (coverage = '0/0-11'::smoc) - Buffers: shared hit=24577 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=12.83..16.84 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 28 - Heap Blocks: exact=3 - Buffers: shared hit=12 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.83 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage = '6/43225 43227'::smoc) - Buffers: shared hit=3 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------ - Bitmap Heap Scan on moc100 (cost=12.83..16.84 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '0/'::smoc) - Heap Blocks: exact=1 - Buffers: shared hit=5 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.83 rows=1 width=0) (actual rows=1 loops=1) - Index Cond: (coverage = '0/'::smoc) - Buffers: shared hit=4 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106888.23..106895.48 rows=100 width=96) (actual rows=78 loops=1) - Recheck Cond: (coverage <> '0/0-11'::smoc) - Rows Removed by Index Recheck: 23 - Heap Blocks: exact=5 - Buffers: shared hit=24821 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106888.20 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/0-11'::smoc) - Buffers: shared hit=24762 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106888.23..106895.48 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=247 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106888.20 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '6/43225 43227'::smoc) - Buffers: shared hit=188 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106888.23..106895.48 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '0/'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=245 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106888.20 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/'::smoc) - Buffers: shared hit=186 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - diff --git a/expected/moc100_5.out b/expected/moc100_5.out deleted file mode 100644 index 3fb98a43..00000000 --- a/expected/moc100_5.out +++ /dev/null @@ -1,309 +0,0 @@ -\set ECHO none - outputfile_for_majorversion ------------------------------ - 16+ -(1 row) - - outputfile_for_arch_bits --------------------------- - 32-bit -(1 row) - -CREATE TABLE moc100 ( - ivoid text, - coverage smoc, - ref_system_name text -); -COPY moc100 FROM STDIN; -CREATE INDEX ON moc100 USING GIN (coverage); -SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; - ivoid ------------------------------------------- - ivo://byu.arvo/dfbsspec/q/getssa - ivo://cadc.nrc.ca/archive/cfht - ivo://cadc.nrc.ca/archive/hst - ivo://cds.vizier/b/assocdata - ivo://cds.vizier/b/swift - ivo://cds.vizier/i/241 - ivo://cds.vizier/iv/12 - ivo://cds.vizier/ix/13 - ivo://cds.vizier/j/a+a/316/147 - ivo://cds.vizier/j/a+as/105/311 - ivo://cds.vizier/j/a+as/122/235 - ivo://chivo/gaia/q/dr1 - ivo://chivo/openngc/q/data - ivo://cxc.harvard.edu/csc - ivo://irsa.ipac/2mass/catalog/psc - ivo://irsa.ipac/2mass/catalog/xsc - ivo://irsa.ipac/2mass/images/asky-ql - ivo://irsa.ipac/cosmos/images - ivo://irsa.ipac/iras/images/issa - ivo://irsa.ipac/mast/scrapbook - ivo://irsa.ipac/spitzer/images/swire - ivo://mssl.ucl.ac.uk/xmmsuss_dsa/xmmsuss - ivo://ned.ipac/sia - ivo://ned.ipac/tap - ivo://svo.cab/cat/gbs - ivo://svo.cab/cat/uves - ivo://svo.cab/cat/xshooter - ivo://vopdc.iap/fss - ivo://vopdc.obspm/imcce/m4ast - ivo://vopdc.obspm/imcce/miriade - ivo://vopdc.obspm/imcce/skybot - ivo://vopdc.obspm/lesia/bestars/besc - ivo://vopdc.obspm/lesia/bestars/bess - ivo://vopdc.obspm/luth/exoplanet - ivo://vopdc.obspm/luth/hess -(35 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '0/'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=0.00..4.01 rows=1 width=96) (actual rows=0 loops=1) - Recheck Cond: (coverage && '0/'::smoc) - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..0.00 rows=1 width=0) (actual rows=0 loops=1) - Index Cond: (coverage && '0/'::smoc) - Planning: - Buffers: shared hit=5 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=35 loops=1) - Filter: (coverage && '4/0'::smoc) - Rows Removed by Filter: 66 - Buffers: shared hit=115 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN --------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=23 loops=1) - Filter: (coverage = '0/0-11'::smoc) - Rows Removed by Filter: 78 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '6/43225 43227'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN -------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=1 loops=1) - Filter: (coverage = '0/'::smoc) - Rows Removed by Filter: 100 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------- - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=78 loops=1) - Filter: (coverage <> '0/0-11'::smoc) - Rows Removed by Filter: 23 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=4 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN ------------------------------------------------------------------------------------ - Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1) - Filter: (coverage <> '0/'::smoc) - Rows Removed by Filter: 1 - Buffers: shared hit=59 - Planning: - Buffers: shared hit=1 -(6 rows) - -SET enable_seqscan = off; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=38.92..42.93 rows=1 width=96) (actual rows=35 loops=1) - Recheck Cond: (coverage && '4/0'::smoc) - Heap Blocks: exact=5 - Buffers: shared hit=86 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..38.92 rows=1 width=0) (actual rows=35 loops=1) - Index Cond: (coverage && '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <@ '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=47.61..51.63 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage <@ '4/0'::smoc) - Rows Removed by Index Recheck: 35 - Heap Blocks: exact=5 - Buffers: shared hit=33 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..47.61 rows=1 width=0) (actual rows=36 loops=1) - Index Cond: (coverage <@ '4/0'::smoc) - Buffers: shared hit=12 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage @> '4/0'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=38.92..42.93 rows=1 width=96) (actual rows=28 loops=1) - Recheck Cond: (coverage @> '4/0'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=4 - Buffers: shared hit=36 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..38.92 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage @> '4/0'::smoc) - Buffers: shared hit=9 - Planning: - Buffers: shared hit=4 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106879.01..106883.02 rows=1 width=96) (actual rows=23 loops=1) - Recheck Cond: (coverage = '0/0-11'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=2 - Buffers: shared hit=24581 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106879.01 rows=1 width=0) (actual rows=24 loops=1) - Index Cond: (coverage = '0/0-11'::smoc) - Buffers: shared hit=24577 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=12.83..16.84 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 28 - Heap Blocks: exact=3 - Buffers: shared hit=12 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.83 rows=1 width=0) (actual rows=29 loops=1) - Index Cond: (coverage = '6/43225 43227'::smoc) - Buffers: shared hit=3 - Planning: - Buffers: shared hit=1 -(10 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------ - Bitmap Heap Scan on moc100 (cost=12.83..16.84 rows=1 width=96) (actual rows=1 loops=1) - Recheck Cond: (coverage = '0/'::smoc) - Heap Blocks: exact=1 - Buffers: shared hit=5 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..12.83 rows=1 width=0) (actual rows=1 loops=1) - Index Cond: (coverage = '0/'::smoc) - Buffers: shared hit=4 - Planning: - Buffers: shared hit=1 -(9 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106888.23..106894.48 rows=100 width=96) (actual rows=78 loops=1) - Recheck Cond: (coverage <> '0/0-11'::smoc) - Rows Removed by Index Recheck: 23 - Heap Blocks: exact=5 - Buffers: shared hit=24804 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106888.20 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/0-11'::smoc) - Buffers: shared hit=24745 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106888.23..106894.48 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '6/43225 43227'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=230 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106888.20 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '6/43225 43227'::smoc) - Buffers: shared hit=171 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------- - Bitmap Heap Scan on moc100 (cost=106888.23..106894.48 rows=100 width=96) (actual rows=100 loops=1) - Recheck Cond: (coverage <> '0/'::smoc) - Rows Removed by Index Recheck: 1 - Heap Blocks: exact=5 - Buffers: shared hit=228 - -> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..106888.20 rows=100 width=0) (actual rows=101 loops=1) - Index Cond: (coverage <> '0/'::smoc) - Buffers: shared hit=169 - Planning: - Buffers: shared hit=1 - JIT: - Functions: 2 - Options: Inlining false, Optimization false, Expressions true, Deforming true -(13 rows) - diff --git a/expected/moc_options.out b/expected/moc_options.out new file mode 100644 index 00000000..2342b79a --- /dev/null +++ b/expected/moc_options.out @@ -0,0 +1,40 @@ +create table moc_opt (m smoc); +insert into moc_opt select format('9/%s', i)::smoc from generate_series(1, 1000) g(i); +analyze moc_opt; +create index moc_opt5 on moc_opt using gin (m); +explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; + QUERY PLAN +--------------------------------------------------------------- + Bitmap Heap Scan on moc_opt (actual rows=1 loops=1) + Recheck Cond: (m && '9/1'::smoc) + Rows Removed by Index Recheck: 254 + Heap Blocks: exact=4 + -> Bitmap Index Scan on moc_opt5 (actual rows=255 loops=1) + Index Cond: (m && '9/1'::smoc) +(6 rows) + +drop index moc_opt5; +create index moc_opt8 on moc_opt using gin (m smoc_gin_ops_fine); +explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; + QUERY PLAN +------------------------------------------------------------- + Bitmap Heap Scan on moc_opt (actual rows=1 loops=1) + Recheck Cond: (m && '9/1'::smoc) + Rows Removed by Index Recheck: 2 + Heap Blocks: exact=1 + -> Bitmap Index Scan on moc_opt8 (actual rows=3 loops=1) + Index Cond: (m && '9/1'::smoc) +(6 rows) + +drop index moc_opt8; +create index moc_opt9 on moc_opt using gin (m smoc_gin_ops (order = 9)); +explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; + QUERY PLAN +------------------------------------------------------------- + Bitmap Heap Scan on moc_opt (actual rows=1 loops=1) + Recheck Cond: (m && '9/1'::smoc) + Heap Blocks: exact=1 + -> Bitmap Index Scan on moc_opt9 (actual rows=1 loops=1) + Index Cond: (m && '9/1'::smoc) +(5 rows) + diff --git a/expected/output_precision.out b/expected/output_precision.out new file mode 100644 index 00000000..9109c4bf --- /dev/null +++ b/expected/output_precision.out @@ -0,0 +1,212 @@ +-- +-- Test default and custom output precisions for double values. +-- +SELECT set_sphere_output( 'RAD' ); + set_sphere_output +------------------- + SET RAD +(1 row) + +-- +-- Check default precision +-- +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +-- +-- Check option extra_float_digits +-- +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +----------------------------- + (0.272707696 , 0.018180513) +(1 row) + +SET extra_float_digits TO -2; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------------- + (0.2727076956241 , 0.01818051304161) +(1 row) + +SET extra_float_digits TO 0; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SET extra_float_digits TO 1; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SET extra_float_digits TO 2; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +---------------------------------------------- + (0.27270769562411401 , 0.018180513041607602) +(1 row) + +SET extra_float_digits TO 3; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +----------------------------------------------- + (0.27270769562411401 , 0.0181805130416076016) +(1 row) + +SET extra_float_digits TO 6; +ERROR: 6 is outside the valid range for parameter "extra_float_digits" (-15 .. 3) +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +----------------------------------------------- + (0.27270769562411401 , 0.0181805130416076016) +(1 row) + +-- +-- Check compatibility behaviour +-- +SELECT set_sphere_output_precision(10); + set_sphere_output_precision +----------------------------- + SET 10 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +SELECT set_sphere_output_precision(12); + set_sphere_output_precision +----------------------------- + SET 12 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------ + (0.272707695624 , 0.0181805130416) +(1 row) + +SELECT set_sphere_output_precision(15); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(17); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(20); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(0); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(-3); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +-- +-- Check extra_float_digits after set_sphere_output_precision. +-- The change of extra_float_digits should not affect the precision of pgsphere +-- output because set_sphere_output_precision enables compatibility mode. +-- +SELECT set_sphere_output_precision(10); + set_sphere_output_precision +----------------------------- + SET 10 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +SET extra_float_digits TO -10; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +-- +-- Check reset_sphere_output_precision. +-- It should disable compatibility mode - extra_float_digits should work. +-- +SELECT reset_sphere_output_precision(); + reset_sphere_output_precision +------------------------------- + RESET +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +---------------------- + (0.27271 , 0.018181) +(1 row) + +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +----------------------------- + (0.272707696 , 0.018180513) +(1 row) + diff --git a/expected/output_precision_1.out b/expected/output_precision_1.out new file mode 100644 index 00000000..02ca5218 --- /dev/null +++ b/expected/output_precision_1.out @@ -0,0 +1,212 @@ +-- +-- Test default and custom output precisions for double values. +-- +SELECT set_sphere_output( 'RAD' ); + set_sphere_output +------------------- + SET RAD +(1 row) + +-- +-- Check default precision +-- +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +-- +-- Check option extra_float_digits +-- +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +----------------------------- + (0.272707696 , 0.018180513) +(1 row) + +SET extra_float_digits TO -2; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------------- + (0.2727076956241 , 0.01818051304161) +(1 row) + +SET extra_float_digits TO 0; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SET extra_float_digits TO 1; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SET extra_float_digits TO 2; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SET extra_float_digits TO 3; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SET extra_float_digits TO 6; +ERROR: 6 is outside the valid range for parameter "extra_float_digits" (-15 .. 3) +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +-- +-- Check compatibility behaviour +-- +SELECT set_sphere_output_precision(10); + set_sphere_output_precision +----------------------------- + SET 10 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +SELECT set_sphere_output_precision(12); + set_sphere_output_precision +----------------------------- + SET 12 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------ + (0.272707695624 , 0.0181805130416) +(1 row) + +SELECT set_sphere_output_precision(15); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(17); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(20); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(0); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +SELECT set_sphere_output_precision(-3); + set_sphere_output_precision +----------------------------- + SET 15 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +------------------------------------------ + (0.272707695624114 , 0.0181805130416076) +(1 row) + +-- +-- Check extra_float_digits after set_sphere_output_precision. +-- The change of extra_float_digits should not affect the precision of pgsphere +-- output because set_sphere_output_precision enables compatibility mode. +-- +SELECT set_sphere_output_precision(10); + set_sphere_output_precision +----------------------------- + SET 10 +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +SET extra_float_digits TO -10; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +-------------------------------- + (0.2727076956 , 0.01818051304) +(1 row) + +-- +-- Check reset_sphere_output_precision. +-- It should disable compatibility mode - extra_float_digits should work. +-- +SELECT reset_sphere_output_precision(); + reset_sphere_output_precision +------------------------------- + RESET +(1 row) + +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +---------------------- + (0.27271 , 0.018181) +(1 row) + +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + spoint +----------------------------- + (0.272707696 , 0.018180513) +(1 row) + diff --git a/expected/pg_sphere.out b/expected/pg_sphere.out deleted file mode 100644 index 1a1b3340..00000000 --- a/expected/pg_sphere.out +++ /dev/null @@ -1,2484 +0,0 @@ --- --- first, define the datatype. Turn off echoing so that expected file --- does not depend on contents of pg_sphere.sql. --- -\set ECHO none -psql:pgs_types.sql:23: NOTICE: TypeCreate: changing argument type of function spoint_out from OPAQUE to spoint -psql:pgs_types.sql:23: NOTICE: TypeCreate: changing return type of function spoint_in from OPAQUE to spoint -psql:pgs_types.sql:46: NOTICE: TypeCreate: changing argument type of function scircle_out from OPAQUE to scircle -psql:pgs_types.sql:46: NOTICE: TypeCreate: changing return type of function scircle_in from OPAQUE to scircle -psql:pgs_types.sql:69: NOTICE: TypeCreate: changing argument type of function sellipse_out from OPAQUE to sellipse -psql:pgs_types.sql:69: NOTICE: TypeCreate: changing return type of function sellipse_in from OPAQUE to sellipse -psql:pgs_types.sql:93: NOTICE: TypeCreate: changing argument type of function sline_out from OPAQUE to sline -psql:pgs_types.sql:93: NOTICE: TypeCreate: changing return type of function sline_in from OPAQUE to sline -psql:pgs_types.sql:118: NOTICE: TypeCreate: changing argument type of function spath_out from OPAQUE to spath -psql:pgs_types.sql:118: NOTICE: TypeCreate: changing return type of function spath_in from OPAQUE to spath -psql:pgs_types.sql:142: NOTICE: TypeCreate: changing argument type of function spoly_out from OPAQUE to spoly -psql:pgs_types.sql:142: NOTICE: TypeCreate: changing return type of function spoly_in from OPAQUE to spoly -psql:pgs_types.sql:166: NOTICE: TypeCreate: changing argument type of function strans_out from OPAQUE to strans -psql:pgs_types.sql:166: NOTICE: TypeCreate: changing return type of function strans_in from OPAQUE to strans -psql:pgs_gist.sql:22: NOTICE: TypeCreate: changing argument type of function spherekey_out from OPAQUE to spherekey -psql:pgs_gist.sql:22: NOTICE: TypeCreate: changing return type of function spherekey_in from OPAQUE to spherekey --- check spherical point operators -SELECT spoint '(0, 90d)' = spoint '(0, 90d)'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(0, 90d)' = spoint '(0,-90d)'; - ?column? ----------- - f -(1 row) - -SELECT spoint '(0,-90d)' = spoint '(0,-90d)'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(0, 90d)' != spoint '(0, 90d)'; - ?column? ----------- - f -(1 row) - -SELECT spoint '(0, 90d)' != spoint '(0,-90d)'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(0,-90d)' != spoint '(0,-90d)'; - ?column? ----------- - f -(1 row) - -SELECT spoint '(0d, 0)' = spoint '(360d,0)'; - ?column? ----------- - t -(1 row) - --- checking spherical circle operators -SELECT scircle '<(0, 90d),1>' = '<(0, 90d),1>' ; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(0,-90d),1>' <> '<(0, 90d),1>' ; - ?column? ----------- - t -(1 row) - --- checking spherical line operators -SELECT sline ( spoint '(0, 90d)', spoint '(0, -89d)' ) = - sline ( spoint '(0, 90d)', spoint '(0, -89d)' ) ; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0, 90d)', spoint '(0, -89d)' ) <> - sline ( spoint '(0, -89d)', spoint '(0, 90d)' ) ; - ?column? ----------- - t -(1 row) - --- checking Euler transformation operators -SELECT strans '-10d,0d,10d,ZZZ' = '-10d,0d,10d,XXX' ; - ?column? ----------- - t -(1 row) - -SELECT strans '-40d,0d,40d,ZZZ' <> '-40d,0d,40d,XXX' ; - ?column? ----------- - f -(1 row) - --- checking polygon operators -\set poly 'spoly \'{(0.1,0),(0.2,0),(0.2,0.1),(0.3,0.1),(0.3,-0.1),(0.4,-0.1),(0.5,0.1),(0.4,0.2),(0.1,0.2)}\'' -SELECT spoint '(0.15,0.10)' @ :poly; -- point inside polygon - ?column? ----------- - t -(1 row) - -SELECT spoint '(0.20,0.00)' @ :poly; -- point contained polygon - ?column? ----------- - t -(1 row) - -SELECT spoint '(0.10,0.10)' @ :poly; -- point contained polygon - ?column? ----------- - t -(1 row) - -SELECT spoint '(0.25,0.50)' @ :poly; -- point outside polygon - ?column? ----------- - f -(1 row) - -SELECT spoint '(0.25,0.00)' @ :poly; -- point outside polygon - ?column? ----------- - f -(1 row) - -SELECT scircle '<(0.15,0.10),0.03>' @ :poly; -- circle inside polygon - ?column? ----------- - t -(1 row) - -SELECT scircle '<(0.20,0.00),0.00>' @ :poly; -- circle contained polygon - ?column? ----------- - t -(1 row) - -SELECT scircle '<(0.20,0.30),0.05>' @ :poly; -- circle outside polygon - ?column? ----------- - f -(1 row) - -SELECT scircle '<(0.25,0.00),0.05>' @ :poly; -- circle overlaps polygon - ?column? ----------- - f -(1 row) - -SELECT scircle '<(0.25,0.00),0.10>' @ :poly; -- circle overlaps polygon - ?column? ----------- - f -(1 row) - -SELECT scircle '<(0.15,0.10),0.03>' && :poly; -- circle inside polygon - ?column? ----------- - t -(1 row) - -SELECT scircle '<(0.20,0.00),0.00>' && :poly; -- circle contained polygon - ?column? ----------- - t -(1 row) - -SELECT scircle '<(0.20,0.30),0.05>' && :poly; -- circle outside polygon - ?column? ----------- - f -(1 row) - -SELECT scircle '<(0.25,0.00),0.05>' && :poly; -- circle overlaps polygon - ?column? ----------- - t -(1 row) - -SELECT scircle '<(0.25,0.00),0.10>' && :poly; -- circle overlaps polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) @ :poly; -- line touches polygon - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) @ :poly; -- line touches polygon - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(0.50, 0.00)', spoint '(0.50,0.20)' ) @ :poly; -- line touches polygon - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) @ :poly; -- line touches and inside polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.45,-0.20)', spoint '(0.45,0.20)' ) @ :poly; -- line overlaps polygon - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(0.45, 0.10)', spoint '(0.45,0.20)' ) @ :poly; -- line overlaps polygon - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(0.24, 0.17)', spoint '(0.25,0.14)' ) @ :poly; -- line inside polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) && :poly; -- line touches polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) && :poly; -- line touches polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.50, 0.00)', spoint '(0.50,0.20)' ) && :poly; -- line touches polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) && :poly; -- line touches and inside polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.45,-0.20)', spoint '(0.45,0.20)' ) && :poly; -- line overlaps polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.45, 0.10)', spoint '(0.45,0.20)' ) && :poly; -- line overlaps polygon - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(0.24, 0.17)', spoint '(0.25,0.14)' ) && :poly; -- line inside polygon - ?column? ----------- - t -(1 row) - -\unset poly -\set poly1 'spoly \'{(0,0),(1,0),(0,1)}\'' -\set poly2 'spoly \'{(1,0),(0,0),(0,1)}\'' -\set poly3 'spoly \'{(0,1),(0,0),(1,0)}\'' -\set poly4 'spoly \'{(0.1,0.9),(0.1,0.1),(0.9,0.1)}\'' -\set poly5 'spoly \'{(0.2,0.0),(1.2,0.0),(0.2,1)}\'' -SELECT :poly1 = :poly2; - ?column? ----------- - f -(1 row) - -SELECT :poly2 = :poly3; - ?column? ----------- - f -(1 row) - -SELECT :poly3 = :poly1; - ?column? ----------- - t -(1 row) - -SELECT :poly1 && :poly2; - ?column? ----------- - t -(1 row) - -SELECT :poly2 && :poly3; - ?column? ----------- - t -(1 row) - -SELECT :poly3 && :poly1; - ?column? ----------- - t -(1 row) - -SELECT :poly1 @ :poly2; - ?column? ----------- - t -(1 row) - -SELECT :poly2 @ :poly3; - ?column? ----------- - t -(1 row) - -SELECT :poly3 @ :poly1; - ?column? ----------- - t -(1 row) - -SELECT :poly1 @ :poly4; - ?column? ----------- - f -(1 row) - -SELECT :poly4 @ :poly1; - ?column? ----------- - t -(1 row) - -SELECT :poly1 && :poly4; - ?column? ----------- - t -(1 row) - -SELECT :poly4 && :poly1; - ?column? ----------- - t -(1 row) - -SELECT :poly1 @ :poly5; - ?column? ----------- - f -(1 row) - -SELECT :poly5 @ :poly1; - ?column? ----------- - f -(1 row) - -SELECT :poly1 && :poly5; - ?column? ----------- - t -(1 row) - -SELECT :poly5 && :poly1; - ?column? ----------- - t -(1 row) - -\unset poly1 -\unset poly2 -\unset poly3 -\unset poly4 -\unset poly5 --- checking path operators -\set poly 'spoly \'{(0.1,0),(0.2,0),(0.2,0.1),(0.3,0.1),(0.3,-0.1),(0.4,-0.1),(0.5,0.1),(0.4,0.2),(0.1,0.2)}\'' -\set path1 'spath \'{(0.1,0),(0.2,0),(0.2,0.1),(0.3,0.1),(0.3,-0.1),(0.4,-0.1),(0.5,0.1),(0.4,0.2),(0.1,0.2)}\'' -\set path2 'spath \'{(0,0),(1,0),(2,0),(3,0)}\'' -\set path3 'spath \'{(0,0),(0,1),(0,1.5)}\'' -SELECT @-@ spath '{(0,0),(1,0),(2,0),(3,0)}'; - ?column? ----------- - 3 -(1 row) - -SELECT :path1 = :path2; - ?column? ----------- - f -(1 row) - -SELECT :path1 = :path1; - ?column? ----------- - t -(1 row) - -SELECT :path1 <> :path2; - ?column? ----------- - t -(1 row) - -SELECT :path1 <> :path1; - ?column? ----------- - f -(1 row) - -SELECT :poly && :path1; - ?column? ----------- - t -(1 row) - -SELECT :path1 && :poly ; - ?column? ----------- - t -(1 row) - -SELECT :path1 @ :poly ; - ?column? ----------- - t -(1 row) - -SELECT :path2 @ :poly ; - ?column? ----------- - f -(1 row) - -SELECT :path1 && :path1; - ?column? ----------- - t -(1 row) - -SELECT :path1 && :path1; - ?column? ----------- - t -(1 row) - -SELECT :poly && :path2; - ?column? ----------- - t -(1 row) - -SELECT :path2 && :poly ; - ?column? ----------- - t -(1 row) - -SELECT :path2 && :path1; - ?column? ----------- - t -(1 row) - -SELECT :poly && :path3; - ?column? ----------- - f -(1 row) - -SELECT :path3 && :poly ; - ?column? ----------- - f -(1 row) - -SELECT :path3 && :path1; - ?column? ----------- - f -(1 row) - -SELECT :path3 && :path2; - ?column? ----------- - t -(1 row) - -SELECT :path1 @ scircle '<(0,1),1>'; - ?column? ----------- - f -(1 row) - -SELECT :path3 @ scircle '<(0,1),1>'; - ?column? ----------- - t -(1 row) - -SELECT :path3 @ scircle '<(0,1),0.7>'; - ?column? ----------- - f -(1 row) - -SELECT :path1 && scircle '<(0,1),1>'; - ?column? ----------- - t -(1 row) - -SELECT :path3 && scircle '<(0,1),1>'; - ?column? ----------- - t -(1 row) - -SELECT :path3 && scircle '<(0,1),0.7>'; - ?column? ----------- - t -(1 row) - -SELECT :path3 && scircle '<(0,-1),0.7>'; - ?column? ----------- - f -(1 row) - -SELECT :path3 @ scircle '<(0,-1),0.7>'; - ?column? ----------- - f -(1 row) - -SELECT :path3 && sline ( spoint '(0,-1)', spoint '(0,1)' ); - ?column? ----------- - t -(1 row) - -SELECT :path3 && sline ( spoint '(-1,0)', spoint '(1,0)' ); - ?column? ----------- - t -(1 row) - -SELECT :path3 && sline ( spoint '(-1,0)', spoint '(-0.3,0)' ); - ?column? ----------- - f -(1 row) - -SELECT spath '{(0.11,0.15),(0.12,0.15),(0.13,0.15)}' @ :poly; - ?column? ----------- - t -(1 row) - --- ellipse tests ---equal operator -SELECT sellipse '<{0d,0d},(170d,-12d),0d>' = sellipse '<{0d,0d},(170d,-12d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{0d,0d},(170d,-12d),0d>' = sellipse '<{0d,0d},(170d,-12d),-2d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,5d},(170d,-12d),0d>' = sellipse '<{5d,5d},(170d,-12d),-2d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,2d},(170d,-12d),0d>' = sellipse '<{5d,2d},(170d,-12d),-2d>'; - ?column? ----------- - f -(1 row) - --- not equal -SELECT sellipse '<{5d,2d},(170d,-12d),0d>' != sellipse '<{5d,2d},(170d,-12d),-2d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,2d},(170d,-12d),0d>' != sellipse '<{5d,2d},(170d,-12d), 0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d, 5d},(300d,0d), 0d>' = sellipse '<{10d,5d},(300d,0d), 180d>' ; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d, 5d},(300d,0d), 90d>' = sellipse '<{10d,5d},(300d,0d), 270d>' ; - ?column? ----------- - t -(1 row) - --- ellipse and point -SELECT spoint '(280d,-20d)' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(280d,-10d)' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(280d,-9.9d)' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spoint '(280d,-10d)' ; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spoint '(280d, -9d)' ; - ?column? ----------- - f -(1 row) - -SELECT spoint '(280d,-10d)' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoint '(280d,-9.9d)' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spoint '(280d,-10d)' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spoint '(280d, -9d)' ; - ?column? ----------- - t -(1 row) - --- ---ellipse and circle (@,&&) --- --- negators and commutators -SELECT scircle '<(280d,-10d),0d>' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d, -9d),0d>' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-10d),0d>' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d, -9d),0d>' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ scircle '<(280d,-10d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ scircle '<(280d, -9d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ scircle '<(280d,-10d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ scircle '<(280d, -9d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-10d),2d>' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d, 0d),2d>' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-10d),2d>' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d, 0d),2d>' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && scircle '<(280d,-10d),2d>' ; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && scircle '<(280d, 0d),2d>' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& scircle '<(280d,-10d),2d>' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& scircle '<(280d, 0d),2d>' ; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-10d),0d>' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - - --- ellipse is circle -SELECT scircle '<(280d,-10d),2d>' @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-18d),2d>' @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-16d),2d>' @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-18d),15d>' @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{5d,5d},(280d,-20d),90d>' @ scircle '<(280d,-10d),2d>' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{5d,5d},(280d,-20d),90d>' @ scircle '<(280d,-18d),2d>' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{5d,5d},(280d,-20d),90d>' @ scircle '<(280d,-16d),2d>' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{5d,5d},(280d,-20d),90d>' @ scircle '<(280d,-18d),15d>' ; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-10d),2d>' && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-18d),2d>' && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-16d),2d>' && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - --- ellipse is line -SELECT scircle '<(280d,-10d),0d>' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-18d),0d>' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-16d),0d>' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-18d),15d>' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-10d),0d>' && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-18d),0d>' && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT scircle '<(280d,-10d),2d>' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-18d),2d>' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-16d),2d>' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-10d),2d>' && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT scircle '<(280d,-18d),2d>' && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,0d},(280d,-20d),90d>' @ scircle '<(280d,-18d),15d>' ; - ?column? ----------- - t -(1 row) - --- ---ellipse and line (@,&&) --- --- negators and commutators -SELECT sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ) @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ) @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ) @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ) && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ) && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ) && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ) !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ) !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ) !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ) !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ) !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ) !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ); - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ); - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ); - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ); - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ); - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ); - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ); - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ); - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ); - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& sline ( spoint '(280d, -9d)', spoint '(280d, -8d)' ); - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& sline ( spoint '(280d, -9d)', spoint '(280d,-12d)' ); - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& sline ( spoint '(280d,-11d)', spoint '(280d,-12d)' ); - ?column? ----------- - f -(1 row) - --- line is point , ellipse is point -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) @ sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) @ sellipse '<{0d,0d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) && sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) && sellipse '<{0d,0d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- line is point , ellipse is circle -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) @ sellipse '<{5d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) && sellipse '<{5d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- line is point , ellipse is a real ellipse -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) @ sellipse '<{10d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -8d)' ) && sellipse '<{10d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- line is a real line , ellipse is point -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{0d,0d},(280d, -8d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{0d,0d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- line is a real line , ellipse is circle -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{5d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{5d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- line is a real line , ellipse is line -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{5d,0d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{5d,0d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- line is a real line , ellipse is a real ellipse -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) @ sellipse '<{10d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sline ( spoint '(280d, -8d)', spoint '(280d, -9d)' ) && sellipse '<{10d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- --- ellipse and path --- --- negators , commutator @,&& -SELECT spath '{(280d, -9d),(280d, -8d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -9d),(280d,-12d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d,-11d),(280d,-12d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d, -9d),(280d, -8d)}' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -9d),(280d,-12d)}' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d,-11d),(280d,-12d)}' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d, -9d),(280d, -8d)}' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d, -9d),(280d,-12d)}' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d,-11d),(280d,-12d)}' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -9d),(280d, -8d)}' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d, -9d),(280d,-12d)}' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d,-11d),(280d,-12d)}' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spath '{(280d, -9d),(280d, -8d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spath '{(280d, -9d),(280d,-12d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spath '{(280d,-11d),(280d,-12d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && spath '{(280d, -9d),(280d, -8d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && spath '{(280d, -9d),(280d,-12d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && spath '{(280d,-11d),(280d,-12d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spath '{(280d, -9d),(280d, -8d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spath '{(280d, -9d),(280d,-12d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spath '{(280d,-11d),(280d,-12d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spath '{(280d, -9d),(280d, -8d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spath '{(280d, -9d),(280d,-12d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spath '{(280d,-11d),(280d,-12d)}'; - ?column? ----------- - f -(1 row) - --- path is a line , ellipse is point -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{0d,0d},(280d, -8d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{0d,0d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- path is a line , ellipse is circle -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{5d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{5d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- path is a line , ellipse is path -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{5d,0d},(280d, -8d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{5d,0d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- path is a line , ellipse is a real ellipse -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' @ sellipse '<{10d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spath '{(280d, -8d),(280d, -9d)}' && sellipse '<{10d,5d},(280d, -8d),90d>'; - ?column? ----------- - t -(1 row) - --- --- ellipse and polygon --- --- negators , commutator @,&& -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}' && sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}' !@ sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}' !&& sellipse '<{10d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' ~ spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !~ spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spoly '{(280d, -9d),(280d,-12d),(279d, -8d)}'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}'; - ?column? ----------- - f -(1 row) - --- ellipse is point -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; - ?column? ----------- - t -(1 row) - --- ellipse is circle -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-10d),(290d,-30d),(270d, -30d)}' @ sellipse '<{2d,2d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{5d,5d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,5d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{2d,2d},(280d,-20d),90d>' @ spoly '{(280d,-10d),(290d,-30d),(270d, -30d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,5d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{5d,5d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-18d),(279d, -12d)}'; - ?column? ----------- - t -(1 row) - --- ellipse is line -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-10d),(290d,-30d),(270d, -30d)}' @ sellipse '<{2d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{5d,0d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,0d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{2d,0d},(280d,-20d),90d>' @ spoly '{(280d,-10d),(290d,-30d),(270d, -30d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,0d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{5d,0d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-18d),(279d, -12d)}'; - ?column? ----------- - t -(1 row) - --- ellipse is a real ellipse -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{5d,2d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-10d),(290d,-30d),(270d, -30d)}' @ sellipse '<{2d,1d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{5d,2d},(280d,-20d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{5d,2d},(280d,-20d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,2d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{2d,1d},(280d,-20d),90d>' @ spoly '{(280d,-10d),(290d,-30d),(270d, -30d)}'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{5d,2d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{5d,2d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-18d),(279d, -12d)}'; - ?column? ----------- - t -(1 row) - --- --- ellipse and ellipse --- --- check @ -SELECT sellipse '<{10d, 5d},(300d,0d), 0d>' @ sellipse '<{10d,5d},(300d,0d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d, 5d},(300d,0d), 90d>' @ sellipse '<{10d,5d},(300d,0d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d, 5d},(300d,0d),180d>' @ sellipse '<{10d,5d},(300d,0d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d, 5d},(300d,0d),270d>' @ sellipse '<{10d,5d},(300d,0d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 2d, 1d},( 52d,6d), 0d>' @ sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - t -(1 row) - --- negators , commutator @,&& -SELECT sellipse '<{ 2d, 1d},( 52d,6d), 0d>' @ sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d, 5d},( 52d,6d), 0d>' @ sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d, 5d},( 90d,9d), 0d>' @ sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 2d, 1d},( 52d,6d), 0d>' && sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d, 5d},( 52d,6d), 0d>' && sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d, 5d},( 90d,9d), 0d>' && sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 2d, 1d},( 52d,6d), 0d>' !@ sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d, 5d},( 52d,6d), 0d>' !@ sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d, 5d},( 90d,9d), 0d>' !@ sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 2d, 1d},( 52d,6d), 0d>' !&& sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d, 5d},( 52d,6d), 0d>' !&& sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d, 5d},( 90d,9d), 0d>' !&& sellipse '<{10d,5d},(50d,5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' ~ sellipse '<{ 2d, 1d},( 52d,6d), 0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' ~ sellipse '<{10d, 5d},( 52d,6d), 0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' ~ sellipse '<{10d, 5d},( 90d,9d), 0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' && sellipse '<{ 2d, 1d},( 52d,6d), 0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' && sellipse '<{10d, 5d},( 52d,6d), 0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' && sellipse '<{10d, 5d},( 90d,9d), 0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' !~ sellipse '<{ 2d, 1d},( 52d,6d), 0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' !~ sellipse '<{10d, 5d},( 52d,6d), 0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' !~ sellipse '<{10d, 5d},( 90d,9d), 0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' !&& sellipse '<{ 2d, 1d},( 52d,6d), 0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' !&& sellipse '<{10d, 5d},( 52d,6d), 0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{10d,5d},(50d,5d),45d>' !&& sellipse '<{10d, 5d},( 90d,9d), 0d>'; - ?column? ----------- - t -(1 row) - --- left ellipse is point right ellipse is point -SELECT sellipse '<{ 0d, 0d},( 50d,-5d), 0d>' @ sellipse '<{0d,0d},(50d,-5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-6d), 0d>' @ sellipse '<{0d,0d},(50d,-5d),45d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-5d), 0d>' && sellipse '<{0d,0d},(50d,-5d),45d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-6d), 0d>' && sellipse '<{0d,0d},(50d,-5d),45d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is line right ellipse is point -SELECT sellipse '<{ 5d, 0d},( 50d, -2d), 90d>' @ sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d,-12d), 90d>' @ sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d, -2d), 90d>' && sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d,-12d), 90d>' && sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is circle right ellipse is point -SELECT sellipse '<{ 5d, 5d},( 50d, -2d), 90d>' @ sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d,-12d), 90d>' @ sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d, -2d), 90d>' && sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d,-12d), 90d>' && sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is real ellipse right ellipse is point -SELECT sellipse '<{ 5d, 3d},( 50d, -2d), 90d>' @ sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 3d},( 50d,-12d), 90d>' @ sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 3d},( 50d, -2d), 90d>' && sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 3d},( 50d,-12d), 90d>' && sellipse '<{0d,0d},(50d,-5d),0d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is point right ellipse is line -SELECT sellipse '<{ 0d, 0d},( 50d,-5d), 0d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-6d), 0d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d, 6d), 0d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-5d), 0d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-6d), 0d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d, 6d), 0d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is line right ellipse is line -SELECT sellipse '<{ 3d, 0d},( 50d,-5d), 90d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 3d, 0d},( 50d,-8d), 90d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 0d},( 50d,-6d), 0d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 0d},( 50d, 6d), 90d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 0d},( 50d,-5d), 90d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 3d, 0d},( 50d,-8d), 90d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 3d, 0d},( 50d,-6d), 0d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 3d, 0d},( 50d, 6d), 90d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is circle right ellipse is line -SELECT sellipse '<{ 3d, 3d},( 50d,-5d), 90d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d,-8d), 90d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d,-6d), 0d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d, 6d), 90d>' @ sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d,-5d), 90d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d,-8d), 90d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d,-6d), 0d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d, 6d), 90d>' && sellipse '<{5d,0d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is point right ellipse is circle -SELECT sellipse '<{ 0d, 0d},( 50d,-5d), 0d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-6d), 0d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d, 6d), 0d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-5d), 0d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d,-6d), 0d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 0d, 0d},( 50d, 6d), 0d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is line right ellipse is circle -SELECT sellipse '<{ 5d, 0d},( 50d,-5d), 90d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d,-6d), 90d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d, 6d), 90d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d,-5d), 90d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d,-6d), 90d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 0d},( 50d, 6d), 90d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - --- left ellipse is circle right ellipse is circle -SELECT sellipse '<{ 3d, 3d},( 50d,-4d), 90d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d,-5d), 90d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d,-6d), 90d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d, 6d), 90d>' @ sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - -SELECT sellipse '<{ 3d, 3d},( 50d,-4d), 90d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d,-5d), 90d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d,-6d), 90d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - t -(1 row) - -SELECT sellipse '<{ 5d, 5d},( 50d, 6d), 90d>' && sellipse '<{5d,5d},(50d,-5d),90d>'; - ?column? ----------- - f -(1 row) - --- index tests -CREATE TABLE spheretmp1 (p spoint); -\copy spheretmp1 from 'data/test_spherepoint.data' -\copy spheretmp1 from 'data/test_spherepoint.data' -\copy spheretmp1 from 'data/test_spherepoint.data' -\copy spheretmp1 from 'data/test_spherepoint.data' -CREATE TABLE spheretmp2 (c scircle); -\copy spheretmp2 from 'data/test_spherecircle.data' -\copy spheretmp2 from 'data/test_spherecircle.data' -\copy spheretmp2 from 'data/test_spherecircle.data' -\copy spheretmp2 from 'data/test_spherecircle.data' -CREATE TABLE spheretmp4 AS - SELECT sline ( p , p - strans '-15d,-15d,-15d,ZXZ' ) AS l - FROM spheretmp1; --- checking input -SELECT count(*) FROM spheretmp1 WHERE p @ scircle '< ( 180d 1m 10s , -2d 23m 59s ) , 10d >'; - count -------- - 32 -(1 row) - --- without idx -SELECT count(*) FROM spheretmp1 WHERE p @ scircle '<(1,1),0.3>'; - count -------- - 32 -(1 row) - -SELECT count(*) FROM spheretmp2 WHERE c @ scircle '<(1,1),0.3>'; - count -------- - 12 -(1 row) - -SELECT count(*) FROM spheretmp2 WHERE c && scircle '<(1,1),0.3>'; - count -------- - 48 -(1 row) - -SELECT count(*) FROM spheretmp4 WHERE l @ scircle '<(1,1),0.3>'; - count -------- - 8 -(1 row) - -SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>'; - count -------- - 40 -(1 row) - -SELECT count(*) FROM spheretmp1 WHERE p = spoint '(3.09 , 1.25)' ; - count -------- - 4 -(1 row) - --- create idx -CREATE INDEX aaaidx ON spheretmp1 USING gist ( p ); -CREATE INDEX bbbidx ON spheretmp2 USING gist ( c ); -CREATE INDEX cccidx ON spheretmp4 USING gist ( l ); ---with idx -SET enable_seqscan = OFF ; -SELECT count(*) FROM spheretmp1 WHERE p @ scircle '<(1,1),0.3>' ; - count -------- - 32 -(1 row) - -SELECT count(*) FROM spheretmp2 WHERE c @ scircle '<(1,1),0.3>' ; - count -------- - 12 -(1 row) - -SELECT count(*) FROM spheretmp2 WHERE c && scircle '<(1,1),0.3>' ; - count -------- - 48 -(1 row) - -SELECT count(*) FROM spheretmp4 WHERE l @ scircle '<(1,1),0.3>' ; - count -------- - 8 -(1 row) - -SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>' ; - count -------- - 40 -(1 row) - -SELECT count(*) FROM spheretmp1 WHERE p = spoint '(3.09 , 1.25)' ; - count -------- - 4 -(1 row) - diff --git a/expected/point.out b/expected/point.out deleted file mode 100644 index d6aa4c25..00000000 --- a/expected/point.out +++ /dev/null @@ -1,240 +0,0 @@ --- radian input -SELECT spoint (-3*pi(), 0); - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint ( 3*pi(), 0); - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint ( 0, pi()); - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint ( 0, -pi()); - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint ( 2*pi(), 2*pi()); - spoint ---------- - (0 , 0) -(1 row) - -SELECT spoint ( pi(), 2*pi()); - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint ( 0, pi()/2); - spoint ------------------------ - (0 , 1.5707963267949) -(1 row) - -SELECT spoint ( 0, -pi()/2); - spoint ------------------------- - (0 , -1.5707963267949) -(1 row) - --- degree input -SELECT spoint '(-540d, 0d)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 540d, 0d)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 0d, 180d)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 0d, -180d)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 360d, 360d)'; - spoint ---------- - (0 , 0) -(1 row) - -SELECT spoint '( 180d, 360d)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 0d, 90d)'; - spoint ------------------------ - (0 , 1.5707963267949) -(1 row) - -SELECT spoint '( 0d, -90d)'; - spoint ------------------------- - (0 , -1.5707963267949) -(1 row) - --- dms input -SELECT spoint '( 0.0d 0m 0s, 0d 0m 0s)'; -ERROR: parsing: syntax error -SELECT spoint '( 0d 60m 0s, 0d 0m 0s)'; -ERROR: parsing: minutes or seconds invalid (min:60.000000 sec:0.000000) -SELECT spoint '( 0d 0m 60s, 0d 0m 0s)'; -ERROR: parsing: minutes or seconds invalid (min:0.000000 sec:60.000000) -SELECT spoint '( 539d 59m 59.9999s, 0d 0m 0s)'; - spoint ------------------------- - (3.14159265310498 , 0) -(1 row) - -SELECT spoint '( 0d 0m 0s, 180d 0m 0s)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 0d 0m 0s, -180d 0m 0s)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 360d 0m 0s, 360d 0m 0s)'; - spoint ---------- - (0 , 0) -(1 row) - -SELECT spoint '( 180d 0m 0s, 360d 0m 0s)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 0d 0m 0s, 90d 0m 0s)'; - spoint ------------------------ - (0 , 1.5707963267949) -(1 row) - -SELECT spoint '( 0d 0m 0s, -90d 0m 0s)'; - spoint ------------------------- - (0 , -1.5707963267949) -(1 row) - --- hms input for latitude -SELECT spoint '( 0.0h 0m 0s, 0)'; -ERROR: parsing: syntax error -SELECT spoint '( 0h 60m 0s, 0)'; -ERROR: parsing: minutes or seconds invalid (min:60.000000 sec:0.000000) -SELECT spoint '( 0h 0m 60s, 0)'; -ERROR: parsing: minutes or seconds invalid (min:0.000000 sec:60.000000) -SELECT spoint '( 35h 59m 59.9999s, 0d 0m 0s)'; - spoint ------------------------- - (3.14159264631759 , 0) -(1 row) - -SELECT spoint '( 0h 0m 0s, 180d 0m 0s)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 0h 0m 0s, -180d 0m 0s)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 24h 0m 0s, 360d 0m 0s)'; - spoint ---------- - (0 , 0) -(1 row) - -SELECT spoint '( 12h 0m 0s, 360d 0m 0s)'; - spoint ------------------------- - (3.14159265358979 , 0) -(1 row) - -SELECT spoint '( 0h 0m 0s, 90d 0m 0s)'; - spoint ------------------------ - (0 , 1.5707963267949) -(1 row) - -SELECT spoint '( 0h 0m 0s, -90d 0m 0s)'; - spoint ------------------------- - (0 , -1.5707963267949) -(1 row) - --- mixed input --- operators -SELECT spoint '(0, 90d)' = spoint '(0, 90d)'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(0, 90d)' = spoint '(0,-90d)'; - ?column? ----------- - f -(1 row) - -SELECT spoint '(0,-90d)' = spoint '(0,-90d)'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(0, 90d)' != spoint '(0, 90d)'; - ?column? ----------- - f -(1 row) - -SELECT spoint '(0, 90d)' != spoint '(0,-90d)'; - ?column? ----------- - t -(1 row) - -SELECT spoint '(0,-90d)' != spoint '(0,-90d)'; - ?column? ----------- - f -(1 row) - -SELECT spoint '(0d, 0)' = spoint '(360d,0)'; - ?column? ----------- - t -(1 row) - diff --git a/expected/points.out b/expected/points.out index 6fb3c17b..f3a0713a 100644 --- a/expected/points.out +++ b/expected/points.out @@ -666,3 +666,19 @@ SELECT '( 0h 2m 30s , -90d 0m 0s)'::spoint<->'( 12h 2m 30s , -90d 0m 0s)'::spoin 0 (1 row) +-- spoint_dwithin function ---------- +SELECT a, b, radius, a <-> b AS "<->", spoint_dwithin(a, b, radius) +FROM (VALUES + ('(0, 0)'::spoint, '(0, 0)'::spoint, 0), + ('(0, 0)', '(0, 1)', 1), + ('(0, 0)', '(0.1, 0.1)', 0.14), + ('(0, 0)', '(0.1, 0.1)', 0.15) + ) sub (a, b, radius); + a | b | radius | <-> | spoint_dwithin +---------+-------------+--------+-----------------+---------------- + (0 , 0) | (0 , 0) | 0 | 0 | t + (0 , 0) | (0 , 1) | 1 | 1 | t + (0 , 0) | (0.1 , 0.1) | 0.14 | 0.1413032986961 | f + (0 , 0) | (0.1 , 0.1) | 0.15 | 0.1413032986961 | t +(4 rows) + diff --git a/expected/poly.out b/expected/poly.out index 50e510e3..5f095a31 100644 --- a/expected/poly.out +++ b/expected/poly.out @@ -12,25 +12,25 @@ SELECT spoint '(0.15,0.10)' @ :poly; -- point inside polygon t (1 row) -SELECT spoint '(0.20,0.00)' @ :poly; -- point contained polygon +SELECT spoint '(0.20,0.00)' @ :poly; -- point contained polygon ?column? ---------- t (1 row) -SELECT spoint '(0.10,0.10)' @ :poly; -- point contained polygon +SELECT spoint '(0.10,0.10)' @ :poly; -- point contained polygon ?column? ---------- t (1 row) -SELECT spoint '(0.25,0.50)' @ :poly; -- point outside polygon +SELECT spoint '(0.25,0.50)' @ :poly; -- point outside polygon ?column? ---------- f (1 row) -SELECT spoint '(0.25,0.00)' @ :poly; -- point outside polygon +SELECT spoint '(0.25,0.00)' @ :poly; -- point outside polygon ?column? ---------- f @@ -42,13 +42,13 @@ SELECT scircle '<(0.15,0.10),0.03>' @ :poly; -- circle inside polygon t (1 row) -SELECT scircle '<(0.20,0.00),0.00>' @ :poly; -- circle contained polygon +SELECT scircle '<(0.20,0.00),0.00>' @ :poly; -- circle contained polygon ?column? ---------- t (1 row) -SELECT scircle '<(0.20,0.30),0.05>' @ :poly; -- circle outside polygon +SELECT scircle '<(0.20,0.30),0.05>' @ :poly; -- circle outside polygon ?column? ---------- f @@ -72,13 +72,13 @@ SELECT scircle '<(0.15,0.10),0.03>' && :poly; -- circle inside polygon t (1 row) -SELECT scircle '<(0.20,0.00),0.00>' && :poly; -- circle contained polygon +SELECT scircle '<(0.20,0.00),0.00>' && :poly; -- circle contained polygon ?column? ---------- t (1 row) -SELECT scircle '<(0.20,0.30),0.05>' && :poly; -- circle outside polygon +SELECT scircle '<(0.20,0.30),0.05>' && :poly; -- circle outside polygon ?column? ---------- f @@ -96,13 +96,13 @@ SELECT scircle '<(0.25,0.00),0.10>' && :poly; -- circle overlaps polyg t (1 row) -SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) @ :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) @ :poly; -- line touches polygon ?column? ---------- f (1 row) -SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) @ :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) @ :poly; -- line touches polygon ?column? ---------- f @@ -114,7 +114,7 @@ SELECT sline ( spoint '(0.50, 0.00)', spoint '(0.50,0.20)' ) @ :poly; -- line f (1 row) -SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) @ :poly; -- line touches and inside polygon +SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) @ :poly; -- line touches and inside polygon ?column? ---------- t @@ -138,13 +138,13 @@ SELECT sline ( spoint '(0.24, 0.17)', spoint '(0.25,0.14)' ) @ :poly; -- line t (1 row) -SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) && :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) && :poly; -- line touches polygon ?column? ---------- t (1 row) -SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) && :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) && :poly; -- line touches polygon ?column? ---------- t @@ -156,7 +156,7 @@ SELECT sline ( spoint '(0.50, 0.00)', spoint '(0.50,0.20)' ) && :poly; -- line t (1 row) -SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) && :poly; -- line touches and inside polygon +SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) && :poly; -- line touches and inside polygon ?column? ---------- t @@ -318,6 +318,18 @@ SELECT spoly '{(10d,0d),(10d,1d),(15d,0d)}'; {(10d , 0d),(10d , 1d),(15d , 0d)} (1 row) +SELECT spoly(ARRAY[0.017453292519943295, 0.03490658503988659, 0.05235987755982988, 0.06981317007977318, 0.08726646259971647, 0.10471975511965977]); + spoly +--------------------------------- + {(1d , 2d),(3d , 4d),(5d , 6d)} +(1 row) + +SELECT spoly(ARRAY[0.17453292519943295, 0.0, 0.17453292519943295, 0.017453292519943295, 0.2617993877991494, 0.0]); + spoly +------------------------------------ + {(10d , 0d),(10d , 1d),(15d , 0d)} +(1 row) + SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]); spoly_deg --------------------------------- @@ -330,13 +342,52 @@ SELECT spoly_deg(ARRAY[10.0, 0.0, 10.0, 1.0, 15.0, 0.0]); {(10d , 0d),(10d , 1d),(15d , 0d)} (1 row) --- incorrect input ----- +--- Constructors +SELECT spoly(NULL::spoint[]); + spoly +------- + +(1 row) + +SELECT spoly(ARRAY[]::spoint[]); +ERROR: spherepoly_from_point_array: invalid number of arguments (must be >= 3) +SELECT spoly(ARRAY[spoint_deg(0, 0)]); +ERROR: spherepoly_from_point_array: invalid number of arguments (must be >= 3) +SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0)]); +ERROR: spherepoly_from_point_array: invalid number of arguments (must be >= 3) +SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10)]); + spoly +------------------------------------ + {(0d , 0d),(10d , 0d),(10d , 10d)} +(1 row) + +SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10), spoint_deg(0, 10)]); + spoly +----------------------------------------------- + {(0d , 0d),(10d , 0d),(10d , 10d),(0d , 10d)} +(1 row) + +--- incorrect input ----- SELECT spoly '{(10d,0d),(10d,1d)}'; ERROR: spherepoly_in: more than two points needed LINE 1: SELECT spoly '{(10d,0d),(10d,1d)}'; ^ +SELECT spoly(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0]); +ERROR: spherepoly_rad: invalid number of arguments (must be even and >= 6) +SELECT spoly(ARRAY[1.0, 2.0, 3.0, NULL, 5.0, 6.0]); +ERROR: spherepoly_rad: input array is invalid because it has null values +SELECT spoly(ARRAY[]::float8[]); +ERROR: spherepoly_rad: invalid number of arguments (must be even and >= 6) +SELECT spoly(NULL::float8[]); + spoly +------- + +(1 row) + SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0]); ERROR: spherepoly_deg: invalid number of arguments (must be even and >= 6) +SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, NULL, 5.0, 6.0]); +ERROR: spherepoly_deg: input array is invalid because it has null values SELECT spoly_deg(ARRAY[]::float8[]); ERROR: spherepoly_deg: invalid number of arguments (must be even and >= 6) SELECT spoly_deg(NULL::float8[]); @@ -352,13 +403,17 @@ LINE 1: SELECT spoly '{(0d,0d),(10d,10d),(0d,10d),(10d,0d)}'; ^ --- degenerate polygons ----- SELECT spoly '{(0d,1d),(0d,2d),(0d,3d)}'; -ERROR: spherepoly_from_array: a line segment overlaps or polygon too large -LINE 1: SELECT spoly '{(0d,1d),(0d,2d),(0d,3d)}'; - ^ + spoly +--------------------------------- + {(0d , 1d),(0d , 2d),(0d , 3d)} +(1 row) + SELECT spoly '{(1d,0d),(2d,0d),(3d,0d)}'; -ERROR: spherepoly_from_array: a line segment overlaps or polygon too large -LINE 1: SELECT spoly '{(1d,0d),(2d,0d),(3d,0d)}'; - ^ + spoly +--------------------------------- + {(1d , 0d),(2d , 0d),(3d , 0d)} +(1 row) + --- functions SELECT npoints( spoly '{(10d,0d),(10d,1d),(15d,0d)}'); npoints @@ -1185,7 +1240,7 @@ SELECT spoly '{(0d,-88d),(90d,-88d),(180d,-88d),(270d,-88d)}' @ spoly '{(0d,89d) (1 row) --- spoly ~ spoly ---- should be true +--- should be true SELECT spoly '{(-1d,-1d),(-1d,1d),(1d,1d),(1d,-1d)}' ~ spoly '{(0d,0d),(0d,0.5d),(0.5d,0.5d),(0.5d,0d)}'; ?column? ---------- @@ -1254,7 +1309,7 @@ SELECT spoly '{(0d,89d),(90d,89d),(180d,89d),(270d,89d)}' ~ spoly '{(0d,-88d),(9 (1 row) --- spoly && spoly ---- should be true +--- should be true SELECT spoly '{(0d,0d),(0d,0.5d),(0.5d,0.5d),(0.5d,0d)}' && spoly '{(-1d,-1d),(-1d,1d),(1d,1d),(1d,-1d)}'; ?column? ---------- @@ -1391,7 +1446,6 @@ SELECT spoly '{(-1d,-1d),(-1d,1d),(1d,1d),(1d,-1d)}' && spoly '{(179d,-1d),(179d -- -- ellipse and polygon -- - -- negators , commutator @,&& SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; ?column? @@ -1538,49 +1592,49 @@ SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spoly '{(280d,-11d),(280d,-12 (1 row) -- ellipse is point -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; ?column? ---------- f (1 row) -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; ?column? ---------- f (1 row) -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; ?column? ---------- f (1 row) -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; ?column? ---------- t (1 row) -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; ?column? ---------- f (1 row) -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; ?column? ---------- t (1 row) -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; ?column? ---------- f (1 row) -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; ?column? ---------- t @@ -1824,3 +1878,36 @@ SELECT spoly_is_convex(NULL); f (1 row) +-- Complex but valid polygon +SELECT '{ + (3.30474723646012 , 1.08600456205300), + (3.30341855309927 , 1.08577960186707), + (3.30341054542378 , 1.08578643990271), + (3.30297351563319 , 1.08633534556428), + (3.30357156120003 , 1.08643683957210), + (3.30358891855857 , 1.08643995044436), + (3.30360894676365 , 1.08644306147078), + (3.30361829343581 , 1.08644430596871), + (3.30362630482521 , 1.08644555030213), + (3.30364633346451 , 1.08644866102000), + (3.30365300940335 , 1.08645052692055), + (3.30366102096957 , 1.08645177113937), + (3.30367036769496 , 1.08645363721023), + (3.30367837934959 , 1.08645488137174), + (3.30368906174976 , 1.08645612569695), + (3.30370107936906 , 1.08645799183673), + (3.30370642025712 , 1.08645985750225), + (3.30373179124734 , 1.08646358962156), + (3.30374514456618 , 1.08646545561358), + (3.30410706158729 , 1.08652886672786), + (3.30427803417922 , 1.08655868846497), + (3.30429673329093 , 1.08655930694968), + (3.30432478121775 , 1.08655930174652), + (3.30433278932944 , 1.08655308246640), + (3.30446348355532 , 1.08638330933224) +}'::spoly; + spoly +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {(3.3047472 , 1.0860046),(3.3034186 , 1.0857796),(3.3034105 , 1.0857864),(3.3029735 , 1.0863353),(3.3035716 , 1.0864368),(3.3035889 , 1.08644),(3.3036089 , 1.0864431),(3.3036183 , 1.0864443),(3.3036263 , 1.0864456),(3.3036463 , 1.0864487),(3.303653 , 1.0864505),(3.303661 , 1.0864518),(3.3036704 , 1.0864536),(3.3036784 , 1.0864549),(3.3036891 , 1.0864561),(3.3037011 , 1.086458),(3.3037064 , 1.0864599),(3.3037318 , 1.0864636),(3.3037451 , 1.0864655),(3.3041071 , 1.0865289),(3.304278 , 1.0865587),(3.3042967 , 1.0865593),(3.3043248 , 1.0865593),(3.3043328 , 1.0865531),(3.3044635 , 1.0863833)} +(1 row) + diff --git a/expected/selectivity.out b/expected/selectivity.out new file mode 100644 index 00000000..e694f0f5 --- /dev/null +++ b/expected/selectivity.out @@ -0,0 +1,124 @@ +-- test selectivity estimator functions +create table spoint10k (star spoint); +insert into spoint10k select spoint(i, i*i) from generate_series(1, 10000) g(i); +create index on spoint10k using gist (star); +analyze spoint10k; +-- "explain analyze" wrapper that removes 'cost=...' since it varies across architectures +-- (we can't use "costs off" since that also removes the estimated row count) +create or replace function explain(query text, do_analyze text default 'true') returns setof text language plpgsql as $$ +declare + line text; +begin + for line in execute format('explain (analyze %s, timing off, summary off) %s', do_analyze, query) loop + return next regexp_replace(line, 'cost=\S+ ', ''); + end loop; + return; +end; +$$; +-- <@ operator selectivity +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), 1)'); + explain +----------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) + Recheck Cond: (star <@ '<(1 , 1) , 1>'::scircle) + Rows Removed by Index Recheck: 1560 + Heap Blocks: exact=55 + -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) + Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), .1)'); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) + Recheck Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) + Rows Removed by Index Recheck: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), .01)'); + explain +--------------------------------------------------------------------------------------------- + Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) +(2 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), 1) @> star'); + explain +----------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) + Recheck Cond: ('<(1 , 1) , 1>'::scircle @> star) + Rows Removed by Index Recheck: 1560 + Heap Blocks: exact=55 + -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) + Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .1) @> star'); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) + Recheck Cond: ('<(1 , 1) , 0.1>'::scircle @> star) + Rows Removed by Index Recheck: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .01) @> star'); + explain +--------------------------------------------------------------------------------------------- + Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) +(2 rows) + +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), 1)'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=7702 width=16) (actual rows=6991 loops=1) + Filter: (star !<@ '<(1 , 1) , 1>'::scircle) + Rows Removed by Filter: 3009 +(3 rows) + +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), .1)'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=9975 width=16) (actual rows=9971 loops=1) + Filter: (star !<@ '<(1 , 1) , 0.1>'::scircle) + Rows Removed by Filter: 29 +(3 rows) + +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), .01)'); + explain +------------------------------------------------------------------------- + Seq Scan on spoint10k (rows=10000 width=16) (actual rows=9999 loops=1) + Filter: (star !<@ '<(1 , 1) , 0.01>'::scircle) + Rows Removed by Filter: 1 +(3 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), 1) !@> star'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=7702 width=16) (actual rows=6991 loops=1) + Filter: ('<(1 , 1) , 1>'::scircle !@> star) + Rows Removed by Filter: 3009 +(3 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .1) !@> star'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=9975 width=16) (actual rows=9971 loops=1) + Filter: ('<(1 , 1) , 0.1>'::scircle !@> star) + Rows Removed by Filter: 29 +(3 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .01) !@> star'); + explain +------------------------------------------------------------------------- + Seq Scan on spoint10k (rows=10000 width=16) (actual rows=9999 loops=1) + Filter: ('<(1 , 1) , 0.01>'::scircle !@> star) + Rows Removed by Filter: 1 +(3 rows) + diff --git a/expected/selectivity_1.out b/expected/selectivity_1.out new file mode 100644 index 00000000..08cd8f74 --- /dev/null +++ b/expected/selectivity_1.out @@ -0,0 +1,124 @@ +-- test selectivity estimator functions +create table spoint10k (star spoint); +insert into spoint10k select spoint(i, i*i) from generate_series(1, 10000) g(i); +create index on spoint10k using gist (star); +analyze spoint10k; +-- "explain analyze" wrapper that removes 'cost=...' since it varies across architectures +-- (we can't use "costs off" since that also removes the estimated row count) +create or replace function explain(query text, do_analyze text default 'true') returns setof text language plpgsql as $$ +declare + line text; +begin + for line in execute format('explain (analyze %s, timing off, summary off) %s', do_analyze, query) loop + return next regexp_replace(line, 'cost=\S+ ', ''); + end loop; + return; +end; +$$; +-- <@ operator selectivity +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), 1)'); + explain +----------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) + Recheck Cond: (star <@ '<(1 , 1) , 1>'::scircle) + Rows Removed by Index Recheck: 1560 + Heap Blocks: exact=55 + -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) + Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), .1)'); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) + Recheck Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) + Rows Removed by Index Recheck: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) +(6 rows) + +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), .01)'); + explain +--------------------------------------------------------------------------------------------- + Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) + Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) +(2 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), 1) @> star'); + explain +----------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) + Recheck Cond: ('<(1 , 1) , 1>'::scircle @> star) + Rows Removed by Index Recheck: 1560 + Heap Blocks: exact=55 + -> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) + Index Cond: ('<(1 , 1) , 1>'::scircle @> star) +(6 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .1) @> star'); + explain +------------------------------------------------------------------------------------------- + Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) + Recheck Cond: ('<(1 , 1) , 0.1>'::scircle @> star) + Rows Removed by Index Recheck: 19 + Heap Blocks: exact=32 + -> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) + Index Cond: ('<(1 , 1) , 0.1>'::scircle @> star) +(6 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .01) @> star'); + explain +--------------------------------------------------------------------------------------------- + Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) + Index Cond: ('<(1 , 1) , 0.01>'::scircle @> star) +(2 rows) + +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), 1)'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=7702 width=16) (actual rows=6991 loops=1) + Filter: (star !<@ '<(1 , 1) , 1>'::scircle) + Rows Removed by Filter: 3009 +(3 rows) + +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), .1)'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=9975 width=16) (actual rows=9971 loops=1) + Filter: (star !<@ '<(1 , 1) , 0.1>'::scircle) + Rows Removed by Filter: 29 +(3 rows) + +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), .01)'); + explain +------------------------------------------------------------------------- + Seq Scan on spoint10k (rows=10000 width=16) (actual rows=9999 loops=1) + Filter: (star !<@ '<(1 , 1) , 0.01>'::scircle) + Rows Removed by Filter: 1 +(3 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), 1) !@> star'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=7702 width=16) (actual rows=6991 loops=1) + Filter: ('<(1 , 1) , 1>'::scircle !@> star) + Rows Removed by Filter: 3009 +(3 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .1) !@> star'); + explain +------------------------------------------------------------------------ + Seq Scan on spoint10k (rows=9975 width=16) (actual rows=9971 loops=1) + Filter: ('<(1 , 1) , 0.1>'::scircle !@> star) + Rows Removed by Filter: 29 +(3 rows) + +select explain('select * from spoint10k where scircle(spoint(1,1), .01) !@> star'); + explain +------------------------------------------------------------------------- + Seq Scan on spoint10k (rows=10000 width=16) (actual rows=9999 loops=1) + Filter: ('<(1 , 1) , 0.01>'::scircle !@> star) + Rows Removed by Filter: 1 +(3 rows) + diff --git a/expected/version.out b/expected/version.out new file mode 100644 index 00000000..c1f0efe9 --- /dev/null +++ b/expected/version.out @@ -0,0 +1,7 @@ +-- Check current pgsphere version +SELECT pg_sphere_version(); + pg_sphere_version +------------------- + 1.5.2 +(1 row) + diff --git a/index_9.5 b/index_9.5 deleted file mode 100644 index e69de29b..00000000 diff --git a/pg_sphere.control b/pg_sphere.control index e2b8ad3f..85f75896 100644 --- a/pg_sphere.control +++ b/pg_sphere.control @@ -1,5 +1,5 @@ # pg_sphere extension comment = 'spherical objects with useful functions, operators and index support' -default_version = '1.3.1' +default_version = '1.5.2' module_pathname = '$libdir/pg_sphere' relocatable = true diff --git a/pg_sphere--1.3.1.sql.in b/pg_sphere_head.sql.in similarity index 100% rename from pg_sphere--1.3.1.sql.in rename to pg_sphere_head.sql.in diff --git a/pgindent-excludes.list b/pgindent-excludes.list new file mode 100644 index 00000000..629df906 --- /dev/null +++ b/pgindent-excludes.list @@ -0,0 +1,3 @@ +pgs_process_moc.h +pgs_healpix.h +pgs_moc.h diff --git a/pgindent-typedefs.list b/pgindent-typedefs.list new file mode 100644 index 00000000..7f2c8fe7 --- /dev/null +++ b/pgindent-typedefs.list @@ -0,0 +1,236 @@ +align_val_t +allocator_type +__alloc_rebind +ArrayType +AttrDefault +AttrNumber +_Base_ptr +BlockNumber +Box3D +BpChar +bpoint +BrinDesc +BrinOpcInfo +brin_serialize_callback_type +BrinValues +__builtin_va_list +_Char_alloc_type +char_type +CommonEntry +__compar_fn_t +ConsiderSplitContext +_Const_Base_ptr +__const_iterator +const_iterator +_Const_Link_type +const_pointer +ConstrCheck +const_reference +const_reverse_iterator +const_void_pointer +coord_t +CPoint +Datum +difference_type +_DistanceType +div_t +DomainConstraintCache +double_t +__dso_handle +__enable_if_t +false> +false_type +__FILE +FILE +first_type +flex_int16_t +flex_uint8_t +float4 +float8 +float_t +FmgrInfo +fmNodePtr +FormData_pg_attribute +__fpos_t +fpos_t +FunctionCallInfo +GISTENTRY +GistEntryVector +GISTPageOpaque +GISTPageOpaqueData +GIST_SPLITVEC +GiSTSPointKey +__gnuc_va_list +Healpix_Base2 +hpint64 +insert_return_type +int16 +__int16_t +int16_t +int32 +__int32_t +int32_t +int64 +__int64_t +int64_t +int8 +__int8_t +int8_t +int_fast16_t +int_fast32_t +int_fast64_t +int_fast8_t +__int_least16_t +int_least16_t +__int_least32_t +int_least32_t +__int_least64_t +int_least64_t +__int_least8_t +int_least8_t +__intmax_t +intmax_t +intptr_t +int_type +_IO_lock_t +iostate +ItemIdData +iterator +iterator_category +iterator_type +key_compare +key_type +layout_vec +ldiv_t +_Link_type +lldiv_t +LocationIndex +__make_not_void +map_const_iter +map_iterator +mapped_type +map_rev_iter +max_align_t +__mbstate_t +mbstate_t +MemoryContext +moc_interval +moc_map +moc_map_entry +moc_out_data +moc_tree_entry +NameData +_Node_allocator +NodeTag +node_type +NullableDatum +nullptr_t +__off64_t +OffsetNumber +__off_t +Oid +ostream +__ostream_type +other +output_map +Page +PageGistNSN +PageHeader +PageHeaderData +PageXLogRecPtr +Pg_finfo_record +PGFunction +Pg_magic_struct +pgs_error_handler +phasevec +Point +Point3D +__pointer +pointer +Pointer +ptrdiff_t +__ptr_rebind +rebind +rebind_alloc +reference +Relation +_Rep_type +reverse_iterator +rintv_iter +rnode_iter +rtype +SBOX +SCIRCLE +second_type +_Self +SELLIPSE +SEuler +Size +size_t +size_type +SLine +Smoc +SPATH +SplitInterval +SPoint +SPOLY +StrategyNumber +streamsize +string +__sv_type +t_ang +tdiff +text +_Tp_alloc_type +TransactionId +true_type +tsize +TupleConstr +TupleDesc +__type +type +TypeCacheEntry +uchar +uint16 +__uint16_t +uint16_t +uint32 +__uint32_t +uint32_t +uint64 +__uint64_t +uint64_t +uint8 +__uint8_t +uint8_t +uint_fast16_t +uint_fast32_t +uint_fast64_t +uint_fast8_t +__uint_least16_t +uint_least16_t +__uint_least32_t +uint_least32_t +__uint_least64_t +uint_least64_t +__uint_least8_t +uint_least8_t +__uintmax_t +uintmax_t +uintptr_t +va_list +value_type +varattrib_4b +vec3 +Vector3D +wctrans_t +wctype_t +wint_t +YY_BUFFER_STATE +YY_CHAR +yy_size_t +yy_state_type +YYSTYPE +yytype_int16 +yytype_int8 +yytype_uint8 diff --git a/pgs_9.5.sql.in b/pgs_9.5.sql.in deleted file mode 100644 index e3b806df..00000000 --- a/pgs_9.5.sql.in +++ /dev/null @@ -1,7 +0,0 @@ --- add functionality that is only available for PostgreSQL 9.5+ - - --- add "fetch" support function to enable index-only scans for spoint3 - -ALTER OPERATOR FAMILY spoint3 USING gist ADD - FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal); diff --git a/pgs_circle_sel.sql.in b/pgs_circle_sel.sql.in new file mode 100644 index 00000000..d1e9c7ee --- /dev/null +++ b/pgs_circle_sel.sql.in @@ -0,0 +1,109 @@ +CREATE FUNCTION spoint_contained_by_circle_sel(internal, oid, internal, integer) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_sel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_sel(internal, oid, internal, integer) IS + 'selectivity estimator function for spoint_contained_by_circle'; + +CREATE FUNCTION spoint_contained_by_circle_joinsel(internal, oid, internal, smallint, internal) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_joinsel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_joinsel(internal, oid, internal, smallint, internal) IS + 'join selectivity estimator function for spoint_contained_by_circle'; + + +CREATE FUNCTION spoint_contained_by_circle_neg_sel(internal, oid, internal, integer) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_neg_sel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_neg_sel(internal, oid, internal, integer) IS + 'selectivity estimator function for spoint_contained_by_circle_neg'; + +CREATE FUNCTION spoint_contained_by_circle_neg_joinsel(internal, oid, internal, smallint, internal) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_neg_joinsel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_neg_joinsel(internal, oid, internal, smallint, internal) IS + 'join selectivity estimator function for spoint_contained_by_circle_neg'; + + +CREATE FUNCTION spoint_contained_by_circle_com_sel(internal, oid, internal, integer) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_com_sel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_com_sel(internal, oid, internal, integer) IS + 'selectivity estimator function for spoint_contained_by_circle_com'; + +CREATE FUNCTION spoint_contained_by_circle_com_joinsel(internal, oid, internal, smallint, internal) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_com_joinsel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_com_joinsel(internal, oid, internal, smallint, internal) IS + 'join selectivity estimator function for spoint_contained_by_circle_com'; + + +CREATE FUNCTION spoint_contained_by_circle_com_neg_sel(internal, oid, internal, integer) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_com_neg_sel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_com_neg_sel(internal, oid, internal, integer) IS + 'selectivity estimator function for spoint_contained_by_circle_com_neg'; + +CREATE FUNCTION spoint_contained_by_circle_com_neg_joinsel(internal, oid, internal, smallint, internal) + RETURNS double precision + AS 'MODULE_PATHNAME' , 'spherepoint_in_circle_com_neg_joinsel' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_contained_by_circle_com_neg_joinsel(internal, oid, internal, smallint, internal) IS + 'join selectivity estimator function for spoint_contained_by_circle_com_neg'; + + +ALTER OPERATOR @> (scircle, spoint) +SET ( + RESTRICT = spoint_contained_by_circle_com_sel, + JOIN = spoint_contained_by_circle_com_joinsel +); + +ALTER OPERATOR <@ (spoint, scircle) +SET ( + RESTRICT = spoint_contained_by_circle_sel, + JOIN = spoint_contained_by_circle_joinsel +); + +ALTER OPERATOR !@> (scircle, spoint) +SET ( + RESTRICT = spoint_contained_by_circle_com_neg_sel, + JOIN = spoint_contained_by_circle_com_neg_joinsel +); + +ALTER OPERATOR !<@ (spoint, scircle) +SET ( + RESTRICT = spoint_contained_by_circle_neg_sel, + JOIN = spoint_contained_by_circle_neg_joinsel +); + + +CREATE FUNCTION spoint_dwithin(spoint, spoint, float8) + RETURNS boolean + AS 'MODULE_PATHNAME', 'spherepoint_dwithin' + LANGUAGE C + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoint_dwithin(spoint, spoint, float8) IS + 'predicate matching spherical points less than a given distance apart'; diff --git a/pgs_gist.sql.in b/pgs_gist.sql.in index e8ac1191..fcd4f116 100644 --- a/pgs_gist.sql.in +++ b/pgs_gist.sql.in @@ -98,12 +98,15 @@ CREATE FUNCTION g_spoint_compress(internal) AS 'MODULE_PATHNAME', 'g_spoint_compress' LANGUAGE 'c'; - CREATE FUNCTION g_spoint_consistent(internal, internal, int4, oid, internal) RETURNS internal AS 'MODULE_PATHNAME', 'g_spoint_consistent' LANGUAGE 'c'; +CREATE FUNCTION g_spoint_distance(internal, spoint, smallint, oid, internal) + RETURNS internal + AS 'MODULE_PATHNAME', 'g_spoint_distance' + LANGUAGE 'c'; CREATE OPERATOR CLASS spoint DEFAULT FOR TYPE spoint USING gist AS @@ -114,6 +117,7 @@ CREATE OPERATOR CLASS spoint OPERATOR 14 @ (spoint, spoly), OPERATOR 15 @ (spoint, sellipse), OPERATOR 16 @ (spoint, sbox), + OPERATOR 17 <-> (spoint, spoint) FOR ORDER BY float_ops, OPERATOR 37 <@ (spoint, scircle), OPERATOR 38 <@ (spoint, sline), OPERATOR 39 <@ (spoint, spath), @@ -127,6 +131,7 @@ CREATE OPERATOR CLASS spoint FUNCTION 5 g_spherekey_penalty (internal, internal, internal), FUNCTION 6 g_spherekey_picksplit (internal, internal), FUNCTION 7 g_spherekey_same (spherekey, spherekey, internal), + FUNCTION 8 g_spoint_distance (internal, spoint, smallint, oid, internal), STORAGE spherekey; diff --git a/pgs_gist_spoint3.sql.in b/pgs_gist_spoint3.sql.in index 0382dade..580a12f7 100644 --- a/pgs_gist_spoint3.sql.in +++ b/pgs_gist_spoint3.sql.in @@ -66,4 +66,5 @@ CREATE OPERATOR CLASS spoint3 FUNCTION 6 g_spoint3_picksplit (internal, internal), FUNCTION 7 g_spoint3_same (bytea, bytea, internal), FUNCTION 8 g_spoint3_distance (internal, internal, int4, oid), + FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal), STORAGE pointkey; diff --git a/pgs_gist_support.sql.in b/pgs_gist_support.sql.in new file mode 100644 index 00000000..97b40597 --- /dev/null +++ b/pgs_gist_support.sql.in @@ -0,0 +1,12 @@ +-- PG12+ has support functions + +CREATE FUNCTION spoint_dwithin_supportfn (internal) + RETURNS internal + AS 'MODULE_PATHNAME', 'spherepoint_dwithin_supportfn' + LANGUAGE 'c'; + +COMMENT ON FUNCTION spoint_dwithin_supportfn(internal) IS + 'support function for spoint_dwithin'; + +ALTER FUNCTION spoint_dwithin(spoint, spoint, float8) + SUPPORT spoint_dwithin_supportfn; diff --git a/pgs_hash.sql.in b/pgs_hash.sql.in new file mode 100644 index 00000000..52fd1ed9 --- /dev/null +++ b/pgs_hash.sql.in @@ -0,0 +1,19 @@ +CREATE FUNCTION spoint_hash32 (spoint) + RETURNS int + IMMUTABLE STRICT + PARALLEL SAFE + LANGUAGE C + AS 'MODULE_PATHNAME', 'spherepoint_hash32'; + +UPDATE pg_operator + SET oprcanhash = true + WHERE oprname = '=' AND + oprleft = 'spoint'::regtype AND oprright = 'spoint'::regtype; + +/* PG17: ALTER OPERATOR = (spoint, spoint) SET (HASHES); */ + +CREATE OPERATOR CLASS spoint_hash_ops + DEFAULT FOR TYPE spoint USING hash + AS + OPERATOR 1 = (spoint, spoint), + FUNCTION 1 spoint_hash32(spoint); diff --git a/pgs_moc_compat.sql.in b/pgs_moc_compat.sql.in deleted file mode 100644 index 212b4f37..00000000 --- a/pgs_moc_compat.sql.in +++ /dev/null @@ -1,22 +0,0 @@ --- a minimal set of backwards-compatible operators for GAVO DaCHS, --- see http://soft.g-vo.org/dachs - -CREATE OPERATOR @ ( - LEFTARG = bigint, - RIGHTARG = smoc, - PROCEDURE = healpix_subset_smoc, - COMMUTATOR = '@>', - NEGATOR = '!<@', - RESTRICT = contsel, - JOIN = contjoinsel -); - -CREATE OPERATOR @ ( - LEFTARG = spoint, - RIGHTARG = smoc, - PROCEDURE = spoint_subset_smoc, - COMMUTATOR = '@>', - NEGATOR = '!<@', - RESTRICT = contsel, - JOIN = contjoinsel -); diff --git a/pgs_moc_ops.sql.in b/pgs_moc_ops.sql.in index 1319f5b0..4e71af36 100644 --- a/pgs_moc_ops.sql.in +++ b/pgs_moc_ops.sql.in @@ -354,6 +354,7 @@ CREATE OPERATOR CLASS smoc_gin_ops FUNCTION 4 smoc_gin_consistent (internal, int2, smoc, int4, internal, internal, internal, internal), --FUNCTION 5 smoc_gin_compare_partial (), --FUNCTION 6 smoc_gin_tri_consistent (), + --FUNCTION 7 (smoc) smoc_gin_options (internal), -- needs PG13 STORAGE int4; CREATE OPERATOR CLASS smoc_gin_ops_fine diff --git a/pgs_moc_options.sql.in b/pgs_moc_options.sql.in new file mode 100644 index 00000000..e2b8e846 --- /dev/null +++ b/pgs_moc_options.sql.in @@ -0,0 +1,12 @@ +-- GIN opclass options + +CREATE FUNCTION smoc_gin_options (internal) + RETURNS void + AS 'MODULE_PATHNAME' + LANGUAGE C + PARALLEL SAFE + IMMUTABLE + STRICT; + +ALTER OPERATOR FAMILY smoc_gin_ops USING gin + ADD FUNCTION 7 (smoc) smoc_gin_options (internal); diff --git a/pgs_point.sql.in b/pgs_point.sql.in index 908707ee..724a1190 100644 --- a/pgs_point.sql.in +++ b/pgs_point.sql.in @@ -26,6 +26,11 @@ CREATE FUNCTION set_sphere_output_precision(INT4) AS 'MODULE_PATHNAME', 'set_sphere_output_precision' LANGUAGE 'c'; +CREATE FUNCTION reset_sphere_output_precision() + RETURNS CSTRING + AS 'MODULE_PATHNAME', 'reset_sphere_output_precision' + LANGUAGE 'c'; + CREATE FUNCTION set_sphere_output(CSTRING) RETURNS CSTRING AS 'MODULE_PATHNAME', 'set_sphere_output' @@ -175,4 +180,3 @@ CREATE OPERATOR <-> ( COMMENT ON OPERATOR <-> (spoint, spoint) IS 'distance between spherical points'; - diff --git a/pgs_polygon.sql.in b/pgs_polygon.sql.in index fdd42772..0e73becf 100644 --- a/pgs_polygon.sql.in +++ b/pgs_polygon.sql.in @@ -1,6 +1,8 @@ - +-- ************************** +-- -- spherical polygon functions - +-- +-- ************************** CREATE FUNCTION npoints(spoly) RETURNS INT4 @@ -934,29 +936,49 @@ COMMENT ON OPERATOR !&& (sellipse, spoly) IS -- --- Aggregate functions to add points to polygon +-- Functions to create a polygon from arrays -- -CREATE FUNCTION spoly_add_point_aggr (spoly, spoint) +CREATE FUNCTION spoly(float8[]) + RETURNS spoly + AS 'MODULE_PATHNAME', 'spherepoly_rad' + LANGUAGE 'c' + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoly(float8[]) IS + 'creates spoly from array of numbers in radians'; + +CREATE FUNCTION spoly(spoint[]) RETURNS spoly - AS 'MODULE_PATHNAME', 'spherepoly_add_point' + AS 'MODULE_PATHNAME', 'spherepoly_from_point_array' LANGUAGE 'c' - IMMUTABLE PARALLEL SAFE; + IMMUTABLE STRICT PARALLEL SAFE; -COMMENT ON FUNCTION spoly_add_point_aggr (spoly, spoint) IS - 'adds a spherical point to spherical polygon. Do not use it standalone!'; +COMMENT ON FUNCTION spoly(spoint[]) IS + 'creates spoly from an array of points'; CREATE FUNCTION spoly_deg(float8[]) RETURNS spoly AS 'MODULE_PATHNAME', 'spherepoly_deg' LANGUAGE 'c' - IMMUTABLE STRICT; + IMMUTABLE STRICT PARALLEL SAFE; COMMENT ON FUNCTION spoly_deg(float8[]) IS - ' Create spoly from array of points. - Two consecutive numbers among those present - refer to the same occurrence and cover its - latitude and longitude, respectively.'; + 'creates spoly from array of numbers in degrees'; + + +-- +-- Aggregate functions to add points to polygon +-- + +CREATE FUNCTION spoly_add_point_aggr (spoly, spoint) + RETURNS spoly + AS 'MODULE_PATHNAME', 'spherepoly_add_point' + LANGUAGE 'c' + IMMUTABLE PARALLEL SAFE; + +COMMENT ON FUNCTION spoly_add_point_aggr (spoly, spoint) IS + 'adds a spherical point to spherical polygon. Do not use it standalone!'; CREATE FUNCTION spoly_add_points_fin_aggr (spoly) RETURNS spoly @@ -974,7 +996,6 @@ CREATE AGGREGATE spoly ( finalfunc = spoly_add_points_fin_aggr ); - -- -- polygon is convex -- diff --git a/sql/bounding_box_gist.sql b/sql/bounding_box_gist.sql index fb862d65..20176c41 100644 --- a/sql/bounding_box_gist.sql +++ b/sql/bounding_box_gist.sql @@ -1,3 +1,4 @@ +SET extra_float_digits = 2; SET enable_seqscan=true; CREATE TABLE bbox_ellipse (e sellipse not null); INSERT INTO bbox_ellipse VALUES ('<{10d, 0.1d}, (0d,0d), 0d>'); diff --git a/sql/epochprop.sql b/sql/epochprop.sql index fea97378..a6c69dd5 100644 --- a/sql/epochprop.sql +++ b/sql/epochprop.sql @@ -1,4 +1,6 @@ -SELECT +SET extra_float_digits = 1; + +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -6,12 +8,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 546.9759, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -19,12 +21,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 0, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -32,12 +34,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), NULL, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -45,12 +47,12 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), NULL, 20) AS tp) AS q; -SELECT +SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), @@ -58,7 +60,7 @@ SELECT to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( - SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), + SELECT epoch_prop(spoint(radians(269.45207695), radians(4.693364966)), 23, NULL, RADIANS(10362/3.6e6), -110, 120) AS tp) AS q; @@ -68,11 +70,11 @@ SELECT epoch_prop(NULL, 0.01 , RADIANS(10362/3.6e6), -110, 120); -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), 23, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, 20) AS tp; -SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), +SELECT epoch_prop_pos(spoint(radians(269.45207695), radians(4.693364966)), RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), 20) AS tp; diff --git a/sql/gist_support.sql b/sql/gist_support.sql new file mode 100644 index 00000000..361b3d61 --- /dev/null +++ b/sql/gist_support.sql @@ -0,0 +1,26 @@ +-- spoint_dwithin function selectivity +set jit = off; -- suppress extra planning output + +select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), 1)'); +select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .1)'); +select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .01)'); + +select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, 1)'); +select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .1)'); +select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .01)'); + +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, 1)', do_analyze := 'false'); +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .1)'); +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01)'); + +-- spoint_dwithin is symmetric in the first two arguments +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .1)'); +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(b.star, a.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .1)'); + +-- both sides indexable, check if the planner figures out the better choice +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .1) and spoint_dwithin(b.star, spoint(1,1), .05)'); +select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) + where spoint_dwithin(a.star, spoint(1,1), .05) and spoint_dwithin(b.star, spoint(1,1), .1)'); diff --git a/sql/index.sql b/sql/index.sql index 7273728e..19d537b2 100644 --- a/sql/index.sql +++ b/sql/index.sql @@ -24,6 +24,7 @@ SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>'; -- create idx CREATE TABLE spheretmp1b AS TABLE spheretmp1; +ANALYZE spheretmp1; CREATE INDEX aaaidx ON spheretmp1 USING gist ( p ); @@ -59,3 +60,30 @@ SELECT count(*) FROM spheretmp4 WHERE l @ scircle '<(1,1),0.3>' ; SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>' ; +-- test spoint3 operator class with and without index-only scan + +SET enable_bitmapscan = OFF; +SET enable_indexonlyscan = ON; + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + +SET enable_indexonlyscan = OFF; + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + +-- test hash opclass + +CREATE TABLE spheretmp1c AS TABLE spheretmp1; + +SELECT p FROM spheretmp1c WHERE p <@ scircle '<(1,1),0.2>' ORDER BY p::text; +WITH points AS (SELECT DISTINCT p FROM spheretmp1c WHERE p <@ scircle '<(1,1),0.2>') + SELECT p FROM points ORDER BY p::text; + +CREATE INDEX spheretmp1c_hash_idx ON spheretmp1c USING hash(p); +EXPLAIN (COSTS OFF) SELECT * FROM spheretmp1c WHERE p = '(0.67 , 0.97)'; diff --git a/sql/index_9.5.sql b/sql/index_9.5.sql deleted file mode 100644 index fe00bcce..00000000 --- a/sql/index_9.5.sql +++ /dev/null @@ -1,18 +0,0 @@ --- test spoint3 operator class with and without index-only scan - -SET enable_seqscan = OFF; -SET enable_bitmapscan = OFF; -SET enable_indexonlyscan = ON; - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - -SET enable_bitmapscan = ON; -SET enable_indexonlyscan = OFF; - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; diff --git a/sql/init.sql b/sql/init.sql index 05b35166..374e2a35 100644 --- a/sql/init.sql +++ b/sql/init.sql @@ -1,7 +1,4 @@ -- --- first, define the datatype. Turn off echoing so that expected file --- does not depend on contents of pg_sphere.sql. +-- Initialize the extension. -- CREATE EXTENSION pg_sphere; - -select pg_sphere_version(); diff --git a/sql/init_extended.sql b/sql/init_extended.sql index 800d7e46..b28f0efd 100644 --- a/sql/init_extended.sql +++ b/sql/init_extended.sql @@ -2,15 +2,15 @@ -- spoint_data and scircle_data tables have to be created and indexed using -\! testsuite/gen_point.pl 1 > results/gen_point_1.sql +\! perl testsuite/gen_point.pl 1 > results/gen_point_1.sql \i results/gen_point_1.sql -- and -\! testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql +\! perl testsuite/gen_circle.pl 1 0.1 > results/gen_circle_1_0.1.sql \i results/gen_circle_1_0.1.sql -- -\! testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql +\! perl testsuite/gen_poly.pl 1 0.1 4 > results/gen_poly_1_0.1_4.sql \i results/gen_poly_1_0.1_4.sql diff --git a/sql/init_test.sql b/sql/init_test.sql index b2793be5..6ef6e89d 100644 --- a/sql/init_test.sql +++ b/sql/init_test.sql @@ -1,4 +1,3 @@ -SET client_min_messages TO NOTICE; +SET client_min_messages TO WARNING; \set ECHO none \i pg_sphere.test.sql -\set ECHO all diff --git a/sql/knn.sql b/sql/knn.sql new file mode 100644 index 00000000..0207c981 --- /dev/null +++ b/sql/knn.sql @@ -0,0 +1,12 @@ +CREATE TABLE points (id int, p spoint, pos int); +INSERT INTO points (id, p) SELECT x, spoint(random()*6.28, (2*random()-1)*1.57) FROM generate_series(1,314159) x; +CREATE INDEX i ON points USING gist (p); +SET enable_indexscan = true; +EXPLAIN (costs off) SELECT p <-> spoint (0.2, 0.3) FROM points ORDER BY 1 LIMIT 100; +UPDATE points SET pos = n FROM + (SELECT id, row_number() OVER (ORDER BY p <-> spoint (0.2, 0.3)) n FROM points ORDER BY p <-> spoint (0.2, 0.3) LIMIT 100) sel + WHERE points.id = sel.id; +SET enable_indexscan = false; +SELECT pos, row_number() OVER (ORDER BY p <-> spoint (0.2, 0.3)) n FROM points ORDER BY p <-> spoint (0.2, 0.3) LIMIT 100; +DROP TABLE points; + diff --git a/sql/moc100.sql b/sql/moc100.sql index 8c700b17..93afd1e6 100644 --- a/sql/moc100.sql +++ b/sql/moc100.sql @@ -1,14 +1,3 @@ -\set ECHO none -SELECT CASE - WHEN setting::int/10000 IN (10, 11, 12) THEN '10, 11, 12' -- moc100 - WHEN setting::int/10000 IN (13, 14, 15) THEN '13, 14, 15' -- moc100_2 - ELSE '16+' -END AS outputfile_for_majorversion -FROM pg_settings WHERE name = 'server_version_num'; - -SELECT (regexp_matches(version(), '..-bit'))[1] outputfile_for_arch_bits; -\set ECHO queries - CREATE TABLE moc100 ( ivoid text, coverage smoc, @@ -119,59 +108,38 @@ ivo://cds.vizier/j/a+as/124/353 6/24603,24796,25383,26065,27212,29368,29399,3101 empty 0/ \N \. +ANALYZE moc100; CREATE INDEX ON moc100 USING GIN (coverage); SELECT ivoid FROM moc100 WHERE coverage && '4/0' ORDER BY ivoid; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '0/'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; +-- PG 10 does not have JIT, ignore errors on SET +DO $$ + begin + set jit = off; + exception + when undefined_object then null; + when others then raise; + end; +$$; + +SELECT explain ($$SELECT * FROM moc100 WHERE coverage && '0/'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage && '4/0'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/0-11'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '6/43225,43227'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/0-11'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/'$$); SET enable_seqscan = off; -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage && '4/0'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <@ '4/0'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage @> '4/0'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/0-11'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '6/43225,43227'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage = '0/'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/0-11'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'; - -EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) - SELECT * FROM moc100 WHERE coverage <> '0/'; +SELECT explain ($$SELECT * FROM moc100 WHERE coverage && '4/0'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <@ '4/0'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage @> '4/0'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/0-11'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '6/43225,43227'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage = '0/'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/0-11'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '6/43225,43227'$$); +SELECT explain ($$SELECT * FROM moc100 WHERE coverage <> '0/'$$); diff --git a/sql/moc_options.sql b/sql/moc_options.sql new file mode 100644 index 00000000..5041f658 --- /dev/null +++ b/sql/moc_options.sql @@ -0,0 +1,14 @@ +create table moc_opt (m smoc); +insert into moc_opt select format('9/%s', i)::smoc from generate_series(1, 1000) g(i); +analyze moc_opt; + +create index moc_opt5 on moc_opt using gin (m); +explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; +drop index moc_opt5; + +create index moc_opt8 on moc_opt using gin (m smoc_gin_ops_fine); +explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; +drop index moc_opt8; + +create index moc_opt9 on moc_opt using gin (m smoc_gin_ops (order = 9)); +explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; diff --git a/sql/output_precision.sql b/sql/output_precision.sql new file mode 100644 index 00000000..514af1ec --- /dev/null +++ b/sql/output_precision.sql @@ -0,0 +1,82 @@ +-- +-- Test default and custom output precisions for double values. +-- + +SELECT set_sphere_output( 'RAD' ); + +-- +-- Check default precision +-- +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +-- +-- Check option extra_float_digits +-- +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO -2; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO 0; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO 1; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO 2; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO 3; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO 6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +-- +-- Check compatibility behaviour +-- +SELECT set_sphere_output_precision(10); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SELECT set_sphere_output_precision(12); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SELECT set_sphere_output_precision(15); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SELECT set_sphere_output_precision(17); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SELECT set_sphere_output_precision(20); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SELECT set_sphere_output_precision(0); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SELECT set_sphere_output_precision(-3); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +-- +-- Check extra_float_digits after set_sphere_output_precision. +-- The change of extra_float_digits should not affect the precision of pgsphere +-- output because set_sphere_output_precision enables compatibility mode. +-- +SELECT set_sphere_output_precision(10); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO -10; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +-- +-- Check reset_sphere_output_precision. +-- It should disable compatibility mode - extra_float_digits should work. +-- +SELECT reset_sphere_output_precision(); +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; + +SET extra_float_digits TO -6; +SELECT '( 1h 2m 30s , +1d 2m 30s)'::spoint; diff --git a/sql/points.sql b/sql/points.sql index 5e63260a..b34ae6ec 100644 --- a/sql/points.sql +++ b/sql/points.sql @@ -240,3 +240,12 @@ SELECT '( 0h 2m 30s , 90d 0m 0s)'::spoint<->'( 12h 2m 30s , 90d 0m 0s)'::spoint; SELECT '( 0h 2m 30s , -90d 0m 0s)'::spoint<->'( 12h 2m 30s , -90d 0m 0s)'::spoint; +-- spoint_dwithin function ---------- + +SELECT a, b, radius, a <-> b AS "<->", spoint_dwithin(a, b, radius) +FROM (VALUES + ('(0, 0)'::spoint, '(0, 0)'::spoint, 0), + ('(0, 0)', '(0, 1)', 1), + ('(0, 0)', '(0.1, 0.1)', 0.14), + ('(0, 0)', '(0.1, 0.1)', 0.15) + ) sub (a, b, radius); diff --git a/sql/poly.sql b/sql/poly.sql index 2281aba1..f742bf07 100644 --- a/sql/poly.sql +++ b/sql/poly.sql @@ -7,31 +7,31 @@ SET extra_float_digits = 0; \set poly 'spoly \'{(0.1,0),(0.2,0),(0.2,0.1),(0.3,0.1),(0.3,-0.1),(0.4,-0.1),(0.5,0.1),(0.4,0.2),(0.1,0.2)}\'' SELECT spoint '(0.15,0.10)' @ :poly; -- point inside polygon -SELECT spoint '(0.20,0.00)' @ :poly; -- point contained polygon -SELECT spoint '(0.10,0.10)' @ :poly; -- point contained polygon -SELECT spoint '(0.25,0.50)' @ :poly; -- point outside polygon -SELECT spoint '(0.25,0.00)' @ :poly; -- point outside polygon +SELECT spoint '(0.20,0.00)' @ :poly; -- point contained polygon +SELECT spoint '(0.10,0.10)' @ :poly; -- point contained polygon +SELECT spoint '(0.25,0.50)' @ :poly; -- point outside polygon +SELECT spoint '(0.25,0.00)' @ :poly; -- point outside polygon SELECT scircle '<(0.15,0.10),0.03>' @ :poly; -- circle inside polygon -SELECT scircle '<(0.20,0.00),0.00>' @ :poly; -- circle contained polygon -SELECT scircle '<(0.20,0.30),0.05>' @ :poly; -- circle outside polygon +SELECT scircle '<(0.20,0.00),0.00>' @ :poly; -- circle contained polygon +SELECT scircle '<(0.20,0.30),0.05>' @ :poly; -- circle outside polygon SELECT scircle '<(0.25,0.00),0.05>' @ :poly; -- circle overlaps polygon SELECT scircle '<(0.25,0.00),0.10>' @ :poly; -- circle overlaps polygon SELECT scircle '<(0.15,0.10),0.03>' && :poly; -- circle inside polygon -SELECT scircle '<(0.20,0.00),0.00>' && :poly; -- circle contained polygon -SELECT scircle '<(0.20,0.30),0.05>' && :poly; -- circle outside polygon +SELECT scircle '<(0.20,0.00),0.00>' && :poly; -- circle contained polygon +SELECT scircle '<(0.20,0.30),0.05>' && :poly; -- circle outside polygon SELECT scircle '<(0.25,0.00),0.05>' && :poly; -- circle overlaps polygon SELECT scircle '<(0.25,0.00),0.10>' && :poly; -- circle overlaps polygon -SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) @ :poly; -- line touches polygon -SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) @ :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) @ :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) @ :poly; -- line touches polygon SELECT sline ( spoint '(0.50, 0.00)', spoint '(0.50,0.20)' ) @ :poly; -- line touches polygon -SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) @ :poly; -- line touches and inside polygon +SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) @ :poly; -- line touches and inside polygon SELECT sline ( spoint '(0.45,-0.20)', spoint '(0.45,0.20)' ) @ :poly; -- line overlaps polygon SELECT sline ( spoint '(0.45, 0.10)', spoint '(0.45,0.20)' ) @ :poly; -- line overlaps polygon SELECT sline ( spoint '(0.24, 0.17)', spoint '(0.25,0.14)' ) @ :poly; -- line inside polygon -SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) && :poly; -- line touches polygon -SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) && :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.00)', spoint '(0.10,0.20)' ) && :poly; -- line touches polygon +SELECT sline ( spoint '(0.00, 0.10)', spoint '(0.10,0.10)' ) && :poly; -- line touches polygon SELECT sline ( spoint '(0.50, 0.00)', spoint '(0.50,0.20)' ) && :poly; -- line touches polygon -SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) && :poly; -- line touches and inside polygon +SELECT sline ( spoint '(0.10, 0.20)', spoint '(0.20,0.00)' ) && :poly; -- line touches and inside polygon SELECT sline ( spoint '(0.45,-0.20)', spoint '(0.45,0.20)' ) && :poly; -- line overlaps polygon SELECT sline ( spoint '(0.45, 0.10)', spoint '(0.45,0.20)' ) && :poly; -- line overlaps polygon SELECT sline ( spoint '(0.24, 0.17)', spoint '(0.25,0.14)' ) && :poly; -- line inside polygon @@ -78,16 +78,44 @@ SELECT spoly '{(359d,0d),(359d,1d),(4d,0d)}'; SELECT spoly '{(10d,0d),(10d,1d),(15d,0d)}'; +SELECT spoly(ARRAY[0.017453292519943295, 0.03490658503988659, 0.05235987755982988, 0.06981317007977318, 0.08726646259971647, 0.10471975511965977]); + +SELECT spoly(ARRAY[0.17453292519943295, 0.0, 0.17453292519943295, 0.017453292519943295, 0.2617993877991494, 0.0]); + SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]); SELECT spoly_deg(ARRAY[10.0, 0.0, 10.0, 1.0, 15.0, 0.0]); --- incorrect input ----- +--- Constructors + +SELECT spoly(NULL::spoint[]); + +SELECT spoly(ARRAY[]::spoint[]); + +SELECT spoly(ARRAY[spoint_deg(0, 0)]); + +SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0)]); + +SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10)]); + +SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10), spoint_deg(0, 10)]); + +--- incorrect input ----- SELECT spoly '{(10d,0d),(10d,1d)}'; +SELECT spoly(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0]); + +SELECT spoly(ARRAY[1.0, 2.0, 3.0, NULL, 5.0, 6.0]); + +SELECT spoly(ARRAY[]::float8[]); + +SELECT spoly(NULL::float8[]); + SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0]); +SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, NULL, 5.0, 6.0]); + SELECT spoly_deg(ARRAY[]::float8[]); SELECT spoly_deg(NULL::float8[]); @@ -443,7 +471,7 @@ SELECT spoly '{(0d,-88d),(90d,-88d),(180d,-88d),(270d,-88d)}' @ spoly '{(0d,89d) --- spoly ~ spoly ---- should be true +--- should be true SELECT spoly '{(-1d,-1d),(-1d,1d),(1d,1d),(1d,-1d)}' ~ spoly '{(0d,0d),(0d,0.5d),(0.5d,0.5d),(0.5d,0d)}'; @@ -471,7 +499,7 @@ SELECT spoly '{(0d,89d),(90d,89d),(180d,89d),(270d,89d)}' ~ spoly '{(0d,-88d),(9 --- spoly && spoly ---- should be true +--- should be true SELECT spoly '{(0d,0d),(0d,0.5d),(0.5d,0.5d),(0.5d,0d)}' && spoly '{(-1d,-1d),(-1d,1d),(1d,1d),(1d,-1d)}'; @@ -522,7 +550,7 @@ SELECT spoly '{(-1d,-1d),(-1d,1d),(1d,1d),(1d,-1d)}' && spoly '{(179d,-1d),(179d -- -- ellipse and polygon -- - + -- negators , commutator @,&& SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{10d,5d},(280d,-20d),90d>'; @@ -551,14 +579,14 @@ SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spoly '{(280d, -9d),(280d,-12 SELECT sellipse '<{10d,5d},(280d,-20d),90d>' !&& spoly '{(280d,-11d),(280d,-12d),(279d, -12d)}'; -- ellipse is point -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; -SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; -SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; -SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; +SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' @ sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}' && sellipse '<{0d,0d},(280d,-20d),90d>'; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' @ spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' ; +SELECT sellipse '<{0d,0d},(280d,-20d),90d>' && spoly '{(280d,-11d),(280d,-20d),(279d, -12d)}'; -- ellipse is circle SELECT spoly '{(280d, -9d),(280d, -8d),(279d, -8d)}' @ sellipse '<{5d,5d},(280d,-20d),90d>'; @@ -622,3 +650,32 @@ SELECT spoly_is_convex(spoly'{(53d 45m 35.0s, 37d 6m 30.0s), (52d 21m 36.0s, 41d SELECT spoly_is_convex(spoly'{(12d,32d),(34d,12d),(59d,21d),(69d,21d)}'); SELECT spoly_is_convex(spoly'{(12d,32d),(34d,12d),(59d,21d),(34d,40d)}'); SELECT spoly_is_convex(NULL); + +-- Complex but valid polygon +SELECT '{ + (3.30474723646012 , 1.08600456205300), + (3.30341855309927 , 1.08577960186707), + (3.30341054542378 , 1.08578643990271), + (3.30297351563319 , 1.08633534556428), + (3.30357156120003 , 1.08643683957210), + (3.30358891855857 , 1.08643995044436), + (3.30360894676365 , 1.08644306147078), + (3.30361829343581 , 1.08644430596871), + (3.30362630482521 , 1.08644555030213), + (3.30364633346451 , 1.08644866102000), + (3.30365300940335 , 1.08645052692055), + (3.30366102096957 , 1.08645177113937), + (3.30367036769496 , 1.08645363721023), + (3.30367837934959 , 1.08645488137174), + (3.30368906174976 , 1.08645612569695), + (3.30370107936906 , 1.08645799183673), + (3.30370642025712 , 1.08645985750225), + (3.30373179124734 , 1.08646358962156), + (3.30374514456618 , 1.08646545561358), + (3.30410706158729 , 1.08652886672786), + (3.30427803417922 , 1.08655868846497), + (3.30429673329093 , 1.08655930694968), + (3.30432478121775 , 1.08655930174652), + (3.30433278932944 , 1.08655308246640), + (3.30446348355532 , 1.08638330933224) +}'::spoly; diff --git a/sql/selectivity.sql b/sql/selectivity.sql new file mode 100644 index 00000000..d0f1d6e2 --- /dev/null +++ b/sql/selectivity.sql @@ -0,0 +1,36 @@ +-- test selectivity estimator functions + +create table spoint10k (star spoint); +insert into spoint10k select spoint(i, i*i) from generate_series(1, 10000) g(i); +create index on spoint10k using gist (star); +analyze spoint10k; + +-- "explain analyze" wrapper that removes 'cost=...' since it varies across architectures +-- (we can't use "costs off" since that also removes the estimated row count) +create or replace function explain(query text, do_analyze text default 'true') returns setof text language plpgsql as $$ +declare + line text; +begin + for line in execute format('explain (analyze %s, timing off, summary off) %s', do_analyze, query) loop + return next regexp_replace(line, 'cost=\S+ ', ''); + end loop; + return; +end; +$$; + +-- <@ operator selectivity +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), 1)'); +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), .1)'); +select explain('select * from spoint10k where star <@ scircle(spoint(1,1), .01)'); + +select explain('select * from spoint10k where scircle(spoint(1,1), 1) @> star'); +select explain('select * from spoint10k where scircle(spoint(1,1), .1) @> star'); +select explain('select * from spoint10k where scircle(spoint(1,1), .01) @> star'); + +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), 1)'); +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), .1)'); +select explain('select * from spoint10k where star !<@ scircle(spoint(1,1), .01)'); + +select explain('select * from spoint10k where scircle(spoint(1,1), 1) !@> star'); +select explain('select * from spoint10k where scircle(spoint(1,1), .1) !@> star'); +select explain('select * from spoint10k where scircle(spoint(1,1), .01) !@> star'); diff --git a/sql/version.sql b/sql/version.sql new file mode 100644 index 00000000..89f62666 --- /dev/null +++ b/sql/version.sql @@ -0,0 +1,3 @@ +-- Check current pgsphere version +SELECT pg_sphere_version(); + diff --git a/src/box.h b/src/box.h index 7314ac03..6444a52a 100644 --- a/src/box.h +++ b/src/box.h @@ -11,8 +11,8 @@ */ typedef struct { - SPoint sw; /* South-west value of a box */ - SPoint ne; /* North-east value of a box */ + SPoint sw; /* South-west value of a box */ + SPoint ne; /* North-east value of a box */ } SBOX; @@ -56,373 +56,373 @@ typedef struct /* * Checks whether two boxes are equal. */ -bool sbox_eq(SBOX *b1, SBOX *b2); +extern bool sbox_eq(SBOX *b1, SBOX *b2); /* * Checks whether a point is contained by a box. */ -bool sbox_cont_point(const SBOX *b, const SPoint *p); +extern bool sbox_cont_point(const SBOX *b, const SPoint *p); /* * Input function of a box. */ -Datum spherebox_in(PG_FUNCTION_ARGS); +extern Datum spherebox_in(PG_FUNCTION_ARGS); /* * Input function of a box from two points. The first point * is the south-west position, the second the north-east position. */ -Datum spherebox_in_from_points(PG_FUNCTION_ARGS); +extern Datum spherebox_in_from_points(PG_FUNCTION_ARGS); /* * Returns the south-west edge of a box. */ -Datum spherebox_sw(PG_FUNCTION_ARGS); +extern Datum spherebox_sw(PG_FUNCTION_ARGS); /* * Returns the north-east edge of a box. */ -Datum spherebox_ne(PG_FUNCTION_ARGS); +extern Datum spherebox_ne(PG_FUNCTION_ARGS); /* * Returns the south-east edge of a box. */ -Datum spherebox_se(PG_FUNCTION_ARGS); +extern Datum spherebox_se(PG_FUNCTION_ARGS); /* * Returns the north-west edge of a box. */ -Datum spherebox_nw(PG_FUNCTION_ARGS); +extern Datum spherebox_nw(PG_FUNCTION_ARGS); /* * Returns the area of a box. */ -Datum spherebox_area(PG_FUNCTION_ARGS); +extern Datum spherebox_area(PG_FUNCTION_ARGS); /* * Returns the circumference of a box. */ -Datum spherebox_circ(PG_FUNCTION_ARGS); +extern Datum spherebox_circ(PG_FUNCTION_ARGS); /* * Checks whether two boxes are equal. */ -Datum spherebox_equal(PG_FUNCTION_ARGS); +extern Datum spherebox_equal(PG_FUNCTION_ARGS); /* * Checks whether two boxes are not equal. */ -Datum spherebox_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_equal_neg(PG_FUNCTION_ARGS); /* * Checks whether a point is contained by a box. */ -Datum spherebox_cont_point(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a point isn't contained by a box. */ -Datum spherebox_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a point is contained by a box. */ -Datum spherebox_cont_point_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a point isn't contained by a box. */ -Datum spherebox_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a circle. */ -Datum spherebox_cont_circle(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a circle. */ -Datum spherebox_cont_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a circle. */ -Datum spherebox_cont_circle_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a circle. */ -Datum spherebox_cont_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a box. */ -Datum spherecircle_cont_box(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a box. */ -Datum spherecircle_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a box. */ -Datum spherecircle_cont_box_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a box. */ -Datum spherecircle_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box overlap. */ -Datum spherebox_overlap_circle(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box don't overlap. */ -Datum spherebox_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box overlap. */ -Datum spherebox_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box don't overlap. */ -Datum spherebox_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a line. */ -Datum spherebox_cont_line(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a line. */ -Datum spherebox_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a line. */ -Datum spherebox_cont_line_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a line. */ -Datum spherebox_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a line overlap. */ -Datum spherebox_overlap_line(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether a box and a line don't overlap. */ -Datum spherebox_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a line overlap. */ -Datum spherebox_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether a box and a line don't overlap. */ -Datum spherebox_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a path. */ -Datum spherebox_cont_path(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a path. */ -Datum spherebox_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a path. */ -Datum spherebox_cont_path_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a path. */ -Datum spherebox_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a path overlap. */ -Datum spherebox_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether a box and a path don't overlap. */ -Datum spherebox_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a path overlap. */ -Datum spherebox_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether a box and a path don't overlap. */ -Datum spherebox_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a polygon. */ -Datum spherebox_cont_poly(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a polygon. */ -Datum spherebox_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a polygon. */ -Datum spherebox_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a polygon. */ -Datum spherebox_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a box. */ -Datum spherepoly_cont_box(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a box. */ -Datum spherepoly_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a box. */ -Datum spherepoly_cont_box_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a box. */ -Datum spherepoly_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box overlap. */ -Datum spherebox_overlap_poly(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box don't overlap. */ -Datum spherebox_overlap_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box overlap. */ -Datum spherebox_overlap_poly_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box don't overlap. */ -Datum spherebox_overlap_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains an ellipse. */ -Datum spherebox_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain an ellipse. */ -Datum spherebox_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains an ellipse. */ -Datum spherebox_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain an ellipse. */ -Datum spherebox_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a box. */ -Datum sphereellipse_cont_box(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a box. */ -Datum sphereellipse_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a box. */ -Datum sphereellipse_cont_box_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a box. */ -Datum sphereellipse_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box overlap. */ -Datum spherebox_overlap_ellipse(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box don't overlap. */ -Datum spherebox_overlap_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box overlap. */ -Datum spherebox_overlap_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box don't overlap. */ -Datum spherebox_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains another box. */ -Datum spherebox_cont_box(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain another box. */ -Datum spherebox_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains another box. */ -Datum spherebox_cont_box_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain another box. */ -Datum spherebox_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two boxes overlap. */ -Datum spherebox_overlap_box(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_box(PG_FUNCTION_ARGS); /* * Checks whether two boxes don't overlap. */ -Datum spherebox_overlap_box_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_box_neg(PG_FUNCTION_ARGS); #endif diff --git a/src/circle.c b/src/circle.c index e28fe0c5..577ac3c4 100644 --- a/src/circle.c +++ b/src/circle.c @@ -391,7 +391,7 @@ spherecircle_area(PG_FUNCTION_ARGS) { SCIRCLE *c = (SCIRCLE *) PG_GETARG_POINTER(0); - PG_RETURN_FLOAT8(PID * (1 - cos(c->radius))); + PG_RETURN_FLOAT8(spherecircle_area_float(c->radius)); } Datum diff --git a/src/circle.h b/src/circle.h index b8aa5200..614b0e81 100644 --- a/src/circle.h +++ b/src/circle.h @@ -10,151 +10,151 @@ */ typedef struct { - SPoint center; /* the center of circle */ - float8 radius; /* the circle radius in radians */ + SPoint center; /* the center of circle */ + float8 radius; /* the circle radius in radians */ } SCIRCLE; /* * Checks whether two circles are equal. */ -bool scircle_eq(const SCIRCLE *c1, const SCIRCLE *c2); +extern bool scircle_eq(const SCIRCLE *c1, const SCIRCLE *c2); /* * Checks whether a circle contains a point. */ -bool spoint_in_circle(const SPoint *p, const SCIRCLE *c); +extern bool spoint_in_circle(const SPoint *p, const SCIRCLE *c); /* * Transforms a circle using an Euler transformation. */ -void euler_scircle_trans(SCIRCLE *out, const SCIRCLE *in, const SEuler *se); +extern void euler_scircle_trans(SCIRCLE *out, const SCIRCLE *in, const SEuler *se); /* * Takes the input and stores it as a spherical circle. */ -Datum spherecircle_in(PG_FUNCTION_ARGS); +extern Datum spherecircle_in(PG_FUNCTION_ARGS); /* * Checks whether two circles are equal. */ -Datum spherecircle_equal(PG_FUNCTION_ARGS); +extern Datum spherecircle_equal(PG_FUNCTION_ARGS); /* * Checks whether two circles are not equal. */ -Datum spherecircle_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_equal_neg(PG_FUNCTION_ARGS); /* * Calculate the distance of two circles. If they overlap, this function * returns 0.0. */ -Datum spherecircle_distance(PG_FUNCTION_ARGS); +extern Datum spherecircle_distance(PG_FUNCTION_ARGS); /* * Calculate the distance of a circle and a point. If a circle contains a point, * this function returns 0.0. */ -Datum spherecircle_point_distance(PG_FUNCTION_ARGS); +extern Datum spherecircle_point_distance(PG_FUNCTION_ARGS); /* * Calculate the distance of a point and a circle. If a circle contains a point, * this function returns 0.0. */ -Datum spherecircle_point_distance_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_point_distance_com(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a point. */ -Datum spherepoint_in_circle(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a point. */ -Datum spherepoint_in_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a point. */ -Datum spherepoint_in_circle_com(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a point. */ -Datum spherepoint_in_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle is contained by other circle. */ -Datum spherecircle_in_circle(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle is not contained by other circle. */ -Datum spherecircle_in_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains other circle. */ -Datum spherecircle_in_circle_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle_com(PG_FUNCTION_ARGS); /* * Checks whether circle does not contain other circle. */ -Datum spherecircle_in_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two circles overlap. */ -Datum spherecircle_overlap(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap(PG_FUNCTION_ARGS); /* * Checks whether two circles overlap. */ -Datum spherecircle_overlap_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_neg(PG_FUNCTION_ARGS); /* * Returns the center of a circle. */ -Datum spherecircle_center(PG_FUNCTION_ARGS); +extern Datum spherecircle_center(PG_FUNCTION_ARGS); /* * Returns the radius of a circle. */ -Datum spherecircle_radius(PG_FUNCTION_ARGS); +extern Datum spherecircle_radius(PG_FUNCTION_ARGS); /* * Converts a point to a circle. */ -Datum spherepoint_to_circle(PG_FUNCTION_ARGS); +extern Datum spherepoint_to_circle(PG_FUNCTION_ARGS); /* * Creates a circle from center and radius. */ -Datum spherecircle_by_center(PG_FUNCTION_ARGS); +extern Datum spherecircle_by_center(PG_FUNCTION_ARGS); /* * Creates a circle from center and radius(in degrees). */ -Datum spherecircle_by_center_deg(PG_FUNCTION_ARGS); +extern Datum spherecircle_by_center_deg(PG_FUNCTION_ARGS); /* * Calculates the area of a circle in square radians. */ -Datum spherecircle_area(PG_FUNCTION_ARGS); +extern Datum spherecircle_area(PG_FUNCTION_ARGS); /* * Calculates the circumference of a circle in radians. */ -Datum spherecircle_circ(PG_FUNCTION_ARGS); +extern Datum spherecircle_circ(PG_FUNCTION_ARGS); /* * Transforms a circle using an Euler transformation. */ -Datum spheretrans_circle(PG_FUNCTION_ARGS); +extern Datum spheretrans_circle(PG_FUNCTION_ARGS); /* * Inverse transformation of a circle using an Euler transformation. */ -Datum spheretrans_circle_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_circle_inverse(PG_FUNCTION_ARGS); #endif diff --git a/src/circle_sel.c b/src/circle_sel.c new file mode 100644 index 00000000..d7bd843b --- /dev/null +++ b/src/circle_sel.c @@ -0,0 +1,218 @@ +#include "circle.h" +#include +#include + +/* Circle selectivity functions */ + +PG_FUNCTION_INFO_V1(spherepoint_in_circle_sel); +PG_FUNCTION_INFO_V1(spherepoint_in_circle_joinsel); +PG_FUNCTION_INFO_V1(spherepoint_in_circle_neg_sel); +PG_FUNCTION_INFO_V1(spherepoint_in_circle_neg_joinsel); +PG_FUNCTION_INFO_V1(spherepoint_in_circle_com_sel); +PG_FUNCTION_INFO_V1(spherepoint_in_circle_com_joinsel); +PG_FUNCTION_INFO_V1(spherepoint_in_circle_com_neg_sel); +PG_FUNCTION_INFO_V1(spherepoint_in_circle_com_neg_joinsel); + +/* + * Common code for spherepoint_in_circle_sel() + */ +static double +spherepoint_in_circle_sel_funcexpr(Node *other) +{ + FuncExpr *ofunc = (FuncExpr *)other; + char *func_name = get_func_name(ofunc->funcid); + Const *arg2; + double radius; + double selec; + + /* + * Safety checks: are we called on a function called scircle that takes a + * const double as 2nd argument? + */ + if (strcmp(func_name, "scircle") != 0) + { + ereport(DEBUG1, (errmsg("<@ selectivity called on function that is not scircle"))); + return DEFAULT_SCIRCLE_SEL; + } + if (list_length(ofunc->args) != 2) + { + ereport(DEBUG1, (errmsg("<@ selectivity called on function that does not have 2 arguments"))); + return DEFAULT_SCIRCLE_SEL; + } + if (!IsA(lsecond(ofunc->args), Const)) + { + ereport(DEBUG1, (errmsg("<@ selectivity called on scircle() with non-const 2nd arg"))); + return DEFAULT_SCIRCLE_SEL; + } + arg2 = (Const *) lsecond(ofunc->args); + if (arg2->consttype != FLOAT8OID) + { + ereport(DEBUG1, (errmsg("<@ selectivity called on scircle() with non-float8 2nd arg"))); + return DEFAULT_SCIRCLE_SEL; + } + + radius = DatumGetFloat8(arg2->constvalue); + selec = spherecircle_area_float(radius) / SPHERE_SURFACE; + CLAMP_PROBABILITY(selec); + + return selec; +} + +static double +spherepoint_in_circle_sel_internal(PG_FUNCTION_ARGS, bool commute, bool negate) +{ + PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0); + Oid operator = PG_GETARG_OID(1); + List *args = (List *) PG_GETARG_POINTER(2); + int varRelid = PG_GETARG_INT32(3); + //Oid collation = PG_GET_COLLATION(); + VariableStatData vardata; + Node *other; + bool varonleft; + double selec; + + /* + * When asked about <>, we do the estimation using the corresponding = + * operator, then convert to <> via "1.0 - eq_selectivity - nullfrac". + */ + if (negate) + { + operator = get_negator(operator); + if (!OidIsValid(operator)) + { + /* Use default selectivity (should we raise an error instead?) */ + return 1.0 - DEFAULT_SCIRCLE_SEL; + } + } + + /* + * If expression is not variable = something or something = variable, then + * punt and return a default estimate. + */ + if (!get_restriction_variable(root, args, varRelid, + &vardata, &other, &varonleft)) + return negate ? (1.0 - DEFAULT_SCIRCLE_SEL) : DEFAULT_SCIRCLE_SEL; + + /* + * We can do a lot better if the something is a constant. (Note: the + * Const might result from estimation rather than being a simple constant + * in the query.) + * Look only at var op circle_const, not var op point_const. + */ + if (IsA(other, Const) && varonleft != commute) + { + Const *constnode = (Const *) other; + SCIRCLE *c; + + Assert(!constnode->constisnull); /* operators are strict, shouldn't have NULLs here */ + c = (SCIRCLE *) constnode->constvalue; + selec = spherecircle_area_float(c->radius) / SPHERE_SURFACE; + CLAMP_PROBABILITY(selec); + } + /* + * Check for <@ scircle(..., radius) + */ + else if (IsA(other, FuncExpr) && varonleft != commute) + { + selec = spherepoint_in_circle_sel_funcexpr(other); + // p *((double * )&((*(Const *)((((FuncExpr*) other)->args->elements)[1].ptr_value)).constvalue)) + } + else + { + ereport(DEBUG1, (errmsg("<@ selectivity not const, other node tag %i", other->type))); + selec = DEFAULT_SCIRCLE_SEL; + } + + ReleaseVariableStats(vardata); + + return negate ? (1.0 - selec) : selec; +} + +/* + * Common code for spherepoint_in_circle_joinsel() + */ +static double +spherepoint_in_circle_joinsel_internal(PG_FUNCTION_ARGS, bool commute) +{ +#ifdef NOT_USED + PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0); + Oid operator = PG_GETARG_OID(1); + List *args = (List *) PG_GETARG_POINTER(2); + + JoinType jointype = (JoinType) PG_GETARG_INT16(3); + SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) PG_GETARG_POINTER(4); + Oid collation = PG_GET_COLLATION(); + double selec; + double selec_inner; + VariableStatData vardata1; + VariableStatData vardata2; + double nd1; + double nd2; + bool isdefault1; + bool isdefault2; + Oid opfuncoid; + AttStatsSlot sslot1; + AttStatsSlot sslot2; + bool join_is_reversed; + RelOptInfo *inner_rel; + + get_join_variables(root, args, sjinfo, + &vardata1, &vardata2, &join_is_reversed); + + ReleaseVariableStats(vardata1); + ReleaseVariableStats(vardata2); +#endif + + /* return a constant default for now; practically joins should use the + * spoint_dwithin function instead which has join support with the + * additional advantage that it's symmetric */ + return DEFAULT_SCIRCLE_SEL; +} + +Datum +spherepoint_in_circle_sel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(spherepoint_in_circle_sel_internal(fcinfo, false, false)); +} + +Datum +spherepoint_in_circle_joinsel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(spherepoint_in_circle_joinsel_internal(fcinfo, false)); +} + +Datum +spherepoint_in_circle_neg_sel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(spherepoint_in_circle_sel_internal(fcinfo, false, true)); +} + +Datum +spherepoint_in_circle_neg_joinsel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(DEFAULT_INEQ_SEL); +} + +Datum +spherepoint_in_circle_com_sel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(spherepoint_in_circle_sel_internal(fcinfo, true, false)); +} + +Datum +spherepoint_in_circle_com_joinsel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(spherepoint_in_circle_joinsel_internal(fcinfo, true)); +} + +Datum +spherepoint_in_circle_com_neg_sel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(spherepoint_in_circle_sel_internal(fcinfo, true, true)); +} + +Datum +spherepoint_in_circle_com_neg_joinsel(PG_FUNCTION_ARGS) +{ + PG_RETURN_FLOAT8(DEFAULT_INEQ_SEL); +} diff --git a/src/ellipse.h b/src/ellipse.h index b27bc3b7..f600936b 100644 --- a/src/ellipse.h +++ b/src/ellipse.h @@ -18,9 +18,9 @@ typedef struct */ float8 rad[2]; - float8 phi, /* the first rotation angle around z axis */ - theta, /* the second rotation angle around x axis */ - psi; /* the last rotation angle around z axis */ + float8 phi, /* the first rotation angle around z axis */ + theta, /* the second rotation angle around x axis */ + psi; /* the last rotation angle around z axis */ } SELLIPSE; /* @@ -47,258 +47,258 @@ typedef struct /* * Checks whether two ellipses are equal . */ -bool sellipse_eq(const SELLIPSE *e1, const SELLIPSE *e2); +extern bool sellipse_eq(const SELLIPSE *e1, const SELLIPSE *e2); /* * Returns the center of an ellipse. */ -void sellipse_center(SPoint *sp, const SELLIPSE *e); +extern void sellipse_center(SPoint *sp, const SELLIPSE *e); /* * Checks whether a ellipse contains point. */ -bool sellipse_cont_point(const SELLIPSE *se, const SPoint *sp); +extern bool sellipse_cont_point(const SELLIPSE *se, const SPoint *sp); /* * Returns the large axis of an ellipse as line. */ -bool sellipse_line(SLine *sl, const SELLIPSE *e); +extern bool sellipse_line(SLine *sl, const SELLIPSE *e); /* * Relationship between a line and an ellipse as PGS_ELLIPSE_LINE_REL int8 value. */ -int8 sellipse_line_pos(const SELLIPSE *se, const SLine *sl); +extern int8 sellipse_line_pos(const SELLIPSE *se, const SLine *sl); /* * Relationship between a circle and an ellipse as PGS_ELLIPSE_CIRCLE_REL int8 value. */ -int8 sellipse_circle_pos(const SELLIPSE *se, const SCIRCLE *sc); +extern int8 sellipse_circle_pos(const SELLIPSE *se, const SCIRCLE *sc); /* * Returns the Euler transformation of an ellipse. */ -void sellipse_trans(SEuler *se, const SELLIPSE *e); +extern void sellipse_trans(SEuler *se, const SELLIPSE *e); /* * Input of the spherical ellipse. */ -Datum sphereellipse_in(PG_FUNCTION_ARGS); +extern Datum sphereellipse_in(PG_FUNCTION_ARGS); /* * Input of the spherical ellipse from center, axes and inclination. */ -Datum sphereellipse_infunc(PG_FUNCTION_ARGS); +extern Datum sphereellipse_infunc(PG_FUNCTION_ARGS); /* * Returns the inclination of an ellipse. */ -Datum sphereellipse_incl(PG_FUNCTION_ARGS); +extern Datum sphereellipse_incl(PG_FUNCTION_ARGS); /* * Returns the length of the major axis of an ellipse. */ -Datum sphereellipse_rad1(PG_FUNCTION_ARGS); +extern Datum sphereellipse_rad1(PG_FUNCTION_ARGS); /* * Returns the length of the minor axis of an ellipse. */ -Datum sphereellipse_rad2(PG_FUNCTION_ARGS); +extern Datum sphereellipse_rad2(PG_FUNCTION_ARGS); /* * Returns the center of an ellipse. */ -Datum sphereellipse_center(PG_FUNCTION_ARGS); +extern Datum sphereellipse_center(PG_FUNCTION_ARGS); /* * Returns the Euler transformation of an ellipse. */ -Datum sphereellipse_trans(PG_FUNCTION_ARGS); +extern Datum sphereellipse_trans(PG_FUNCTION_ARGS); /* * Casts a spherical ellipse as circle. The created circle is the boundary * circle of ellipse. The diameter of returned circle is equal to length of * major axis of ellipse. */ -Datum sphereellipse_circle(PG_FUNCTION_ARGS); +extern Datum sphereellipse_circle(PG_FUNCTION_ARGS); /* * Casts a spherical point to an ellipse. */ -Datum spherepoint_ellipse(PG_FUNCTION_ARGS); +extern Datum spherepoint_ellipse(PG_FUNCTION_ARGS); /* * Casts a spherical circle to an ellipse. */ -Datum spherecircle_ellipse(PG_FUNCTION_ARGS); +extern Datum spherecircle_ellipse(PG_FUNCTION_ARGS); /* * Checks whether two ellipses are equal. */ -Datum sphereellipse_equal(PG_FUNCTION_ARGS); +extern Datum sphereellipse_equal(PG_FUNCTION_ARGS); /* * Checks whether two ellipses are not equal. */ -Datum sphereellipse_equal_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_equal_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a point. */ -Datum sphereellipse_cont_point(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a point. */ -Datum sphereellipse_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a point. */ -Datum sphereellipse_cont_point_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a point. */ -Datum sphereellipse_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a line. */ -Datum sphereellipse_cont_line(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a line. */ -Datum sphereellipse_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a line. */ -Datum sphereellipse_cont_line_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a line. */ -Datum sphereellipse_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line overlap. */ -Datum sphereellipse_overlap_line(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line don't overlap. */ -Datum sphereellipse_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line overlap. */ -Datum sphereellipse_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line don't overlap. */ -Datum sphereellipse_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a circle. */ -Datum sphereellipse_cont_circle(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a circle. */ -Datum sphereellipse_cont_circle_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a circle. */ -Datum sphereellipse_cont_circle_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a circle. */ -Datum sphereellipse_cont_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains an ellipse. */ -Datum spherecircle_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain an ellipse. */ -Datum spherecircle_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains an ellipse. */ -Datum spherecircle_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain an ellipse. */ -Datum spherecircle_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse overlap. */ -Datum sphereellipse_overlap_circle(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse don't overlap. */ -Datum sphereellipse_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse overlap. */ -Datum sphereellipse_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse don't overlap. */ -Datum sphereellipse_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains other ellipse. */ -Datum sphereellipse_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain other ellipse. */ -Datum sphereellipse_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse is contained by other ellipse. */ -Datum sphereellipse_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse isn't contained by other ellipse. */ -Datum sphereellipse_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two ellipses overlap. */ -Datum sphereellipse_overlap_ellipse(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_ellipse(PG_FUNCTION_ARGS); /* * Checks whether two ellipses don't overlap. */ -Datum sphereellipse_overlap_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_ellipse_neg(PG_FUNCTION_ARGS); /* * Transforms an ellipse using an Euler transformation. */ -Datum spheretrans_ellipse(PG_FUNCTION_ARGS); +extern Datum spheretrans_ellipse(PG_FUNCTION_ARGS); /* * Transforms an ellipse using an Euler transformation. */ -Datum spheretrans_ellipse_inv(PG_FUNCTION_ARGS); +extern Datum spheretrans_ellipse_inv(PG_FUNCTION_ARGS); #endif diff --git a/src/epochprop.c b/src/epochprop.c index ab9abc88..12ad6219 100644 --- a/src/epochprop.c +++ b/src/epochprop.c @@ -133,6 +133,7 @@ epoch_prop(PG_FUNCTION_ARGS) { phasevec input, output; ArrayType *result; Datum retvals[6]; + bool output_null[6] = {0, 0, 0, 0, 0, 0}; if (PG_ARGISNULL(0)) { ereport(ERROR, @@ -141,25 +142,29 @@ epoch_prop(PG_FUNCTION_ARGS) { memcpy(&(input.pos), (void*)PG_GETARG_POINTER(0), sizeof(SPoint)); if (PG_ARGISNULL(1)) { input.parallax = 0; + output_null[2] = 1; + /* The way we do our computation, with a bad parallax the RV + will be horribly off, too, so null this out, too; if avaialble, + we will fiddle in the original RV below again. */ + output_null[5] = 1; } else { input.parallax = PG_GETARG_FLOAT8(1); } input.parallax_valid = fabs(input.parallax) > PX_MIN; - - if (PG_ARGISNULL(2)) { - input.pm[0] = 0; - } else { - input.pm[0] = PG_GETARG_FLOAT8(2); - } - if (PG_ARGISNULL(3)) { + if (PG_ARGISNULL(2) || PG_ARGISNULL(3)) { + input.pm[0] = 0; input.pm[1] = 0; + output_null[3] = 1; + output_null[4] = 1; } else { + input.pm[0] = PG_GETARG_FLOAT8(2); input.pm[1] = PG_GETARG_FLOAT8(3); } if (PG_ARGISNULL(4)) { input.rv = 0; + output_null[5] = 1; } else { input.rv = PG_GETARG_FLOAT8(4); } @@ -172,6 +177,15 @@ epoch_prop(PG_FUNCTION_ARGS) { propagate_phasevec(&input, delta_t, &output); + /* If we have an invalid parallax but a good RV, preserve the original, + untransformed RV on output. See + https://github.com/ivoa-std/udf-catalogue/pull/20#issuecomment-2115053757 + for the rationale. */ + if (!PG_ARGISNULL(4) && !input.parallax_valid) { + output_null[5] = 0; + output.rv = input.rv; + } + /* change to internal units: rad, rad/yr, mas, and km/s */ retvals[0] = Float8GetDatum(output.pos.lng); retvals[1] = Float8GetDatum(output.pos.lat); @@ -181,7 +195,6 @@ epoch_prop(PG_FUNCTION_ARGS) { retvals[5] = Float8GetDatum(output.rv); { - bool isnull[6] = {0, 0, 0, 0, 0, 0}; int lower_bounds[1] = {1}; int dims[1] = {6}; #ifdef USE_FLOAT8_BYVAL @@ -190,13 +203,7 @@ epoch_prop(PG_FUNCTION_ARGS) { bool embyval = false; #endif - if (! output.parallax_valid) { - /* invalidate parallax and rv */ - isnull[2] = 1; - isnull[5] = 1; - } - - result = construct_md_array(retvals, isnull, 1, dims, lower_bounds, + result = construct_md_array(retvals, output_null, 1, dims, lower_bounds, FLOAT8OID, sizeof(float8), embyval, 'd'); } PG_RETURN_ARRAYTYPE_P(result); diff --git a/src/epochprop.h b/src/epochprop.h index 9e1b87e8..3b61a02c 100644 --- a/src/epochprop.h +++ b/src/epochprop.h @@ -3,24 +3,15 @@ #include -Datum epoch_prop(PG_FUNCTION_ARGS); +extern Datum epoch_prop(PG_FUNCTION_ARGS); -/* a cartesian point; this is like geo_decl's point, but you can't -have both geo_decls and pg_sphere right now (both define a type Point, -not to mention they have different ideas on EPSILON */ -typedef struct s_cpoint { - double x, y; -} CPoint; - -typedef struct s_phasevec { - SPoint pos; /* Position as an SPoint */ - double pm[2]; /* Proper motion long/lat in rad/year, - PM in longitude has cos(lat) applied */ - double parallax; /* in rad */ - double rv; /* radial velocity in km/s */ - int parallax_valid; /* 1 if the parallax really is a NULL */ +typedef struct s_phasevec +{ + SPoint pos; /* Position as an SPoint */ + double pm[2]; /* Proper motion long/lat in rad/year, PM in + * longitude has cos(lat) applied */ + double parallax; /* in rad */ + double rv; /* radial velocity in km/s */ + int parallax_valid; /* 1 if we accept the parallax as physical */ } phasevec; - - - diff --git a/src/euler.c b/src/euler.c index a45f7b3c..f9d41906 100644 --- a/src/euler.c +++ b/src/euler.c @@ -109,8 +109,8 @@ spheretrans_from_float8_and_type(PG_FUNCTION_ARGS) d[1] = PG_GETARG_DATUM(1); d[2] = PG_GETARG_DATUM(2); se = (SEuler *) DatumGetPointer( - DirectFunctionCall3(spheretrans_from_float8, - d[0], d[1], d[2])); + DirectFunctionCall3(spheretrans_from_float8, + d[0], d[1], d[2])); for (i = 0; i < 3; i++) { @@ -165,7 +165,8 @@ seuler_set_zxz(SEuler *se) bool strans_eq(const SEuler *e1, const SEuler *e2) { - SPoint in[2], p[4]; + SPoint in[2], + p[4]; in[0].lng = 0.0; in[0].lat = 0.0; @@ -210,6 +211,7 @@ Datum spheretrans_theta(PG_FUNCTION_ARGS) { SEuler *se = (SEuler *) PG_GETARG_POINTER(0); + PG_RETURN_FLOAT8(se->theta); } @@ -267,8 +269,8 @@ spheretrans_type(PG_FUNCTION_ARGS) void spheretrans_inv(SEuler *se) { - float8 lng[3]; - const unsigned char c = se->phi_a; + float8 lng[3]; + const unsigned char c = se->phi_a; lng[2] = -se->phi; lng[1] = -se->theta; @@ -298,7 +300,7 @@ strans_zxz(SEuler *ret, const SEuler *se) } else { - SEuler tmp; + SEuler tmp; tmp.psi = 0.0; tmp.theta = 0.0; @@ -339,7 +341,7 @@ spheretrans_invert(PG_FUNCTION_ARGS) void seuler_trans_zxz(SEuler *out, const SEuler *in, const SEuler *se) { - SPoint sp[4]; + SPoint sp[4]; sp[0].lng = 0.0; sp[0].lat = 0.0; @@ -380,7 +382,8 @@ spheretrans_trans_inv(PG_FUNCTION_ARGS) void euler_spoint_trans(SPoint *out, const SPoint *in, const SEuler *se) { - Vector3D v, o; + Vector3D v, + o; spoint_vector3d(&v, in); euler_vector_trans(&o, &v, se); @@ -425,7 +428,9 @@ spherevector_to_euler_inv(SEuler *se, const SPoint *spb, const SPoint *spe) } else { - Vector3D vbeg, vend, vtmp; + Vector3D vbeg, + vend, + vtmp; SPoint spt[2]; SEuler set; @@ -448,7 +453,7 @@ spherevector_to_euler_inv(SEuler *se, const SPoint *spb, const SPoint *spe) bool spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe) { - bool ret; + bool ret; ret = spherevector_to_euler_inv(se, spb, spe); if (ret) @@ -461,10 +466,13 @@ spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe) void euler_vector_trans(Vector3D *out, const Vector3D *in, const SEuler *se) { - int i; - unsigned char t; - const double *a; - double u[3], vr[3], sa, ca; + int i; + unsigned char t; + const double *a; + double u[3], + vr[3], + sa, + ca; t = 0; a = NULL; diff --git a/src/euler.h b/src/euler.h index 35e3a2ca..6baca284 100644 --- a/src/euler.h +++ b/src/euler.h @@ -12,12 +12,12 @@ */ typedef struct { - unsigned char phi_a:2, /* first axis */ - theta_a:2, /* second axis */ - psi_a:2; /* third axis */ - float8 phi, /* first rotation angle */ - theta, /* second rotation angle */ - psi; /* third rotation angle */ + unsigned char phi_a:2, /* first axis */ + theta_a:2, /* second axis */ + psi_a:2; /* third axis */ + float8 phi, /* first rotation angle */ + theta, /* second rotation angle */ + psi; /* third rotation angle */ } SEuler; @@ -25,137 +25,137 @@ typedef struct * Transforms a spherical point and returns the pointer to a transformed spherical * point. */ -void euler_spoint_trans(SPoint *out, const SPoint *in, const SEuler *se); +extern void euler_spoint_trans(SPoint *out, const SPoint *in, const SEuler *se); /* * Transforms a spherical vector from 'spb' to 'spe' into an Euler transformation. * Returns true if the transformation was successful. */ -bool spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe); +extern bool spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe); /* * Sets the axes of transformation to ZXZ. */ -void seuler_set_zxz(SEuler *se); +extern void seuler_set_zxz(SEuler *se); /* * Checks equality of two transformations. */ -bool strans_eq(const SEuler *e1, const SEuler *e2); +extern bool strans_eq(const SEuler *e1, const SEuler *e2); /* * Transforms a vector using an Euler transformation. Returns the pointer to * the result vector. */ -void euler_vector_trans(Vector3D *out, const Vector3D *in, const SEuler *se); +extern void euler_vector_trans(Vector3D *out, const Vector3D *in, const SEuler *se); /* * Inverts an Euler transformation. Returns the pointer to the * inverted transformation. */ -void spheretrans_inverse(SEuler *se_out, const SEuler *se_in); +extern void spheretrans_inverse(SEuler *se_out, const SEuler *se_in); /* * Inverts an Euler transformation replacing the original Euler transformation. * Returns the pointer to the inverted transformation. */ -void spheretrans_inv(SEuler *se); +extern void spheretrans_inv(SEuler *se); /* * Converts an Euler transformation to a ZXZ-axis transformation. Returns * the pointer to the converted transformation. */ -void strans_zxz(SEuler *ret, const SEuler *se); +extern void strans_zxz(SEuler *ret, const SEuler *se); /* * Transforms an Euler transformation 'in' into 'out' using 'se'. The result * is always a ZXZ-axis transformation. Returns the pointer to the transformed * transformation. */ -void seuler_trans_zxz(SEuler *out, const SEuler *in, const SEuler *se); +extern void seuler_trans_zxz(SEuler *out, const SEuler *in, const SEuler *se); /* * Input of an Euler transformation. */ -Datum spheretrans_in(PG_FUNCTION_ARGS); +extern Datum spheretrans_in(PG_FUNCTION_ARGS); /* * Input of an Euler transformation with axis Z,X,Z from three angles * (phi, theta, psi) in radians. */ -Datum spheretrans_from_float8(PG_FUNCTION_ARGS); +extern Datum spheretrans_from_float8(PG_FUNCTION_ARGS); /* * Returns the first angle of an Euler transformation in radians. */ -Datum spheretrans_phi(PG_FUNCTION_ARGS); +extern Datum spheretrans_phi(PG_FUNCTION_ARGS); /* * Returns the second angle of an Euler transformation in radians. */ -Datum spheretrans_theta(PG_FUNCTION_ARGS); +extern Datum spheretrans_theta(PG_FUNCTION_ARGS); /* * Returns the third angle of an Euler transformation in radians. */ -Datum spheretrans_psi(PG_FUNCTION_ARGS); +extern Datum spheretrans_psi(PG_FUNCTION_ARGS); /* * Returns the axis of an Euler transformation as three letter code. */ -Datum spheretrans_type(PG_FUNCTION_ARGS); +extern Datum spheretrans_type(PG_FUNCTION_ARGS); /* * Returns the Euler transformation (does nothing). This function is needed * for +strans operator. */ -Datum spheretrans(PG_FUNCTION_ARGS); +extern Datum spheretrans(PG_FUNCTION_ARGS); /* * Returns the inverse Euler transformation. */ -Datum spheretrans_invert(PG_FUNCTION_ARGS); +extern Datum spheretrans_invert(PG_FUNCTION_ARGS); /* * Convert an Euler transformation to a ZXZ-axis transformation. */ -Datum spheretrans_zxz(PG_FUNCTION_ARGS); +extern Datum spheretrans_zxz(PG_FUNCTION_ARGS); /* * This function creates an Euler transformation from 3 angle values in * radians and three letter code used for axes. A letter can be X, Y or Z * (case-insensitive). */ -Datum spheretrans_from_float8_and_type(PG_FUNCTION_ARGS); +extern Datum spheretrans_from_float8_and_type(PG_FUNCTION_ARGS); /* * Checks equality of two Euler transformations. */ -Datum spheretrans_equal(PG_FUNCTION_ARGS); +extern Datum spheretrans_equal(PG_FUNCTION_ARGS); /* * Checks inequality of two Euler transformations. */ -Datum spheretrans_not_equal(PG_FUNCTION_ARGS); +extern Datum spheretrans_not_equal(PG_FUNCTION_ARGS); /* * Transforms an Euler transformation. */ -Datum spheretrans_trans(PG_FUNCTION_ARGS); +extern Datum spheretrans_trans(PG_FUNCTION_ARGS); /* * Transforms inverse an Euler transformations. */ -Datum spheretrans_trans_inv(PG_FUNCTION_ARGS); +extern Datum spheretrans_trans_inv(PG_FUNCTION_ARGS); /* * Transforms a spherical point. */ -Datum spheretrans_point(PG_FUNCTION_ARGS); +extern Datum spheretrans_point(PG_FUNCTION_ARGS); /* * Perform inverse transformation of a spherical point. */ -Datum spheretrans_point_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_point_inverse(PG_FUNCTION_ARGS); #endif diff --git a/src/gist.c b/src/gist.c index b3223a50..0fef2ac6 100644 --- a/src/gist.c +++ b/src/gist.c @@ -36,6 +36,7 @@ PG_FUNCTION_INFO_V1(g_spherekey_penalty); PG_FUNCTION_INFO_V1(g_spherekey_picksplit); PG_FUNCTION_INFO_V1(g_spoint3_penalty); PG_FUNCTION_INFO_V1(g_spoint3_picksplit); +PG_FUNCTION_INFO_V1(g_spoint_distance); PG_FUNCTION_INFO_V1(g_spoint3_distance); PG_FUNCTION_INFO_V1(g_spoint3_fetch); @@ -510,7 +511,7 @@ g_spoint_consistent(PG_FUNCTION_ARGS) SCK_INTERLEAVE(SELLIPSE, sphereellipse_gen_key, 0); break; case 42: - SCK_INTERLEAVE(SBOX, spherebox_gen_key , 0); + SCK_INTERLEAVE(SBOX, spherebox_gen_key, 0); break; } @@ -681,6 +682,13 @@ g_spoint3_consistent(PG_FUNCTION_ARGS) PG_RETURN_BOOL(false); } +static double +distance_vector_point_3d(Vector3D *v, double x, double y, double z) +{ + /* as v has length = 1 by design */ + return acos((v->x * x + v->y * y + v->z * z) / sqrt(x * x + y * y + z * z)); +} + Datum g_spoint3_distance(PG_FUNCTION_ARGS) { @@ -1672,6 +1680,224 @@ fallbackSplit(Box3D *boxes, OffsetNumber maxoff, GIST_SPLITVEC *v) v->spl_ldatum_exists = v->spl_rdatum_exists = false; } + +Datum +g_spoint_distance(PG_FUNCTION_ARGS) +{ + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + Box3D *box = (Box3D *) DatumGetPointer(entry->key); + double retval; + SPoint *point = (SPoint *) PG_GETARG_POINTER(1); + Vector3D v_point, + v_low, + v_high; + + switch (strategy) + { + case 17: + /* Prepare data for calculation */ + spoint_vector3d(&v_point, point); + v_low.x = (double) box->low.coord[0] / MAXCVALUE; + v_low.y = (double) box->low.coord[1] / MAXCVALUE; + v_low.z = (double) box->low.coord[2] / MAXCVALUE; + v_high.x = (double) box->high.coord[0] / MAXCVALUE; + v_high.y = (double) box->high.coord[1] / MAXCVALUE; + v_high.z = (double) box->high.coord[2] / MAXCVALUE; + + /* + * a box splits space into 27 subspaces (6+12+8+1) with different + * distance calculation + */ + if (v_point.x < v_low.x) + { + if (v_point.y < v_low.y) + { + if (v_point.z < v_low.z) + { + /* point2point distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_low.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_low.y, v_point.z); + } + else + { + /* point2point distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_low.y, v_high.z); + } + } + else if (v_point.y < v_high.y) + { + if (v_point.z < v_low.z) + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_point.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2plane distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_point.y, v_point.z); + } + else + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_point.y, v_high.z); + } + } + else + { + if (v_point.z < v_low.z) + { + /* point2point distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_high.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_high.y, v_point.z); + } + else + { + /* point2point distance */ + retval = distance_vector_point_3d(&v_point, v_low.x, v_high.y, v_high.z); + } + } + } + else if (v_point.x < v_high.x) + { + if (v_point.y < v_low.y) + { + if (v_point.z < v_low.z) + { + /* p2line distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_low.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2plane distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_low.y, v_point.z); + } + else + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_low.y, v_high.z); + } + } + else if (v_point.y < v_high.y) + { + if (v_point.z < v_low.z) + { + /* point2plane distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_point.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* inside cube */ + retval = 0; + } + else + { + /* point2plane distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_point.y, v_high.z); + } + } + else + { + if (v_point.z < v_low.z) + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_high.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2plane distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_high.y, v_point.z); + } + else + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_point.x, v_high.y, v_high.z); + } + } + } + else + { + if (v_point.y < v_low.y) + { + if (v_point.z < v_low.z) + { + /* p2p distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_low.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_low.y, v_point.z); + } + else + { + /* point2point distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_low.y, v_high.z); + } + } + else if (v_point.y < v_high.y) + { + if (v_point.z < v_low.z) + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_point.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2plane distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_point.y, v_point.z); + } + else + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_point.y, v_high.z); + } + } + else + { + if (v_point.z < v_low.z) + { + /* point2point distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_high.y, v_low.z); + } + else if (v_point.z < v_high.z) + { + /* point2line distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_high.y, v_point.z); + } + else + { + /* point2point distance */ + retval = distance_vector_point_3d(&v_point, v_high.x, v_high.y, v_high.z); + } + } + } + + elog(DEBUG1, "distance (%lg,%lg,%lg %lg,%lg,%lg) <-> (%lg,%lg) = %lg", + v_low.x, v_low.y, v_low.z, + v_high.x, v_high.y, v_high.z, + point->lng, point->lat, + retval + ); + break; + + default: + elog(ERROR, "unrecognized cube strategy number: %d", strategy); + retval = 0; /* keep compiler quiet */ + break; + } + + PG_RETURN_FLOAT8(retval); +} + /* * Represents information about an entry that can be placed to either group * without affecting overlap over selected axis ("common entry"). @@ -2203,7 +2429,7 @@ do_picksplit(Box3D *boxes, OffsetNumber maxoff, GIST_SPLITVEC *v) { box = &boxes[i]; commonEntries[i].delta = fabs((unionSizeBox3D(leftBox, box) - leftBoxSize) - - (unionSizeBox3D(rightBox, box) - rightBoxSize)); + (unionSizeBox3D(rightBox, box) - rightBoxSize)); } /* diff --git a/src/gist.h b/src/gist.h index 6dac2a47..58e32f10 100644 --- a/src/gist.h +++ b/src/gist.h @@ -11,150 +11,150 @@ typedef unsigned char uchar; /* PGS_KEY_REL Key relationships */ -#define SCKEY_DISJ 0 /* two keys are disjunct */ -#define SCKEY_OVERLAP 1 /* two keys are overlapping */ -#define SCKEY_IN 2 /* first key contains second key */ -#define SCKEY_SAME 3 /* keys are equal */ +#define SCKEY_DISJ 0 /* two keys are disjunct */ +#define SCKEY_OVERLAP 1 /* two keys are overlapping */ +#define SCKEY_IN 2 /* first key contains second key */ +#define SCKEY_SAME 3 /* keys are equal */ -uchar spherekey_interleave(const int32 *k1, const int32 *k2); +extern uchar spherekey_interleave(const int32 *k1, const int32 *k2); /* * For given "query" of "pgstype" of PGS_DATA_TYPES type, puts key of cached * query into "key" pointer. Returns true when given query is equal to * current query. */ -bool gq_cache_get_value(unsigned pgstype, const void *query, int32 **key); +extern bool gq_cache_get_value(unsigned pgstype, const void *query, int32 **key); /* * Copy current query, type and its key value to cache. */ -void gq_cache_set_value(unsigned pgstype, const void *query, const int32 *key); +extern void gq_cache_set_value(unsigned pgstype, const void *query, const int32 *key); /* * Input function of key value. Just a dummy. But PostgreSQL need this * function to create a data type. */ -Datum spherekey_in(PG_FUNCTION_ARGS); +extern Datum spherekey_in(PG_FUNCTION_ARGS); /* * Output function of key value. Just a dummy. But PostgreSQL need this * function to create a data type. */ -Datum spherekey_out(PG_FUNCTION_ARGS); +extern Datum spherekey_out(PG_FUNCTION_ARGS); /* * GIST's decompress method. This function does nothing. */ -Datum g_spherekey_decompress(PG_FUNCTION_ARGS); +extern Datum g_spherekey_decompress(PG_FUNCTION_ARGS); /* * GIST's compress method for circle. Creates the key value from a spherical * circle. */ -Datum g_scircle_compress(PG_FUNCTION_ARGS); +extern Datum g_scircle_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for point. Creates the key value from a spherical point. */ -Datum g_spoint_compress(PG_FUNCTION_ARGS); +extern Datum g_spoint_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for line. Creates the key value from a spherical line. */ -Datum g_sline_compress(PG_FUNCTION_ARGS); +extern Datum g_sline_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for path. Creates the key value from a spherical path. */ -Datum g_spath_compress(PG_FUNCTION_ARGS); +extern Datum g_spath_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for polygon. Creates the key value from a spherical * polygon. */ -Datum g_spoly_compress(PG_FUNCTION_ARGS); +extern Datum g_spoly_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for ellipse. Creates the key value from a spherical * ellipse. */ -Datum g_sellipse_compress(PG_FUNCTION_ARGS); +extern Datum g_sellipse_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for box. Creates the key value from a spherical box. */ -Datum g_sbox_compress(PG_FUNCTION_ARGS); +extern Datum g_sbox_compress(PG_FUNCTION_ARGS); /* * The GiST Union method for boxes. Returns the minimal bounding box that * encloses all the entries in entryvec. */ -Datum g_spherekey_union(PG_FUNCTION_ARGS); +extern Datum g_spherekey_union(PG_FUNCTION_ARGS); /* * GIST's equality method. */ -Datum g_spherekey_same(PG_FUNCTION_ARGS); +extern Datum g_spherekey_same(PG_FUNCTION_ARGS); /* * GIST's consistent method for a point. */ -Datum g_spoint_consistent(PG_FUNCTION_ARGS); +extern Datum g_spoint_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a circle. */ -Datum g_scircle_consistent(PG_FUNCTION_ARGS); +extern Datum g_scircle_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a line. */ -Datum g_sline_consistent(PG_FUNCTION_ARGS); +extern Datum g_sline_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a path. */ -Datum g_spath_consistent(PG_FUNCTION_ARGS); +extern Datum g_spath_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a polygon. */ -Datum g_spoly_consistent(PG_FUNCTION_ARGS); +extern Datum g_spoly_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for an ellipse. */ -Datum g_sellipse_consistent(PG_FUNCTION_ARGS); +extern Datum g_sellipse_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a box. */ -Datum g_sbox_consistent(PG_FUNCTION_ARGS); +extern Datum g_sbox_consistent(PG_FUNCTION_ARGS); /* * GIST's penalty method. */ -Datum g_spherekey_penalty(PG_FUNCTION_ARGS); +extern Datum g_spherekey_penalty(PG_FUNCTION_ARGS); /* * GIST's picksplit method. This method is using the double sorting node * splitting algorithm for R-Trees. See "A new double sorting-based node * splitting algorithm for R-tree", A. Korotkov. */ -Datum g_spherekey_picksplit(PG_FUNCTION_ARGS); - -Datum pointkey_in(PG_FUNCTION_ARGS); -Datum pointkey_out(PG_FUNCTION_ARGS); -Datum pointkey_volume(PG_FUNCTION_ARGS); -Datum pointkey_area(PG_FUNCTION_ARGS); -Datum pointkey_perimeter(PG_FUNCTION_ARGS); -Datum g_spoint3_compress(PG_FUNCTION_ARGS); -Datum g_spoint3_union(PG_FUNCTION_ARGS); -Datum g_spoint3_same(PG_FUNCTION_ARGS); -Datum g_spoint3_consistent(PG_FUNCTION_ARGS); -Datum g_spoint3_penalty(PG_FUNCTION_ARGS); -Datum g_spoint3_picksplit(PG_FUNCTION_ARGS); -Datum g_spoint3_distance(PG_FUNCTION_ARGS); -Datum g_spoint3_fetch(PG_FUNCTION_ARGS); +extern Datum g_spherekey_picksplit(PG_FUNCTION_ARGS); + +extern Datum pointkey_in(PG_FUNCTION_ARGS); +extern Datum pointkey_out(PG_FUNCTION_ARGS); +extern Datum pointkey_volume(PG_FUNCTION_ARGS); +extern Datum pointkey_area(PG_FUNCTION_ARGS); +extern Datum pointkey_perimeter(PG_FUNCTION_ARGS); +extern Datum g_spoint3_compress(PG_FUNCTION_ARGS); +extern Datum g_spoint3_union(PG_FUNCTION_ARGS); +extern Datum g_spoint3_same(PG_FUNCTION_ARGS); +extern Datum g_spoint3_consistent(PG_FUNCTION_ARGS); +extern Datum g_spoint3_penalty(PG_FUNCTION_ARGS); +extern Datum g_spoint3_picksplit(PG_FUNCTION_ARGS); +extern Datum g_spoint3_distance(PG_FUNCTION_ARGS); +extern Datum g_spoint3_fetch(PG_FUNCTION_ARGS); #endif diff --git a/src/gist_support.c b/src/gist_support.c new file mode 100644 index 00000000..95aa65cb --- /dev/null +++ b/src/gist_support.c @@ -0,0 +1,223 @@ +/********************************************************************** + * + * pgsphere gist_support.c + * based on gserialized_supportfn.c from PostGIS + * + * PostGIS - Spatial Types for PostgreSQL + * http://postgis.net + * + * PostGIS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * PostGIS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PostGIS. If not, see . + * + **********************************************************************/ + + +/* PostgreSQL */ +#include "postgres.h" +#if PG_VERSION_NUM >= 120000 +#include "funcapi.h" +#include "access/htup_details.h" +#include "access/stratnum.h" +#include "catalog/namespace.h" +#include "catalog/pg_opfamily.h" +#include "catalog/pg_type_d.h" +#include "catalog/pg_am_d.h" +#include "nodes/supportnodes.h" +#include "nodes/nodeFuncs.h" +#include "nodes/makefuncs.h" +#include "optimizer/optimizer.h" +#include "parser/parse_func.h" +#include "parser/parse_type.h" +#include "utils/array.h" +#include "utils/builtins.h" +#include "utils/lsyscache.h" +#include "utils/numeric.h" +#include "utils/selfuncs.h" +#include "utils/syscache.h" + +#include "point.h" +#include "circle.h" + +static Oid +scircleTypeOid(Oid callingfunc) +{ + /* type must be in same namespace as the caller */ + char *nspname = get_namespace_name(get_func_namespace(callingfunc)); + List *type_name_list = list_make2(makeString(nspname), makeString("scircle")); + TypeName *type_name = makeTypeNameFromNameList(type_name_list); + Oid type_oid = LookupTypeNameOid(NULL, type_name, true); + if (type_oid == InvalidOid) + elog(ERROR, "%s: unable to lookup type 'scircle'", __func__); + return type_oid; +} + +static Oid +scircleFunctionOid(Oid geotype, Oid callingfunc) +{ + const Oid radiustype = FLOAT8OID; /* Should always be FLOAT8OID */ + const Oid scircle_function_args[2] = {geotype, radiustype}; + const bool noError = true; + /* Expand function must be in same namespace as the caller */ + char *nspname = get_namespace_name(get_func_namespace(callingfunc)); + List *scircle_function_name = list_make2(makeString(nspname), makeString("scircle")); + Oid scircle_function_oid = LookupFuncName(scircle_function_name, 2, scircle_function_args, noError); + if (scircle_function_oid == InvalidOid) + elog(ERROR, "%s: unable to lookup 'scircle(Oid[%u], Oid[%u])'", __func__, geotype, radiustype); + return scircle_function_oid; +} + +PG_FUNCTION_INFO_V1(spherepoint_dwithin_supportfn); +Datum spherepoint_dwithin_supportfn(PG_FUNCTION_ARGS) +{ + Node *rawreq = (Node *) PG_GETARG_POINTER(0); + Node *ret = NULL; + + if (IsA(rawreq, SupportRequestSelectivity)) + { + SupportRequestSelectivity *req = (SupportRequestSelectivity *) rawreq; + Node *radiusarg = (Node *) list_nth(req->args, 2); + float8 selec; + ereport(DEBUG1, (errmsg("spherepoint_dwithin_supportfn sel called on %d", req->funcid))); + + /* + * If the radius is a constant, compute the circle constant. + */ + if (IsA(radiusarg, Const)) + { + Const *constarg = (Const *) radiusarg; + float8 radius = DatumGetFloat8(constarg->constvalue); + selec = spherecircle_area_float(radius) / SPHERE_SURFACE; + ereport(DEBUG1, (errmsg("spherepoint_dwithin_supportfn const radius %g", radius))); + } + else + { + selec = DEFAULT_SCIRCLE_SEL; + ereport(DEBUG1, (errmsg("spherepoint_dwithin_supportfn non-const radius"))); + } + + if (req->is_join) + { + req->selectivity = selec; + } + else + { + req->selectivity = selec; + } + CLAMP_PROBABILITY(req->selectivity); + ereport(DEBUG1, (errmsg("spherepoint_dwithin_supportfn selectivity %g is_join %d", req->selectivity, req->is_join))); + ret = rawreq; + } + + else if (IsA(rawreq, SupportRequestIndexCondition)) + { + SupportRequestIndexCondition *req = (SupportRequestIndexCondition *) rawreq; + + FuncExpr *clause = (FuncExpr *) req->node; + Oid funcid = clause->funcid; + Oid opfamilyoid = req->opfamily; /* OPERATOR FAMILY of the index */ + + Node *leftarg, *rightarg, *radiusarg; + Oid leftdatatype, oproid; + + Oid scircle_type_oid = scircleTypeOid(funcid); + Expr *scircle_expr; + Expr *expr; + + /* + * Extract "leftarg" as the arg matching the index and "rightarg" as + * the other, even if they were in the opposite order in the call. + */ + if (req->indexarg == 0) + { + leftarg = linitial(clause->args); + rightarg = lsecond(clause->args); + } + else if (req->indexarg == 1) + { + rightarg = linitial(clause->args); + leftarg = lsecond(clause->args); + } + else + PG_RETURN_POINTER((Node *)NULL); + + leftdatatype = exprType(leftarg); + Assert(leftdatatype == exprType(rightarg)); /* expect spoint, spoint */ + + radiusarg = (Node *) list_nth(clause->args, 2); + + /* + * Given the index operator family and the arguments and the desired + * strategy number we can now lookup the operator we want. + */ + oproid = get_opfamily_member(opfamilyoid, + leftdatatype, + scircle_type_oid, + 37); /* spoint <@ scircle */ + if (!OidIsValid(oproid)) + elog(ERROR, + "no spatial operator found for '%s': opfamily %u types %d %d strategy %d", + "scircle", + opfamilyoid, + leftdatatype, + scircle_type_oid, + 37); + + /* + * If both the right argument and the radius are a constant, compute + * the circle constant. (makeFuncExpr won't constify by itself + * unfortunately.) + */ + if (IsA(rightarg, Const) && IsA(radiusarg, Const)) + { + Datum center = ((Const *) rightarg)->constvalue; + Datum radius = ((Const *) radiusarg)->constvalue; + Datum circle = DirectFunctionCall2(spherecircle_by_center, center, radius); + scircle_expr = (Expr *) makeConst(scircle_type_oid, -1, InvalidOid, + sizeof(SCIRCLE), circle, false, false); + ereport(DEBUG1, (errmsg("spherepoint_dwithin_supportfn index condition const"))); + } + else + { + Oid scircle_function_oid = scircleFunctionOid(leftdatatype, clause->funcid); + scircle_expr = (Expr *) makeFuncExpr(scircle_function_oid, leftdatatype, + list_make2(rightarg, radiusarg), + InvalidOid, InvalidOid, COERCE_EXPLICIT_CALL); + ereport(DEBUG1, (errmsg("spherepoint_dwithin_supportfn index condition function"))); + } + + /* + * The comparison expression has to be a pseudo constant, + * (not volatile or dependent on the target index table) + */ +#if PG_VERSION_NUM >= 140000 + if (!is_pseudo_constant_for_index(req->root, (Node*)scircle_expr, req->index)) +#else + if (!is_pseudo_constant_for_index((Node*)scircle_expr, req->index)) +#endif + PG_RETURN_POINTER((Node*)NULL); + + /* OK, we can make an index expression */ + expr = make_opclause(oproid, BOOLOID, false, + (Expr *) leftarg, scircle_expr, + InvalidOid, InvalidOid); + + ret = (Node *)(list_make1(expr)); + + /* This is an exact index lookup */ + req->lossy = false; + } + + PG_RETURN_POINTER(ret); +} + +#endif /* PG_VERSION_NUM */ diff --git a/src/gnomo.h b/src/gnomo.h index bae1d11f..c7a27777 100644 --- a/src/gnomo.h +++ b/src/gnomo.h @@ -3,7 +3,7 @@ /* function prototypes for the direct and inverse gnomonic projections */ -Datum gnomonic_proj(PG_FUNCTION_ARGS); -Datum gnomonic_inv(PG_FUNCTION_ARGS); +extern Datum gnomonic_proj(PG_FUNCTION_ARGS); +extern Datum gnomonic_inv(PG_FUNCTION_ARGS); #endif diff --git a/src/key.h b/src/key.h index aa77ca98..e4c39dc8 100644 --- a/src/key.h +++ b/src/key.h @@ -20,30 +20,32 @@ typedef struct { - char vl_len_[4]; + char vl_len_[4]; union { - struct /* the compiler will probably insert 4 bytes of padding here */ + struct /* the compiler will probably insert 4 bytes + * of padding here */ { - float8 lat, - lng; + float8 lat, + lng; }; }; -} GiSTSPointKey_Leaf; +} GiSTSPointKey_Leaf; typedef struct { - char vl_len_[4]; + char vl_len_[4]; union { - struct /* the compiler will probably insert 4 bytes of padding here */ + struct /* the compiler will probably insert 4 bytes + * of padding here */ { - float8 lat, - lng; + float8 lat, + lng; }; struct { - int32 k[6]; + int32 k[6]; }; }; } GiSTSPointKey; @@ -51,10 +53,12 @@ typedef struct #define INTERNAL_KEY_SIZE sizeof(GiSTSPointKey) #define LEAF_KEY_SIZE sizeof(GiSTSPointKey_Leaf) #define IS_LEAF(key) (VARSIZE(key) == LEAF_KEY_SIZE) + #define ALLOC_LEAF_KEY(key) do { \ key = (GiSTSPointKey *)palloc0(LEAF_KEY_SIZE); \ SET_VARSIZE(key, LEAF_KEY_SIZE); \ } while (0) ; + #define ALLOC_INTERNAL_KEY(key) do { \ key = (GiSTSPointKey *)palloc0(INTERNAL_KEY_SIZE); \ SET_VARSIZE(key, INTERNAL_KEY_SIZE); \ @@ -63,128 +67,128 @@ typedef struct /* * Returns the union of two keys. Result is placed into 'kunion'. */ -void spherekey_union_two(int32 *kunion, const int32 *key); +extern void spherekey_union_two(int32 *kunion, const int32 *key); /* * Returns the intersection of two keys. Returns NULL if there is * no intersection. Result is placed into 'kinter'. */ -bool spherekey_inter_two(int32 *kinter, const int32 *key); +extern bool spherekey_inter_two(int32 *kinter, const int32 *key); /* * Generates the key of a spherical point and returns it. Result is placed * into 'k'. */ -void spherepoint_gen_key(int32 *k, const SPoint *sp); +extern void spherepoint_gen_key(int32 *k, const SPoint *sp); /* * Generates the circle's key and returns it. Result is placed into 'k'. */ -void spherecircle_gen_key(int32 *k, const SCIRCLE *c); +extern void spherecircle_gen_key(int32 *k, const SCIRCLE *c); /* * Generates the key of a spherical ellipse and returns it. Result is placed * into 'k'. */ -void sphereellipse_gen_key(int32 *k, const SELLIPSE *e); +extern void sphereellipse_gen_key(int32 *k, const SELLIPSE *e); /* * Generates the key of a spherical line and returns it. Result is placed * into 'k'. */ -void sphereline_gen_key(int32 *k, const SLine *sl); +extern void sphereline_gen_key(int32 *k, const SLine *sl); /* * Generates the key of a polygon and returns it. Result is placed into 'k'. */ -void spherepoly_gen_key(int32 *k, const SPOLY *sp); +extern void spherepoly_gen_key(int32 *k, const SPOLY *sp); /* * Generates the key of a path and returns it. Result is placed into 'k'. */ -void spherepath_gen_key(int32 *k, const SPATH *sp); +extern void spherepath_gen_key(int32 *k, const SPATH *sp); /* * Generates the key of a box and returns it. Result is placed into 'k'. */ -void spherebox_gen_key(int32 *key, const SBOX *box); +extern void spherebox_gen_key(int32 *key, const SBOX *box); /* * Returns true if the first key is less than the second key. */ -Datum spherekey_lt(PG_FUNCTION_ARGS); +extern Datum spherekey_lt(PG_FUNCTION_ARGS); /* * Returns true if the first key is less or equal than the second key. */ -Datum spherekey_le(PG_FUNCTION_ARGS); +extern Datum spherekey_le(PG_FUNCTION_ARGS); /* * Returns true if two keys are equal. */ -Datum spherekey_eq(PG_FUNCTION_ARGS); +extern Datum spherekey_eq(PG_FUNCTION_ARGS); /* * Returns true if two keys are not equal. */ -Datum spherekey_eq_neg(PG_FUNCTION_ARGS); +extern Datum spherekey_eq_neg(PG_FUNCTION_ARGS); /* * Returns true if the first key is greater or equal than the second key. */ -Datum spherekey_ge(PG_FUNCTION_ARGS); +extern Datum spherekey_ge(PG_FUNCTION_ARGS); /* * Returns true if the first key is greater than the second key. */ -Datum spherekey_gt(PG_FUNCTION_ARGS); +extern Datum spherekey_gt(PG_FUNCTION_ARGS); /* * Returns relationship between the two keys. * Calls skey_cmp(const int32 *, const int32 *) for two keys. */ -Datum spherekey_cmp(PG_FUNCTION_ARGS); +extern Datum spherekey_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical points. * Calls skey_cmp(const int32 *, const int32 *) for two points. */ -Datum spherepoint_cmp(PG_FUNCTION_ARGS); +extern Datum spherepoint_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical circles. * Calls skey_cmp(const int32 *, const int32 *) for two circles. */ -Datum spherecircle_cmp(PG_FUNCTION_ARGS); +extern Datum spherecircle_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical ellipses. * Calls skey_cmp(const int32 *, const int32 *) for two ellipses. */ -Datum sphereellipse_cmp(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical lines. * Calls skey_cmp(const int32 *, const int32 *) for two lines. */ -Datum sphereline_cmp(PG_FUNCTION_ARGS); +extern Datum sphereline_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical paths. * Calls skey_cmp(const int32 *, const int32 *) for two paths. */ -Datum spherepath_cmp(PG_FUNCTION_ARGS); +extern Datum spherepath_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical polygons. * Calls skey_cmp(const int32 *, const int32 *) for two polygons. */ -Datum spherepoly_cmp(PG_FUNCTION_ARGS); +extern Datum spherepoly_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical boxes. * Calls skey_cmp(const int32 *, const int32 *) for two boxes. */ -Datum spherebox_cmp(PG_FUNCTION_ARGS); +extern Datum spherebox_cmp(PG_FUNCTION_ARGS); #endif diff --git a/src/line.c b/src/line.c index ad02575f..59785f1f 100644 --- a/src/line.c +++ b/src/line.c @@ -496,6 +496,15 @@ sline_sline_pos(const SLine *l1, const SLine *l2) vector3d_spoint(&p[2], &v[1][0]); vector3d_spoint(&p[3], &v[1][1]); + /* check connected lines */ + if (FPgt(il2->length, 0.0) && (vector3d_eq(&v[0][0], &v[1][0]) || + vector3d_eq(&v[0][0], &v[1][1]) || + vector3d_eq(&v[0][1], &v[1][0]) || + vector3d_eq(&v[0][1], &v[1][1]))) + { + return PGS_LINE_CONNECT; + } + /* Check, sl2 is at equator */ if (FPzero(p[2].lat) && FPzero(p[3].lat)) { @@ -520,15 +529,6 @@ sline_sline_pos(const SLine *l1, const SLine *l2) return PGS_LINE_AVOID; } - /* check connected lines */ - if (FPgt(il2->length, 0.0) && (vector3d_eq(&v[0][0], &v[1][0]) || - vector3d_eq(&v[0][0], &v[1][1]) || - vector3d_eq(&v[0][1], &v[1][0]) || - vector3d_eq(&v[0][1], &v[1][1]))) - { - return PGS_LINE_CONNECT; - } - /* Now sl2 is not at equator */ if (FPle(il2->length, seg_length)) diff --git a/src/line.h b/src/line.h index 002f3714..deaa028d 100644 --- a/src/line.h +++ b/src/line.h @@ -10,10 +10,10 @@ */ typedef struct { - float8 phi, /* the first rotation angle around z axis */ - theta, /* the second rotation angle around x axis */ - psi; /* the last rotation angle around z axis */ - float8 length; /* the length of the line */ + float8 phi, /* the first rotation angle around z axis */ + theta, /* the second rotation angle around x axis */ + psi; /* the last rotation angle around z axis */ + float8 length; /* the length of the line */ } SLine; /* PGS_RELATIONSHIPS Object relationships */ @@ -37,47 +37,47 @@ typedef struct * * Returns false if the distance between the 'pbeg' and the 'pend' is 180deg. */ -bool sline_from_points(SLine *sl, const SPoint *pbeg, const SPoint *pend); +extern bool sline_from_points(SLine *sl, const SPoint *pbeg, const SPoint *pend); /* * Returns a meridian line of a given longitude in radians. The result is placed * into 'sl'. */ -void sline_meridian(SLine *sl, float8 lng); +extern void sline_meridian(SLine *sl, float8 lng); /* * Returns the starting point of a line 'l'. Result is placed into 'p'. */ -void sline_begin(SPoint *p, const SLine *l); +extern void sline_begin(SPoint *p, const SLine *l); /* * Returns the ending point of a line 'l'. Result is placed into 'p'. */ -void sline_end(SPoint *p, const SLine *l); +extern void sline_end(SPoint *p, const SLine *l); /* * Puts the minimum and the maximum latitudes of a spherical line 's1' into 'minlat' * and 'maxlat'. */ -void sline_min_max_lat(const SLine *sl, float8 *minlat, float8 *maxlat); +extern void sline_min_max_lat(const SLine *sl, float8 *minlat, float8 *maxlat); /* * Calculates spherical points with a latitude 'lat' on a spherical line. * * Returns the number of found points or <0 if undefined. */ -int32 sphereline_latitude_points(const SLine *sl, float8 lat, SPoint *p1, SPoint *p2); +extern int32 sphereline_latitude_points(const SLine *sl, float8 lat, SPoint *p1, SPoint *p2); /* * Returns true if two lines are equal. */ -bool sline_eq(const SLine *l1, const SLine *l2); +extern bool sline_eq(const SLine *l1, const SLine *l2); /* * Returns the relationship between a line and a circle as PGS_CIRCLE_LINE_REL * int8 value. */ -int8 sphereline_circle_pos(const SLine *sl, const SCIRCLE *sc); +extern int8 sphereline_circle_pos(const SLine *sl, const SCIRCLE *sc); /* * Assuming that a line and a circle overlap, this function returns true @@ -87,31 +87,31 @@ int8 sphereline_circle_pos(const SLine *sl, const SCIRCLE *sc); * * See sphereline_circle_pos (const SLine *, const SCIRCLE *) */ -bool sline_circle_touch(const SLine *sl, const SCIRCLE *sc); +extern bool sline_circle_touch(const SLine *sl, const SCIRCLE *sc); /* * Returns the relationship between two lines as PGS_LINE_LINE_REL int8 value. */ -int8 sline_sline_pos(const SLine *l1, const SLine *l2); +extern int8 sline_sline_pos(const SLine *l1, const SLine *l2); /* * Checks whether a point is on a line. */ -bool spoint_at_sline(const SPoint *p, const SLine *sl); +extern bool spoint_at_sline(const SPoint *p, const SLine *sl); /* * Returns the Euler transformation of a line. * * See spheretrans_from_line(PG_FUNCTION_ARGS) */ -void sphereline_to_euler(SEuler *se, const SLine *sl); +extern void sphereline_to_euler(SEuler *se, const SLine *sl); /* * Returns the inverse Euler transformation of a line. * * See spheretrans_from_line(PG_FUNCTION_ARGS) */ -void sphereline_to_euler_inv(SEuler *se, const SLine *sl); +extern void sphereline_to_euler_inv(SEuler *se, const SLine *sl); /* * Transforms a line using an Euler transformation. @@ -122,187 +122,187 @@ void sphereline_to_euler_inv(SEuler *se, const SLine *sl); * * See spheretrans_line (PG_FUNCTION_ARGS) */ -void euler_sline_trans(SLine *out, const SLine *in, const SEuler *se); +extern void euler_sline_trans(SLine *out, const SLine *in, const SEuler *se); /* * Puts the center of a line 'sl' into point 'c'. */ -void sline_center(SPoint *c, const SLine *sl); +extern void sline_center(SPoint *c, const SLine *sl); /* * Calculates the distance between a line 'sl' and a point 'p' */ -float8 sline_point_dist(const SLine *sl, const SPoint *p); +float8 sline_point_dist(const SLine *sl, const SPoint *p); /* * The input function for spherical line. */ -Datum sphereline_in(PG_FUNCTION_ARGS); +extern Datum sphereline_in(PG_FUNCTION_ARGS); /* * Create a line from a spherical point. */ -Datum sphereline_from_point(PG_FUNCTION_ARGS); +extern Datum sphereline_from_point(PG_FUNCTION_ARGS); /* * This function creates a spherical line using a starting point * and an ending point. The distance between the points must not be * equal to 180deg. */ -Datum sphereline_from_points(PG_FUNCTION_ARGS); +extern Datum sphereline_from_points(PG_FUNCTION_ARGS); /* * This function creates a spherical line using a given Euler transformation * and the length of a line. If the length is less than zero, an error occurs. * If the length is larger than 360deg, it is set to 360deg. */ -Datum sphereline_from_trans(PG_FUNCTION_ARGS); +extern Datum sphereline_from_trans(PG_FUNCTION_ARGS); /* * This function creates a meridian running from south to north. * The float8 param provides the longitude in radians. */ -Datum sphereline_meridian(PG_FUNCTION_ARGS); +extern Datum sphereline_meridian(PG_FUNCTION_ARGS); /* * Swaps the starting point and the ending point of a line. */ -Datum sphereline_swap_beg_end(PG_FUNCTION_ARGS); +extern Datum sphereline_swap_beg_end(PG_FUNCTION_ARGS); /* * Turns the line while preserving the starting & ending points. */ -Datum sphereline_turn(PG_FUNCTION_ARGS); +extern Datum sphereline_turn(PG_FUNCTION_ARGS); /* * Returns the beginning of a line. */ -Datum sphereline_begin(PG_FUNCTION_ARGS); +extern Datum sphereline_begin(PG_FUNCTION_ARGS); /* * Returns the ending of a line. */ -Datum sphereline_end(PG_FUNCTION_ARGS); +extern Datum sphereline_end(PG_FUNCTION_ARGS); /* * Returns the length of a line in radians. */ -Datum sphereline_length(PG_FUNCTION_ARGS); +extern Datum sphereline_length(PG_FUNCTION_ARGS); /* * Checks whether a line contains a point. */ -Datum sphereline_cont_point(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a line doesn't contain a point. */ -Datum sphereline_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a line contains a point. */ -Datum sphereline_cont_point_com(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a line doesn't contain a point. */ -Datum sphereline_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a line. */ -Datum spherecircle_cont_line(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a line. */ -Datum spherecircle_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a line. */ -Datum spherecircle_cont_line_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a line. */ -Datum spherecircle_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a line overlap. */ -Datum sphereline_overlap_circle(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether circle and a line don't overlap. */ -Datum sphereline_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a line overlap. */ -Datum sphereline_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether circle and a line don't overlap. */ -Datum sphereline_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two lines are equal. */ -Datum sphereline_equal(PG_FUNCTION_ARGS); +extern Datum sphereline_equal(PG_FUNCTION_ARGS); /* * Checks whether two lines are not equal. */ -Datum sphereline_equal_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_equal_neg(PG_FUNCTION_ARGS); /* * Checks whether two lines cross each other. */ -Datum sphereline_crosses(PG_FUNCTION_ARGS); +extern Datum sphereline_crosses(PG_FUNCTION_ARGS); /* * Checks whether two lines don't cross each other. */ -Datum sphereline_crosses_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_crosses_neg(PG_FUNCTION_ARGS); /* * Checks whether two lines overlap. */ -Datum sphereline_overlap(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap(PG_FUNCTION_ARGS); /* * Checks whether two lines are overlap. */ -Datum sphereline_overlap_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_neg(PG_FUNCTION_ARGS); /* * Returns an Euler transformation. An inverse transformation with it puts * the line into equator beginning at (0,0) and ending at (0,length). */ -Datum spheretrans_from_line(PG_FUNCTION_ARGS); +extern Datum spheretrans_from_line(PG_FUNCTION_ARGS); /* * Transforms a line with an Euler transformation. */ -Datum spheretrans_line(PG_FUNCTION_ARGS); +extern Datum spheretrans_line(PG_FUNCTION_ARGS); /* * Transforms a line with an inverse Euler transformation. */ -Datum spheretrans_line_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_line_inverse(PG_FUNCTION_ARGS); /* * Returns the distance between a line and a point. */ -Datum sphereline_point_distance(PG_FUNCTION_ARGS); +extern Datum sphereline_point_distance(PG_FUNCTION_ARGS); /* * Returns the distance between a point and a line. */ -Datum sphereline_point_distance_com(PG_FUNCTION_ARGS); +extern Datum sphereline_point_distance_com(PG_FUNCTION_ARGS); #endif diff --git a/src/moc.c b/src/moc.c index 6f1cbaf0..4457aa65 100644 --- a/src/moc.c +++ b/src/moc.c @@ -3,7 +3,8 @@ #include #include -#include +#include "access/gin.h" +#include "access/reloptions.h" #include "circle.h" #include "polygon.h" @@ -45,6 +46,7 @@ PG_FUNCTION_INFO_V1(smoc_gin_extract_value_fine); PG_FUNCTION_INFO_V1(smoc_gin_extract_query); PG_FUNCTION_INFO_V1(smoc_gin_extract_query_fine); PG_FUNCTION_INFO_V1(smoc_gin_consistent); +PG_FUNCTION_INFO_V1(smoc_gin_options); int32 smoc_output_type = 0; @@ -1079,7 +1081,6 @@ smoc_gin_extract_internal(Smoc *moc_a, int32 *nkeys, int gin_order) if (*nkeys >= nalloc) { nalloc *= 2; - Assert(nalloc < 2000000); keys = repalloc(keys, nalloc * sizeof(Datum)); } keys[(*nkeys)++] = Int32GetDatum(p); @@ -1094,8 +1095,9 @@ smoc_gin_extract_value(PG_FUNCTION_ARGS) { Smoc* moc_a = (Smoc *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); int32* nkeys = (int32 *) PG_GETARG_POINTER(1); + int order = SMOC_GIN_GET_ORDER(); - PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, MOC_GIN_ORDER)); + PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, order)); } Datum @@ -1114,13 +1116,14 @@ smoc_gin_extract_query(PG_FUNCTION_ARGS) int32* nkeys = (int32 *) PG_GETARG_POINTER(1); StrategyNumber st = PG_GETARG_UINT16(2); int32* searchmode = (int32 *) PG_GETARG_POINTER(6); + int order = SMOC_GIN_GET_ORDER(); if (st == MOC_GIN_STRATEGY_SUBSET || (st == MOC_GIN_STRATEGY_EQUAL && moc_a->area == 0)) *searchmode = GIN_SEARCH_MODE_INCLUDE_EMPTY; else if (st == MOC_GIN_STRATEGY_UNEQUAL) *searchmode = GIN_SEARCH_MODE_ALL; - PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, MOC_GIN_ORDER)); + PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, order)); } Datum @@ -1202,3 +1205,21 @@ smoc_gin_consistent(PG_FUNCTION_ARGS) /* not reached */ PG_RETURN_NULL(); } + +#if PG_VERSION_NUM >= 130000 +Datum +smoc_gin_options(PG_FUNCTION_ARGS) +{ + local_relopts *relopts = (local_relopts *) PG_GETARG_POINTER(0); + + init_local_reloptions(relopts, sizeof(SMocGinOptions)); + add_local_int_reloption(relopts, "order", + "smoc order to store in index", + MOC_GIN_ORDER_DEFAULT, + 0, + 12, /* maximum order fitting into 32bit */ + offsetof(SMocGinOptions, order)); + + PG_RETURN_VOID(); +} +#endif diff --git a/src/output.c b/src/output.c index 7598d466..7df58899 100644 --- a/src/output.c +++ b/src/output.c @@ -1,5 +1,12 @@ #include "types.h" +#if PG_VERSION_NUM >= 120000 +#include "utils/float.h" +#include "common/shortest_dec.h" +#endif + +#include + #if !defined(PGSPHERE_VERSION) #error "PGSPHERE_VERSION macro is not set" #endif @@ -9,7 +16,6 @@ /* Output functions */ - /* Output modes */ #define OUTPUT_RAD 1 /* output in radians */ #define OUTPUT_DEG 2 /* output in degrees */ @@ -25,7 +31,7 @@ static unsigned char sphere_output = OUTPUT_RAD; /* * Defines the precision of floating point values in output. */ -static int sphere_output_precision = DBL_DIG; +static int sphere_output_precision = INT_MAX; PG_FUNCTION_INFO_V1(set_sphere_output); PG_FUNCTION_INFO_V1(spherepoint_out); @@ -37,6 +43,7 @@ PG_FUNCTION_INFO_V1(spherepath_out); PG_FUNCTION_INFO_V1(sphereellipse_out); PG_FUNCTION_INFO_V1(spherebox_out); PG_FUNCTION_INFO_V1(set_sphere_output_precision); +PG_FUNCTION_INFO_V1(reset_sphere_output_precision); PG_FUNCTION_INFO_V1(pg_sphere_version); /* @@ -94,6 +101,8 @@ Datum spherebox_out(PG_FUNCTION_ARGS); */ Datum pg_sphere_version(PG_FUNCTION_ARGS); +static void +spheretrans_out_buffer(StringInfo si, const SEuler *se); /* * Converts radians to DEG ( degrees, minutes, seconds ) @@ -128,6 +137,116 @@ rad_to_dms(double rad, unsigned int *deg, unsigned int *min, double *sec) } } +static void +pgs_strinfo_put_chr(StringInfo si, char c) +{ + appendStringInfoChar(si, c); +} + +static void +pgs_strinfo_put_str(StringInfo si, char *s) +{ + appendStringInfoString(si, s); +} + +static void +pgs_strinfo_put_d64(StringInfo si, double value) +{ + int cw, + ndig; + char buf[128]; + +#if PG_VERSION_NUM >= 120000 + + if (extra_float_digits > 0) + { + cw = double_to_shortest_decimal_buf(value, buf); + } + else + { + ndig = DBL_DIG + extra_float_digits; + if (ndig < 1) + ndig = 1; + + cw = pg_strfromd(buf, 128, ndig, value); + } + +#else + + ndig = DBL_DIG + extra_float_digits; + if (ndig < 1) + ndig = 1; + + cw = snprintf(buf, 128, "%.*g", ndig, value); + +#endif + + if (cw < 0) + { + fflush(stderr); + abort(); + } + + pgs_strinfo_put_str(si, buf); +} + +static void +pgs_strinfo_put_lng_dms(StringInfo si, double lng) +{ + unsigned int lngdeg, + lngmin; + double lngsec; + + rad_to_dms(lng, &lngdeg, &lngmin, &lngsec); + + appendStringInfo(si, "%3ud %2um ", lngdeg, lngmin); + pgs_strinfo_put_d64(si, lngsec); + pgs_strinfo_put_chr(si, 's'); +} + +static void +pgs_strinfo_put_lng_hms(StringInfo si, double lng) +{ + unsigned int lnghour, + lngmin; + double lngsec; + + rad_to_dms(lng / 15.0, &lnghour, &lngmin, &lngsec); + + appendStringInfo(si, "%3uh %2um ", lnghour, lngmin); + pgs_strinfo_put_d64(si, lngsec); + pgs_strinfo_put_chr(si, 's'); +} + +static void +pgs_strinfo_put_lat_dms(StringInfo si, double lat) +{ + unsigned int latdeg, + latmin; + double latsec; + const char latsign = lat >= 0 ? '+' : '-'; + + rad_to_dms(lat, &latdeg, &latmin, &latsec); + + appendStringInfo(si, "%c%2ud %2um ", latsign, latdeg, latmin); + pgs_strinfo_put_d64(si, latsec); + pgs_strinfo_put_chr(si, 's'); +} + +static void +pgs_strinfo_put_radius_dms(StringInfo si, double radius) +{ + unsigned int rdeg, + rmin; + double rsec; + + rad_to_dms(radius, &rdeg, &rmin, &rsec); + + appendStringInfo(si, "%2ud %2um ", rdeg, rmin); + pgs_strinfo_put_d64(si, rsec); + pgs_strinfo_put_chr(si, 's'); +} + Datum set_sphere_output_precision(PG_FUNCTION_ARGS) { @@ -144,6 +263,18 @@ set_sphere_output_precision(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(buf); } +Datum +reset_sphere_output_precision(PG_FUNCTION_ARGS) +{ + char *buf = (char *) palloc(20); + + sphere_output_precision = INT_MAX; + + sprintf(buf, "RESET"); + + PG_RETURN_CSTRING(buf); +} + Datum set_sphere_output(PG_FUNCTION_ARGS) { @@ -176,8 +307,8 @@ set_sphere_output(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(buf); } -Datum -spherepoint_out(PG_FUNCTION_ARGS) +static Datum +spherepoint_out_compat(PG_FUNCTION_ARGS) { SPoint *sp = (SPoint *) PG_GETARG_POINTER(0); char *buffer = (char *) palloc(255); @@ -227,11 +358,89 @@ spherepoint_out(PG_FUNCTION_ARGS) } PG_RETURN_CSTRING(buffer); +} + +static void +spherepoint_out_deg(StringInfo si, const SPoint *sp) +{ + pgs_strinfo_put_chr(si, '('); + pgs_strinfo_put_d64(si, RADIANS * sp->lng); + pgs_strinfo_put_str(si, "d, "); + pgs_strinfo_put_d64(si, RADIANS * sp->lat); + pgs_strinfo_put_str(si, "d)"); +} +static void +spherepoint_out_rad(StringInfo si, const SPoint *sp) +{ + pgs_strinfo_put_chr(si, '('); + pgs_strinfo_put_d64(si, sp->lng); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_d64(si, sp->lat); + pgs_strinfo_put_str(si, ")"); +} + +static void +spherepoint_out_dms(StringInfo si, const SPoint *sp) +{ + pgs_strinfo_put_chr(si, '('); + pgs_strinfo_put_lng_dms(si, sp->lng); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_lat_dms(si, sp->lat); + pgs_strinfo_put_chr(si, ')'); +} + +static void +spherepoint_out_hms(StringInfo si, const SPoint *sp) +{ + pgs_strinfo_put_chr(si, '('); + pgs_strinfo_put_lng_hms(si, sp->lng); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_lat_dms(si, sp->lat); + pgs_strinfo_put_chr(si, ')'); +} + +static inline void +spherepoint_out_buffer(StringInfo si, const SPoint *sp) +{ + switch (sphere_output) + { + case OUTPUT_DEG: + spherepoint_out_deg(si, sp); + break; + case OUTPUT_DMS: + spherepoint_out_dms(si, sp); + break; + case OUTPUT_HMS: + spherepoint_out_hms(si, sp); + break; + default: + spherepoint_out_rad(si, sp); + break; + } } Datum -spherecircle_out(PG_FUNCTION_ARGS) +spherepoint_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SPoint *sp; + + if (sphere_output_precision != INT_MAX) + return spherepoint_out_compat(fcinfo); + + sp = (SPoint *) PG_GETARG_POINTER(0); + if (!sp) + PG_RETURN_NULL(); + + initStringInfo(&si); + spherepoint_out_buffer(&si, sp); + + PG_RETURN_CSTRING(si.data); +} + +static Datum +spherecircle_out_compat(PG_FUNCTION_ARGS) { SCIRCLE *c = (SCIRCLE *) PG_GETARG_POINTER(0); char *buffer = (char *) palloc(255); @@ -272,12 +481,86 @@ spherecircle_out(PG_FUNCTION_ARGS) } pfree(pointstr); + PG_RETURN_CSTRING(buffer); +} + +static void +spherecircle_out_deg(StringInfo si, const SCIRCLE *sc) +{ + pgs_strinfo_put_chr(si, '<'); + spherepoint_out_deg(si, &sc->center); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_d64(si, RADIANS * sc->radius); + pgs_strinfo_put_chr(si, '>'); +} +static void +spherecircle_out_rad(StringInfo si, const SCIRCLE *sc) +{ + pgs_strinfo_put_chr(si, '<'); + spherepoint_out_rad(si, &sc->center); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_d64(si, sc->radius); + pgs_strinfo_put_chr(si, '>'); +} + +static void +spherecircle_out_dms(StringInfo si, const SCIRCLE *sc) +{ + pgs_strinfo_put_chr(si, '<'); + spherepoint_out_dms(si, &sc->center); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_radius_dms(si, sc->radius); + pgs_strinfo_put_chr(si, '>'); +} + +static void +spherecircle_out_hms(StringInfo si, const SCIRCLE *sc) +{ + pgs_strinfo_put_chr(si, '<'); + spherepoint_out_hms(si, &sc->center); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_radius_dms(si, sc->radius); + pgs_strinfo_put_chr(si, '>'); } Datum -sphereellipse_out(PG_FUNCTION_ARGS) +spherecircle_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SCIRCLE *sc; + + if (sphere_output_precision != INT_MAX) + return spherecircle_out_compat(fcinfo); + + sc = (SCIRCLE *) PG_GETARG_POINTER(0); + if (!sc) + PG_RETURN_NULL(); + + initStringInfo(&si); + + switch (sphere_output) + { + case OUTPUT_DEG: + spherecircle_out_deg(&si, sc); + break; + case OUTPUT_DMS: + spherecircle_out_dms(&si, sc); + break; + case OUTPUT_HMS: + spherecircle_out_hms(&si, sc); + break; + default: + spherecircle_out_rad(&si, sc); + break; + } + + PG_RETURN_CSTRING(si.data); +} + +static Datum +sphereellipse_out_compat(PG_FUNCTION_ARGS) { SELLIPSE *e = (SELLIPSE *) PG_GETARG_POINTER(0); char *buffer = (char *) palloc(255); @@ -333,8 +616,88 @@ sphereellipse_out(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(buffer); } +static void +sphereellipse_out_deg(StringInfo si, SELLIPSE *e) +{ + const SPoint sp = { e->psi, e->theta }; + + pgs_strinfo_put_str(si, "<{ "); + pgs_strinfo_put_d64(si, RADIANS * e->rad[0]); + pgs_strinfo_put_str(si, "d , "); + pgs_strinfo_put_d64(si, RADIANS * e->rad[1]); + pgs_strinfo_put_str(si, "d },"); + spherepoint_out_buffer(si, &sp); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_d64(si, RADIANS * e->phi); + pgs_strinfo_put_str(si, "d>"); +} + +static void +sphereellipse_out_rad(StringInfo si, SELLIPSE *e) +{ + const SPoint sp = { e->psi, e->theta }; + + pgs_strinfo_put_str(si, "<{ "); + pgs_strinfo_put_d64(si, e->rad[0]); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_d64(si, e->rad[1]); + pgs_strinfo_put_str(si, " },"); + spherepoint_out_buffer(si, &sp); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_d64(si, e->phi); + pgs_strinfo_put_str(si, ">"); +} + +static void +sphereellipse_out_dms(StringInfo si, SELLIPSE *e) +{ + const SPoint sp = { e->psi, e->theta }; + + pgs_strinfo_put_str(si, "<{ "); + pgs_strinfo_put_lng_dms(si, e->rad[0]); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_lng_dms(si, e->rad[1]); + pgs_strinfo_put_str(si, " },"); + spherepoint_out_buffer(si, &sp); + pgs_strinfo_put_str(si, " , "); + pgs_strinfo_put_lng_dms(si, e->phi); + pgs_strinfo_put_str(si, ">"); +} + Datum -sphereline_out(PG_FUNCTION_ARGS) +sphereellipse_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SELLIPSE *e; + + if (sphere_output_precision != INT_MAX) + return sphereellipse_out_compat(fcinfo); + + e = (SELLIPSE *) PG_GETARG_POINTER(0); + if (!e) + PG_RETURN_NULL(); + + initStringInfo(&si); + + switch (sphere_output) + { + case OUTPUT_DEG: + sphereellipse_out_deg(&si, e); + break; + case OUTPUT_HMS: + case OUTPUT_DMS: + sphereellipse_out_dms(&si, e); + break; + default: + sphereellipse_out_rad(&si, e); + break; + } + + PG_RETURN_CSTRING(si.data); +} + +static Datum +sphereline_out_compat(PG_FUNCTION_ARGS) { SLine *sl = (SLine *) PG_GETARG_POINTER(0); char *out = (char *) palloc(255); @@ -384,7 +747,49 @@ sphereline_out(PG_FUNCTION_ARGS) } Datum -spheretrans_out(PG_FUNCTION_ARGS) +sphereline_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SLine *sl; + SEuler se; + + if (sphere_output_precision != INT_MAX) + return sphereline_out_compat(fcinfo); + + sl = (SLine *) PG_GETARG_POINTER(0); + if (!sl) + PG_RETURN_NULL(); + + seuler_set_zxz(&se); + se.phi = sl->phi; + se.theta = sl->theta; + se.psi = sl->psi; + + initStringInfo(&si); + + pgs_strinfo_put_str(&si, "( "); + spheretrans_out_buffer(&si, &se); + pgs_strinfo_put_str(&si, " ), "); + + switch (sphere_output) + { + case OUTPUT_DEG: + pgs_strinfo_put_d64(&si, RADIANS * sl->length); + break; + case OUTPUT_HMS: + case OUTPUT_DMS: + pgs_strinfo_put_lng_dms(&si, sl->length); + break; + default: + pgs_strinfo_put_d64(&si, sl->length); + break; + } + + PG_RETURN_CSTRING(si.data); +} + +static Datum +spheretrans_out_compat(PG_FUNCTION_ARGS) { SEuler *se = (SEuler *) PG_GETARG_POINTER(0); char *buffer = (char *) palloc(255); @@ -469,8 +874,117 @@ spheretrans_out(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(buffer); } +static void +spheretrans_out_deg(StringInfo si, SPoint sp[3]) +{ + int i; + + for (i = 0; i < 3; ++i) + { + pgs_strinfo_put_d64(si, RADIANS * sp[i].lng); + pgs_strinfo_put_str(si, ", "); + } +} + +static void +spheretrans_out_rad(StringInfo si, SPoint sp[3]) +{ + int i; + + for (i = 0; i < 3; ++i) + { + pgs_strinfo_put_d64(si, sp[i].lng); + pgs_strinfo_put_str(si, ", "); + } +} + +static void +spheretrans_out_dms(StringInfo si, SPoint sp[3]) +{ + int i; + + for (i = 0; i < 3; ++i) + { + pgs_strinfo_put_lng_dms(si, sp[i].lng); + pgs_strinfo_put_str(si, ", "); + } +} + +static void +spheretrans_out_buffer(StringInfo si, const SEuler *se) +{ + SPoint val[3]; + unsigned char t[3]; + int i; + + val[0].lat = val[1].lat = val[2].lat = 0.0; + val[0].lng = se->phi; + val[1].lng = se->theta; + val[2].lng = se->psi; + + t[0] = se->phi_a; + t[1] = se->theta_a; + t[2] = se->psi_a; + + spoint_check(&val[0]); + spoint_check(&val[1]); + spoint_check(&val[2]); + + switch (sphere_output) + { + case OUTPUT_DEG: + spheretrans_out_deg(si, val); + break; + case OUTPUT_HMS: + case OUTPUT_DMS: + spheretrans_out_dms(si, val); + break; + default: + spheretrans_out_rad(si, val); + break; + } + + for (i = 0; i < 3; i++) + { + switch (t[i]) + { + case EULER_AXIS_X: + pgs_strinfo_put_chr(si, 'X'); + break; + case EULER_AXIS_Y: + pgs_strinfo_put_chr(si, 'Y'); + break; + case EULER_AXIS_Z: + pgs_strinfo_put_chr(si, 'Z'); + break; + default: + Assert(false); + } + } +} + Datum -spherepath_out(PG_FUNCTION_ARGS) +spheretrans_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SEuler *se; + + if (sphere_output_precision != INT_MAX) + return spheretrans_out_compat(fcinfo); + + se = (SEuler *) PG_GETARG_POINTER(0); + if (!se) + PG_RETURN_NULL(); + + initStringInfo(&si); + + spheretrans_out_buffer(&si, se); + + PG_RETURN_CSTRING(si.data); +} + +static Datum +spherepath_out_compat(PG_FUNCTION_ARGS) { SPATH *path = PG_GETARG_SPATH(0); int32 i; @@ -494,7 +1008,37 @@ spherepath_out(PG_FUNCTION_ARGS) } Datum -spherepoly_out(PG_FUNCTION_ARGS) +spherepath_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SPATH *path; + int32 i; + + if (sphere_output_precision != INT_MAX) + return spherepath_out_compat(fcinfo); + + path = PG_GETARG_SPATH(0); + if (!path) + PG_RETURN_NULL(); + + initStringInfo(&si); + + pgs_strinfo_put_chr(&si, '{'); + + for (i = 0; i < path->npts; ++i) + { + if (i > 0) + pgs_strinfo_put_chr(&si, ','); + spherepoint_out_buffer(&si, &path->p[i]); + } + + pgs_strinfo_put_chr(&si, '}'); + + PG_RETURN_CSTRING(si.data); +} + +static Datum +spherepoly_out_compat(PG_FUNCTION_ARGS) { SPOLY *poly = PG_GETARG_SPOLY(0); int32 i; @@ -518,7 +1062,37 @@ spherepoly_out(PG_FUNCTION_ARGS) } Datum -spherebox_out(PG_FUNCTION_ARGS) +spherepoly_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SPOLY *poly; + int32 i; + + if (sphere_output_precision != INT_MAX) + return spherepoly_out_compat(fcinfo); + + poly = PG_GETARG_SPOLY(0); + if (!poly) + PG_RETURN_NULL(); + + initStringInfo(&si); + + pgs_strinfo_put_chr(&si, '{'); + + for (i = 0; i < poly->npts; ++i) + { + if (i > 0) + pgs_strinfo_put_chr(&si, ','); + spherepoint_out_buffer(&si, &poly->p[i]); + } + + pgs_strinfo_put_chr(&si, '}'); + + PG_RETURN_CSTRING(si.data); +} + +static Datum +spherebox_out_compat(PG_FUNCTION_ARGS) { SBOX *box = (SBOX *) PG_GETARG_POINTER(0); char *buffer = (char *) palloc(255); @@ -535,6 +1109,30 @@ spherebox_out(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(buffer); } +Datum +spherebox_out(PG_FUNCTION_ARGS) +{ + StringInfoData si; + SBOX *box; + + if (sphere_output_precision != INT_MAX) + return spherebox_out_compat(fcinfo); + + box = (SBOX *) PG_GETARG_POINTER(0); + if (!box) + PG_RETURN_NULL(); + + initStringInfo(&si); + + pgs_strinfo_put_chr(&si, '('); + spherepoint_out_buffer(&si, &box->sw); + pgs_strinfo_put_str(&si, ", "); + spherepoint_out_buffer(&si, &box->ne); + pgs_strinfo_put_chr(&si, ')'); + + PG_RETURN_CSTRING(si.data); +} + Datum pg_sphere_version(PG_FUNCTION_ARGS) { diff --git a/src/path.h b/src/path.h index 91e1662e..8f98cee5 100644 --- a/src/path.h +++ b/src/path.h @@ -12,22 +12,22 @@ */ typedef struct { - char vl_len_[4]; /* total size in bytes */ - int32 npts; /* count of points */ - SPoint p[1]; /* variable length array of SPoints */ + char vl_len_[4]; /* total size in bytes */ + int32 npts; /* count of points */ + SPoint p[1]; /* variable length array of SPoints */ } SPATH; /* Path and circle */ -#define PGS_CIRCLE_PATH_AVOID 0 /* circle avoids path */ -#define PGS_CIRCLE_CONT_PATH 1 /* circle contains path */ -#define PGS_CIRCLE_PATH_OVER 2 /* circle overlaps path */ +#define PGS_CIRCLE_PATH_AVOID 0 /* circle avoids path */ +#define PGS_CIRCLE_CONT_PATH 1 /* circle contains path */ +#define PGS_CIRCLE_PATH_OVER 2 /* circle overlaps path */ /* Path and polygon */ -#define PGS_POLY_PATH_AVOID 0 /* polygon avoids path */ -#define PGS_POLY_CONT_PATH 1 /* polygon contains path */ -#define PGS_POLY_PATH_OVER 2 /* polygon and path overlap */ +#define PGS_POLY_PATH_AVOID 0 /* polygon avoids path */ +#define PGS_POLY_CONT_PATH 1 /* polygon contains path */ +#define PGS_POLY_PATH_OVER 2 /* polygon and path overlap */ /* Path and ellipse */ #define PGS_ELLIPSE_PATH_AVOID 0 /* ellipse avoids path */ @@ -41,12 +41,12 @@ typedef struct /* * Checks whether two paths are equal. */ -bool spath_eq(const SPATH *p1, const SPATH *p2); +extern bool spath_eq(const SPATH *p1, const SPATH *p2); /* * Checks whether a path contains a point. */ -bool spath_cont_point(const SPATH *path, const SPoint *sp); +extern bool spath_cont_point(const SPATH *path, const SPoint *sp); /* * Returns the i-th line segment of a path. @@ -57,24 +57,24 @@ bool spath_cont_point(const SPATH *path, const SPoint *sp); * * Returns the pointer to the line segment or NULL if fails. */ -bool spath_segment(SLine *sl, const SPATH *path, int32 i); +extern bool spath_segment(SLine *sl, const SPATH *path, int32 i); /* * Input function of path. */ -Datum spherepath_in(PG_FUNCTION_ARGS); +extern Datum spherepath_in(PG_FUNCTION_ARGS); /* * Returns the n-th point of a path. * * See spherepath_get_point(PG_FUNCTION_ARGS) */ -Datum spherepath_get_point(PG_FUNCTION_ARGS); +extern Datum spherepath_get_point(PG_FUNCTION_ARGS); /* * Returns spath as array of points */ -Datum spherepath_get_array(PG_FUNCTION_ARGS); +extern Datum spherepath_get_array(PG_FUNCTION_ARGS); /* * This function interpolates between points of path. Returns the @@ -82,212 +82,212 @@ Datum spherepath_get_array(PG_FUNCTION_ARGS); * * See spherepath_point(PG_FUNCTION_ARGS) */ -Datum spherepath_point(PG_FUNCTION_ARGS); +extern Datum spherepath_point(PG_FUNCTION_ARGS); /* * Checks whether two paths are equal. */ -Datum spherepath_equal(PG_FUNCTION_ARGS); +extern Datum spherepath_equal(PG_FUNCTION_ARGS); /* * Checks whether two paths aren't equal. */ -Datum spherepath_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_equal_neg(PG_FUNCTION_ARGS); /* * Returns the length of a path. */ -Datum spherepath_length(PG_FUNCTION_ARGS); +extern Datum spherepath_length(PG_FUNCTION_ARGS); /* * Returns the number of points in a path. */ -Datum spherepath_npts(PG_FUNCTION_ARGS); +extern Datum spherepath_npts(PG_FUNCTION_ARGS); /* * Changes the direction of a path. */ -Datum spherepath_swap(PG_FUNCTION_ARGS); +extern Datum spherepath_swap(PG_FUNCTION_ARGS); /* * Checks whether a path contains a point. */ -Datum spherepath_cont_point(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a path doesn't contain a point. */ -Datum spherepath_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a path contains a point. */ -Datum spherepath_cont_point_com(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a path doesn't contain a point. */ -Datum spherepath_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a path and a line overlap. */ -Datum spherepath_overlap_line(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether a path and a line don't overlap. */ -Datum spherepath_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether path and line overlap. */ -Datum spherepath_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether a path and a line don't overlap. */ -Datum spherepath_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a path. */ -Datum spherecircle_cont_path(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a path. */ -Datum spherecircle_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a path. */ -Datum spherecircle_cont_path_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a path. */ -Datum spherecircle_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path overlap. */ -Datum spherecircle_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path don't overlap. */ -Datum spherecircle_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path overlap. */ -Datum spherecircle_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path don't overlap. */ -Datum spherecircle_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a path. */ -Datum spherepoly_cont_path(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a path. */ -Datum spherepoly_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains path. */ -Datum spherepoly_cont_path_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a path. */ -Datum spherepoly_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path overlap. */ -Datum spherepoly_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path don't overlap. */ -Datum spherepoly_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path overlap. */ -Datum spherepoly_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path don't overlap. */ -Datum spherepoly_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two paths overlap. */ -Datum spherepath_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether two paths don't overlap. */ -Datum spherepath_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains path. */ -Datum sphereellipse_cont_path(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a path. */ -Datum sphereellipse_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a path. */ -Datum sphereellipse_cont_path_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a path. */ -Datum sphereellipse_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path overlap. */ -Datum sphereellipse_overlap_path(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path don't overlap. */ -Datum sphereellipse_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path overlap. */ -Datum sphereellipse_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path don't overlap. */ -Datum sphereellipse_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Performs an Euler transformation on a path. */ -Datum spheretrans_path(PG_FUNCTION_ARGS); +extern Datum spheretrans_path(PG_FUNCTION_ARGS); /* * Performs an inverse Euler transformation on a path. */ -Datum spheretrans_path_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_path_inverse(PG_FUNCTION_ARGS); /* * State transition function for aggregate function spath(spoint). Never @@ -295,11 +295,11 @@ Datum spheretrans_path_inverse(PG_FUNCTION_ARGS); * * Adds a point to a path. */ -Datum spherepath_add_point(PG_FUNCTION_ARGS); +extern Datum spherepath_add_point(PG_FUNCTION_ARGS); /* * Finalize function for adding spoints to a path. */ -Datum spherepath_add_points_finalize(PG_FUNCTION_ARGS); +extern Datum spherepath_add_points_finalize(PG_FUNCTION_ARGS); #endif diff --git a/src/pg_sphere.h b/src/pg_sphere.h index 24d950a4..9cfc5f21 100644 --- a/src/pg_sphere.h +++ b/src/pg_sphere.h @@ -72,7 +72,7 @@ #else #define PGSPHERE_FLOAT_STORE 0 #endif -#endif // PGSPHERE_FLOAT_STORE +#endif /* PGSPHERE_FLOAT_STORE */ #define EPSILON 1.0E-09 @@ -84,6 +84,7 @@ static inline bool FPeq(double A, double B) { const volatile double AB = A - B; + return A == B || fabs(AB) <= EPSILON; } @@ -91,6 +92,7 @@ static inline bool FPne(double A, double B) { const volatile double AB = A - B; + return A != B && fabs(AB) > EPSILON; } @@ -98,6 +100,7 @@ static inline bool FPlt(double A, double B) { const volatile double AE = A + EPSILON; + return AE < B; } @@ -105,6 +108,7 @@ static inline bool FPle(double A, double B) { const volatile double BE = B + EPSILON; + return A <= BE; } @@ -112,6 +116,7 @@ static inline bool FPgt(double A, double B) { const volatile double BE = B + EPSILON; + return A > BE; } @@ -119,6 +124,7 @@ static inline bool FPge(double A, double B) { const volatile double AE = A + EPSILON; + return AE >= B; } @@ -160,7 +166,7 @@ FPge(double A, double B) return A + EPSILON >= B; } -#endif // PGSPHERE_FLOAT_STORE +#endif /* PGSPHERE_FLOAT_STORE */ /*--------------------------------------------------------------------- * Point - (x,y) @@ -171,7 +177,6 @@ typedef struct y; } Point; -void sphere_yyparse(void); +extern void sphere_yyparse(void); #endif - diff --git a/src/pgs_chealpix.h b/src/pgs_chealpix.h index c3233d10..f15b4fe1 100644 --- a/src/pgs_chealpix.h +++ b/src/pgs_chealpix.h @@ -2,7 +2,7 @@ #define __PGS_CHEALPIX_H__ #include -#include /* PostgreSQL type definitions */ +#include /* PostgreSQL type definitions */ /* * Actually, chealpix changed its API: thus, this file must be included first, * directly or indirectly. diff --git a/src/pgs_moc.h b/src/pgs_moc.h index 6bad1ae7..68116d09 100644 --- a/src/pgs_moc.h +++ b/src/pgs_moc.h @@ -122,7 +122,7 @@ next_interval(int32 a) #define MOC_AREA_ALL_SKY 3458764513820540928 -#define MOC_GIN_ORDER 5 /* order 5 has 12 * 4^5 = 12288 pixels */ +#define MOC_GIN_ORDER_DEFAULT 5 /* order 5 has 12 * 4^5 = 12288 pixels */ #define MOC_GIN_ORDER_FINE 8 /* order 8 has 12 * 4^8 = 786432 pixels */ #define MOC_GIN_STRATEGY_INTERSECTS 1 #define MOC_GIN_STRATEGY_SUBSET 2 @@ -130,4 +130,21 @@ next_interval(int32 a) #define MOC_GIN_STRATEGY_EQUAL 4 #define MOC_GIN_STRATEGY_UNEQUAL 5 +/* smoc_gin_ops opclass options */ +#if PG_VERSION_NUM >= 130000 +Datum smoc_gin_options(PG_FUNCTION_ARGS); + +typedef struct +{ + int32 vl_len_; /* varlena header (do not touch directly!) */ + int order; /* smoc order to store in index (default 5) */ +} SMocGinOptions; + +#define SMOC_GIN_GET_ORDER() (PG_HAS_OPCLASS_OPTIONS() ? \ + ((SMocGinOptions *) PG_GET_OPCLASS_OPTIONS())->order : \ + MOC_GIN_ORDER_DEFAULT) +#else +#define SMOC_GIN_GET_ORDER() MOC_GIN_ORDER_DEFAULT +#endif + #endif diff --git a/src/pgs_util.h b/src/pgs_util.h index b79170ba..f04d5be9 100644 --- a/src/pgs_util.h +++ b/src/pgs_util.h @@ -1,24 +1,29 @@ #ifndef __PGS_UTIL_H__ #define __PGS_UTIL_H__ -#define PI 3.14159265358979323846 /* pi */ -#define PIH 1.57079632679489661923 /* pi/2 */ -#define PID 6.2831853071795864769 /* 2*pi */ -#define RADIANS 57.295779513082320877 /* 180/pi */ +#define PI 3.14159265358979323846 /* pi */ +#define PIH 1.57079632679489661923 /* pi/2 */ +#define PID 6.2831853071795864769 /* 2*pi */ +#define RADIANS 57.295779513082320877 /* 180/pi */ #define PI_EPS 4.4408920985006261617e-16 /* 2 ** -51 */ -#define Sqr(a) ( (a) * (a) ) /* square function as macro */ +#define Sqr(a) ( (a) * (a) ) /* square function as macro */ #ifdef EPSILON #undef EPSILON #endif -#define EPSILON 1.0E-09 /* precision of floating point values */ +#define EPSILON 1.0E-09 /* precision of floating point values */ + +/* spherical circle constants */ +#define SPHERE_SURFACE (4 * PI) +#define DEFAULT_SCIRCLE_SEL 1e-7 /* convert pg_sphere theta [pi/2 .. -pi/2] to healpix theta [0 .. pi] ([north .. south pole]) */ static inline double conv_theta(double x) { - double y = PIH - x; + double y = PIH - x; + if (fabs(x) < PI_EPS / 2) return PIH; if (fabs(y) < PI_EPS / 2) @@ -26,9 +31,19 @@ conv_theta(double x) return y; } -static inline double deg_to_rad(double in) +static inline double +deg_to_rad(double in) { return in * PI / 180; } +/* + * Area of circle on sphere + */ +static inline double +spherecircle_area_float(double radius) +{ + return PID * (1 - cos(radius)); +} + #endif diff --git a/src/point.c b/src/point.c index 0cbfa009..26ae5f54 100644 --- a/src/point.c +++ b/src/point.c @@ -8,6 +8,7 @@ PG_FUNCTION_INFO_V1(spherepoint_in); PG_FUNCTION_INFO_V1(spherepoint_from_long_lat); PG_FUNCTION_INFO_V1(spherepoint_from_long_lat_deg); PG_FUNCTION_INFO_V1(spherepoint_distance); +PG_FUNCTION_INFO_V1(spherepoint_dwithin); PG_FUNCTION_INFO_V1(spherepoint_long); PG_FUNCTION_INFO_V1(spherepoint_lat); PG_FUNCTION_INFO_V1(spherepoint_x); @@ -15,6 +16,7 @@ PG_FUNCTION_INFO_V1(spherepoint_y); PG_FUNCTION_INFO_V1(spherepoint_z); PG_FUNCTION_INFO_V1(spherepoint_xyz); PG_FUNCTION_INFO_V1(spherepoint_equal); +PG_FUNCTION_INFO_V1(spherepoint_hash32); static Oid point_id = InvalidOid; @@ -223,6 +225,17 @@ spherepoint_distance(PG_FUNCTION_ARGS) } +Datum +spherepoint_dwithin(PG_FUNCTION_ARGS) +{ + SPoint *p1 = (SPoint *) PG_GETARG_POINTER(0); + SPoint *p2 = (SPoint *) PG_GETARG_POINTER(1); + float8 within = PG_GETARG_FLOAT8(2); + float8 dist = spoint_dist(p1, p2); + + PG_RETURN_BOOL(FPle(dist, within)); +} + Datum spherepoint_long(PG_FUNCTION_ARGS) { @@ -297,3 +310,13 @@ spherepoint_equal(PG_FUNCTION_ARGS) PG_RETURN_BOOL(spoint_eq(p1, p2)); } + +Datum +spherepoint_hash32(PG_FUNCTION_ARGS) +{ + SPoint *p1 = (SPoint *) PG_GETARG_POINTER(0); + Datum h1 = DirectFunctionCall1(hashfloat8, Float8GetDatum(p1->lat)); + Datum h2 = DirectFunctionCall1(hashfloat8, Float8GetDatum(p1->lng)); + + PG_RETURN_INT32(DatumGetInt32(h1) ^ DatumGetInt32(h2)); +} diff --git a/src/point.h b/src/point.h index 9269cf78..b9d85d14 100644 --- a/src/point.h +++ b/src/point.h @@ -11,95 +11,109 @@ */ typedef struct { - float8 lng; /* longitude value in radians */ - float8 lat; /* latitude value in radians */ + float8 lng; /* longitude value in radians */ + float8 lat; /* latitude value in radians */ } SPoint; -Oid get_spoint_type_oid(void); +extern Oid get_spoint_type_oid(void); /* * Calculate the distance between two spherical points in radians. */ -float8 spoint_dist(const SPoint *p1, const SPoint *p2); + +extern float8 spoint_dist(const SPoint *p1, const SPoint *p2); /* * Check whether two points are equal. */ -bool spoint_eq(const SPoint *p1, const SPoint *p2); + +extern bool spoint_eq(const SPoint *p1, const SPoint *p2); /* * Check the longitude and latitude values of a spherical point. */ -void spoint_check(SPoint *spoint); + +extern void spoint_check(SPoint *spoint); /* * Transforms a 3d vector into a spherical point. */ -void vector3d_spoint(SPoint *p, const Vector3D *v); + +extern void vector3d_spoint(SPoint *p, const Vector3D *v); /* * Transforms a spherical point into a 3d vector. */ -void spoint_vector3d(Vector3D *v, const SPoint *p); + +extern void spoint_vector3d(Vector3D *v, const SPoint *p); /* * Take the input and store it as a spherical point. */ -Datum spherepoint_in(PG_FUNCTION_ARGS); + +extern Datum spherepoint_in(PG_FUNCTION_ARGS); /* * Create spherical point from lat, lng and store to first argument(pointer) */ -void create_spherepoint_from_long_lat(SPoint *p, float8 lng, float8 lat); + +extern void create_spherepoint_from_long_lat(SPoint *p, float8 lng, float8 lat); /* * Create a spherical point from longitude and latitude both in radians. */ -Datum spherepoint_from_long_lat(PG_FUNCTION_ARGS); + +extern Datum spherepoint_from_long_lat(PG_FUNCTION_ARGS); /* * Create a spherical point from longitude and latitude both in degrees. */ -Datum spherepoint_from_long_lat_deg(PG_FUNCTION_ARGS); + +extern Datum spherepoint_from_long_lat_deg(PG_FUNCTION_ARGS); /* * Calculate the distance between two spherical points. */ -Datum spherepoint_distance(PG_FUNCTION_ARGS); +extern Datum spherepoint_distance(PG_FUNCTION_ARGS); /* * Longitude of a spherical point. */ -Datum spherepoint_long(PG_FUNCTION_ARGS); +extern Datum spherepoint_long(PG_FUNCTION_ARGS); /* * Latitude of a spherical point. */ -Datum spherepoint_lat(PG_FUNCTION_ARGS); +extern Datum spherepoint_lat(PG_FUNCTION_ARGS); /* * Cartesian x-value of a spherical point. */ -Datum spherepoint_x(PG_FUNCTION_ARGS); +extern Datum spherepoint_x(PG_FUNCTION_ARGS); /* * Cartesian y-value of a spherical point. */ -Datum spherepoint_y(PG_FUNCTION_ARGS); +extern Datum spherepoint_y(PG_FUNCTION_ARGS); /* * Cartesian z-value of a spherical point. */ -Datum spherepoint_z(PG_FUNCTION_ARGS); +extern Datum spherepoint_z(PG_FUNCTION_ARGS); /* * Cartesian values of a spherical point as an array. */ -Datum spherepoint_xyz(PG_FUNCTION_ARGS); +extern Datum spherepoint_xyz(PG_FUNCTION_ARGS); /* * Check whether two points are equal. */ -Datum spherepoint_equal(PG_FUNCTION_ARGS); +extern Datum spherepoint_equal(PG_FUNCTION_ARGS); + +/* + * Compute a 32-bit hash value of a point. + */ +extern Datum spherepoint_hash32(PG_FUNCTION_ARGS); #endif diff --git a/src/polygon.c b/src/polygon.c index 57786b85..ac91c6e5 100644 --- a/src/polygon.c +++ b/src/polygon.c @@ -6,6 +6,7 @@ PG_FUNCTION_INFO_V1(spherepoly_in); PG_FUNCTION_INFO_V1(spherepoly_deg); +PG_FUNCTION_INFO_V1(spherepoly_rad); PG_FUNCTION_INFO_V1(spherepoly_equal); PG_FUNCTION_INFO_V1(spherepoly_equal_neg); PG_FUNCTION_INFO_V1(spherepoly_circ); @@ -60,7 +61,7 @@ PG_FUNCTION_INFO_V1(spheretrans_poly_inverse); PG_FUNCTION_INFO_V1(spherepoly_add_point); PG_FUNCTION_INFO_V1(spherepoly_add_points_finalize); PG_FUNCTION_INFO_V1(spherepoly_is_convex); - +PG_FUNCTION_INFO_V1(spherepoly_from_point_array); /* * Writes "center" of a polygon into 'v'. @@ -906,6 +907,56 @@ spherepoly_in(PG_FUNCTION_ARGS) PG_RETURN_POINTER(poly); } +Datum +spherepoly_rad(PG_FUNCTION_ARGS) +{ + int i, + np; + ArrayType *float_vector = PG_GETARG_ARRAYTYPE_P(0); + float8 *array_data; + SPoint *points; + + np = ArrayGetNItems(ARR_NDIM(float_vector), ARR_DIMS(float_vector)); + + if (ARR_HASNULL(float_vector)) + { + elog(ERROR, + "spherepoly_rad: input array is invalid because it has null values" + ); + PG_RETURN_NULL(); + } + + if (np < 6 || np % 2 != 0) + { + elog(ERROR, + "spherepoly_rad: invalid number of arguments (must be even and >= 6)" + ); + PG_RETURN_NULL(); + } + + np /= 2; + + points = (SPoint *) palloc(np * sizeof(SPoint)); + if (points == NULL) + { + elog(ERROR, + "spherepoly_rad: failed to allocate memory for points array" + ); + PG_RETURN_NULL(); + } + + array_data = (float8 *) ARR_DATA_PTR(float_vector); + + for (i = 0; i < np; i++) + { + create_spherepoint_from_long_lat(&points[i], + array_data[2 * i], + array_data[2 * i + 1] + ); + } + PG_RETURN_POINTER(spherepoly_from_array(points, np)); +} + Datum spherepoly_deg(PG_FUNCTION_ARGS) { @@ -917,12 +968,19 @@ spherepoly_deg(PG_FUNCTION_ARGS) np = ArrayGetNItems(ARR_NDIM(float_vector), ARR_DIMS(float_vector)); + if (ARR_HASNULL(float_vector)) + { + elog(ERROR, + "spherepoly_deg: input array is invalid because it has null values" + ); + PG_RETURN_NULL(); + } + if (np < 6 || np % 2 != 0) { - elog( - ERROR, - "spherepoly_deg: invalid number of arguments (must be even and >= 6)" - ); + elog(ERROR, + "spherepoly_deg: invalid number of arguments (must be even and >= 6)" + ); PG_RETURN_NULL(); } @@ -931,10 +989,9 @@ spherepoly_deg(PG_FUNCTION_ARGS) points = (SPoint *) palloc(np * sizeof(SPoint)); if (points == NULL) { - elog( - ERROR, - "spherepoly_deg: failed for allocate memory for points array" - ); + elog(ERROR, + "spherepoly_deg: failed to allocate memory for points array" + ); PG_RETURN_NULL(); } @@ -942,12 +999,37 @@ spherepoly_deg(PG_FUNCTION_ARGS) for (i = 0; i < np; i++) { - create_spherepoint_from_long_lat( - &points[i], - deg_to_rad(array_data[2 * i]), - deg_to_rad(array_data[2 * i + 1]) - ); + create_spherepoint_from_long_lat(&points[i], + deg_to_rad(array_data[2 * i]), + deg_to_rad(array_data[2 * i + 1]) + ); + } + PG_RETURN_POINTER(spherepoly_from_array(points, np)); +} + +Datum +spherepoly_from_point_array(PG_FUNCTION_ARGS) +{ + SPoint *points; + ArrayType *inarr = PG_GETARG_ARRAYTYPE_P(0); + const int np = ArrayGetNItems(ARR_NDIM(inarr), ARR_DIMS(inarr)); + + if (np < 3) + { + elog(ERROR, "spherepoly_from_point_array: " + "invalid number of arguments (must be >= 3)"); + PG_RETURN_NULL(); } + + if (ARR_HASNULL(inarr)) + { + elog(ERROR, "spherepoly_from_point_array: " + "input array is invalid because it has null values"); + PG_RETURN_NULL(); + } + + points = (SPoint *) ARR_DATA_PTR(inarr); + PG_RETURN_POINTER(spherepoly_from_array(points, np)); } diff --git a/src/polygon.h b/src/polygon.h index d52a9c61..0233c413 100644 --- a/src/polygon.h +++ b/src/polygon.h @@ -12,9 +12,9 @@ */ typedef struct { - char vl_len_[4]; /* total size in bytes */ - int32 npts; /* count of points */ - SPoint p[1]; /* variable length array of SPoints */ + char vl_len_[4]; /* total size in bytes */ + int32 npts; /* count of points */ + SPoint p[1]; /* variable length array of SPoints */ } SPOLY; #define MAX_POINTS 1024 @@ -26,20 +26,20 @@ typedef struct #define PGS_ELLIPSE_POLY_OVER 3 /* ellipse overlaps polygon */ /* Polygon and circle */ -#define PGS_CIRCLE_POLY_AVOID 0 /* circle avoids polygon */ -#define PGS_POLY_CONT_CIRCLE 1 /* polygon contains circle */ -#define PGS_CIRCLE_CONT_POLY 2 /* circle contains polygon */ -#define PGS_CIRCLE_POLY_OVER 3 /* circle overlap polygon */ +#define PGS_CIRCLE_POLY_AVOID 0 /* circle avoids polygon */ +#define PGS_POLY_CONT_CIRCLE 1 /* polygon contains circle */ +#define PGS_CIRCLE_CONT_POLY 2 /* circle contains polygon */ +#define PGS_CIRCLE_POLY_OVER 3 /* circle overlap polygon */ /* Polygon and line */ -#define PGS_LINE_POLY_AVOID 0 /* line avoids polygon */ -#define PGS_POLY_CONT_LINE 1 /* polygon contains line */ -#define PGS_LINE_POLY_OVER 2 /* line overlap polygon */ +#define PGS_LINE_POLY_AVOID 0 /* line avoids polygon */ +#define PGS_POLY_CONT_LINE 1 /* polygon contains line */ +#define PGS_LINE_POLY_OVER 2 /* line overlap polygon */ /* Polygon and polygon */ -#define PGS_POLY_AVOID 0 /* polygon avoids other polygon */ -#define PGS_POLY_CONT 1 /* polygon contains other polygon */ -#define PGS_POLY_OVER 2 /* polygons overlap */ +#define PGS_POLY_AVOID 0 /* polygon avoids other polygon */ +#define PGS_POLY_CONT 1 /* polygon contains other polygon */ +#define PGS_POLY_OVER 2 /* polygons overlap */ #define PG_GETARG_SPOLY( arg ) \ @@ -53,7 +53,7 @@ typedef struct * * If 'dir' is true, check with reverse polygon of 'p2'. */ -bool spoly_eq(const SPOLY *p1, const SPOLY *p2, bool dir); +extern bool spoly_eq(const SPOLY *p1, const SPOLY *p2, bool dir); /* * Returns the i-th line segment of a polygon. @@ -62,7 +62,7 @@ bool spoly_eq(const SPOLY *p1, const SPOLY *p2, bool dir); * poly - pointer to the polygon * i - number of the segment */ -bool spoly_segment(SLine *sl, const SPOLY *poly, int32 i); +extern bool spoly_segment(SLine *sl, const SPOLY *poly, int32 i); /* * Checks whether a polygon contains a point. @@ -70,12 +70,12 @@ bool spoly_segment(SLine *sl, const SPOLY *poly, int32 i); * pg - pointer to the polygon * sp - pointer to the point */ -bool spoly_contains_point(const SPOLY *pg, const SPoint *sp); +extern bool spoly_contains_point(const SPOLY *pg, const SPoint *sp); /* * Returns the n-th point of a spoly. */ -Datum spherepoly_get_point(PG_FUNCTION_ARGS); +extern Datum spherepoly_get_point(PG_FUNCTION_ARGS); /* * Returns the relationship between a polygon and a line as @@ -84,283 +84,295 @@ Datum spherepoly_get_point(PG_FUNCTION_ARGS); * poly - pointer to the polygon * line - pointer to the line */ -int8 poly_line_pos(const SPOLY *poly, const SLine *line); +extern int8 poly_line_pos(const SPOLY *poly, const SLine *line); /* - * Input of a spherical from sequence of pairconsecutive numbers(lng, lat). + * Creates a spherical polygon (spoly) from an array of pair-consecutive + * numbers (lng, lat), in radians. */ -Datum spherepoly_deg(PG_FUNCTION_ARGS); +extern Datum spherepoly_rad(PG_FUNCTION_ARGS); + +/* + * Creates a spherical polygon (spoly) from an array of pair-consecutive + * numbers (lng, lat), in degrees. + */ +extern Datum spherepoly_deg(PG_FUNCTION_ARGS); + +/* + * Creates a spherical polygon (spoly) from an array of spoint elements. + */ +extern Datum spherepoly_from_point_array(PG_FUNCTION_ARGS); /* * Input of a spherical polygon. */ -Datum spherepoly_in(PG_FUNCTION_ARGS); +extern Datum spherepoly_in(PG_FUNCTION_ARGS); /* * Checks whether two polygons are equal. */ -Datum spherepoly_equal(PG_FUNCTION_ARGS); +extern Datum spherepoly_equal(PG_FUNCTION_ARGS); /* * Checks whether two polygons are not equal. */ -Datum spherepoly_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_equal_neg(PG_FUNCTION_ARGS); /* * Circumstance of a polygon. Returns circumference in radians * (float8 datum). */ -Datum spherepoly_circ(PG_FUNCTION_ARGS); +extern Datum spherepoly_circ(PG_FUNCTION_ARGS); /* * Count points (edges) of a polygon. */ -Datum spherepoly_npts(PG_FUNCTION_ARGS); +extern Datum spherepoly_npts(PG_FUNCTION_ARGS); /* * Returns area of a polygon. */ -Datum spherepoly_area(PG_FUNCTION_ARGS); +extern Datum spherepoly_area(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a point. */ -Datum spherepoly_cont_point(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a point. */ -Datum spherepoly_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a point. */ -Datum spherepoly_cont_point_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a point. */ -Datum spherepoly_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a circle. */ -Datum spherepoly_cont_circle(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a circle. */ -Datum spherepoly_cont_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a circle. */ -Datum spherepoly_cont_circle_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a circle. */ -Datum spherepoly_cont_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a polygon. */ -Datum spherecircle_cont_poly(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a polygon. */ -Datum spherecircle_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a polygon. */ -Datum spherecircle_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a polygon. */ -Datum spherecircle_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle overlap. */ -Datum spherepoly_overlap_circle(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle don't overlap. */ -Datum spherepoly_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle overlap. */ -Datum spherepoly_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle don't overlap. */ -Datum spherepoly_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a line. */ -Datum spherepoly_cont_line(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a line. */ -Datum spherepoly_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a line. */ -Datum spherepoly_cont_line_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a line. */ -Datum spherepoly_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line overlap. */ -Datum spherepoly_overlap_line(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line don't overlap. */ -Datum spherepoly_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line overlap. */ -Datum spherepoly_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line don't overlap. */ -Datum spherepoly_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains other polygon. */ -Datum spherepoly_cont_poly(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain other polygon. */ -Datum spherepoly_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains other polygon. */ -Datum spherepoly_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain other polygon. */ -Datum spherepoly_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two polygons overlap. */ -Datum spherepoly_overlap_poly(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_poly(PG_FUNCTION_ARGS); /* * Checks whether two polygons don't overlap. */ -Datum spherepoly_overlap_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains an ellipse. */ -Datum spherepoly_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain an ellipse. */ -Datum spherepoly_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains an ellipse. */ -Datum spherepoly_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain an ellipse. */ -Datum spherepoly_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a polygon. */ -Datum sphereellipse_cont_poly(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a polygon. */ -Datum sphereellipse_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a polygon. */ -Datum sphereellipse_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a polygon. */ -Datum sphereellipse_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse overlap. */ -Datum spherepoly_overlap_ellipse(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse don't overlap. */ -Datum spherepoly_overlap_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse overlap. */ -Datum spherepoly_overlap_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse don't overlap. */ -Datum spherepoly_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Performs inverse transform on a polygon using an Euler transformation. */ -Datum spheretrans_poly(PG_FUNCTION_ARGS); +extern Datum spheretrans_poly(PG_FUNCTION_ARGS); /* * Performs inverse transform on a polygon using an Euler transformation. */ -Datum spheretrans_poly_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_poly_inverse(PG_FUNCTION_ARGS); /* * State transition function for the aggregate function spoly(spoint). Never * call this function outside an aggregate function! Adds a point to a polygon. */ -Datum spherepoly_add_point(PG_FUNCTION_ARGS); +extern Datum spherepoly_add_point(PG_FUNCTION_ARGS); /* * Finalize function for adding spoints to a polygon. */ -Datum spherepoly_add_points_finalize(PG_FUNCTION_ARGS); +extern Datum spherepoly_add_points_finalize(PG_FUNCTION_ARGS); /* * Returns spoly as array of points */ -Datum spherepoly_get_array(PG_FUNCTION_ARGS); +extern Datum spherepoly_get_array(PG_FUNCTION_ARGS); /* * Checks whether a polygon is convex */ -Datum spherepoly_is_convex(PG_FUNCTION_ARGS); +extern Datum spherepoly_is_convex(PG_FUNCTION_ARGS); #endif diff --git a/src/process_moc.cpp b/src/process_moc.cpp index 4a9e3423..76883e13 100644 --- a/src/process_moc.cpp +++ b/src/process_moc.cpp @@ -122,7 +122,7 @@ char* data_as_char(Smoc* moc, size_t offset = 0) static char* detoasted_offset(Smoc* moc, size_t offset = 0) { - return offset + reinterpret_cast(&(moc->version)); + return offset + reinterpret_cast(moc) + offsetof(Smoc, version); } template @@ -240,7 +240,7 @@ struct moc_tree_layout { rest_level = entries - rest_entries; this_page = page_rest; - } + } else // there is only a single page fragment at this level { rest_level = 0; @@ -526,13 +526,13 @@ get_moc_size(void* moc_in_context, pgs_error_handler error_out) } if (check == b_tree_inf) throw std::logic_error("infinite loop for MOC B-tree depth"); - + // layout: start with the section of the ends of each B+-tree level size_t depth = m.layout.size() - 1; moc_size += depth * MOC_INDEX_ALIGN; // layout: B+-tree layout, starting at root node for (unsigned k = depth; k >= 1; --k) -{ +{ m.layout[k].layout_level(moc_size, MOC_TREE_ENTRY_SIZE); } if (m.layout[depth].level_end > static_cast( @@ -568,7 +568,7 @@ create_moc_release_context(void* moc_in_context, Smoc* moc, hpint64 area = 0; - // this guards against + // this guards against char* moc_data = detoasted_offset(moc, 0); // All levels will be filled out from end to beginning such that @@ -726,7 +726,7 @@ order_break(output_map & outputs, const moc_interval & x, int max_order) void ascii_out(std::string & m_s, char* s, Smoc* moc, int32 begin, int32 end, int32 entry_size) -{ +{ // moc output fiddling: int order = moc->order; m_s.reserve(end); // rough guess @@ -817,7 +817,7 @@ create_moc_out_context(Smoc* moc, int32 end, pgs_error_handler error_out) return ret; } -void +void release_moc_out_context(moc_out_data out_context, pgs_error_handler error_out) { release_context(out_context.context, error_out); diff --git a/src/sbuffer.h b/src/sbuffer.h index 57599eee..b16f152c 100644 --- a/src/sbuffer.h +++ b/src/sbuffer.h @@ -3,89 +3,89 @@ /* Parser buffer declarations */ -#define STYPE_UNKNOWN 0 /* unknown type */ -#define STYPE_POINT 1 /* input is spherical type */ -#define STYPE_CIRCLE 2 /* input is spherical circle */ -#define STYPE_LINE 3 /* input is spherical line */ -#define STYPE_EULER 4 /* input is Euler transformation */ -#define STYPE_PATH 5 /* input is spherical path or polygon */ -#define STYPE_ELLIPSE 6 /* input is spherical ellipse */ -#define STYPE_BOX 7 /* input is spherical box */ +#define STYPE_UNKNOWN 0 /* unknown type */ +#define STYPE_POINT 1 /* input is spherical type */ +#define STYPE_CIRCLE 2 /* input is spherical circle */ +#define STYPE_LINE 3 /* input is spherical line */ +#define STYPE_EULER 4 /* input is Euler transformation */ +#define STYPE_PATH 5 /* input is spherical path or polygon */ +#define STYPE_ELLIPSE 6 /* input is spherical ellipse */ +#define STYPE_BOX 7 /* input is spherical box */ /* PGS_EULER_AXIS Euler axis */ -#define EULER_AXIS_X 1 /* x - axis for Euler transformation */ -#define EULER_AXIS_Y 2 /* y - axis for Euler transformation */ -#define EULER_AXIS_Z 3 /* z - axis for Euler transformation */ +#define EULER_AXIS_X 1 /* x - axis for Euler transformation */ +#define EULER_AXIS_Y 2 /* y - axis for Euler transformation */ +#define EULER_AXIS_Z 3 /* z - axis for Euler transformation */ -int sphere_yylex(); -void sphere_yyerror(const char *str); -void sphere_flush_scanner_buffer(void); +extern int sphere_yylex(); +extern void sphere_yyerror(const char *str); +extern void sphere_flush_scanner_buffer(void); /* Sets the data type */ -void set_spheretype(unsigned char st); +extern void set_spheretype(unsigned char st); /* Initialize the input buffer */ -void init_buffer(char *buffer); +extern void init_buffer(char *buffer); /* Resets the input buffer */ -void reset_buffer(void); +extern void reset_buffer(void); /* * Read the "offset" number of bytes from "buf" buffer. * Returns the number of read bytes. */ -int get_buffer(char *buf, int offset); +extern int get_buffer(char *buf, int offset); /* * Input of an angle. When is_deg > 0 then "a" is in degrees, * otherwise it's in radians. Returns the unique ID (position) of the angle. */ -int set_angle(unsigned char is_deg, double a); +extern int set_angle(unsigned char is_deg, double a); /* * Set the sign of an angle. "apos" is the angle. "s" is a sign of the angle * ( < 0 .. - , > 0 .. + ). Returns the unique ID (position) of the angle. */ -int set_angle_sign(int apos, int s); +extern int set_angle_sign(int apos, int s); /* * Creates a spherical point. "lngpos" is the ID of a longitude angle, "latpos" * is the ID of a latitude angle. Returns the unique ID (position) of the spherical * point. */ -int set_point(int lngpos, int latpos); +extern int set_point(int lngpos, int latpos); /* * Creates a spherical circle. "spos" is the ID of a spherical point, "rpos" * is the ID of a radius angle. */ -void set_circle(int spos, int rpos); +extern void set_circle(int spos, int rpos); /* * Sets the length of a spherical line. "length" is the ID of a length angle. */ -void set_line(int length); +extern void set_line(int length); /* * Creates an Euler transformation. "phi" is the ID of a first angle, * "theta" is the ID of a second angle, "psi" is the ID of a third angle, * "etype" is the three letter code of Euler transformation axes. */ -void set_euler(int phi, int theta, int psi, char *etype); +extern void set_euler(int phi, int theta, int psi, char *etype); /* * Creates a spherical ellipse. "r1" is the ID of a first radius angle, * "r2" is the ID of a second radius angle, "sp" is the ID of a spherical * point ( center ), "inc" is the ID of an inclination angle. */ -void set_ellipse(int r1, int r2, int sp, int inc); +extern void set_ellipse(int r1, int r2, int sp, int inc); /* * Returns the point parameters. "lng" is the pointer to a longitude * value, "lat" is the pointer to a latitude value. Returns 0 if user * input is a spherical point. */ -int get_point(double *lng, double *lat); +extern int get_point(double *lng, double *lat); /* * Returns the circle parameters. "lng" is pointer to a longitude @@ -93,7 +93,7 @@ int get_point(double *lng, double *lat); * "radius" is the pointer to the radius value. Returns 0 if user input * is a spherical circle. */ -int get_circle(double *lng, double *lat, double *radius); +extern int get_circle(double *lng, double *lat, double *radius); /* * Returns the ellipse parameters. "lng" is the pointer to a longitude value @@ -102,8 +102,8 @@ int get_circle(double *lng, double *lat, double *radius); * radius value, "inc" is the pointer to an inclination angle. Returns 0 if user * input is a spherical ellipse. */ -int get_ellipse(double *lng, double *lat, double *r1, - double *r2, double *inc); +extern int get_ellipse(double *lng, double *lat, double *r1, + double *r2, double *inc); /* * Returns the line parameters. "phi" is the pointer to the first angle @@ -112,8 +112,8 @@ int get_ellipse(double *lng, double *lat, double *r1, * "etype" is the pointer to the axes value of Euler transformation, "length" is * the pointer to the length value. Returns 0 if user input is a spherical line. */ -int get_line(double *phi, double *theta, double *psi, - unsigned char *etype, double *length); +extern int get_line(double *phi, double *theta, double *psi, + unsigned char *etype, double *length); /* * Returns the Euler transformation parameters. "phi" is the pointer to the @@ -122,20 +122,20 @@ int get_line(double *phi, double *theta, double *psi, * transformation, "etype" is the pointer to the axes value of Euler transformation. * Returns 0 if user input is an Euler transformation. */ -int get_euler(double *phi, double *theta, - double *psi, unsigned char *etype); +extern int get_euler(double *phi, double *theta, + double *psi, unsigned char *etype); /* * Returns the number of path elements. */ -int get_path_count(void); +extern int get_path_count(void); /* * Returns the elements of a path. "spos" is the number of element, "lng" is * the ID of longitude angle, "lat" is the ID of a latitude angle. Returns 0 * if user input is a path or a polygon and "spos" is valid. */ -int get_path_elem(int spos, double *lng, double *lat); +extern int get_path_elem(int spos, double *lng, double *lat); /* * Returns the elements of a box. "lng1" is the ID of the first longitude @@ -143,6 +143,6 @@ int get_path_elem(int spos, double *lng, double *lat); * the second longitude angle, "lat2" is the ID of the second latitude angle. * Returns 0 if user input is a box. */ -int get_box(double *lng1, double *lat1, double *lng2, double *lat2); +extern int get_box(double *lng1, double *lat1, double *lng2, double *lat2); #endif diff --git a/src/sparse.c b/src/sparse.c index f2200860..16a65d11 100644 --- a/src/sparse.c +++ b/src/sparse.c @@ -74,7 +74,7 @@ #define yychar sphere_yychar /* First part of user prologue. */ -#line 1 "sparse.y" +#line 1 "src/sparse.y" #include #include @@ -110,7 +110,7 @@ static double human2dec(double d, double m, double s) } -#line 114 "sparse.c" +#line 114 "src/sparse.c" # ifndef YY_NULLPTR # if defined __cplusplus @@ -134,8 +134,8 @@ static double human2dec(double d, double m, double s) /* Use api.header.include to #include this header instead of duplicating it here. */ -#ifndef YY_SPHERE_YY_SPARSE_H_INCLUDED -# define YY_SPHERE_YY_SPARSE_H_INCLUDED +#ifndef YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED +# define YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -160,9 +160,9 @@ extern int sphere_yydebug; CLOSEPOINT = 266, OPENARR = 267, CLOSEARR = 268, - SIGN = 269, - INT = 270, - FLOAT = 271, + TOK_SIGN = 269, + TOK_INT = 270, + TOK_FLOAT = 271, EULERAXIS = 272 }; #endif @@ -178,22 +178,22 @@ extern int sphere_yydebug; #define CLOSEPOINT 266 #define OPENARR 267 #define CLOSEARR 268 -#define SIGN 269 -#define INT 270 -#define FLOAT 271 +#define TOK_SIGN 269 +#define TOK_INT 270 +#define TOK_FLOAT 271 #define EULERAXIS 272 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 41 "sparse.y" +#line 41 "src/sparse.y" int i; double d; char c[3]; -#line 197 "sparse.c" +#line 197 "src/sparse.c" }; typedef union YYSTYPE YYSTYPE; @@ -206,7 +206,7 @@ extern YYSTYPE sphere_yylval; int sphere_yyparse (void); -#endif /* !YY_SPHERE_YY_SPARSE_H_INCLUDED */ +#endif /* !YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED */ @@ -515,10 +515,11 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "HOUR", "DEG", "MIN", "SEC", "COMMA", "OPENCIRC", "CLOSECIRC", "OPENPOINT", "CLOSEPOINT", "OPENARR", - "CLOSEARR", "SIGN", "INT", "FLOAT", "EULERAXIS", "$accept", "commands", - "command", "number", "angle_lat_us", "angle_long_us", "angle_long", - "angle_lat", "spherepoint", "spherecircle", "eulertrans", "sphereline", - "spherepointlist", "spherepath", "sphereellipse", "spherebox", YY_NULLPTR + "CLOSEARR", "TOK_SIGN", "TOK_INT", "TOK_FLOAT", "EULERAXIS", "$accept", + "commands", "command", "number", "angle_lat_us", "angle_long_us", + "angle_long", "angle_lat", "spherepoint", "spherecircle", "eulertrans", + "sphereline", "spherepointlist", "spherepath", "sphereellipse", + "spherebox", YY_NULLPTR }; #endif @@ -1349,265 +1350,265 @@ yyparse (void) switch (yyn) { case 4: -#line 70 "sparse.y" +#line 70 "src/sparse.y" { set_spheretype( STYPE_POINT ); } -#line 1355 "sparse.c" +#line 1356 "src/sparse.c" break; case 5: -#line 71 "sparse.y" +#line 71 "src/sparse.y" { set_spheretype( STYPE_CIRCLE ); } -#line 1361 "sparse.c" +#line 1362 "src/sparse.c" break; case 6: -#line 72 "sparse.y" +#line 72 "src/sparse.y" { set_spheretype( STYPE_LINE ); } -#line 1367 "sparse.c" +#line 1368 "src/sparse.c" break; case 7: -#line 73 "sparse.y" +#line 73 "src/sparse.y" { set_spheretype( STYPE_EULER ); } -#line 1373 "sparse.c" +#line 1374 "src/sparse.c" break; case 8: -#line 74 "sparse.y" +#line 74 "src/sparse.y" { set_spheretype( STYPE_PATH ); } -#line 1379 "sparse.c" +#line 1380 "src/sparse.c" break; case 9: -#line 75 "sparse.y" +#line 75 "src/sparse.y" { set_spheretype( STYPE_ELLIPSE ); } -#line 1385 "sparse.c" +#line 1386 "src/sparse.c" break; case 10: -#line 76 "sparse.y" +#line 76 "src/sparse.y" { set_spheretype( STYPE_BOX ); } -#line 1391 "sparse.c" +#line 1392 "src/sparse.c" break; case 11: -#line 81 "sparse.y" +#line 81 "src/sparse.y" { (yyval.d) = (yyvsp[0].d); } -#line 1397 "sparse.c" +#line 1398 "src/sparse.c" break; case 12: -#line 82 "sparse.y" +#line 82 "src/sparse.y" { (yyval.d) = (yyvsp[0].i); } -#line 1403 "sparse.c" +#line 1404 "src/sparse.c" break; case 13: -#line 87 "sparse.y" +#line 87 "src/sparse.y" { (yyval.i) = set_angle(0, (yyvsp[0].d) ); } -#line 1409 "sparse.c" +#line 1410 "src/sparse.c" break; case 14: -#line 88 "sparse.y" +#line 88 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].d), 0, 0) ); } -#line 1415 "sparse.c" +#line 1416 "src/sparse.c" break; case 15: -#line 89 "sparse.y" +#line 89 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].i), 0, 0) ); } -#line 1421 "sparse.c" +#line 1422 "src/sparse.c" break; case 16: -#line 90 "sparse.y" +#line 90 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-2].i), (yyvsp[0].d), 0) ); } -#line 1427 "sparse.c" +#line 1428 "src/sparse.c" break; case 17: -#line 91 "sparse.y" +#line 91 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].d), 0) ); } -#line 1433 "sparse.c" +#line 1434 "src/sparse.c" break; case 18: -#line 92 "sparse.y" +#line 92 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].i), 0) ); } -#line 1439 "sparse.c" +#line 1440 "src/sparse.c" break; case 19: -#line 93 "sparse.y" +#line 93 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d)) ); } -#line 1445 "sparse.c" +#line 1446 "src/sparse.c" break; case 20: -#line 94 "sparse.y" +#line 94 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d)) ); } -#line 1451 "sparse.c" +#line 1452 "src/sparse.c" break; case 21: -#line 99 "sparse.y" +#line 99 "src/sparse.y" { (yyval.i) = set_angle(0, (yyvsp[0].d)); } -#line 1457 "sparse.c" +#line 1458 "src/sparse.c" break; case 22: -#line 100 "sparse.y" +#line 100 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].d), 0, 0)); } -#line 1463 "sparse.c" +#line 1464 "src/sparse.c" break; case 23: -#line 101 "sparse.y" +#line 101 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-1].i), 0, 0)); } -#line 1469 "sparse.c" +#line 1470 "src/sparse.c" break; case 24: -#line 102 "sparse.y" +#line 102 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-2].i), (yyvsp[0].d), 0)); } -#line 1475 "sparse.c" +#line 1476 "src/sparse.c" break; case 25: -#line 103 "sparse.y" +#line 103 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].d), 0)); } -#line 1481 "sparse.c" +#line 1482 "src/sparse.c" break; case 26: -#line 104 "sparse.y" +#line 104 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-3].i), (yyvsp[-1].i), 0)); } -#line 1487 "sparse.c" +#line 1488 "src/sparse.c" break; case 27: -#line 105 "sparse.y" +#line 105 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d))); } -#line 1493 "sparse.c" +#line 1494 "src/sparse.c" break; case 28: -#line 106 "sparse.y" +#line 106 "src/sparse.y" { (yyval.i) = set_angle(1, human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d))); } -#line 1499 "sparse.c" +#line 1500 "src/sparse.c" break; case 29: -#line 107 "sparse.y" +#line 107 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-2].i), (yyvsp[0].d), 0)); } -#line 1505 "sparse.c" +#line 1506 "src/sparse.c" break; case 30: -#line 108 "sparse.y" +#line 108 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].d))); } -#line 1511 "sparse.c" +#line 1512 "src/sparse.c" break; case 31: -#line 109 "sparse.y" +#line 109 "src/sparse.y" { (yyval.i) = set_angle(1, 15 * human2dec((yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].d))); } -#line 1517 "sparse.c" +#line 1518 "src/sparse.c" break; case 32: -#line 114 "sparse.y" +#line 114 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), 1); } -#line 1523 "sparse.c" +#line 1524 "src/sparse.c" break; case 33: -#line 115 "sparse.y" +#line 115 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), (yyvsp[-1].i)); } -#line 1529 "sparse.c" +#line 1530 "src/sparse.c" break; case 34: -#line 120 "sparse.y" +#line 120 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), 1); } -#line 1535 "sparse.c" +#line 1536 "src/sparse.c" break; case 35: -#line 121 "sparse.y" +#line 121 "src/sparse.y" { (yyval.i) = set_angle_sign((yyvsp[0].i), (yyvsp[-1].i)); } -#line 1541 "sparse.c" +#line 1542 "src/sparse.c" break; case 36: -#line 128 "sparse.y" +#line 128 "src/sparse.y" { (yyval.i) = set_point((yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1549 "sparse.c" +#line 1550 "src/sparse.c" break; case 37: -#line 136 "sparse.y" +#line 136 "src/sparse.y" { set_circle((yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1557 "sparse.c" +#line 1558 "src/sparse.c" break; case 38: -#line 144 "sparse.y" +#line 144 "src/sparse.y" { set_euler((yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].i), "ZXZ"); } -#line 1565 "sparse.c" +#line 1566 "src/sparse.c" break; case 39: -#line 148 "sparse.y" +#line 148 "src/sparse.y" { set_euler((yyvsp[-6].i), (yyvsp[-4].i), (yyvsp[-2].i), (yyvsp[0].c)); } -#line 1573 "sparse.c" +#line 1574 "src/sparse.c" break; case 40: -#line 156 "sparse.y" +#line 156 "src/sparse.y" { set_line ((yyvsp[0].i)); } -#line 1581 "sparse.c" +#line 1582 "src/sparse.c" break; case 43: -#line 168 "sparse.y" +#line 168 "src/sparse.y" { } -#line 1587 "sparse.c" +#line 1588 "src/sparse.c" break; case 44: -#line 174 "sparse.y" +#line 174 "src/sparse.y" { set_ellipse((yyvsp[-8].i), (yyvsp[-6].i), (yyvsp[-3].i), (yyvsp[-1].i)); } -#line 1595 "sparse.c" +#line 1596 "src/sparse.c" break; case 45: -#line 181 "sparse.y" +#line 181 "src/sparse.y" { } -#line 1601 "sparse.c" +#line 1602 "src/sparse.c" break; case 46: -#line 182 "sparse.y" +#line 182 "src/sparse.y" { } -#line 1607 "sparse.c" +#line 1608 "src/sparse.c" break; -#line 1611 "sparse.c" +#line 1612 "src/sparse.c" default: break; } diff --git a/src/sparse.h b/src/sparse.h index 032b5fdb..c6607ba4 100644 --- a/src/sparse.h +++ b/src/sparse.h @@ -34,8 +34,8 @@ /* Undocumented macros, especially those whose name start with YY_, are private implementation details. Do not rely on them. */ -#ifndef YY_SPHERE_YY_SPARSE_H_INCLUDED -# define YY_SPHERE_YY_SPARSE_H_INCLUDED +#ifndef YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED +# define YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -60,9 +60,9 @@ extern int sphere_yydebug; CLOSEPOINT = 266, OPENARR = 267, CLOSEARR = 268, - SIGN = 269, - INT = 270, - FLOAT = 271, + TOK_SIGN = 269, + TOK_INT = 270, + TOK_FLOAT = 271, EULERAXIS = 272 }; #endif @@ -78,22 +78,22 @@ extern int sphere_yydebug; #define CLOSEPOINT 266 #define OPENARR 267 #define CLOSEARR 268 -#define SIGN 269 -#define INT 270 -#define FLOAT 271 +#define TOK_SIGN 269 +#define TOK_INT 270 +#define TOK_FLOAT 271 #define EULERAXIS 272 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 41 "sparse.y" +#line 41 "src/sparse.y" int i; double d; char c[3]; -#line 97 "sparse.h" +#line 97 "src/sparse.h" }; typedef union YYSTYPE YYSTYPE; @@ -106,4 +106,4 @@ extern YYSTYPE sphere_yylval; int sphere_yyparse (void); -#endif /* !YY_SPHERE_YY_SPARSE_H_INCLUDED */ +#endif /* !YY_SPHERE_YY_SRC_SPARSE_H_INCLUDED */ diff --git a/src/sparse.y b/src/sparse.y index 22e87781..0b65d9ff 100644 --- a/src/sparse.y +++ b/src/sparse.y @@ -44,9 +44,9 @@ static double human2dec(double d, double m, double s) char c[3]; } -%token SIGN -%token INT -%token FLOAT +%token TOK_SIGN +%token TOK_INT +%token TOK_FLOAT %token EULERAXIS %left COMMA @@ -78,47 +78,47 @@ command: /* unsigned number */ number : - FLOAT { $$ = $1; } - | INT { $$ = $1; } + TOK_FLOAT { $$ = $1; } + | TOK_INT { $$ = $1; } ; /* unsigned longitude */ angle_lat_us : number { $$ = set_angle(0, $1 ); } - | FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } - | INT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } - | INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0) ); } - | INT DEG FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } - | INT DEG INT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } - | INT DEG INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5) ); } - | INT DEG INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5) ); } + | TOK_FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } + | TOK_INT DEG { $$ = set_angle(1, human2dec($1, 0, 0) ); } + | TOK_INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0) ); } + | TOK_INT DEG TOK_FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } + | TOK_INT DEG TOK_INT MIN { $$ = set_angle(1, human2dec($1, $3, 0) ); } + | TOK_INT DEG TOK_INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5) ); } + | TOK_INT DEG TOK_INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5) ); } ; /* unsigned latitude */ angle_long_us : number { $$ = set_angle(0, $1); } - | FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } - | INT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } - | INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0)); } - | INT DEG FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } - | INT DEG INT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } - | INT DEG INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5)); } - | INT DEG INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5)); } - | INT HOUR number { $$ = set_angle(1, 15 * human2dec($1, $3, 0)); } - | INT HOUR INT MIN number { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } - | INT HOUR INT MIN number SEC { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } + | TOK_FLOAT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } + | TOK_INT DEG { $$ = set_angle(1, human2dec($1, 0, 0)); } + | TOK_INT DEG number { $$ = set_angle(1, human2dec($1, $3, 0)); } + | TOK_INT DEG TOK_FLOAT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } + | TOK_INT DEG TOK_INT MIN { $$ = set_angle(1, human2dec($1, $3, 0)); } + | TOK_INT DEG TOK_INT MIN number { $$ = set_angle(1, human2dec($1, $3, $5)); } + | TOK_INT DEG TOK_INT MIN number SEC { $$ = set_angle(1, human2dec($1, $3, $5)); } + | TOK_INT HOUR number { $$ = set_angle(1, 15 * human2dec($1, $3, 0)); } + | TOK_INT HOUR TOK_INT MIN number { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } + | TOK_INT HOUR TOK_INT MIN number SEC { $$ = set_angle(1, 15 * human2dec($1, $3, $5)); } ; /* longitude */ angle_long : angle_long_us { $$ = set_angle_sign($1, 1); } - | SIGN angle_long_us { $$ = set_angle_sign($2, $1); } + | TOK_SIGN angle_long_us { $$ = set_angle_sign($2, $1); } ; /* latitude */ angle_lat : angle_lat_us { $$ = set_angle_sign($1, 1); } - | SIGN angle_lat_us { $$ = set_angle_sign($2, $1); } + | TOK_SIGN angle_lat_us { $$ = set_angle_sign($2, $1); } ; diff --git a/src/sscan.c b/src/sscan.c index 3d904c67..50e0e70d 100644 --- a/src/sscan.c +++ b/src/sscan.c @@ -1,6 +1,6 @@ -#line 2 "sscan.c" +#line 2 "src/sscan.c" -#line 4 "sscan.c" +#line 4 "src/sscan.c" #define YY_INT_ALIGNED short int @@ -722,8 +722,8 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "sscan.l" -#line 2 "sscan.l" +#line 1 "src/sscan.l" +#line 2 "src/sscan.l" #include #include "string.h" #include "sparse.h" @@ -745,8 +745,8 @@ void sphere_flush_scanner_buffer(void) { YY_FLUSH_BUFFER; } -#line 749 "sscan.c" -#line 750 "sscan.c" +#line 749 "src/sscan.c" +#line 750 "src/sscan.c" #define INITIAL 0 @@ -961,9 +961,9 @@ YY_DECL } { -#line 35 "sscan.l" +#line 35 "src/sscan.l" -#line 967 "sscan.c" +#line 967 "src/sscan.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1018,106 +1018,106 @@ YY_DECL case 1: YY_RULE_SETUP -#line 36 "sscan.l" -sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return SIGN; +#line 36 "src/sscan.l" +sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return TOK_SIGN; YY_BREAK case 2: YY_RULE_SETUP -#line 37 "sscan.l" -sphere_yylval.i = atoi(yytext); return INT; +#line 37 "src/sscan.l" +sphere_yylval.i = atoi(yytext); return TOK_INT; YY_BREAK case 3: YY_RULE_SETUP -#line 38 "sscan.l" -sphere_yylval.d = atof(yytext); return FLOAT; +#line 38 "src/sscan.l" +sphere_yylval.d = atof(yytext); return TOK_FLOAT; YY_BREAK case 4: YY_RULE_SETUP -#line 39 "sscan.l" +#line 39 "src/sscan.l" memcpy(&sphere_yylval.c[0], yytext, 3); return EULERAXIS; YY_BREAK case 5: YY_RULE_SETUP -#line 40 "sscan.l" +#line 40 "src/sscan.l" return HOUR; YY_BREAK case 6: YY_RULE_SETUP -#line 41 "sscan.l" +#line 41 "src/sscan.l" return DEG; YY_BREAK case 7: YY_RULE_SETUP -#line 42 "sscan.l" +#line 42 "src/sscan.l" return MIN; YY_BREAK case 8: YY_RULE_SETUP -#line 43 "sscan.l" +#line 43 "src/sscan.l" return MIN; YY_BREAK case 9: YY_RULE_SETUP -#line 44 "sscan.l" +#line 44 "src/sscan.l" return SEC; YY_BREAK case 10: YY_RULE_SETUP -#line 45 "sscan.l" +#line 45 "src/sscan.l" return SEC; YY_BREAK case 11: YY_RULE_SETUP -#line 46 "sscan.l" +#line 46 "src/sscan.l" return COMMA; YY_BREAK case 12: YY_RULE_SETUP -#line 47 "sscan.l" +#line 47 "src/sscan.l" return OPENCIRC; YY_BREAK case 13: YY_RULE_SETUP -#line 48 "sscan.l" +#line 48 "src/sscan.l" return CLOSECIRC; YY_BREAK case 14: YY_RULE_SETUP -#line 49 "sscan.l" +#line 49 "src/sscan.l" return OPENPOINT; YY_BREAK case 15: YY_RULE_SETUP -#line 50 "sscan.l" +#line 50 "src/sscan.l" return CLOSEPOINT; YY_BREAK case 16: YY_RULE_SETUP -#line 51 "sscan.l" +#line 51 "src/sscan.l" return OPENARR; YY_BREAK case 17: YY_RULE_SETUP -#line 52 "sscan.l" +#line 52 "src/sscan.l" return CLOSEARR; YY_BREAK case 18: /* rule 18 can match eol */ YY_RULE_SETUP -#line 53 "sscan.l" +#line 53 "src/sscan.l" /* discard spaces */ YY_BREAK case 19: YY_RULE_SETUP -#line 54 "sscan.l" +#line 54 "src/sscan.l" /* alert parser of the garbage */ YY_BREAK case 20: YY_RULE_SETUP -#line 55 "sscan.l" +#line 55 "src/sscan.l" ECHO; YY_BREAK -#line 1121 "sscan.c" +#line 1121 "src/sscan.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2086,6 +2086,6 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 55 "sscan.l" +#line 55 "src/sscan.l" diff --git a/src/sscan.l b/src/sscan.l index 99bd8ac6..d3103b6d 100644 --- a/src/sscan.l +++ b/src/sscan.l @@ -33,9 +33,9 @@ real ({int})?\.({int}) float ({int}|{real})([eE]{sign}{int})? %% -{sign} sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return SIGN; -{int} sphere_yylval.i = atoi(yytext); return INT; -{float} sphere_yylval.d = atof(yytext); return FLOAT; +{sign} sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return TOK_SIGN; +{int} sphere_yylval.i = atoi(yytext); return TOK_INT; +{float} sphere_yylval.d = atof(yytext); return TOK_FLOAT; [x-zX-Z]{3} memcpy(&sphere_yylval.c[0], yytext, 3); return EULERAXIS; h return HOUR; d return DEG; diff --git a/src/vector3d.h b/src/vector3d.h index 23ba9b9e..47a5a82b 100644 --- a/src/vector3d.h +++ b/src/vector3d.h @@ -10,9 +10,9 @@ */ typedef struct { - float8 x; /* x (-1.0 .. 1.0) */ - float8 y; /* y (-1.0 .. 1.0) */ - float8 z; /* z (-1.0 .. 1.0) */ + float8 x; /* x (-1.0 .. 1.0) */ + float8 y; /* y (-1.0 .. 1.0) */ + float8 z; /* z (-1.0 .. 1.0) */ } Vector3D; @@ -20,27 +20,28 @@ typedef struct * Calculate the cross product of two vectors. Puts * cross product of v1 and v2 into out and returns it. */ -void vector3d_cross(Vector3D *out, const Vector3D *v1, const Vector3D *v2); +extern void vector3d_cross(Vector3D *out, const Vector3D *v1, + const Vector3D *v2); /* * Checks equality of two vectors. */ -bool vector3d_eq(const Vector3D *a, const Vector3D *b); +extern bool vector3d_eq(const Vector3D *a, const Vector3D *b); /* * Calculate the scalar product of two vectors. */ -float8 vector3d_scalar(Vector3D *v1, Vector3D *v2); +extern float8 vector3d_scalar(Vector3D *v1, Vector3D *v2); /* * Calculate the length of a vector. */ -float8 vector3d_length(const Vector3D *v); +extern float8 vector3d_length(const Vector3D *v); -/* - * Calculate result + scalar*delta +/* + * Calculate result + scalar*delta */ -void vector3d_addwithscalar( - Vector3D *result, double scalar, const Vector3D *delta); +extern void vector3d_addwithscalar(Vector3D *result, double scalar, + const Vector3D *delta); #endif diff --git a/test_top_build_dir/Makefile b/test_top_build_dir/Makefile deleted file mode 100644 index 80919a1a..00000000 --- a/test_top_build_dir/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -install: - ln -s / ../tmp_check/install diff --git a/upgrade_scripts/pg_sphere--1.3.1--1.4.0.sql.in b/upgrade_scripts/pg_sphere--1.3.1--1.4.0.sql.in new file mode 100644 index 00000000..70f9506c --- /dev/null +++ b/upgrade_scripts/pg_sphere--1.3.1--1.4.0.sql.in @@ -0,0 +1,44 @@ +-- add "fetch" support function to enable index-only scans for spoint3 + +-- g_spoint3_fetch was already part of the spoint3 opclass in older versions +-- around 1.0, but later made optional (see bdc37d1) + +DO $$ +BEGIN + ALTER OPERATOR FAMILY spoint3 USING gist ADD + FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal); +EXCEPTION + WHEN duplicate_object THEN NULL; + WHEN OTHERS THEN RAISE; +END; +$$; + +-- remove legacy spellings of operators +DROP OPERATOR IF EXISTS @(bigint, smoc); +DROP OPERATOR IF EXISTS @(spoint, smoc); + +-- add spoly function that takes an array of float8 values in radians +CREATE FUNCTION spoly(float8[]) + RETURNS spoly + AS 'MODULE_PATHNAME', 'spherepoly_rad' + LANGUAGE 'c' + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoly(float8[]) IS + 'creates spoly from array of numbers in radians'; + +CREATE FUNCTION spoly(spoint[]) + RETURNS spoly + AS 'MODULE_PATHNAME', 'spherepoly_from_point_array' + LANGUAGE 'c' + IMMUTABLE STRICT PARALLEL SAFE; + +COMMENT ON FUNCTION spoly(spoint[]) IS + 'creates spoly from an array of points'; + +-- add PARALLEL SAFE to spoly_deg(float8[]) +ALTER FUNCTION spoly_deg(float8[]) IMMUTABLE STRICT PARALLEL SAFE; + +-- update comment on spoly_deg function +COMMENT ON FUNCTION spoly_deg(float8[]) IS + 'creates spoly from array of numbers in degrees'; diff --git a/upgrade_scripts/pg_sphere--1.4.2--1.5.0.sql.in b/upgrade_scripts/pg_sphere--1.4.2--1.5.0.sql.in new file mode 100644 index 00000000..8b2ce2b9 --- /dev/null +++ b/upgrade_scripts/pg_sphere--1.4.2--1.5.0.sql.in @@ -0,0 +1,21 @@ +-- Upgrade: 1.4.2 -> 1.5.0 + +CREATE OR REPLACE FUNCTION g_spoint_distance(internal, spoint, smallint, oid, internal) + RETURNS internal + AS 'MODULE_PATHNAME', 'g_spoint_distance' + LANGUAGE 'c'; + +DO $$ +BEGIN + ALTER OPERATOR FAMILY spoint USING gist ADD + FUNCTION 8 (spoint, spoint) g_spoint_distance (internal, spoint, smallint, oid, internal); +EXCEPTION + WHEN duplicate_object THEN NULL; + WHEN OTHERS THEN RAISE; +END; +$$; + +CREATE FUNCTION reset_sphere_output_precision() + RETURNS CSTRING + AS 'MODULE_PATHNAME', 'reset_sphere_output_precision' + LANGUAGE 'c'; diff --git a/upgrade_scripts/pg_sphere--1.5.0--1.5.1.sql.in b/upgrade_scripts/pg_sphere--1.5.0--1.5.1.sql.in new file mode 100644 index 00000000..20c7cf63 --- /dev/null +++ b/upgrade_scripts/pg_sphere--1.5.0--1.5.1.sql.in @@ -0,0 +1,11 @@ +-- Upgrade: 1.5.0 -> 1.5.1 + +DO $$ +BEGIN + ALTER OPERATOR FAMILY spoint USING gist ADD + OPERATOR 17 <-> (spoint, spoint) FOR ORDER BY float_ops; +EXCEPTION + WHEN duplicate_object THEN NULL; + WHEN OTHERS THEN RAISE; +END; +$$; diff --git a/upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in b/upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in new file mode 100644 index 00000000..3ff6a66e --- /dev/null +++ b/upgrade_scripts/pg_sphere--1.5.1--1.5.2.sql.in @@ -0,0 +1,2 @@ +-- Upgrade: 1.5.1 -> 1.5.2 +-- Nothing to do yet diff --git a/upgrade_scripts/pg_sphere--unpackaged--1.1.5.sql.in b/upgrade_scripts/pg_sphere--unpackaged--1.1.5.sql.in deleted file mode 100644 index 450e6b7d..00000000 --- a/upgrade_scripts/pg_sphere--unpackaged--1.1.5.sql.in +++ /dev/null @@ -1,2 +0,0 @@ --- complain if this upgrade script is run via psql -\echo Use "CREATE EXTENSION pg_sphere FROM unpackaged" to load this file. \quit diff --git a/upgrade_scripts/pg_sphere--unpackaged--1.1.5beta0gavo.sql.in b/upgrade_scripts/pg_sphere--unpackaged--1.1.5beta0gavo.sql.in deleted file mode 100644 index 450e6b7d..00000000 --- a/upgrade_scripts/pg_sphere--unpackaged--1.1.5beta0gavo.sql.in +++ /dev/null @@ -1,2 +0,0 @@ --- complain if this upgrade script is run via psql -\echo Use "CREATE EXTENSION pg_sphere FROM unpackaged" to load this file. \quit diff --git a/upgrade_scripts/pgs_box.sql.in b/upgrade_scripts/pgs_box.sql.in deleted file mode 100644 index 3c259c50..00000000 --- a/upgrade_scripts/pgs_box.sql.in +++ /dev/null @@ -1,95 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION sbox(spoint, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION sw(sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION se(sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION nw(sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION ne(sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION area(sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION circum(sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR @-@(NONE, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_equal(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR =(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(sbox, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_box(sbox, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_box_com(sbox, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_box_neg(sbox, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_box_com_neg(sbox, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_box(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sbox, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_box_neg(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sbox, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_cont_point_com(spoint, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_cont_point_com_neg(spoint, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_cont_point(sbox, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_cont_point_neg(sbox, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_circle(sbox, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_circle_com(scircle, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_circle_neg(sbox, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_circle_com_neg(scircle, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_box(scircle, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_box_com(sbox, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_box_neg(scircle, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_box_com_neg(sbox, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_circle(sbox, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sbox, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_circle_com(scircle, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(scircle, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_circle_neg(sbox, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sbox, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_circle_com_neg(scircle, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(scircle, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_line(sbox, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_line_com(sline, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_line_neg(sbox, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_line_com_neg(sline, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_line(sbox, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sbox, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_line_com(sline, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sline, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_line_neg(sbox, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sbox, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_line_com_neg(sline, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sline, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_ellipse(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_ellipse_com(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_ellipse_neg(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_ellipse_com_neg(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_box(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_box_com(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_box_neg(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_box_com_neg(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_ellipse(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_ellipse_com(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_ellipse_neg(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_ellipse_com_neg(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_poly(sbox, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_poly_com(spoly, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_poly_neg(sbox, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_poly_com_neg(spoly, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_box(spoly, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_box_com(sbox, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_box_neg(spoly, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_box_com_neg(sbox, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_poly(sbox, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sbox, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_poly_com(spoly, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spoly, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_poly_neg(sbox, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sbox, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_poly_com_neg(spoly, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spoly, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_path(sbox, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_path_com(spath, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_path_neg(sbox, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_contains_path_com_neg(spath, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_path(sbox, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sbox, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_path_com(spath, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spath, sbox); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_path_neg(sbox, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sbox, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_overlap_path_com_neg(spath, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spath, sbox); diff --git a/upgrade_scripts/pgs_circle.sql.in b/upgrade_scripts/pgs_circle.sql.in deleted file mode 100644 index ddd2ab85..00000000 --- a/upgrade_scripts/pgs_circle.sql.in +++ /dev/null @@ -1,31 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION area(scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION radius(scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle(spoint, float8); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_equal(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR =(scircle, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_equal_neg(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(scircle, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_overlap(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(scircle, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_overlap_neg(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(scircle, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION center(scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR @@(NONE, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION circum(scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR @-@(NONE, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contained_by_circle(scircle, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint_contained_by_circle(spoint, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint_contained_by_circle_neg(spoint, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint_contained_by_circle_com(scircle, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint_contained_by_circle_com_neg(scircle, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION dist(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR <->(scircle, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION dist(scircle, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR <->(scircle, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION dist(spoint, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR <->(spoint, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_circle(scircle, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(scircle, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_circle_inverse(scircle, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(scircle, strans); diff --git a/upgrade_scripts/pgs_contains_ops_compat.sql.in b/upgrade_scripts/pgs_contains_ops_compat.sql.in deleted file mode 100644 index d0e9c229..00000000 --- a/upgrade_scripts/pgs_contains_ops_compat.sql.in +++ /dev/null @@ -1,120 +0,0 @@ -ALTER EXTENSION pg_sphere ADD OPERATOR ~(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR @(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(scircle, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(scircle, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoint, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(scircle, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoint, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spoly, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoint, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spoly, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoint, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(scircle, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoly, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(scircle, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoly, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spoly, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR @(scircle, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spoly, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(scircle, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sbox, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sbox, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoint, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sbox, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoint, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(scircle, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sbox, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(scircle, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sbox, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sbox, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR @(scircle, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sbox, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(scircle, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spoly, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sbox, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spoly, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sbox, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sbox, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoly, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sbox, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoly, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoint, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sline, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sline, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoint, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(scircle, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sline, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(scircle, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sline, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spoly, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sline, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spoly, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sline, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sellipse, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoint, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sellipse, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoint, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sellipse, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sbox, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR @(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sellipse, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sline, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sellipse, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sline, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spath, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spoint, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spath, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spoint, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sbox, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spath, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sbox, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spath, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(scircle, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spath, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(scircle, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spath, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sellipse, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spath, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sellipse, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spath, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(spoly, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR @(spath, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(spoly, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(spath, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR ~(sbox, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR @(sline, sbox); -ALTER EXTENSION pg_sphere ADD OPERATOR !~(sbox, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !@(sline, sbox); diff --git a/upgrade_scripts/pgs_ellipse.sql.in b/upgrade_scripts/pgs_ellipse.sql.in deleted file mode 100644 index 77e2d777..00000000 --- a/upgrade_scripts/pgs_ellipse.sql.in +++ /dev/null @@ -1,55 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse(spoint, float8, float8, float8); -ALTER EXTENSION pg_sphere ADD FUNCTION inc(sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION lrad(sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION srad(sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle(sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse(scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION strans(sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION center(sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR @@(NONE, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_equal(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR =(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_equal_neg(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_ellipse(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_ellipse_com(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_ellipse_neg(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_ellipse_com_neg(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_ellipse(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_ellipse_neg(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sellipse, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_point(sellipse, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_point_com(spoint, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_point_neg(sellipse, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_point_com_neg(spoint, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_ellipse(sellipse, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(sellipse, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(sellipse, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_circle(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_circle_com(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_circle_neg(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_circle_com_neg(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_ellipse(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_ellipse_com(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_ellipse_neg(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_ellipse_com_neg(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_circle(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_circle_com(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_circle_neg(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sellipse, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_circle_com_neg(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(scircle, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sellipse, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_line_com(sline, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sline, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sellipse, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_line_com_neg(sline, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sline, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_line(sellipse, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_line_com(sline, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_line_neg(sellipse, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_line_com_neg(sline, sellipse); diff --git a/upgrade_scripts/pgs_euler.sql.in b/upgrade_scripts/pgs_euler.sql.in deleted file mode 100644 index 8ed4ca4c..00000000 --- a/upgrade_scripts/pgs_euler.sql.in +++ /dev/null @@ -1,23 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION strans_zxz(strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans(FLOAT8, FLOAT8, FLOAT8); -ALTER EXTENSION pg_sphere ADD FUNCTION strans(FLOAT8, FLOAT8, FLOAT8, CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION phi(strans); -ALTER EXTENSION pg_sphere ADD FUNCTION theta(strans); -ALTER EXTENSION pg_sphere ADD FUNCTION psi(strans); -ALTER EXTENSION pg_sphere ADD FUNCTION axes(strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_equal(strans, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR =(strans, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_not_equal(strans, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(strans, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans(strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(NONE, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_invert(strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(NONE, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_point(spoint, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(spoint, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_point_inverse(spoint, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(spoint, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_trans(strans, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(strans, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_trans_inv(strans, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(strans, strans); diff --git a/upgrade_scripts/pgs_gist.sql.in b/upgrade_scripts/pgs_gist.sql.in deleted file mode 100644 index aaa0e4eb..00000000 --- a/upgrade_scripts/pgs_gist.sql.in +++ /dev/null @@ -1,27 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION spherekey_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION spherekey_out(spherekey); -ALTER EXTENSION pg_sphere ADD TYPE spherekey; -ALTER EXTENSION pg_sphere ADD FUNCTION g_spherekey_decompress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_spherekey_union(bytea, internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_spherekey_picksplit(internal, internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_spoint_compress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_spoint_consistent(internal, internal, int4, oid, internal); -ALTER EXTENSION pg_sphere ADD OPERATOR CLASS spoint USING gist; -ALTER EXTENSION pg_sphere ADD FUNCTION g_scircle_compress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_scircle_consistent(internal, internal, int4, oid, internal); -ALTER EXTENSION pg_sphere ADD OPERATOR CLASS scircle USING gist; -ALTER EXTENSION pg_sphere ADD FUNCTION g_sline_compress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_sline_consistent(internal, internal, int4, oid, internal); -ALTER EXTENSION pg_sphere ADD OPERATOR CLASS sline USING gist; -ALTER EXTENSION pg_sphere ADD FUNCTION g_sellipse_compress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_sellipse_consistent(internal, internal, int4, oid, internal); -ALTER EXTENSION pg_sphere ADD OPERATOR CLASS sellipse USING gist; -ALTER EXTENSION pg_sphere ADD FUNCTION g_spoly_compress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_spoly_consistent(internal, internal, int4, oid, internal); -ALTER EXTENSION pg_sphere ADD OPERATOR CLASS spoly USING gist; -ALTER EXTENSION pg_sphere ADD FUNCTION g_spath_compress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_spath_consistent(internal, internal, int4, oid, internal); -ALTER EXTENSION pg_sphere ADD OPERATOR CLASS spath USING gist; -ALTER EXTENSION pg_sphere ADD FUNCTION g_sbox_compress(internal); -ALTER EXTENSION pg_sphere ADD FUNCTION g_sbox_consistent(internal, internal, int4, oid, internal); -ALTER EXTENSION pg_sphere ADD OPERATOR CLASS sbox USING gist; diff --git a/upgrade_scripts/pgs_line.sql.in b/upgrade_scripts/pgs_line.sql.in deleted file mode 100644 index 3e9c6cee..00000000 --- a/upgrade_scripts/pgs_line.sql.in +++ /dev/null @@ -1,41 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION sline(spoint, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION sline(strans, float8); -ALTER EXTENSION pg_sphere ADD FUNCTION meridian(float8); -ALTER EXTENSION pg_sphere ADD FUNCTION sl_beg(sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sl_end(sline); -ALTER EXTENSION pg_sphere ADD FUNCTION strans(sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sline(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_equal(sline, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR =(sline, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_equal_neg(sline, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(sline, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION length(sline); -ALTER EXTENSION pg_sphere ADD OPERATOR @-@(NONE, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION swap(sline); -ALTER EXTENSION pg_sphere ADD OPERATOR -(NONE, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION turn(sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !(NONE, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_crosses(sline, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR #(sline, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_crosses_neg(sline, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !#(sline, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_overlap(sline, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sline, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_overlap_neg(sline, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sline, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_line(sline, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(sline, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_line_inverse(sline, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(sline, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_overlap_circle(sline, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sline, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_overlap_circle_com(scircle, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(scircle, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_overlap_circle_neg(sline, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sline, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_overlap_circle_com_neg(scircle, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(scircle, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_line(scircle, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_line_com(sline, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_line_neg(scircle, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_line_com_neg(sline, scircle); diff --git a/upgrade_scripts/pgs_path.sql.in b/upgrade_scripts/pgs_path.sql.in deleted file mode 100644 index e40b4457..00000000 --- a/upgrade_scripts/pgs_path.sql.in +++ /dev/null @@ -1,67 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION npoints(spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint(spath, int4); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint(spath, float8); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_equal(spath, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR =(spath, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_equal_neg(spath, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(spath, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION length(spath); -ALTER EXTENSION pg_sphere ADD OPERATOR @-@(NONE, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION swap(spath); -ALTER EXTENSION pg_sphere ADD OPERATOR -(NONE, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_overlap_path(spath, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spath, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_overlap_path_neg(spath, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spath, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_contains_point(spath, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_contains_point_com(spoint, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_contains_point_neg(spath, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_contains_point_com_neg(spoint, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_path(spath, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(spath, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_path_inverse(spath, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(spath, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_path(scircle, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_path_com(spath, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_path_neg(scircle, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_path_com_neg(spath, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_overlap_path(scircle, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(scircle, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_overlap_path_com(spath, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spath, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_overlap_path_neg(scircle, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(scircle, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_overlap_path_com_neg(spath, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spath, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_overlap_line(spath, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spath, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_overlap_line_com(sline, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sline, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_overlap_line_neg(spath, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spath, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_overlap_line_com_neg(sline, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sline, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_path(sellipse, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_path_com(spath, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_path_neg(sellipse, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_path_com_neg(spath, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_path(sellipse, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sellipse, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_path_com(spath, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spath, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_path_neg(sellipse, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sellipse, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_overlap_path_com_neg(spath, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spath, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_path(spoly, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_path_com(spath, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_path_neg(spoly, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_path_com_neg(spath, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_path(spoly, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spoly, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_path_com(spath, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spath, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_path_neg(spoly, spath); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spoly, spath); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_path_com_neg(spath, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spath, spoly); diff --git a/upgrade_scripts/pgs_point.sql.in b/upgrade_scripts/pgs_point.sql.in deleted file mode 100644 index 754128f6..00000000 --- a/upgrade_scripts/pgs_point.sql.in +++ /dev/null @@ -1,14 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION spoint(FLOAT8, FLOAT8); -ALTER EXTENSION pg_sphere ADD FUNCTION set_sphere_output_precision(INT4); -ALTER EXTENSION pg_sphere ADD FUNCTION set_sphere_output(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION long(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION lat(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION x(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION y(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION xyz(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION z(spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint_equal(spoint, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR =(spoint, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(spoint, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION dist(spoint, spoint); -ALTER EXTENSION pg_sphere ADD OPERATOR <->(spoint, spoint); diff --git a/upgrade_scripts/pgs_polygon.sql.in b/upgrade_scripts/pgs_polygon.sql.in deleted file mode 100644 index 6a76b2fa..00000000 --- a/upgrade_scripts/pgs_polygon.sql.in +++ /dev/null @@ -1,68 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION npoints(spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION area(spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_equal(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR =(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_not_equal(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR <>(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION circum(spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR @-@(NONE, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_polygon(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_polygon_com(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_polygon_neg(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_polygon_com_neg(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_polygon(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_polygon_neg(spoly, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spoly, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_point(spoly, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_point_com(spoint, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_point_neg(spoly, spoint); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_point_com_neg(spoint, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_poly(spoly, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR +(spoly, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_poly_inverse(spoly, strans); -ALTER EXTENSION pg_sphere ADD OPERATOR -(spoly, strans); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_circle(spoly, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_circle_com(scircle, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_circle_neg(spoly, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_circle_com_neg(scircle, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_polygon(scircle, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_polygon_com(spoly, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_polygon_neg(scircle, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_contains_polygon_com_neg(spoly, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_circle(spoly, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spoly, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_circle_com(scircle, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(scircle, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_circle_neg(spoly, scircle); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spoly, scircle); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_circle_com_neg(scircle, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(scircle, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_line(spoly, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_line_com(sline, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_line_neg(spoly, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_line_com_neg(sline, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_line(spoly, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spoly, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_line_com(sline, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sline, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_line_neg(spoly, sline); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spoly, sline); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_line_com_neg(sline, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sline, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_ellipse(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_ellipse_com(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_ellipse_neg(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_contains_ellipse_com_neg(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_polygon(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_polygon_com(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_polygon_neg(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_contains_polygon_com_neg(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_ellipse(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_ellipse_com(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR &&(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_ellipse_neg(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(spoly, sellipse); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_overlap_ellipse_com_neg(sellipse, spoly); -ALTER EXTENSION pg_sphere ADD OPERATOR !&&(sellipse, spoly); diff --git a/upgrade_scripts/pgs_pre111.sql.in b/upgrade_scripts/pgs_pre111.sql.in deleted file mode 100644 index 33a98ae8..00000000 --- a/upgrade_scripts/pgs_pre111.sql.in +++ /dev/null @@ -1,7 +0,0 @@ --- versions before 2009-11-01 (i.e., release 1.1.1.) lack pg_sphere_version(), --- see https://postgrespro.ru/list/id/20091101150558.9B87B1073FEE@pgfoundry.org - -CREATE OR REPLACE FUNCTION pg_sphere_version() - RETURNS CSTRING - AS 'MODULE_PATHNAME', 'pg_sphere_version' - LANGUAGE 'c'; diff --git a/upgrade_scripts/pgs_types.sql.in b/upgrade_scripts/pgs_types.sql.in deleted file mode 100644 index 95378a0f..00000000 --- a/upgrade_scripts/pgs_types.sql.in +++ /dev/null @@ -1,24 +0,0 @@ -ALTER EXTENSION pg_sphere ADD FUNCTION spoint_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION spoint_out(spoint); -ALTER EXTENSION pg_sphere ADD TYPE spoint; -ALTER EXTENSION pg_sphere ADD FUNCTION strans_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION strans_out(strans); -ALTER EXTENSION pg_sphere ADD TYPE strans; -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION scircle_out(scircle); -ALTER EXTENSION pg_sphere ADD TYPE scircle; -ALTER EXTENSION pg_sphere ADD FUNCTION sline_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION sline_out(sline); -ALTER EXTENSION pg_sphere ADD TYPE sline; -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION sellipse_out(sellipse); -ALTER EXTENSION pg_sphere ADD TYPE sellipse; -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION spoly_out(spoly); -ALTER EXTENSION pg_sphere ADD TYPE spoly; -ALTER EXTENSION pg_sphere ADD FUNCTION spath_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION spath_out(spath); -ALTER EXTENSION pg_sphere ADD TYPE spath; -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_in(CSTRING); -ALTER EXTENSION pg_sphere ADD FUNCTION sbox_out(sbox); -ALTER EXTENSION pg_sphere ADD TYPE sbox;