H3C HEALPix library for PostgreSQL  (version 1.2)
common.h
Go to the documentation of this file.
1 
7 #include <math.h>
8 #include <stdlib.h>
9 #include "postgres.h"
10 #ifndef H3C_COMMON_H
11 #define H3C_COMMON_H
12 
13 #if 1
14 /* If You have not specified the H3C_INT4 then use long */
15 #ifndef H3C_INT4
16 
17 #ifndef H3C_INT8
18 
19 #ifndef h3c_ipix_t
20 typedef long h3c_ipix_t;
21 
22 #endif
23 
24 #else
25 
26 #ifndef h3c_ipix_t
27 /*#define h3c_ipix_t long long
28  typedef long long h3c_ipix_t ;*/
29 typedef int64 h3c_ipix_t ;
30 #endif /* h3c_ipix_t */
31 
32 #endif /* H3C_INT8 */
33 
34 #else
35 
36 #ifndef h3c_ipix_t
37 /*#define h3c_ipix_t long int
38  typedef unsigned long int h3c_ipix_t;*/
39 typedef uint32 h3c_ipix_t;
40 #endif /* h3c_ipix_t */
41 
42 
43 #endif /* H3C_INT4 */
44 
45 #else
46 /* Currently Helpix lib deals only with long
47  * Use Healpix_Base2 for int64 but it misses class members query_disc...
48  */
49 typedef long h3c_ipix_t;
50 #endif
51 
52 
53 #ifndef H3C_LONG_DOUBLE
54 typedef double h3c_coord_t;
55 #define H3C_HALF 0.5
56 #define H3C_PI 3.1415926535897932384626433832795028841968
57 #define H3C_2PI 6.2831853071795864769252867665590057683936
58 #define H3C_INV_2PI 0.1591549430918953357688837633725143620345
59 #define H3C_PI_2 1.5707963267948966192313216916397514420984
60 #define H3C_DEGRA 0.0174532925199432957692369076848861271344
61 #define H3C_RADEG 57.2957795130823208767981548141051703324122
62 #define H3C_LG2 0.6931471805599453094172321214581765680755
63 
64 #else /* H3C_LONG_DOUBLE */
65 typedef long double h3c_coord_t;
66 #define H3C_HALF 0.5L
67 #define H3C_PI 3.1415926535897932384626433832795028841968L
68 #define H3C_2PI 6.2831853071795864769252867665590057683936L
69 #define H3C_INV_2PI 0.1591549430918953357688837633725143620345L
70 #define H3C_PI_2 1.5707963267948966192313216916397514420984L
71 #define H3C_DEGRA 0.0174532925199432957692369076848861271344L
72 #define H3C_RADEG 57.2957795130823208767981548141051703324122L
73 #define H3C_LG2 0.6931471805599453094172321214581765680755L
74 
75 #endif /* H3C_LONG_DOUBLE */
76 
77 #define H3C_DISJUNCT 0 /* disjunct areas */
78 
79 #define H3C_MAX_N_POLY_VERTEX 100 /* Maximal number of vertices in the polygon */
80 
81 typedef struct
82 {
83  int n;
84  h3c_coord_t *ra; /* array of RAs of vertices */
85  h3c_coord_t *dec; /* array of DECs of vertices */
86  h3c_coord_t *x; /* array of X coords on the cube face of vertices */
87  h3c_coord_t *y; /* array of Y coords on the cube face of vertices */
88  h3c_coord_t *ax; /* array of x projections of the edge between vertices */
89  h3c_coord_t *ay; /* array of y projections of the edge between vertices */
90 } h3c_poly;
91 
92 
93 #ifdef __cplusplus
94 extern "C" {
95 #endif
96  int h3c_check_sphere_point_in_poly(/*struct h3c_prm *hprm,*/ int n,
97  h3c_coord_t in_ra[], h3c_coord_t in_dec[],
98  h3c_coord_t ra0, h3c_coord_t dec0);
100  h3c_coord_t in_ra[], h3c_coord_t in_dec[],
101  h3c_coord_t ra0, h3c_coord_t dec0);
102  void h3c_poly_center(int, h3c_coord_t *, h3c_coord_t *, h3c_coord_t *);
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif
h3c_check_sphere_point_in_poly_convex
int h3c_check_sphere_point_in_poly_convex(int n, h3c_coord_t *in_ra, h3c_coord_t *in_dec, h3c_coord_t ra0, h3c_coord_t dec0)
verify if a point is inside a convex polygon
Definition: h3c_poly_more.c:185
h3c_poly_center
void h3c_poly_center(int, h3c_coord_t *, h3c_coord_t *, h3c_coord_t *)
get the polgon center
Definition: h3c_poly_more.c:86