changeset 1665:cde14129b717

Use string for dimension class storage
author bert <bert>
date Fri, 06 Feb 2004 22:21:29 +0000
parents 17b4ee9d0ccf
children 3c956d0fd772
files libsrc2/volume.c
diffstat 1 files changed, 51 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libsrc2/volume.c
+++ b/libsrc2/volume.c
@@ -254,7 +254,6 @@
 	  
           if (hdf_size[i] > dimensions[i]->length) {
               hdf_size[i] = dimensions[i]->length;
-	      
           }
       }
     
@@ -355,8 +354,33 @@
     miset_attr_at_loc(dataset_id, "spacing", MI_TYPE_STRING,
                       strlen(name), name);
 
-    miset_attr_at_loc(dataset_id, "class", MI_TYPE_INT, 1, 
-                      &dimensions[i]->class);
+    switch (dimensions[i]->class) {
+    case MI_DIMCLASS_SPATIAL:
+        name = "spatial";
+        break;
+    case MI_DIMCLASS_TIME:
+        name = "time___";
+        break;
+    case MI_DIMCLASS_SFREQUENCY:
+        name = "sfreq__";
+        break;
+    case MI_DIMCLASS_TFREQUENCY:
+        name = "tfreq__";
+        break;
+    case MI_DIMCLASS_USER:
+        name = "user___";
+        break;
+    case MI_DIMCLASS_RECORD:
+        name = "record_";
+        break;
+    case MI_DIMCLASS_ANY:
+    default:
+        /* These should not be seen in this context!!!
+         */
+        return (MI_ERROR);
+    }
+    miset_attr_at_loc(dataset_id, "class", MI_TYPE_STRING, strlen(name),
+                      name);
    
    /* Create Dimension attribute "direction_cosines"  */
     miset_attr_at_loc(dataset_id, "direction_cosines", MI_TYPE_DOUBLE,
@@ -601,7 +625,7 @@
             hdim->attr |= MI_DIMATTR_NOT_REGULARLY_SAMPLED;
         }
 
-        r = miget_attribute(volume, path, "class", MI_TYPE_INT, 1, &hdim->class);
+        r = miget_attribute(volume, path, "class", MI_TYPE_INT, 1, temp);
         if (r < 0) {
             /* Get the default class. */
             if (!strcmp(dimname, "time")) {
@@ -611,6 +635,29 @@
                 hdim->class =  MI_DIMCLASS_SPATIAL;
             }
         }
+        else {
+            if (!strcmp(temp, "spatial")) {
+                hdim->class = MI_DIMCLASS_SPATIAL;
+            }
+            else if (!strcmp(temp, "time___")) {
+                hdim->class = MI_DIMCLASS_TIME;
+            }
+            else if (!strcmp(temp, "sfreq__")) {
+                hdim->class = MI_DIMCLASS_SFREQUENCY;
+            }
+            else if (!strcmp(temp, "tfreq__")) {
+                hdim->class = MI_DIMCLASS_TFREQUENCY;
+            }
+            else if (!strcmp(temp, "user___")) {
+                hdim->class = MI_DIMCLASS_USER;
+            }
+            else if (!strcmp(temp, "record_")) {
+                hdim->class = MI_DIMCLASS_RECORD;
+            }
+            else {
+                /* TODO: error message?? */
+            }
+        }
         r = miget_attribute(volume, path, "length", MI_TYPE_UINT, 1, &hdim->length);
         if (r < 0) {
             fprintf(stderr, "Can't get length\n");