00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 # include <config.h>
00030 #endif
00031
00032 #include <string.h>
00033
00034 #include <cxtypes.h>
00035 #include <cxmemory.h>
00036 #include <cxmessages.h>
00037 #include <cxmap.h>
00038 #include <cxstrutils.h>
00039
00040 #include <cpl_error.h>
00041 #include <cpl_image.h>
00042
00043 #include "gialias.h"
00044 #include "gierror.h"
00045 #include "giutils.h"
00046 #include "gilinedata.h"
00047
00048
00049
00050
00051
00052
00053
00054
00055
00058 struct GiLineData {
00059
00060 const cxchar* model;
00061
00062 cxint nfibers;
00063 cxint nlines;
00064 cxint* ignore;
00065
00066 cxdouble* wavelength;
00067
00068 cpl_image* status;
00069
00070 cx_map* values;
00071
00072 };
00073
00074
00075 inline static cxbool
00076 _giraffe_linedata_compare(cxcptr s, cxcptr t)
00077 {
00078
00079 return strcmp(s, t) < 0 ? TRUE : FALSE;
00080
00081 }
00082
00083
00084 inline static cxptr
00085 _giraffe_linedata_get_data(cx_map* map, const cxchar* name)
00086 {
00087
00088
00089 cpl_image* data = cx_map_get(map, name);
00090
00091 if (data == NULL) {
00092 return NULL;
00093 }
00094
00095 return cpl_image_get_data(data);
00096
00097 }
00098
00099
00100 inline static void
00101 _giraffe_linedata_clear(GiLineData* self)
00102 {
00103
00104 self->nfibers = 0;
00105 self->nlines = 0;
00106
00107 if (self->model) {
00108 cx_free((cxptr)self->model);
00109 self->model = NULL;
00110 }
00111
00112 if (self->ignore) {
00113 cx_free(self->ignore);
00114 self->ignore = NULL;
00115 }
00116
00117 if (self->wavelength) {
00118 cx_free(self->wavelength);
00119 self->wavelength = NULL;
00120 }
00121
00122 if (self->status) {
00123 cpl_image_delete(self->status);
00124 self->status = NULL;
00125 }
00126
00127 if (self->values) {
00128 cx_map_clear(self->values);
00129 }
00130
00131 cx_assert(cx_map_empty(self->values));
00132
00133 return;
00134 }
00135
00136
00137 inline static cxint
00138 _giraffe_linedata_assign(GiLineData* self, cx_map* map, const cxchar* name,
00139 const cpl_image* values)
00140 {
00141
00142 cx_map_iterator position = cx_map_find(map, name);
00143
00144
00145 if (cpl_image_get_size_x(values) != self->nfibers) {
00146 return 1;
00147 }
00148
00149 if (cpl_image_get_size_y(values) != self->nlines) {
00150 return 2;
00151 }
00152
00153 if (position == cx_map_end(map)) {
00154 cx_map_insert(map, cx_strdup(name), values);
00155 }
00156 else {
00157
00158 cpl_image* previous = cx_map_assign(map, position, values);
00159
00160 if (previous != NULL) {
00161 cpl_image_delete(previous);
00162 previous = NULL;
00163 }
00164
00165 }
00166
00167 return 0;
00168
00169 }
00170
00171
00172 inline static cxint
00173 _giraffe_linedata_set(GiLineData* self, cx_map* map, const cxchar* name,
00174 cxint i, cxint j, cxdouble value)
00175 {
00176
00177 cxdouble* data = NULL;
00178
00179 cx_map_const_iterator position = cx_map_find(map, name);
00180
00181
00182 if (position == cx_map_end(map)) {
00183
00184 cpl_image* buffer = cpl_image_new(self->nfibers, self->nlines,
00185 CPL_TYPE_DOUBLE);
00186 cx_map_insert(map, cx_strdup(name), buffer);
00187 data = cpl_image_get_data(buffer);
00188
00189 }
00190 else {
00191
00192 data = cpl_image_get_data(cx_map_get_value(map, position));
00193
00194 }
00195
00196 data[self->nfibers * j + i] = value;
00197
00198 return 0;
00199
00200 }
00201
00202
00203 inline static cxint
00204 _giraffe_linedata_get(const GiLineData* self, const cx_map* map,
00205 const cxchar* name, cxint i, cxint j, cxdouble* value)
00206 {
00207
00208 cxdouble* data = NULL;
00209
00210 cx_map_const_iterator position = cx_map_find(map, name);
00211
00212 if (position == cx_map_end(map)) {
00213 return 1;
00214 }
00215
00216 data = cpl_image_get_data(cx_map_get_value(map, position));
00217 *value = data[self->nfibers * j + i];
00218
00219 return 0;
00220
00221 }
00222
00223
00224 GiLineData*
00225 giraffe_linedata_new(void)
00226 {
00227
00228 GiLineData* self = cx_calloc(1, sizeof *self);
00229
00230 self->nfibers = 0;
00231 self->nlines = 0;
00232
00233 self->model = NULL;
00234 self->ignore = NULL;
00235
00236 self->wavelength = NULL;
00237 self->status = NULL;
00238
00239 self->values = cx_map_new(_giraffe_linedata_compare, cx_free,
00240 (cx_free_func)cpl_image_delete);
00241 cx_assert(cx_map_empty(self->values));
00242
00243 return self;
00244
00245 }
00246
00247
00248 GiLineData*
00249 giraffe_linedata_create(const cpl_table* lines, const cpl_table* fibers,
00250 const cxchar* model)
00251 {
00252 cxint i;
00253
00254 GiLineData* self = NULL;
00255
00256
00257 if (lines == NULL) {
00258 return NULL;
00259 }
00260
00261 if (!cpl_table_has_column(lines, "WLEN")) {
00262 return NULL;
00263 }
00264
00265 if (fibers == NULL) {
00266 return NULL;
00267 }
00268
00269 if (model == NULL) {
00270 return NULL;
00271 }
00272
00273 self = cx_malloc(sizeof(GiLineData));
00274 cx_assert(self);
00275
00276 self->nfibers = cpl_table_get_nrow(fibers);
00277 self->nlines = cpl_table_get_nrow(lines);
00278
00279 self->model = cx_strdup(model);
00280 self->ignore = cx_calloc(self->nlines, sizeof(cxint));
00281
00282 self->wavelength = cx_calloc(self->nlines, sizeof(cxdouble));
00283
00284 for (i = 0; i < self->nlines; i++) {
00285 self->wavelength[i] = cpl_table_get(lines, "WLEN", i, NULL);
00286 }
00287
00288
00289 self->status = NULL;
00290
00291 self->values = cx_map_new(_giraffe_linedata_compare, cx_free,
00292 (cx_free_func)cpl_image_delete);
00293 cx_assert(cx_map_empty(self->values));
00294
00295 return self;
00296
00297 }
00298
00299
00300 void
00301 giraffe_linedata_delete(GiLineData* self)
00302 {
00303
00304 if (self) {
00305 _giraffe_linedata_clear(self);
00306
00307 if (self->values != NULL) {
00308 cx_map_delete(self->values);
00309 }
00310
00311 cx_free(self);
00312 }
00313
00314 return;
00315
00316 }
00317
00318
00319 cxint
00320 giraffe_linedata_reset(GiLineData* self, const cpl_table* lines,
00321 const cpl_table* fibers, const cxchar* model)
00322 {
00323
00324 cxint i;
00325
00326
00327 cx_assert(self != NULL);
00328
00329 if (lines == NULL) {
00330 return 1;
00331 }
00332
00333 if (!cpl_table_has_column(lines, "WLEN")) {
00334 return 1;
00335 }
00336
00337 if (fibers == NULL) {
00338 return 1;
00339 }
00340
00341 if (model == NULL) {
00342 return 1;
00343 }
00344
00345
00346 self->nfibers = cpl_table_get_nrow(fibers);
00347 self->nlines = cpl_table_get_nrow(lines);
00348
00349 if (self->model != NULL) {
00350 cx_free((cxchar*)self->model);
00351 }
00352 self->model = cx_strdup(model);
00353
00354 if (self->ignore != NULL) {
00355 cx_free(self->ignore);
00356 }
00357 self->ignore = cx_calloc(self->nlines, sizeof(cxint));
00358
00359 self->wavelength = cx_realloc(self->wavelength,
00360 self->nlines * sizeof(cxdouble));
00361
00362 for (i = 0; i < self->nlines; i++) {
00363
00364 self->wavelength[i] = cpl_table_get(lines, "WLEN", i,
00365 NULL);
00366
00367 }
00368
00369 if (self->status != NULL) {
00370 cpl_image_delete(self->status);
00371 self->status = NULL;
00372 }
00373
00374 if (!cx_map_empty(self->values)) {
00375 cx_map_clear(self->values);
00376 }
00377
00378 return 0;
00379
00380 }
00381
00382
00383 const cxchar*
00384 giraffe_linedata_model(const GiLineData* self)
00385 {
00386
00387 cx_assert(self != NULL);
00388
00389 return self->model;
00390
00391 }
00392
00393
00394 cxsize
00395 giraffe_linedata_lines(const GiLineData* self)
00396 {
00397
00398 cx_assert(self != NULL);
00399
00400 return self->nlines;
00401
00402 }
00403
00404
00405 cxsize
00406 giraffe_linedata_fibers(const GiLineData* self)
00407 {
00408
00409 cx_assert(self != NULL);
00410
00411 return self->nfibers;
00412
00413 }
00414
00415
00416 cxbool
00417 giraffe_linedata_contains(GiLineData* self, const cxchar* name)
00418 {
00419
00420 cx_map_const_iterator position;
00421
00422
00423 cx_assert(self != NULL);
00424
00425 if (name == NULL) {
00426 return FALSE;
00427 }
00428
00429 position = cx_map_find(self->values, name);
00430
00431 if (position == cx_map_end(self->values)) {
00432 return FALSE;
00433 }
00434
00435 return TRUE;
00436
00437 }
00438
00439
00440 cxsize
00441 giraffe_linedata_rejected(const GiLineData* self)
00442 {
00443
00444 cxint i;
00445 cxint* status;
00446
00447 cxsize count = 0;
00448
00449
00450 cx_assert(self != NULL);
00451
00452 if (self->status != NULL) {
00453
00454 status = cpl_image_get_data(self->status);
00455
00456 for (i = 0; i < self->nfibers * self->nlines; i++) {
00457 if (status[i] > 0) {
00458 ++count;
00459 }
00460 }
00461
00462 }
00463
00464 return count;
00465
00466 }
00467
00468
00469 cxsize
00470 giraffe_linedata_accepted(const GiLineData* self)
00471 {
00472
00473 cxsize count = 0;
00474
00475
00476 cx_assert(self != NULL);
00477
00478 count = self->nfibers * self->nlines;
00479
00480 return count - giraffe_linedata_rejected(self);
00481
00482 }
00483
00484
00485 cpl_image*
00486 giraffe_linedata_status(const GiLineData* self)
00487 {
00488
00489 cx_assert(self != NULL);
00490
00491 if (self->status == NULL) {
00492 return cpl_image_new(self->nfibers, self->nlines, CPL_TYPE_INT);
00493 }
00494
00495 return cpl_image_duplicate(self->status);
00496
00497 }
00498
00499
00500 cxint
00501 giraffe_linedata_set_status(GiLineData* self, cxint fiber, cxint line,
00502 cxint status)
00503 {
00504
00505 cxint* data = NULL;
00506
00507
00508 cx_assert(self != NULL);
00509
00510 if (fiber >= self->nfibers) {
00511 return 1;
00512 }
00513
00514 if (line >= self->nlines) {
00515 return 1;
00516 }
00517
00518 if (self->status == NULL) {
00519 self->status = cpl_image_new(self->nfibers, self->nlines,
00520 CPL_TYPE_INT);
00521 if (self->status == NULL) {
00522 return -1;
00523 }
00524 }
00525
00526 data = cpl_image_get_data(self->status);
00527
00528 data[self->nfibers * line + fiber] = status;
00529
00530 if (status != 0) {
00531 self->ignore[line] += 1;
00532 }
00533
00534 return 0;
00535
00536 }
00537
00538
00539 cxint
00540 giraffe_linedata_get_status(const GiLineData* self, cxint fiber, cxint line)
00541 {
00542
00543 cxint* data = NULL;
00544
00545
00546 cx_assert(self != NULL);
00547
00548 if (fiber >= self->nfibers) {
00549 return 1;
00550 }
00551
00552 if (line >= self->nlines) {
00553 return 1;
00554 }
00555
00556 if (self->status == NULL) {
00557 return 0;
00558 }
00559
00560 data = cpl_image_get_data(self->status);
00561
00562 return data[self->nfibers * line + fiber];
00563
00564 }
00565
00566
00567 cxint
00568 giraffe_linedata_set_wavelength(GiLineData* self, cxint line, cxdouble lambda)
00569 {
00570
00571 cx_assert(self != NULL);
00572
00573 if (line < 0 || line >= self->nlines) {
00574 return 1;
00575 }
00576
00577 self->wavelength[line] = lambda;
00578
00579 return 0;
00580
00581 }
00582
00583
00584 cxdouble
00585 giraffe_linedata_get_wavelength(const GiLineData* self, cxint line)
00586 {
00587
00588 const cxchar* const fctid = "giraffe_linedata_get_wavelength";
00589
00590
00591 cx_assert(self != NULL);
00592
00593 if (line < 0 || line >= self->nlines) {
00594 cpl_error_set(fctid, CPL_ERROR_ILLEGAL_INPUT);
00595 return 0.;
00596 }
00597
00598 return self->wavelength[line];
00599
00600 }
00601
00602
00603 cxint
00604 giraffe_linedata_set(GiLineData* self, const cxchar* name, cxint fiber,
00605 cxint line, cxdouble value)
00606 {
00607
00608 cxint status = 0;
00609
00610 cx_assert(self != NULL);
00611
00612 if (name == NULL) {
00613 return 1;
00614 }
00615
00616 if (fiber >= self->nfibers) {
00617 return 1;
00618 }
00619
00620 if (line >= self->nlines) {
00621 return 1;
00622 }
00623
00624 status = _giraffe_linedata_set(self, self->values, name, fiber, line,
00625 value);
00626
00627 if (status != 0) {
00628 return 1;
00629 }
00630
00631 return 0;
00632
00633 }
00634
00635
00636 cxdouble
00637 giraffe_linedata_get(const GiLineData* self, const cxchar* name, cxint fiber,
00638 cxint line)
00639 {
00640
00641 const cxchar* const fctid = "giraffe_linedata_get";
00642
00643 cxint status = 0;
00644
00645 cxdouble value = 0.;
00646
00647
00648 cx_assert(self != NULL);
00649
00650 if (name == NULL) {
00651 return 1;
00652 }
00653
00654 if (fiber >= self->nfibers) {
00655 return 1;
00656 }
00657
00658 if (line >= self->nlines) {
00659 return 1;
00660 }
00661
00662 status = _giraffe_linedata_get(self, self->values, name, fiber, line,
00663 &value);
00664
00665 if (status != 0) {
00666 cpl_error_set(fctid, CPL_ERROR_DATA_NOT_FOUND);
00667 return 0.;
00668 }
00669
00670 return value;
00671
00672 }
00673
00674
00675 cxint
00676 giraffe_linedata_set_data(GiLineData* self, const cxchar* name,
00677 const cpl_image* data)
00678 {
00679
00680 cxint status = 0;
00681
00682
00683 cx_assert(self != NULL);
00684
00685 if (name == NULL) {
00686 return 1;
00687 }
00688
00689 if (data == NULL) {
00690 return 1;
00691 }
00692
00693 status = _giraffe_linedata_assign(self, self->values, name, data);
00694
00695 if (status != 0) {
00696 return 1;
00697 }
00698
00699 return 0;
00700
00701 }
00702
00703
00704 const cpl_image*
00705 giraffe_linedata_get_data(const GiLineData* self, const cxchar* name)
00706 {
00707
00708 cx_assert(self != NULL);
00709
00710 if (name == NULL) {
00711 return NULL;
00712 }
00713
00714 return cx_map_get(self->values, name);
00715
00716 }
00717
00718
00719 cxint
00720 giraffe_linedata_load(GiLineData* self, const cxchar* filename)
00721 {
00722
00723 cxsize extension = 1;
00724
00725 cpl_table* lines = NULL;
00726
00727 cpl_propertylist* p = NULL;
00728
00729
00730 if (self == NULL || filename == NULL) {
00731 return -1;
00732 }
00733
00734 _giraffe_linedata_clear(self);
00735
00736
00737 giraffe_error_push();
00738
00739 p = cpl_propertylist_load(filename, 0);
00740
00741 if (p == NULL) {
00742 return 1;
00743 }
00744
00745 if (cpl_propertylist_has(p, GIALIAS_WSOL_LMNAME) == 0) {
00746 return 1;
00747 }
00748 else {
00749
00750 self->model = cx_strdup(cpl_propertylist_get_string(p,
00751 GIALIAS_WSOL_LMNAME));
00752
00753 }
00754
00755 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00756
00757 if (p != NULL) {
00758 cpl_propertylist_delete(p);
00759 p = NULL;
00760 }
00761
00762 return 1;
00763
00764 }
00765
00766 giraffe_error_pop();
00767
00768 cpl_propertylist_delete(p);
00769 p = NULL;
00770
00771
00772
00773
00774
00775
00776 lines = cpl_table_load(filename, extension, 0);
00777
00778 if (lines == NULL) {
00779 _giraffe_linedata_clear(self);
00780 return 2;
00781 }
00782
00783 if (cpl_table_has_column(lines, "WLEN") == FALSE) {
00784 _giraffe_linedata_clear(self);
00785 return 2;
00786 }
00787 else {
00788
00789 const cxdouble* lambda = cpl_table_get_data_double(lines, "WLEN");
00790
00791 self->nlines = cpl_table_get_nrow(lines);
00792
00793 self->ignore = cx_calloc(self->nlines, sizeof(cxint));
00794 self->wavelength = cx_malloc(self->nlines * sizeof(cxdouble));
00795
00796 memcpy(self->wavelength, lambda, self->nlines * sizeof(cxdouble));
00797 }
00798
00799 ++extension;
00800
00801 self->status = cpl_image_load(filename, CPL_TYPE_INT, 0, extension);
00802
00803 if (self->status == NULL) {
00804 _giraffe_linedata_clear(self);
00805 return 2;
00806 }
00807
00808 self->nfibers = cpl_image_get_size_x(self->status);
00809
00810 ++extension;
00811
00812
00813
00814
00815
00816
00817
00818
00819 p = cpl_propertylist_load(filename, extension);
00820
00821
00822
00823
00824
00825 while ((p != NULL) && (extension < 22)) {
00826
00827 const cxchar* name = cpl_propertylist_get_string(p, GIALIAS_EXTNAME);
00828
00829 if (name == NULL) {
00830 cpl_propertylist_delete(p);
00831 p = NULL;
00832
00833 _giraffe_linedata_clear(self);
00834
00835 return 3;
00836 }
00837 else {
00838
00839 cpl_image* buffer = cpl_image_load(filename, CPL_TYPE_DOUBLE,
00840 0, extension);
00841
00842 if ((cpl_image_get_size_x(buffer) != self->nfibers) ||
00843 (cpl_image_get_size_y(buffer) != self->nlines)) {
00844
00845 cpl_image_delete(buffer);
00846 buffer = NULL;
00847
00848 cpl_propertylist_delete(p);
00849 p = NULL;
00850
00851 _giraffe_linedata_clear(self);
00852
00853 return 3;
00854
00855 }
00856
00857 cx_map_insert(self->values, cx_strdup(name), buffer);
00858
00859 }
00860
00861 ++extension;
00862
00863 cpl_propertylist_delete(p);
00864 p = cpl_propertylist_load(filename, extension);
00865
00866 }
00867
00868 cpl_propertylist_delete(p);
00869 p = NULL;
00870
00871 return 0;
00872
00873 }
00874
00875
00876 cxint
00877 giraffe_linedata_save(GiLineData* self, const cpl_propertylist* properties,
00878 const cxchar* filename)
00879 {
00880
00881 cxint status = 0;
00882
00883 cpl_propertylist* p = NULL;
00884
00885
00886 if (self == NULL || properties == NULL || filename == NULL) {
00887 return -1;
00888 }
00889
00890 p = cpl_propertylist_duplicate(properties);
00891
00892 status = giraffe_linedata_writer(self, p, filename, NULL);
00893
00894 cpl_propertylist_delete(p);
00895 p = NULL;
00896
00897 return status;
00898
00899 }
00900
00901
00902 cxint
00903 giraffe_linedata_writer(const GiLineData* self, cpl_propertylist* properties,
00904 const cxchar* filename, cxcptr data)
00905 {
00906
00907 const cxchar* const fctid = "giraffe_linedata_writer";
00908
00909 cx_map_const_iterator position;
00910
00911 cpl_propertylist* p = NULL;
00912
00913 cpl_table* lines = NULL;
00914
00915
00916
00917 data = NULL;
00918
00919 if (self == NULL || properties == NULL || filename == NULL) {
00920 return -1;
00921 }
00922
00923 lines = cpl_table_new(self->nlines);
00924
00925 if (lines == NULL) {
00926 return 1;
00927 }
00928
00929 giraffe_error_push();
00930
00931 cpl_table_new_column(lines, "WLEN", CPL_TYPE_DOUBLE);
00932 cpl_table_copy_data_double(lines, "WLEN", self->wavelength);
00933
00934 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00935 cpl_table_delete(lines);
00936 lines = NULL;
00937
00938 return 1;
00939 }
00940
00941 giraffe_error_pop();
00942
00943
00944
00945
00946
00947
00948 cpl_propertylist_erase_regexp(properties, "^CRPIX[0-9]$", 0);
00949 cpl_propertylist_erase_regexp(properties, "^CRVAL[0-9]$", 0);
00950 cpl_propertylist_erase_regexp(properties, "^CDELT[0-9]$", 0);
00951 cpl_propertylist_erase_regexp(properties, "^CTYPE[0-9]$", 0);
00952
00953
00954 cpl_propertylist_update_string(properties, GIALIAS_WSOL_LMNAME,
00955 self->model);
00956 cpl_propertylist_set_comment(properties, GIALIAS_WSOL_LMNAME,
00957 "Line profile model");
00958
00959 p = cpl_propertylist_new();
00960 cpl_propertylist_append_string(p, GIALIAS_EXTNAME, "LINES");
00961 cpl_propertylist_set_comment(p, GIALIAS_EXTNAME, "FITS Extension name");
00962
00963 giraffe_error_push();
00964
00965 cpl_table_save(lines, properties, p, filename, CPL_IO_CREATE);
00966
00967 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00968
00969 cpl_propertylist_delete(p);
00970 p = NULL;
00971
00972 cpl_table_delete(lines);
00973 lines = NULL;
00974
00975 return 2;
00976 }
00977
00978 cpl_table_delete(lines);
00979 lines = NULL;
00980
00981 giraffe_error_pop();
00982
00983 cpl_propertylist_set_string(p, GIALIAS_EXTNAME, "LINE_FLAGS");
00984
00985 giraffe_error_push();
00986
00987 if (self->status == NULL) {
00988
00989 cpl_image* status = cpl_image_new(self->nfibers, self->nlines,
00990 CPL_TYPE_INT);
00991
00992 cpl_image_save(status, filename, CPL_BPP_16_SIGNED, p,
00993 CPL_IO_EXTEND);
00994 cpl_image_delete(status);
00995 status = NULL;
00996
00997 }
00998 else {
00999 cpl_image_save(self->status, filename, CPL_BPP_16_SIGNED, p,
01000 CPL_IO_EXTEND);
01001 }
01002
01003 if (cpl_error_get_code() != CPL_ERROR_NONE) {
01004 cpl_propertylist_delete(p);
01005 p = NULL;
01006
01007 return 2;
01008 }
01009
01010 position = cx_map_begin(self->values);
01011 while (position != cx_map_end(self->values)) {
01012
01013 cxint format = 0;
01014
01015 const cpl_image* ldata = cx_map_get_value(self->values, position);
01016
01017
01018 switch (cpl_image_get_type(ldata)) {
01019 case CPL_TYPE_INT:
01020 format = CPL_BPP_32_SIGNED;
01021 break;
01022
01023 case CPL_TYPE_FLOAT:
01024 format = CPL_BPP_IEEE_FLOAT;
01025 break;
01026
01027 case CPL_TYPE_DOUBLE:
01028 format = CPL_BPP_IEEE_FLOAT;
01029 break;
01030
01031 default:
01032 cpl_propertylist_delete(p);
01033 p = NULL;
01034
01035 cpl_error_set(fctid, CPL_ERROR_TYPE_MISMATCH);
01036 return 2;
01037
01038 break;
01039 }
01040
01041 cpl_propertylist_set_string(p, GIALIAS_EXTNAME,
01042 cx_map_get_key(self->values, position));
01043
01044 cpl_image_save(ldata, filename, format, p, CPL_IO_EXTEND);
01045
01046 if (cpl_error_get_code() != CPL_ERROR_NONE) {
01047 cpl_propertylist_delete(p);
01048 p = NULL;
01049
01050 return 2;
01051 }
01052
01053 position = cx_map_next(self->values, position);
01054
01055 }
01056
01057 giraffe_error_pop();
01058
01059 cpl_propertylist_delete(p);
01060 p = NULL;
01061
01062 return 0;
01063
01064 }