forked from postgrespro/pgsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.sgm
884 lines (848 loc) · 32.3 KB
/
functions.sgm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
<sect1 id="funcs">
<title>
Functions
</title>
<para>
The functions described below are implemented without having an
operator. If you are missing some functions, see
<xref linkend="operators"/> and use the operators.
</para>
<sect2 id="func.area">
<title>
Area function
</title>
<para>
The <function>area</function> function returns the area of a
spherical object in square radians. Supported data types are:
<type>scircle</type>, <type>spolygon</type> (if the polygon
is convex), <type>sbox</type>, and <type>smoc</type>.
</para>
<example>
<title>Area of a spherical circle as a multiple of &pgr;</title>
<programlisting>
<![CDATA[sql> SELECT area( scircle '<(0d,90d),60d>' ) / pi() AS area;]]>
<![CDATA[ area]]>
<![CDATA[------]]>
<![CDATA[ 1]]>
<![CDATA[(1 row)]]>
<![CDATA[sql> SELECT area(smoc '0/1-3');]]>
<![CDATA[ area]]>
<![CDATA[-------------------]]>
<![CDATA[ 3.141592653589793]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect2>
<sect2 id="func.spoint">
<title>
<type>spoint</type> functions
</title>
<sect3 id="func.spoint.ll">
<title>
Longitude and latitude
</title>
<para>
The functions
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>long</function></funcdef>
<paramdef>spoint <parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>lat</function></funcdef>
<paramdef>spoint <parameter>p</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
returns the longitude or latitude value of a
spherical position <parameter>p</parameter> in radians.
</para>
<example>
<title>Get the longitude and latitude of a spherical point in degrees</title>
<programlisting>
<![CDATA[sql> SELECT long ( spoint '(10d,20d)' ) * 180.0 / pi() AS longitude;]]>
<![CDATA[ longitude]]>
<![CDATA[------------]]>
<![CDATA[ 10]]>
<![CDATA[(1 row)]]>
<![CDATA[]]>
<![CDATA[sql> SELECT lat ( spoint '(10d,20d)' ) * 180.0 / pi() AS latitude;]]>
<![CDATA[ latitude]]>
<![CDATA[----------]]>
<![CDATA[ 20]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect3>
<sect3 id="func.spoint.cart">
<title>
Cartesian coordinates
</title>
<para>
The functions
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>x</function></funcdef>
<paramdef>spoint <parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>y</function></funcdef>
<paramdef>spoint <parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>z</function></funcdef>
<paramdef>spoint <parameter>p</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
return the Cartesian
<literal>x</literal>, <literal>y</literal> or
<literal>z</literal> value of a spherical position
<parameter>p</parameter>. The returned values are always
between <literal>-1.0</literal> and <literal>+1.0</literal>.
</para>
<example>
<title>
Get the Cartesian <literal>z</literal>-value
of a spherical point
</title>
<programlisting>
<![CDATA[sql> SELECT z ( spoint '(10d,-90d)' ) AS z;]]>
<![CDATA[ z]]>
<![CDATA[----]]>
<![CDATA[ -1]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
<para>
You can get a <type>float8</type> array of Cartesian values using the function
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>xyz</function></funcdef>
<paramdef>spoint <parameter>p</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<example>
<title>
Get the Cartesian values of a spherical point
</title>
<programlisting>
<![CDATA[sql> SELECT xyz ( spoint '(0d,0d)' ) AS cart;]]>
<![CDATA[ cart]]>
<![CDATA[---------]]>
<![CDATA[ {1,0,0}]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect3>
</sect2>
<sect2 id="funcs.strans">
<title>
<type>strans</type> functions
</title>
<sect3 id="funcs.strans.zxz">
<title>
Converting to ZXZ
</title>
<para>
Using the function
<function>strans_zxz(strans),</function> you can convert
an Euler transformation to <literal>ZXZ</literal> axes
transformation.
</para>
<example>
<title>Change the transformation axes to <literal>ZXZ</literal></title>
<simpara>
Convert the transformation <literal>strans '20d, -270d, 70.5d,
XZY'</literal> to a <literal>ZXZ</literal> transformation.
</simpara>
<programlisting>
<![CDATA[sql> SELECT strans_zxz ( strans '20d, -270d, 70.5d, XZY' );]]>
</programlisting>
</example>
</sect3>
<sect3 id="funcs.strans.axes">
<title>
Angles and axes
</title>
<para>
It is possible to get the components of an Euler
transformation.
</para>
<table frame="all" rowsep="1" colsep="1">
<title>Getting Euler transformation attributes</title>
<tgroup cols="2" colsep="1" rowsep="1">
<colspec colname="col0" align="left"/>
<colspec colname="col1" align="left" colwidth="2*"/>
<thead valign="middle">
<row>
<entry>
function
</entry>
<entry>
description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<function>phi</function>
</entry>
<entry>
first angle of a transformation
</entry>
</row>
<row>
<entry>
<function>theta</function>
</entry>
<entry>
second angle of a transformation
</entry>
</row>
<row>
<entry>
<function>psi</function>
</entry>
<entry>
third angle of a transformation
</entry>
</row>
<row>
<entry>
<function>axes</function>
</entry>
<entry>
transformation axes as a three letter code
</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
The angles will always returned as a <type>float8</type> value in radians.
The axes are returned as a three letter code.
</para>
<example>
<title>Get the second axis and its rotation angle</title>
<programlisting>
<![CDATA[sql> SELECT theta( strans '20d,30d,40d,XZY' ) * 180 / pi() AS theta;]]>
<![CDATA[ theta]]>
<![CDATA[-------]]>
<![CDATA[ 30]]>
<![CDATA[(1 row)]]>
<![CDATA[sql> SELECT substring ( axes ( strans '20d,30d,40d,XZY' ) from 2 for 1 ) AS axis;]]>
<![CDATA[ axis]]>
<![CDATA[------]]>
<![CDATA[ Z]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect3>
</sect2>
<sect2 id="func.circle">
<title>
scircle functions
</title>
<para>
You can get the radius of a spherical circle in radians using
the <function>radius</function> function. The center of the
circle is available with
the operator <literal>@@</literal> (<xref
linkend="op.center"/>).
</para>
<example>
<title>Radius of a spherical circle in degrees</title>
<programlisting>
<![CDATA[sql> SELECT 180.0 * radius( scircle '<(0d,90d),60d>' ) / pi() AS radius;]]>
<![CDATA[ radius]]>
<![CDATA[--------]]>
<![CDATA[ 60]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect2>
<sect2 id="funcs.sellipse">
<title>
<type>sellipse</type> functions
</title>
<para>
<application>pgSphere</application> provides 4 functions to get
the parameters of a spherical ellipse:
</para>
<table frame="all" rowsep="1" colsep="1">
<title>Getting spherical ellipse attributes</title>
<tgroup cols="2" colsep="1" rowsep="1">
<colspec colname="col0" align="left"/>
<colspec colname="col1" align="left" colwidth="2*"/>
<thead valign="middle">
<row>
<entry>
function
</entry>
<entry>
description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<function>lrad</function>
</entry>
<entry>
the major radius of the ellipse
</entry>
</row>
<row>
<entry>
<function>srad</function>
</entry>
<entry>
the minor radius of the ellipse
</entry>
</row>
<row>
<entry>
<function>center</function>
</entry>
<entry>
the center of the ellipse
</entry>
</row>
<row>
<entry>
<function>inc</function>
</entry>
<entry>
the inclination of the ellipse
</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
To get the ellipse center, you can use the
operator <literal>@@</literal> (<xref linkend="op.center"/>)
instead of using the function
<function>center(sellipse)</function>.
</para>
<example>
<title>Get the minor radius of an ellipse</title>
<programlisting>
<![CDATA[sql> SELECT srad ( sellipse '< { 10d, 5d }, ( 20d, 0d ), 90d >' )]]>
<![CDATA[ * 180.0/ pi() AS srad ;]]>
<![CDATA[ srad]]>
<![CDATA[------]]>
<![CDATA[ 5]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect2>
<sect2 id="funcs.sline">
<title>
<type>sline</type> functions
</title>
<sect3 id="funcs.sline.be">
<title>
Begin and end
</title>
<para>
To get the beginning and the end of a line,
<application>pgSphere</application> provides two functions:
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>sl_beg</function></funcdef>
<paramdef>sline <parameter>line</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>sl_end</function></funcdef>
<paramdef>sline <parameter>line</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<example>
<title>Get the beginning of a line</title>
<programlisting>
<![CDATA[sql> SELECT sl_beg( sline '(10d, 90d, 270d, ZXZ ), 20d';]]>
</programlisting>
</example>
</sect3>
<sect3 id="funcs.sline.meridian">
<title>
Create a meridian
</title>
<para>
You can create a meridian as a line using the function
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>meridian</function></funcdef>
<paramdef>float8 <parameter>lng</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
The function returns a line starting at a latitude of
-90° and ending at a latitude of 90°. The line goes
along the given longitude <parameter>lng</parameter> in
radians.
</para>
<example>
<title>A meridian for longitude 20°</title>
<programlisting>
<![CDATA[sql> SELECT set_sphere_output('DEG');]]>
<![CDATA[ set_sphere_output ]]>
<![CDATA[-------------------]]>
<![CDATA[ SET DEG]]>
<![CDATA[(1 row)]]>
<![CDATA[]]>
<![CDATA[sql> SELECT meridian (20.0 *pi() / 180.0 );]]>
<![CDATA[ sline ]]>
<![CDATA[-------------------------------]]>
<![CDATA[ ( 270d, 90d, 20d, ZXZ ), 180d]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect3>
</sect2>
<sect2 id="funcs.spath">
<title>
<type>spath</type> functions
</title>
<sect3 id="funcs.spath.npts">
<title>
Count of points
</title>
<para>
You can get the count of points of a spherical path using the
function:
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>npoints</function></funcdef>
<paramdef>spath <parameter>path</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<example>
<title>Count of spath's points</title>
<programlisting>
<![CDATA[sql> SELECT npoints ( spath '{(0,0),(1,0)}' );]]>
<![CDATA[ npoints]]>
<![CDATA[---------]]>
<![CDATA[ 2]]>
<![CDATA[ (1 row)]]>
<![CDATA[]]>
</programlisting>
</example>
</sect3>
<sect3 id="funcs.spath.pos">
<title>
Positions at a path
</title>
<para>
<application>pgSphere</application> provides three functions to
get points at a path.
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>spoint</function></funcdef>
<paramdef>spath <parameter>path</parameter></paramdef>
<paramdef>int4 <parameter>i</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>spoint</function></funcdef>
<paramdef>spath <parameter>path</parameter></paramdef>
<paramdef>float8 <parameter>f</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>spath_as_array</function></funcdef>
<paramdef>spath <parameter>path</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
The first function returns the <parameter>i</parameter>-th
point of a path. If <parameter>i</parameter> is less than 1
or larger than the count of <type>spath</type> points, the
function returns <literal>NULL</literal>. The second
function does nearly the same, but does linear interpolation
between edge positions.
</para>
<example>
<title>
Get the “center” of a one segment <type>spath</type>
</title>
<programlisting>
<![CDATA[sql> SELECT spoint ( spath '{(0d,0d),(30d,0d)}', 1.5 );]]>
<![CDATA[ spoint]]>
<![CDATA[------------]]>
<![CDATA[ (15d , 0d)]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
<example>
<title>
Get i-th point of a path
</title>
<programlisting>
<![CDATA[sql> SELECT spoint( spath '{(0, 0),(1, 1)}', 1 );]]>
<![CDATA[ spoint ]]>
<![CDATA[------------]]>
<![CDATA[ (0 , 0) ]]>
<![CDATA[(1 row)]]>
<![CDATA[]]>
<![CDATA[sql> SELECT spoint( spath '{(0, 0),(1, 1)}', 2 );]]>
<![CDATA[ spoint ]]>
<![CDATA[------------]]>
<![CDATA[ (1 , 1) ]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
<example>
<title>
Get array representation of points
</title>
<programlisting>
<![CDATA[sql> SELECT spath_as_array( spath '{(0, 0),(1, 1)}');]]>
<![CDATA[ spath_as_array ]]>
<![CDATA[-----------------------]]>
<![CDATA[ {"(0 , 0)","(1 , 1)"}]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect3>
</sect2>
<sect2 id="funcs.spoly">
<title>
<type>spoly</type> functions
</title>
<sect3 id="funcs.spoly.npts">
<title>
Count of edges
</title>
<para>
Similar to an <type>spath</type> (<xref linkend="funcs.spath.npts"/>),
you can get the count of edges of a spherical polygon using the
function:
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>npoints</function></funcdef>
<paramdef>spoly <parameter>polygon</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<example>
<title>Count of edges of a spherical polygon</title>
<programlisting>
<![CDATA[sql> SELECT npoints ( spoly '{(0,0),(1,0),(1,1)}' );]]>
<![CDATA[ npoints]]>
<![CDATA[---------]]>
<![CDATA[ 3]]>
<![CDATA[ (1 row)]]>
</programlisting>
</example>
</sect3>
<sect3 id="funcs.spoly.pos">
<title>
Positions at a polygon
</title>
<para>
<application>pgSphere</application> provides two functions to
get points at a path.
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>spoint</function></funcdef>
<paramdef>spoly <parameter>path</parameter></paramdef>
<paramdef>int4 <parameter>i</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>spoly_as_array</function></funcdef>
<paramdef>spath <parameter>path</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<example>
<title>Get by index</title>
<programlisting>
<![CDATA[sql> SELECT spoint( spoly '{(0,0),(1,0),(1,1)}', 1 );]]>
<![CDATA[ spoint ]]>
<![CDATA[---------]]>
<![CDATA[ (0 , 0)]]>
<![CDATA[ (1 row)]]>
<![CDATA[]]>
<![CDATA[sql> SELECT spoint( spoly '{(0,0),(1,0),(1,1)}', 2 );]]>
<![CDATA[ spoint ]]>
<![CDATA[---------]]>
<![CDATA[ (1 , 0)]]>
<![CDATA[ (1 row)]]>
<![CDATA[]]>
<![CDATA[sql> SELECT spoint( spoly '{(0,0),(1,0),(1,1)}', 3 );]]>
<![CDATA[ spoint ]]>
<![CDATA[---------]]>
<![CDATA[ (1 , 1)]]>
<![CDATA[ (1 row)]]>
</programlisting>
</example>
<example>
<title>Represent points as array</title>
<programlisting>
<![CDATA[sql> SELECT spoly_as_array( spoly '{(0,0),(1,0),(1,1)}' );]]>
<![CDATA[ spoly_as_array ]]>
<![CDATA[---------------------------------]]>
<![CDATA[ {"(0 , 0)","(1 , 0)","(1 , 1)"}]]>
<![CDATA[(1 row)]]>
</programlisting>
</example>
</sect3>
</sect2>
<sect2 id="funcs.sbox">
<title>
<type>sbox</type> functions
</title>
<para>
The functions
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>sw</function></funcdef>
<paramdef>sbox <parameter>box</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>ne</function></funcdef>
<paramdef>sbox <parameter>box</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>se</function></funcdef>
<paramdef>sbox <parameter>box</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>nw</function></funcdef>
<paramdef>sbox <parameter>box</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
return the corresponding southwest, northeast, southeast, or
northwest edge.
The returned value will be a spherical point.
</para>
<example>
<title>The southwest edge of a box</title>
<programlisting>
<![CDATA[sql> SELECT sw ( sbox '( (0d,0d), (90d,0d) )' ) ;]]>
</programlisting>
</example>
</sect2>
<sect2 id="funcs.smoc">
<title>
<type>smoc</type> functions
</title>
<funcsynopsis>
<funcprototype>
<funcdef><function>smoc_info</function></funcdef>
<paramdef>smoc</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Returns information about the internal representation of the smoc.
</para>
<example>
<title>A circle</title>
<programlisting>
<![CDATA[sql> SELECT smoc_info('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');]]>
<![CDATA[ smoc_info]]>
<![CDATA[--------------------------------------------------------------------------------------------------------------------------------]]>
<![CDATA[ version: 0, order: 2, depth: 1, first: 0, last: 3458764513820540928, area: 1261007895663738880, tree_begin: 48, data_begin: 72]]>
</programlisting>
</example>
<funcsynopsis>
<funcprototype>
<funcdef><function>smoc_degrade</function></funcdef>
<paramdef><parameter>order</parameter> int</paramdef>
<paramdef>smoc</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Adjusts the order of an smoc to be more or less precise.
</para>
<para>
When order is smaller than smoc's maximal order, the MOC resolution
is degraded to the new order, and its maximal order is set to that
order. When order is larger than the smoc's maximal order, smoc's
shape is not modified, but its maximal order is raised to order.
</para>
<funcsynopsis>
<funcprototype>
<funcdef><function>sum</function></funcdef>
<paramdef>smoc</paramdef>
</funcprototype>
<funcprototype>
<funcdef><function>intersection</function></funcdef>
<paramdef>smoc</paramdef>
</funcprototype>
</funcsynopsis>
<para>
<type>smoc</type> union and intersection are available as aggregate functions
that compute the aggretated coverage over a given column.
</para>
<example>
<title>Computing the overall coverage of a catalog</title>
<programlisting>
<![CDATA[SELECT sum(coverage) FROM ivoa;]]>
<![CDATA[ sum]]>
<![CDATA[-----------]]>
<![CDATA[ 0/0-11 6/]]>
</programlisting>
</example>
<funcsynopsis>
<funcprototype>
<funcdef><function>max_order</function></funcdef>
<paramdef>smoc</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Returns the maximal order of an smoc.
</para>
<para>
The maximal order of a MOC can be higher than than the highest
order appearing in the serialisation. For instance, in the example
below the full-sky coverage given at order 6 means that no patch
larger than about 1 degree is not covered. In the ASCII
serialisation, give the maximum order with an with an empty cell
list.
</para>
<example>
<title>Obtaining a MOC order</title>
<programlisting>
<![CDATA[SELECT max_order(smoc('0/0-11 6/')) as order;]]>
<![CDATA[ order]]>
<![CDATA[-----------]]>
<![CDATA[ 6 ]]>
</programlisting>
</example>
</sect2>
<sect2 id="funcs.epochprop">
<title>
Epoch propagation
</title>
<sect3 id="funcs.epochprop.full">
<title>6-Parameter Epoch Propagation</title>
<funcsynopsis>
<funcprototype>
<funcdef><type>double precision[6]</type>
<function>epoch_prop</function></funcdef>
<paramdef>spoint <parameter>pos</parameter></paramdef>
<paramdef>double precision <parameter>parallax</parameter></paramdef>
<paramdef>double precision <parameter>pm_long</parameter></paramdef>
<paramdef>double precision <parameter>pm_lat</parameter></paramdef>
<paramdef>double precision <parameter>radial_velocity</parameter></paramdef>
<paramdef>double precision <parameter>delta_t</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Propagates a spherical phase vector in time (in particular,
applies proper motion to positions)
</para>
<para>
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
(Julian) years.
</para>
<para>
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
pm_lat are in rad/yr, parallax is in mas, and radial_velocity is
in km/s. If you are only interested in the position, consider
the epoch_prop_pos functions below that have a somewhat less
contorted signature.
</para>
<para>
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.
</para>
<para>
This uses the rigorous method derived in "The Hipparcos and Tycho
Catalogues", ESA Special Publication 1200 (1997), p 94f. It does
not take into account relativistic effects, and it also does not
account for secular aberration.
</para>
<example>
<title>Propagating Barnard's star into the past</title>
<programlisting><![CDATA[
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
]]></programlisting>
</example>
</sect3>
<sect3>
<title>Epoch Propagation of Positions Only</title>
<funcsynopsis>
<funcprototype>
<funcdef><type>spoint</type>
<function>epoch_prop_pos</function></funcdef>
<paramdef>spoint <parameter>pos</parameter></paramdef>
<paramdef>double precision <parameter>parallax</parameter></paramdef>
<paramdef>double precision <parameter>pm_long</parameter></paramdef>
<paramdef>double precision <parameter>pm_lat</parameter></paramdef>
<paramdef>double precision <parameter>radial_velocity</parameter></paramdef>
<paramdef>double precision <parameter>delta_t</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<funcsynopsis>
<funcprototype>
<funcdef><type>spoint</type>
<function>epoch_prop_pos</function></funcdef>
<paramdef>spoint <parameter>pos</parameter></paramdef>
<paramdef>double precision <parameter>pm_long</parameter></paramdef>
<paramdef>double precision <parameter>pm_lat</parameter></paramdef>
<paramdef>double precision <parameter>delta_t</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
These are simplified versions of epoch_prop returning only spoints;
the propagated values for the other coordinates are discarded
(but still internallay computed; these functions do not
run any faster than epoch_prop itself).
</para>
<para>
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).
</para>
<example>
<title>Barnard's star, position and proper motion</title>
<programlisting><![CDATA[
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)
]]></programlisting>
</example>
</sect3>
</sect2>
</sect1>