]> pd.if.org Git - isea/blob - isea.h
Initial checkin.
[isea] / isea.h
1 #ifndef ISEA_H_
2 #define ISEA_H_ 1
3
4 #include "hex.h"
5
6 enum isea_poly { ISEA_NONE, ISEA_ICOSAHEDRON = 20 };
7 enum isea_topology { ISEA_HEXAGON=6, ISEA_TRIANGLE=3, ISEA_DIAMOND=4 };
8 enum isea_address_form { ISEA_GEO, ISEA_Q2DI, ISEA_SEQNUM, ISEA_INTERLEAVE,
9         ISEA_PLANE, ISEA_Q2DD, ISEA_PROJTRI, ISEA_VERTEX2DD, ISEA_HEX
10 };
11
12 /* TODO calculate this */
13 #define ISEA_SCALE 0.8301572857837594396028083
14
15 struct isea_dgg {
16         int     polyhedron; /* ignored, icosahedron */
17         double  o_lat, o_lon, o_az; /* orientation, radians */
18         int     pole; /* true if standard snyder */
19         int     topology; /* ignored, hexagon */
20         int     aperture; /* valid values depend on partitioning method */
21         int     resolution;
22         double  radius; /* radius of the earth in meters, ignored 1.0 */
23         int     output; /* an isea_address_form */
24         int     triangle; /* triangle of last transformed point */
25         int     quad; /* quad of last transformed point */
26         unsigned long serial;
27 };
28
29 struct isea_pt {
30         double x, y;
31 };
32
33 struct isea_geo {
34         double lon, lat;
35 };
36
37 extern struct isea_dgg isea_standard_dgg;
38
39 struct isea_address {
40         int     type; /* enum isea_address_form */
41         int     number;
42         double  x,y; /* or i,j or lon,lat depending on type */
43 };
44
45 #if 0
46 struct isea_address {
47         unsigned        validity; /* which are good */
48         struct coord geo;
49         struct point plane;
50         unsigned long seqnum;
51         unsigned quad;
52         unsigned triangle;
53         struct point quad_xy;
54         struct point quad_ij;
55         struct point triangle_xy;
56         unsigned vertex;
57 };
58 #endif
59
60 /* set the orientation */
61 int isea_orient(struct isea_dgg *dgg, double lon, double lat, double az);
62 int isea_orient_isea(struct isea_dgg *d);
63 int isea_orient_pole(struct isea_dgg *d);
64 int isea_orient_dymax(struct isea_dgg *d);
65
66 /* set a clip region */
67 int isea_region(struct isea_dgg *dgg, double lon, double lat);
68
69 /* ensure validity */
70 int isea_valid(struct isea_dgg *dgg);
71
72 /* set the resolution by picking the nearest area */
73 int isea_resolution_area(struct isea_dgg *dgg, double area);
74
75 /* the characteristic length scale */
76 double isea_cell_cls(struct isea_dgg *dgg);
77
78 /* intercell distance as projected */
79 double isea_cell_width(struct isea_dgg *dgg);
80
81 double isea_cell_area(struct isea_dgg *dgg);
82
83 /* total number of cells */
84 double isea_cell_count(struct isea_dgg *dgg);
85
86 /* set the resolution by picking the nearest intercell distance */
87 int isea_resolution_distance(struct isea_dgg *dgg, double distance);
88
89 /* grid size in cells */
90 int isea_grid_size(struct isea_dgg *dgg);
91
92 int isea_grid_init(struct isea_dgg *d);
93
94 /* const? */
95 struct isea_dgg *isea_grid_standard(void);
96
97 /* coordinate projection */
98
99 /* returns triangle, out may be null */
100 int isea_transform(struct isea_dgg *dgg, struct isea_geo *in,
101                 struct isea_pt *out);
102
103 struct isea_pt isea_forward(struct isea_dgg *g, struct isea_geo *in);
104
105 /* returns seqnum */
106 int isea_readdress(struct isea_dgg *dgg, int input, struct isea_pt *in,
107                 int output, struct isea_pt *out);
108
109 struct isea_pt isea_triangle_xy(int triangle);
110 int isea_xy_triangle(struct isea_pt *p, double radius);
111
112 /* grid changes */
113 /*
114  * the idea is that if you have a cartesian coordinate, and just want
115  * to change the resolution, it's just a re-bin, not a new
116  * projection.
117  */
118 int isea_tranform_grid(void);
119
120 /* grid generation */
121
122 /* address conversion */
123 void isea_rotate(struct isea_pt *pt, double degrees);
124 int isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di);
125 int isea_ptdd(int triangle, struct isea_pt *pt);
126 int isea_ptdi(struct isea_dgg *g, int tri, struct isea_pt *pt, struct isea_pt *di);
127 int isea_hex(struct isea_dgg *g, int tri, struct isea_pt *pt, struct isea_pt *di);
128 int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *h);
129
130 /* binning point values */
131
132 /* presence/absence binning */
133 int isea_snyder_forward(struct isea_geo *ll, struct isea_pt *out);
134
135 #endif