/* * options * * orientation * -l longitude * -z azimuth * -p latitude * * -I isea standard orientation * -D dymaxion orientation * -P vertex at pole * * -a aperture * -r resolution * -t h t d hex tri diamond * * addressing * -O q2dd seqnum interleave plane q2dd projtri vertex2dd * -I * * operation * -g generate grid * -x transform * -b bin point values (average) * -e bin point presence * -G spacing resolution generate graticule */ #if 0 void usage(void) { fprintf(stderr, "%s", "isea [-l ] [-z ] [-p ] [-I] [-D] [-P] [-a ] [-r ] [-t ] [-A ] [-g] [-b] [-e] [-x]\n"); } void die(char *s) { fprintf(stderr, "%s\n", s); exit(EXIT_FAILURE); } static int verbose = 0; static int precision = 10; void options(int ac, char **av, struct isea_dgg *g) { int i = 1; char *optarg; for (i=1;iradius = strtod(av[++i],NULL); break; case 'l': g->o_lon = strtod(av[++i],NULL); break; case 'p': g->o_lat = strtod(av[++i],NULL); break; case 'z': g->o_az = strtod(av[++i],NULL); break; case 'd': precision = atoi(av[++i]); break; case 'a': g->aperture = atoi(av[++i]); break; case 'r': g->resolution = atoi(av[++i]); break; case 't': switch (av[++i][0]) { case 'h': g->topology = ISEA_HEXAGON; break; case 't': g->topology = ISEA_TRIANGLE; break; case 'd': g->topology = ISEA_DIAMOND; break; default: usage(); die("Invalid topology"); break; }; break; case 'O': if (av[i][2]) { optarg = &av[i][2]; } else { optarg = av[++i]; } if (!strcmp(optarg, "projtri")) { g->output = ISEA_PROJTRI; } else if (!strcmp(optarg, "vertex2dd")) { g->output = ISEA_VERTEX2DD; } else if (!strcmp(optarg, "q2dd")) { g->output = ISEA_Q2DD; } else if (!strcmp(optarg, "q2di")) { g->output = ISEA_Q2DI; } else if (!strcmp(optarg, "seqnum")) { g->output = ISEA_SEQNUM; } else if (!strcmp(optarg, "plane")) { g->output = ISEA_PLANE; } else { fprintf(stderr, "unknown output format: %s\n",optarg); die("exiting"); } break; default: usage(); die("Unknown option"); } } } #endif #define PROJ_PARMS__ \ struct isea_dgg dgg; #define PJ_LIB__ #include PROJ_HEAD(isea, "Icosahedral Snyder Equal Area") "\n\tSph"; FORWARD(s_forward); struct isea_pt out; struct isea_geo in; in.lon = lp.lam; in.lat = lp.phi; out = isea_forward(&P->dgg, &in); xy.x = out.x; xy.y = out.y; return xy; } FREEUP; if (P) pj_dalloc(P); } ENTRY0(isea) char *opt; P->fwd = s_forward; isea_grid_init(&P->dgg); P->dgg.output = ISEA_PLANE; /* P->dgg.radius = P->a; /* otherwise defaults to 1 */ /* calling library will scale, I think */ opt = pj_param(P->params, "sorient").s; if (opt) { if (!strcmp(opt, "isea")) { isea_orient_isea(&P->dgg); } else if (!strcmp(opt, "pole")) { isea_orient_pole(&P->dgg); } else { E_ERROR(-34); } } if (pj_param(P->params, "tazi").i) { P->dgg.o_az = pj_param(P->params, "razi").f; } if (pj_param(P->params, "tlon_0").i) { P->dgg.o_lon = pj_param(P->params, "rlon_0").f; } if (pj_param(P->params, "tlat_0").i) { P->dgg.o_lat = pj_param(P->params, "rlat_0").f; } if (pj_param(P->params, "taperture").i) { P->dgg.aperture = pj_param(P->params, "iaperture").i; } if (pj_param(P->params, "tresolution").i) { P->dgg.resolution = pj_param(P->params, "iresolution").i; } opt = pj_param(P->params, "smode").s; if (opt) { if (!strcmp(opt, "plane")) { P->dgg.output = ISEA_PLANE; } else if (!strcmp(opt, "di")) { P->dgg.output = ISEA_Q2DI; } else if (!strcmp(opt, "dd")) { P->dgg.output = ISEA_Q2DD; } else if (!strcmp(opt, "hex")) { P->dgg.output = ISEA_HEX; } else { E_ERROR(-34); } } if (pj_param(P->params, "trescale").i) { P->dgg.radius = ISEA_SCALE; } if (pj_param(P->params, "tresolution").i) { P->dgg.resolution = pj_param(P->params, "iresolution").i; } else { P->dgg.resolution = 4; } if (pj_param(P->params, "taperture").i) { P->dgg.aperture = pj_param(P->params, "iaperture").i; } else { P->dgg.aperture = 3; } ENDENTRY(P) #if 0 int main(int ac, char *av[]) { struct isea_dgg dgg; struct isea_geo in; struct isea_pt out, coord; int tri,calctri; int graticule = 0; int quad = 0; char line[1024]; char *rest, *nl; isea_grid_init(&dgg); dgg.output = ISEA_PLANE; dgg.radius = ISEA_SCALE; /* 0.8301572857837594396028083; */ options(ac, av, &dgg); if (0) { printf("isea lat = %lf, lon = %lf, az = %lf\n", dgg.o_lat * 180.0 / M_PI, dgg.o_lon * 180.0 / M_PI, dgg.o_az * 180.0 / M_PI); } while (fgets(line, sizeof line, stdin)) { line[sizeof line-1] = 0; if (line[0] == '#') { continue; } if (!strncmp(line, "ENDPOLY", 7)) { printf("%s", line); continue; } in.lon = strtod(line, &rest); in.lat = strtod(rest, &rest); nl = strchr(rest, '\n'); if (nl) *nl = 0; in.lon *= M_PI / 180.0; in.lat *= M_PI / 180.0; out = isea_forward(&dgg, &in); tri = dgg.triangle; quad = ((tri - 1) % 5) + ((tri - 1) / 10) * 5 + 1; coord = out; if (dgg.output == ISEA_PLANE) { calctri = isea_xy_triangle(&coord, dgg.output == ISEA_PLANE ? dgg.radius : 1.0); if (tri != calctri) { fprintf(stderr, "got %d (%f, %f), expected %d\n", calctri, out.x, out.y, tri); } } in.lon *= 180.0 / M_PI; in.lat *= 180.0 / M_PI; switch (dgg.output) { case ISEA_PLANE: printf("%d %.*f %.*f%s\n", tri, precision, out.x, precision, out.y, rest); break; case ISEA_PROJTRI: printf("%d %.*f %.*f%s\n", tri-1, precision, out.x, precision, out.y, rest); break; case ISEA_VERTEX2DD: printf("%d %d %.*f %.*f%s\n", quad, tri-1, precision, out.x, precision, out.y, rest); break; case ISEA_Q2DD: /* Same as above, we just don't print as much */ printf("%d %.*f %.*f%s\n", quad, precision, out.x, precision, out.y, rest); break; case ISEA_Q2DI: printf("%d %.0lf %.0lf%s\n", dgg.quad, coord.x, coord.y, rest); break; case ISEA_SEQNUM: quad = isea_ptdi(&dgg, tri, &out, &coord); printf("%d%s\n", isea_disn(&dgg, quad, &coord), rest); break; } fflush(stdout); } if (graticule) { } exit(EXIT_SUCCESS); } #endif