]> pd.if.org Git - isea/blob - t/plane.c
Initial checkin.
[isea] / t / plane.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <math.h>
5
6 #include "tap.h"
7 #include "isea.h"
8
9 #include "testing.h"
10
11 void iso(struct hex *h) {
12         hex_iso(h);
13         printf("iso(%d,%d,%d)", h->x, h->y, h->z);
14 }
15 void xy(struct hex *h) {
16         hex_xy(h);
17         printf("xy(%d,%d)", h->x, h->y);
18 }
19
20 #include "hexes2.pt"
21 #include "hexes2.dgg"
22
23 int main(void) {
24         int i, j;
25
26         char isea[64], sahr[64];
27         struct isea_dgg g;
28         struct isea_pt xy;
29         struct isea_geo ll;
30
31         isea_grid_init(&g);
32         g.output = ISEA_PLANE;
33         g.radius = ISEA_SCALE;
34
35         i=0;
36         while (input[i].data) i++;
37
38         plan_tests(i * 2);
39
40         for (j=0; j<i; j++) {
41                 skip(2, "don't have known output");
42                 continue;
43                 /* convert to radians */
44                 ll.lon = input[j].a * M_PI / 180.0;
45                 ll.lat = input[j].b * M_PI / 180.0;
46                 xy = isea_forward(&g, &ll);
47                 sprintf(isea, "%.7f", xy.x);
48                 sprintf(sahr, "%.7f", dgg[j].a);
49                 ok(!strcmp(isea,sahr), "plane X (%f, %f %s) %s != %s / %s",
50                                 input[j].a, input[j].b, input[j].data,
51                                 isea, sahr,
52                                 xy.x, dgg[j].a, dgg[j].data);
53                 sprintf(isea, "%.7f", xy.y);
54                 sprintf(sahr, "%.7f", dgg[j].b);
55                 ok(!strcmp(isea,sahr), "plane Y (%f, %f %s) %f != %f",
56                                 input[j].a, input[j].b, input[j].data,
57                                 xy.y, dgg[j].b);
58         }
59
60         return exit_status();
61
62 }