1 /* 2 # This file is part of the Astrometry.net suite. 3 # Licensed under a 3-clause BSD style license - see LICENSE 4 */ 5 6 #ifndef CODE_KD_H 7 #define CODE_KD_H 8 9 #include "astrometry/kdtree.h" 10 #include "astrometry/qfits_header.h" 11 #include "astrometry/anqfits.h" 12 13 #define AN_FILETYPE_CODETREE "CKDT" 14 15 #define CODETREE_NAME "codes" 16 17 typedef struct { 18 kdtree_t* tree; 19 qfits_header* header; 20 int* inverse_perm; 21 } codetree_t; 22 23 codetree_t* codetree_open(const char* fn); 24 25 codetree_t* codetree_open_fits(anqfits_t* fits); 26 27 int codetree_get(codetree_t* s, unsigned int codeid, double* code); 28 29 int codetree_N(codetree_t* s); 30 31 int codetree_nodes(codetree_t* s); 32 33 int codetree_D(codetree_t* s); 34 35 int codetree_get_permuted(codetree_t* s, int index); 36 37 qfits_header* codetree_header(codetree_t* s); 38 39 int codetree_close(codetree_t* s); 40 41 // for writing 42 codetree_t* codetree_new(void); 43 44 int codetree_append_to(codetree_t* s, FILE* fid); 45 46 int codetree_write_to_file(codetree_t* s, const char* fn); 47 48 int codetree_write_to_file_flipped(codetree_t* s, const char* fn); 49 50 #endif 51