#ifndef ISEA_H_ #define ISEA_H_ 1 #include "hex.h" enum isea_poly { ISEA_NONE, ISEA_ICOSAHEDRON = 20 }; enum isea_topology { ISEA_HEXAGON=6, ISEA_TRIANGLE=3, ISEA_DIAMOND=4 }; enum isea_address_form { ISEA_GEO, ISEA_Q2DI, ISEA_SEQNUM, ISEA_INTERLEAVE, ISEA_PLANE, ISEA_Q2DD, ISEA_PROJTRI, ISEA_VERTEX2DD, ISEA_HEX }; /* TODO calculate this */ #define ISEA_SCALE 0.8301572857837594396028083 struct isea_dgg { int polyhedron; /* ignored, icosahedron */ double o_lat, o_lon, o_az; /* orientation, radians */ int pole; /* true if standard snyder */ int topology; /* ignored, hexagon */ int aperture; /* valid values depend on partitioning method */ int resolution; double radius; /* radius of the earth in meters, ignored 1.0 */ int output; /* an isea_address_form */ int triangle; /* triangle of last transformed point */ int quad; /* quad of last transformed point */ unsigned long serial; }; struct isea_pt { double x, y; }; struct isea_geo { double lon, lat; }; extern struct isea_dgg isea_standard_dgg; struct isea_address { int type; /* enum isea_address_form */ int number; double x,y; /* or i,j or lon,lat depending on type */ }; #if 0 struct isea_address { unsigned validity; /* which are good */ struct coord geo; struct point plane; unsigned long seqnum; unsigned quad; unsigned triangle; struct point quad_xy; struct point quad_ij; struct point triangle_xy; unsigned vertex; }; #endif /* set the orientation */ int isea_orient(struct isea_dgg *dgg, double lon, double lat, double az); int isea_orient_isea(struct isea_dgg *d); int isea_orient_pole(struct isea_dgg *d); int isea_orient_dymax(struct isea_dgg *d); /* set a clip region */ int isea_region(struct isea_dgg *dgg, double lon, double lat); /* ensure validity */ int isea_valid(struct isea_dgg *dgg); /* set the resolution by picking the nearest area */ int isea_resolution_area(struct isea_dgg *dgg, double area); /* the characteristic length scale */ double isea_cell_cls(struct isea_dgg *dgg); /* intercell distance as projected */ double isea_cell_width(struct isea_dgg *dgg); double isea_cell_area(struct isea_dgg *dgg); /* total number of cells */ double isea_cell_count(struct isea_dgg *dgg); /* set the resolution by picking the nearest intercell distance */ int isea_resolution_distance(struct isea_dgg *dgg, double distance); /* grid size in cells */ int isea_grid_size(struct isea_dgg *dgg); int isea_grid_init(struct isea_dgg *d); /* const? */ struct isea_dgg *isea_grid_standard(void); /* coordinate projection */ /* returns triangle, out may be null */ int isea_transform(struct isea_dgg *dgg, struct isea_geo *in, struct isea_pt *out); struct isea_pt isea_forward(struct isea_dgg *g, struct isea_geo *in); /* returns seqnum */ int isea_readdress(struct isea_dgg *dgg, int input, struct isea_pt *in, int output, struct isea_pt *out); struct isea_pt isea_triangle_xy(int triangle); int isea_xy_triangle(struct isea_pt *p, double radius); /* grid changes */ /* * the idea is that if you have a cartesian coordinate, and just want * to change the resolution, it's just a re-bin, not a new * projection. */ int isea_tranform_grid(void); /* grid generation */ /* address conversion */ void isea_rotate(struct isea_pt *pt, double degrees); int isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di); int isea_ptdd(int triangle, struct isea_pt *pt); int isea_ptdi(struct isea_dgg *g, int tri, struct isea_pt *pt, struct isea_pt *di); int isea_hex(struct isea_dgg *g, int tri, struct isea_pt *pt, struct isea_pt *di); int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *h); /* binning point values */ /* presence/absence binning */ int isea_snyder_forward(struct isea_geo *ll, struct isea_pt *out); #endif