Skip to content

Commit 9c91983

Browse files
df7cbmsdemlei
authored andcommitted
Rename smoc_area to area and make it return steradians
1 parent b7eb98e commit 9c91983

File tree

5 files changed

+42
-18
lines changed

5 files changed

+42
-18
lines changed

doc/functions.sgm

+7-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
The <function>area</function> function returns the area of a
1616
spherical object in square radians. Supported data types are:
1717
<type>scircle</type>, <type>spolygon</type> (if the polygon
18-
is convex), and <type>sbox</type>.
18+
is convex), <type>sbox</type>, and <type>smoc</type>.
1919
</para>
2020
<example>
2121
<title>Area of a spherical circle as a multiple of &pgr;</title>
@@ -24,6 +24,11 @@
2424
<![CDATA[ area]]>
2525
<![CDATA[------]]>
2626
<![CDATA[ 1]]>
27+
<![CDATA[(1 row)]]>
28+
<![CDATA[sql> SELECT area(smoc '0/1-3');]]>
29+
<![CDATA[ area]]>
30+
<![CDATA[-------------------]]>
31+
<![CDATA[ 3.141592653589793]]>
2732
<![CDATA[(1 row)]]>
2833
</programlisting>
2934
</example>
@@ -592,16 +597,6 @@
592597
</programlisting>
593598
</example>
594599

595-
<funcsynopsis>
596-
<funcprototype>
597-
<funcdef><function>smoc_area</function></funcdef>
598-
<paramdef>smoc</paramdef>
599-
</funcprototype>
600-
</funcsynopsis>
601-
<para>
602-
Returns the size of an smoc in order 29 pixels.
603-
</para>
604-
605600
<funcsynopsis>
606601
<funcprototype>
607602
<funcdef><function>smoc_degrade</function></funcdef>
@@ -631,7 +626,7 @@
631626
</funcsynopsis>
632627
<para>
633628
<type>smoc</type> union and intersection are available as aggregate functions
634-
that compute the aggretated area over a given column.
629+
that compute the aggretated coverage over a given column.
635630
</para>
636631
<example>
637632
<title>Computing the overall coverage of a catalog</title>

expected/moc.out

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SET client_min_messages = 'notice';
2-
-- SET client_min_messages = 'warning';
2+
SET extra_float_digits = 0; -- make results compatible with 9.6 .. 11
33
SELECT smoc(''); -- expected: '0/'
44
smoc
55
------
@@ -42,6 +42,30 @@ SELECT smoc_info('0/1-2'::smoc);
4242
version: 0, order: 0, depth: 1, first: 288230376151711744, last: 864691128455135232, area: 576460752303423488, tree_begin: 48, data_begin: 72
4343
(1 row)
4444

45+
SELECT area('0/'::smoc);
46+
area
47+
------
48+
0
49+
(1 row)
50+
51+
SELECT area('29/1'::smoc);
52+
area
53+
----------------------
54+
3.63319635209232e-18
55+
(1 row)
56+
57+
SELECT area('0/1-3'::smoc);
58+
area
59+
------------------
60+
3.14159265358979
61+
(1 row)
62+
63+
SELECT area('0/0-11'::smoc);
64+
area
65+
------------------
66+
12.5663706143592
67+
(1 row)
68+
4569
SELECT '(0.78, 0.81)'::spoint <@ '7/123-456,10000-20000'::smoc;
4670
?column?
4771
----------

moc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ smoc_area(PG_FUNCTION_ARGS)
418418
/* get just the MOC header: */
419419
Smoc *moc = (Smoc *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0,
420420
MOC_HEADER_VARSIZE);
421-
PG_RETURN_INT64(moc->area);
421+
PG_RETURN_FLOAT8(moc->area * 4.0 * M_PI / MOC_AREA_ALL_SKY);
422422
}
423423

424424
Datum

pgs_moc_ops.sql.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ CREATE FUNCTION smoc_info (smoc)
88
IMMUTABLE
99
STRICT;
1010

11-
CREATE FUNCTION smoc_area (smoc)
12-
RETURNS bigint
13-
AS 'MODULE_PATHNAME'
11+
CREATE FUNCTION area (smoc)
12+
RETURNS double precision
13+
AS 'MODULE_PATHNAME', 'smoc_area'
1414
LANGUAGE C
1515
PARALLEL SAFE
1616
IMMUTABLE

sql/moc.sql

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SET client_min_messages = 'notice';
2-
-- SET client_min_messages = 'warning';
2+
SET extra_float_digits = 0; -- make results compatible with 9.6 .. 11
33

44
SELECT smoc(''); -- expected: '0/'
55
SELECT '0/'::smoc; -- expected: '0/'
@@ -10,6 +10,11 @@ SELECT '0/0,1,2,3,7'::smoc; -- expected: '0/0-3,7'
1010
SELECT smoc_info('0/'::smoc);
1111
SELECT smoc_info('0/1-2'::smoc);
1212

13+
SELECT area('0/'::smoc);
14+
SELECT area('29/1'::smoc);
15+
SELECT area('0/1-3'::smoc);
16+
SELECT area('0/0-11'::smoc);
17+
1318
SELECT '(0.78, 0.81)'::spoint <@ '7/123-456,10000-20000'::smoc;
1419
SELECT '(0.78, 0.81)'::spoint <@ '7/123-456,1000-2000'::smoc;
1520

0 commit comments

Comments
 (0)