File tree Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,33 @@ image_band_json(Imaging im) {
84
84
return json ;
85
85
}
86
86
87
+ char *
88
+ single_band_json (Imaging im ) {
89
+ char * format = "{\"bands\": [\"%s\"]}" ;
90
+ char * json ;
91
+ // Bands can be 1 band * (maybe but probably not) 2 characters each
92
+ int len = strlen (format ) + 2 + 1 ;
93
+ int err ;
94
+
95
+ json = calloc (1 , len );
96
+
97
+ if (!json ) {
98
+ return NULL ;
99
+ }
100
+
101
+ err = PyOS_snprintf (
102
+ json ,
103
+ len ,
104
+ format ,
105
+ im -> band_names [0 ]
106
+ );
107
+ if (err < 0 ) {
108
+ return NULL ;
109
+ }
110
+ return json ;
111
+ }
112
+
113
+
87
114
char *
88
115
assemble_metadata (const char * band_json ) {
89
116
/* format is
@@ -179,7 +206,17 @@ export_imaging_schema(Imaging im, struct ArrowSchema *schema) {
179
206
}
180
207
181
208
if (im -> bands == 1 ) {
182
- return export_named_type (schema , im -> arrow_band_format , im -> band_names [0 ]);
209
+ retval = export_named_type (schema , im -> arrow_band_format , im -> band_names [0 ]);
210
+ if (retval != 0 ) {
211
+ return retval ;
212
+ }
213
+ // band related metadata
214
+ band_json = single_band_json (im );
215
+ if (band_json ) {
216
+ schema -> metadata = assemble_metadata (band_json );
217
+ free (band_json );
218
+ }
219
+ return retval ;
183
220
}
184
221
185
222
retval = export_named_type (schema , "+w:4" , "" );
You can’t perform that action at this time.
0 commit comments