Skip to content

Commit

Permalink
feat: calculate coordinates of additional in xlsform entity (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujanadh authored Nov 22, 2024
1 parent 720dd47 commit daf8874
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion osm_fieldwork/update_xlsform.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,22 @@ def append_select_one_from_file_row(df: pd.DataFrame, entity_name: str) -> pd.Da
}
)

# Prepare the row for calculating coordinates based on the additional entity
coordinates_row = pd.DataFrame(
{
"type": ["calculate"],
"name": ["additional_geometry"],
"calculation": [f"instance('{entity_name}')/root/item[name=${entity_name}]/geometry"],
"label::English(en)": ["additional_geometry"],
"label::Swahili(sw)": ["additional_geometry"],
"label::French(fr)": ["additional_geometry"],
"label::Spanish(es)": ["additional_geometry"],
}
)
# Insert the new row into the DataFrame
top_df = df.iloc[:row_index_to_split_on]
bottom_df = df.iloc[row_index_to_split_on:]
return pd.concat([top_df, additional_row, bottom_df], ignore_index=True)
return pd.concat([top_df, additional_row, coordinates_row, bottom_df], ignore_index=True)


async def append_mandatory_fields(
Expand Down

0 comments on commit daf8874

Please sign in to comment.