34 #ifndef _POSIX_C_SOURCE
35 #define _POSIX_C_SOURCE 200112L
39 #define _XOPEN_SOURCE 500
45 #include <sys/types.h>
46 #include <sys/socket.h>
48 #include <netinet/in.h>
62 #include "casu_mods.h"
63 #include "catalogue/casu_utils.h"
64 #include "catalogue/casu_wcsutils.h"
66 #define CACHEDIR ".catcache"
67 #define CACHEIND ".catcache/index"
70 #define CDS "cdsarc.u-strasbg.fr"
74 static cpl_table *casu_2mass_extract(
char *path,
float ramin,
float ramax,
75 float decmin,
float decmax);
76 static cpl_table *casu_ppmxl_extract(
char *path,
float ramin1,
float ramax1,
77 float decmin,
float decmax);
78 static cpl_table *casu_apass_extract(
char *path,
float ramin1,
float ramax1,
79 float decmin,
float decmax);
80 static cpl_table *casu_local_extract(
char *path,
float ramin1,
float ramax1,
81 float decmin,
float decmax);
82 static cpl_table *check_cache(
char *catname,
float ra1_im,
float ra2_im,
83 float dec1_im,
float dec2_im,
char *cacheloc);
84 static void addto_cache(cpl_table *stds,
char *catname,
float ramin,
85 float ramax,
float decmin,
float decmax,
87 static char *form_request(
float ra,
float dec,
float dra,
float ddec,
88 float equinox,
const char *catid);
89 static char *url_encode(
char *instring);
90 static int connect_site(
const char *site,
int *sock);
91 static int send_request(
int sock,
char *req_string,
int isbin);
92 static int get_response(
int soc, cpl_table **outtab);
159 extern int casu_getstds(cpl_propertylist *plist,
int cache,
char *path,
160 char *catname,
int cdssearch,
char *cacheloc,
161 cpl_table **stds,
int *status) {
162 const char *fctid =
"casu_getstds";
163 double xx1,xx2,yy1,yy2,r,d,xx,yy,*rad,*decd,dra,ddec;
164 float ramin,ramax,decmin,decmax,*ra,*dec,*x,*y,ramid,decmid;
168 char *req_string,catname2[64],*cdscatname,*cdscatid,*path2;
169 int isbin = (cdssearch > 6 ? 1 : 0);
174 if (*status != CASU_OK)
187 ddec = decmax - decmin;
188 ramid = 0.5*(ramax+ramin);
189 decmid = 0.5*(decmax+decmin);
191 cpl_msg_info(fctid,
"Searching catalogue %d, RA/Dec range [%f:%f, %f:%f]", cdssearch, ramin, ramax, decmin, decmax);
197 if (casu_getstds_cdslist(cdssearch,&cdscatname,&cdscatid,status) !=
200 (void)strcpy(catname2,cdscatname);
201 freespace(cdscatname);
203 (void)strcpy(catname2,catname);
207 *stds = check_cache(catname2,ramin,ramax,decmin,decmax,cacheloc);
216 if (cdssearch == 0) {
217 cpl_msg_info(fctid,
"Reading local catalogue");
219 path2 = cpl_strdup(path);
220 if (! strcmp(catname2,
"casu_2mass")) {
221 *stds = casu_2mass_extract(dirname(path2),ramin,ramax,decmin,
223 }
else if (! strcmp(catname2,
"casu_ppmxl")) {
224 *stds = casu_ppmxl_extract(dirname(path2),ramin,ramax,decmin,
226 }
else if (! strcmp(catname2,
"casu_apass")) {
227 *stds = casu_apass_extract(dirname(path2),ramin,ramax,decmin,
230 *stds = casu_local_extract(path2,ramin,ramax,decmin,decmax);
234 cpl_msg_error(fctid,
"Unable to extract data in %s",path);
241 cpl_msg_info(fctid,
"Requesting catalogue data from CDS");
243 req_string = form_request(ramid,decmid,dra,ddec,2000.0,
249 if (connect_site(CDS,&sock) != CASU_OK) {
250 cpl_msg_warning(fctid,
"Couldn't connect to CDS");
256 if (send_request(sock,req_string,isbin) != CASU_OK) {
257 cpl_msg_warning(fctid,
"Couldn't send request to site CDS");
264 if (get_response(sock,stds) != CASU_OK) {
265 cpl_msg_warning(fctid,
"Error receiving info from site CDS");
275 cpl_table_name_column(*stds,
"RAJ2000",
"RA");
276 cpl_table_name_column(*stds,
"DEJ2000",
"Dec");
282 addto_cache(*stds,catname2,ramin,ramax,decmin,decmax,cacheloc);
287 n = (int)cpl_table_get_nrow(*stds);
288 cpl_msg_info(fctid,
"Found %d stars in catalogue", n);
295 cpl_table_new_column(*stds,
"xpredict",CPL_TYPE_FLOAT);
296 cpl_table_new_column(*stds,
"ypredict",CPL_TYPE_FLOAT);
302 wcs = cpl_wcs_new_from_propertylist((
const cpl_propertylist *)plist);
303 if (cpl_table_get_column_type(*stds,
"RA") == CPL_TYPE_FLOAT) {
304 ra = cpl_table_get_data_float(*stds,
"RA");
305 dec = cpl_table_get_data_float(*stds,
"Dec");
306 x = cpl_malloc(n*
sizeof(*x));
307 y = cpl_malloc(n*
sizeof(*y));
308 for (i = 0; i < n; i++) {
316 rad = cpl_table_get_data_double(*stds,
"RA");
317 decd = cpl_table_get_data_double(*stds,
"Dec");
318 x = cpl_malloc(n*
sizeof(*x));
319 y = cpl_malloc(n*
sizeof(*y));
320 for (i = 0; i < n; i++) {
332 cpl_table_wrap_float(*stds,x,
"xpredict");
333 cpl_table_set_column_unit(*stds,
"xpredict",
"pixels");
334 cpl_table_wrap_float(*stds,y,
"ypredict");
335 cpl_table_set_column_unit(*stds,
"ypredict",
"pixels");
339 p = cpl_propertylist_new();
340 cpl_propertylist_append_bool(p,
"ypredict",0);
341 cpl_table_sort(*stds,p);
342 cpl_propertylist_delete(p);
389 static const int maxcds = 7;
390 static const char *cdscatnames[8] =
391 {
"",
"2mass",
"usnob",
"ppmxl",
"landolt",
"wise",
"apass",
"gaiaedr3"};
392 static const char *cdscats[8] =
393 {
"",
"II/246",
"I/284",
"I/317",
"II/183A",
"II/311",
"II/336",
"I/350"};
395 extern int casu_getstds_cdslist(
int cdschoice,
char **cdscatname,
396 char **cdscatid,
int *status) {
397 const char *fctid =
"casu_getstds_cdslist";
399 if (*status != CASU_OK)
406 if (cdschoice < 0 || cdschoice > maxcds) {
407 cpl_msg_error(fctid,
"CDS catalogue choice must be >= 0 && <= %d",
411 *cdscatname = cpl_strdup(cdscatnames[cdschoice]);
412 *cdscatid = cpl_strdup(cdscats[cdschoice]);
446 for (
int i=1; i<=maxcds; i++) {
447 if (!strcmp(cdscatname, cdscatnames[i])) {
485 static cpl_table *casu_2mass_extract(
char *path,
float ramin1,
float ramax1,
486 float decmin,
float decmax) {
488 int i,nrows,start,finish,first_index,last_index,irow,init,j;
489 int first_index_ra,last_index_ra,wrap,iwrap;
490 float dectest,ratest,ramin,ramax;
491 char fullname[SZBUF];
493 const char *deccol =
"Dec";
498 o = cpl_table_new(0);
503 a = cpl_array_wrap_string((
char **)&deccol,1);
507 wrap = (ramin1 < 0.0 && ramax1 > 0.0) ? 2 : 1;
512 for (iwrap = 0; iwrap < wrap; iwrap++) {
515 ramin = ramin1 + 360.0;
528 first_index_ra = (int)ramin;
529 last_index_ra = min((
int)ramax,359);
534 for (i = first_index_ra; i <= last_index_ra; i++) {
539 (void)snprintf(fullname,SZBUF,
"%s/npsc%03d.fits",path,i);
544 p = cpl_propertylist_load(fullname,1);
550 nrows = cpl_propertylist_get_int(p,
"NAXIS2");
551 cpl_propertylist_delete(p);
558 first_index = nrows/2;
559 while (finish - start >= 2) {
560 t = cpl_table_load_window(fullname,1,1,a,(cpl_size)first_index,
562 dectest = cpl_table_get_double(t,
"Dec",0,NULL);
564 if (dectest < decmin) {
566 first_index = (first_index + finish)/2;
568 finish = first_index;
569 first_index = (first_index + start)/2;
578 last_index = start + (finish - start)/2;
579 while (finish - start >= 2) {
580 t = cpl_table_load_window(fullname,1,1,a,(cpl_size)last_index,
582 dectest = cpl_table_get_double(t,
"Dec",0,NULL);
584 if (dectest < decmax) {
586 last_index = (last_index + finish)/2;
589 last_index = (last_index + start)/2;
592 if (last_index < first_index)
593 last_index = first_index;
597 nrows = last_index - first_index + 1;
598 if ((t = cpl_table_load_window(fullname,1,1,NULL,
599 (cpl_size)first_index,
600 (cpl_size)nrows)) == NULL) {
605 cpl_table_unselect_all(t);
611 for (j = 0; j < nrows; j++) {
612 ratest = cpl_table_get_double(t,
"RA",(cpl_size)j,NULL);
613 if (cpl_error_get_code() != CPL_ERROR_NONE) {
619 if (ratest >= ramin && ratest <= ramax)
620 cpl_table_select_row(t,(cpl_size)j);
626 s = cpl_table_extract_selected(t);
628 cpl_table_copy_structure(o,t);
631 irow = (int)cpl_table_get_nrow(o) + 1;
632 cpl_table_insert(o,s,(cpl_size)irow);
677 static cpl_table *casu_ppmxl_extract(
char *path,
float ramin1,
float ramax1,
678 float decmin,
float decmax) {
680 int i,nrows,start,finish,first_index,last_index,irow,init,j;
681 int first_index_ra,last_index_ra,wrap,iwrap;
682 float dectest,ratest,ramin,ramax;
683 char fullname[SZBUF];
685 const char *deccol =
"Dec";
690 o = cpl_table_new(0);
695 a = cpl_array_wrap_string((
char **)&deccol,1);
699 wrap = (ramin1 < 0.0 && ramax1 > 0.0) ? 2 : 1;
704 for (iwrap = 0; iwrap < wrap; iwrap++) {
707 ramin = ramin1 + 360.0;
720 first_index_ra = (int)ramin;
721 last_index_ra = min((
int)ramax,359);
726 for (i = first_index_ra; i <= last_index_ra; i++) {
731 (void)snprintf(fullname,SZBUF,
"%s/nppmxl%03d.fits",path,i);
736 p = cpl_propertylist_load(fullname,1);
742 nrows = cpl_propertylist_get_int(p,
"NAXIS2");
743 cpl_propertylist_delete(p);
750 first_index = nrows/2;
751 while (finish - start >= 2) {
752 t = cpl_table_load_window(fullname,1,1,a,(cpl_size)first_index,
754 dectest = (float)cpl_table_get_double(t,
"Dec",0,NULL);
756 if (dectest < decmin) {
758 first_index = (first_index + finish)/2;
760 finish = first_index;
761 first_index = (first_index + start)/2;
770 last_index = start + (finish - start)/2;
771 while (finish - start >= 2) {
772 t = cpl_table_load_window(fullname,1,1,a,(cpl_size)last_index,
774 dectest = (float)cpl_table_get_double(t,
"Dec",0,NULL);
776 if (dectest < decmax) {
778 last_index = (last_index + finish)/2;
781 last_index = (last_index + start)/2;
784 if (last_index < first_index)
785 last_index = first_index;
789 nrows = last_index - first_index + 1;
790 if ((t = cpl_table_load_window(fullname,1,1,NULL,
791 (cpl_size)first_index,
792 (cpl_size)nrows)) == NULL) {
797 cpl_table_unselect_all(t);
803 for (j = 0; j < nrows; j++) {
804 ratest = (float)cpl_table_get_double(t,
"RA",(cpl_size)j,NULL);
805 if (cpl_error_get_code() != CPL_ERROR_NONE) {
811 if (ratest >= ramin && ratest <= ramax)
812 cpl_table_select_row(t,(cpl_size)j);
818 s = cpl_table_extract_selected(t);
820 cpl_table_copy_structure(o,t);
823 irow = (int)cpl_table_get_nrow(o) + 1;
824 cpl_table_insert(o,s,(cpl_size)irow);
869 static cpl_table *casu_apass_extract(
char *path,
float ramin1,
float ramax1,
870 float decmin,
float decmax) {
872 int i,nrows,start,finish,first_index,last_index,irow,init,j;
873 int first_index_ra,last_index_ra,wrap,iwrap;
874 float dectest,ratest,ramin,ramax;
875 char fullname[SZBUF];
877 const char *racol =
"RA";
882 o = cpl_table_new(0);
887 a = cpl_array_wrap_string((
char **)&racol,1);
891 wrap = (ramin1 < 0.0 && ramax1 > 0.0) ? 2 : 1;
896 for (iwrap = 0; iwrap < wrap; iwrap++) {
899 ramin = ramin1 + 360.0;
912 first_index_ra = (int)ramin;
913 last_index_ra = min((
int)ramax,359);
918 for (i = first_index_ra; i <= last_index_ra; i++) {
923 (void)snprintf(fullname,SZBUF,
"%s/casuapass_%03d.fits",path,i);
928 p = cpl_propertylist_load(fullname,1);
934 nrows = cpl_propertylist_get_int(p,
"NAXIS2");
935 cpl_propertylist_delete(p);
942 first_index = nrows/2;
943 while (finish - start >= 2) {
944 t = cpl_table_load_window(fullname,1,1,a,(cpl_size)first_index,
946 ratest = (float)cpl_table_get_double(t,
"RA",0,NULL);
948 if (ratest < ramin) {
950 first_index = (first_index + finish)/2;
952 finish = first_index;
953 first_index = (first_index + start)/2;
962 last_index = start + (finish - start)/2;
963 while (finish - start >= 2) {
964 t = cpl_table_load_window(fullname,1,1,a,(cpl_size)last_index,
966 ratest = (float)cpl_table_get_double(t,
"RA",0,NULL);
968 if (ratest < ramax) {
970 last_index = (last_index + finish)/2;
973 last_index = (last_index + start)/2;
976 if (last_index < first_index)
977 last_index = first_index;
981 nrows = last_index - first_index + 1;
982 if ((t = cpl_table_load_window(fullname,1,1,NULL,
983 (cpl_size)first_index,
984 (cpl_size)nrows)) == NULL) {
989 cpl_table_unselect_all(t);
995 for (j = 0; j < nrows; j++) {
996 dectest = (float)cpl_table_get_double(t,
"Dec",(cpl_size)j,NULL);
997 if (cpl_error_get_code() != CPL_ERROR_NONE) {
1003 if (dectest >= decmin && dectest <= decmax)
1004 cpl_table_select_row(t,(cpl_size)j);
1010 s = cpl_table_extract_selected(t);
1012 cpl_table_copy_structure(o,t);
1015 irow = (int)cpl_table_get_nrow(o) + 1;
1016 cpl_table_insert(o,s,(cpl_size)irow);
1020 cpl_table_delete(t);
1021 cpl_table_delete(s);
1027 cpl_array_unwrap(a);
1062 static cpl_table *casu_local_extract(
char *path,
float ramin1,
float ramax1,
1063 float decmin,
float decmax) {
1064 cpl_table *whole,*out,*out2;
1065 int wrap,iwrap,nrows;
1067 cpl_propertylist *p;
1072 whole = cpl_table_load((
const char *)path,1,0);
1076 wrap = (ramin1 < 0.0 && ramax1 > 0.0) ? 2 : 1;
1082 for (iwrap = 0; iwrap < wrap; iwrap++) {
1085 ramin = ramin1 + 360.0;
1095 cpl_table_unselect_all(whole);
1099 cpl_table_or_selected_double(whole,
"RA",CPL_NOT_LESS_THAN,
1101 cpl_table_and_selected_double(whole,
"RA",CPL_NOT_GREATER_THAN,
1103 cpl_table_and_selected_double(whole,
"Dec",CPL_NOT_LESS_THAN,
1105 cpl_table_and_selected_double(whole,
"Dec",CPL_NOT_GREATER_THAN,
1111 out = cpl_table_extract_selected(whole);
1113 out2 = cpl_table_extract_selected(whole);
1114 nrows = cpl_table_get_nrow(out);
1115 cpl_table_insert(out,out2,nrows+1);
1116 cpl_table_delete(out2);
1122 p = cpl_propertylist_new();
1123 cpl_propertylist_append_bool(p,
"Dec",0);
1124 cpl_table_sort(out,p);
1125 cpl_propertylist_delete(p);
1161 static cpl_table *check_cache(
char *catname,
float ra1_im,
float ra2_im,
1162 float dec1_im,
float dec2_im,
char *cacheloc) {
1165 char fname[BUFSIZ],catname2[SZBUF];
1166 char * cat_cache = NULL;
1167 float best,ra1_cat,ra2_cat,dec1_cat,dec2_cat,d1,d2,fra,fdec,ftot;
1172 (void)snprintf(fname,BUFSIZ,
"%s/%s",cacheloc,CACHEIND);
1173 fd = fopen(fname,
"r");
1179 wrap1 = (ra1_im < 0.0 ? 1 : 0);
1185 while (fscanf(fd,
"%8191s %1023s %g %g %g %g",
1186 fname,catname2,&ra1_cat,&ra2_cat,
1187 &dec1_cat,&dec2_cat) != EOF) {
1188 wrap2 = (ra1_cat < 0.0 ? 1 : 0);
1191 if (strcmp(catname,catname2))
1196 if (!(((ra1_im >= ra1_cat && ra1_im <= ra2_cat) ||
1197 (ra2_im >= ra1_cat && ra2_im <= ra2_cat)) &&
1198 ((dec1_im >= dec1_cat && dec1_im <= dec2_cat) ||
1199 (dec2_im >= dec1_cat && dec2_im <= dec2_cat))))
1204 d1 = max(0.0,ra1_cat-ra1_im);
1205 d2 = max(0.0,ra2_im-ra2_cat);
1206 fra = 1.0 - (d1 + d2)/(ra2_im - ra1_im);
1207 d1 = max(0.0,dec1_cat-dec1_im);
1208 d2 = max(0.0,dec2_im-dec2_cat);
1209 fdec = 1.0 - (d1 + d2)/(dec2_im - dec1_im);
1215 cpl_free(cat_cache);
1216 cat_cache = cpl_sprintf(
"%s/%s/%s",cacheloc,CACHEDIR,fname);
1230 out_cat = cpl_table_load(cat_cache,1,1);
1231 cpl_free(cat_cache);
1233 cpl_msg_info(cpl_func,
"Using cached catalogue data");
1268 static void addto_cache(cpl_table *stds,
char *catname,
float ramin,
1269 float ramax,
float decmin,
float decmax,
1272 char newname[SZBUF];
1278 (void)snprintf(newname,SZBUF,
"%s/%s",cacheloc,CACHEDIR);
1279 if (access(newname,0) != 0)
1280 mkdir(newname,0755);
1284 (void)snprintf(newname,SZBUF,
"%s/%s",cacheloc,CACHEIND);
1285 fd = fopen(newname,
"a");
1293 snprintf(newname,SZBUF,
"%s/%s/cch_%08d",cacheloc,CACHEDIR,i);
1294 if (access(newname,F_OK) != 0)
1301 snprintf(newname,SZBUF,
"%s/%s/cch_%08d",cacheloc,CACHEDIR,i);
1302 cpl_table_save(stds,NULL,NULL,newname,CPL_IO_DEFAULT);
1303 snprintf(newname,SZBUF,
"cch_%08d",i);
1304 if (cpl_error_get_code() == CPL_ERROR_NONE)
1305 fprintf(fd,
"%s %s %g %g %g %g\n",newname,catname,ramin-0.0005,
1306 ramax+0.0005,decmin-0.0005,decmax+0.0005);
1335 static int get_response(
int sock, cpl_table **outtab) {
1336 int nnewline,i,nv,irem = 0,fd;
1338 char buf[BUFMAX],outfile[32];
1339 const char *fctid =
"get_response";
1345 nv = recv(sock,buf,
sizeof(buf),0);
1347 cpl_msg_warning(fctid,
"Unable to find double newline");
1350 for (i = 0; i < nv; i++) {
1351 if (buf[i] ==
'\n') {
1356 if (nnewline && buf[i] !=
'\r')
1360 if (nnewline == 2) {
1368 for (i = irem; i < nv; i++)
1369 buf[i-irem] = buf[i];
1374 (void)snprintf(outfile,32,
"stdsXXXXXX");
1375 fd = mkstemp(outfile);
1380 ssize_t written = write(fd,buf,nv);
1382 cpl_msg_info(cpl_func,
"Not all bytes could be written - "
1385 nv = recv(sock,buf,
sizeof(buf),0);
1389 cpl_msg_warning(fctid,
"Read from socket failed");
1400 *outtab = cpl_table_load(outfile,1,0);
1401 if (cpl_error_get_code() != CPL_ERROR_NONE) {
1402 cpl_msg_warning(fctid,
"No standards were found");
1408 nrows = (int)cpl_table_get_nrow(*outtab);
1410 cpl_msg_warning(fctid,
"No standards table had no rows");
1451 static int send_request(
int sock,
char *req_string,
int isbin) {
1453 const char *fctid =
"send_request";
1458 sprintf(buf,
"GET /viz-bin/asu-binfits?%s HTTP/1.0\r\n\r\n",req_string);
1460 sprintf(buf,
"GET /viz-bin/asu-fits?%s HTTP/1.0\r\n\r\n",req_string);
1462 if (send(sock,buf,strlen(buf),0) < 0) {
1463 cpl_msg_warning(fctid,
"Attempt to send message failed, error: %d\n",
1495 static int connect_site(
const char *site,
int *sock) {
1497 struct sockaddr_in ssin;
1498 const char *fctid =
"connect_site";
1502 hp = gethostbyname(site);
1504 cpl_msg_warning(fctid,
"Unable to get host information for %s\n",site);
1507 ssin.sin_family = hp->h_addrtype;
1508 memcpy(&ssin.sin_addr,hp->h_addr_list[0],hp->h_length);
1509 ssin.sin_port = htons(PORT);
1513 *sock = socket(hp->h_addrtype,SOCK_STREAM,0);
1515 cpl_msg_warning(fctid,
"Unable to create socket descriptor for %s\n",
1517 return (CASU_FATAL);
1522 if (connect(*sock,(
struct sockaddr*)&ssin,
sizeof(ssin)) < 0) {
1523 cpl_msg_warning(fctid,
"Unable to connect to site: %s\n",site);
1562 static char *form_request(
float ra,
float dec,
float dra,
float ddec,
1563 float equinox,
const char *catid) {
1564 static char buf[2*BUFSIZ];
1565 char buf2[BUFSIZ],equi[1];
1571 (void)snprintf(buf2,BUFSIZ,
"-c=%8.3f %8.3f",ra,dec);
1572 (void)strncpy(buf,url_encode(buf2),BUFSIZ);
1576 (void)snprintf(buf2,BUFSIZ,
"-c.bd=%g/%g",dra,ddec);
1577 (void)strncat(buf,
"&",BUFSIZ);
1578 (void)strncat(buf,url_encode(buf2),BUFSIZ);
1582 (void)snprintf(buf2,BUFSIZ,
"-source=%s",catid);
1583 (void)strncat(buf,
"&",BUFSIZ);
1584 (void)strncat(buf,url_encode(buf2),BUFSIZ);
1588 equi[0] = (equinox == 1950.0 ?
'B' :
'J');
1589 (void)snprintf(buf2,BUFSIZ,
"-c.eq=%c%g",equi[0],equinox);
1590 (void)strncat(buf,
"&",BUFSIZ);
1591 (void)strncat(buf,url_encode(buf2),BUFSIZ);
1596 (void)snprintf(buf2,BUFSIZ,
"-out.max=unlimited");
1597 (void)strncat(buf,
"&",BUFSIZ);
1598 (void)strncat(buf,url_encode(buf2),BUFSIZ);
1599 (void)snprintf(buf2,BUFSIZ,
"-sort=_RA*-c.eq");
1600 (void)strncat(buf,
"&",BUFSIZ);
1601 (void)strncat(buf,url_encode(buf2),BUFSIZ);
1602 (void)snprintf(buf2,BUFSIZ,
"-out.add=_RA*-c.eq");
1603 (void)strncat(buf,
"&",BUFSIZ);
1604 (void)strncat(buf,url_encode(buf2),BUFSIZ);
1605 (void)snprintf(buf2,BUFSIZ,
"-out.add=_DEC*-c.eq");
1606 (void)strncat(buf,
"&",BUFSIZ);
1607 (void)strncat(buf,url_encode(buf2),BUFSIZ);
1634 static char *url_encode(
char *instring) {
1635 static char buf[BUFSIZ];
1642 buf[k] = instring[k];
1643 }
while (instring[k++] !=
'=');
1644 len = strlen(instring);
1650 for (i = k; i < len; i++) {
1651 assert(j < (
int)
sizeof(buf));
1652 if (instring[i] ==
' ')
1654 else if (isalnum((
unsigned char)instring[i]))
1655 buf[j++] = instring[i];
1657 sprintf(buf+j,
"%%%2x",(
unsigned char)instring[i]);
int casu_get_cdschoice(const char *cdscatname)
int casu_getstds(cpl_propertylist *plist, int cache, char *path, char *catname, int cdssearch, char *cacheloc, cpl_table **stds, int *status)
Get a table of standard stars that appear on an image from a catalogue.
void casu_radectoxy(cpl_wcs *wcs, double ra, double dec, double *x, double *y)
int casu_coverage(cpl_propertylist *plist, int fudge, double *ra1, double *ra2, double *dec1, double *dec2, int *status)