Skip to content
Snippets Groups Projects
Commit 3aba5dba authored by Jesse Mapel's avatar Jesse Mapel
Browse files

Added check for repeated fields in protobuf

parent 162bc90f
No related branches found
No related tags found
No related merge requests found
......@@ -270,6 +270,9 @@ class IsisStore(object):
arr = arr.ravel().tolist()
point_spec.aprioriCovar.extend(arr)
# If field is repeated you must extend instead of assign
elif cnf._CONTROLPOINTFILEENTRYV0002.fields_by_name[attr].label == 3:
getattr(point_spec, attr).extend(g.iloc[0][df_attr])
else:
setattr(point_spec, attr, attrtype(g.iloc[0][df_attr]))
......@@ -284,7 +287,11 @@ class IsisStore(object):
# Un-mangle common attribute names between points and measures
df_attr = self.measure_field_map.get(attr, attr)
if df_attr in g.columns:
setattr(measure_spec, attr, attrtype(m[df_attr]))
# If field is repeated you must extend instead of assign
if cnf._CONTROLPOINTFILEENTRYV0002_MEASURE.fields_by_name[attr].label == 3:
getattr(measure_spec, attr).extend(m[df_attr])
else:
setattr(measure_spec, attr, attrtype(m[df_attr]))
# ISIS pixels are centered on (0.5, 0.5). NDArrays are (0,0) based.
measure_spec.sample = m['sample'] + 0.5
measure_spec.line = m['line'] + 0.5
......
......@@ -39,12 +39,12 @@ class TestWriteIsisControlNetwork(unittest.TestCase):
serial_times = {295: '1971-07-31T01:24:11.754',
296: '1971-07-31T01:24:36.970'}
cls.serials = {i:'APOLLO15/METRIC/{}'.format(j) for i, j in enumerate(serial_times.values())}
columns = ['id', 'pointType', 'serialnumber', 'measureType', 'sample', 'line', 'image_index']
columns = ['id', 'pointType', 'serialnumber', 'measureType', 'sample', 'line', 'image_index', 'pointLog', 'measureLog']
data = []
for i in range(cls.npts):
data.append((i, 2, cls.serials[0], 2, 0, 0, 0))
data.append((i, 2, cls.serials[1], 2, 0, 0, 1))
data.append((i, 2, cls.serials[0], 2, 0, 0, 0, [], []))
data.append((i, 2, cls.serials[1], 2, 0, 0, 1, [], []))
df = pd.DataFrame(data, columns=columns)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment