From daf887419d309ed1697a3a27e6e0f307adc17451 Mon Sep 17 00:00:00 2001 From: Sujan Adhikari <109404840+Sujanadh@users.noreply.github.com> Date: Fri, 22 Nov 2024 23:07:42 +0545 Subject: [PATCH] feat: calculate coordinates of additional in xlsform entity (#312) --- osm_fieldwork/update_xlsform.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/osm_fieldwork/update_xlsform.py b/osm_fieldwork/update_xlsform.py index cd50fcd3..fd249153 100644 --- a/osm_fieldwork/update_xlsform.py +++ b/osm_fieldwork/update_xlsform.py @@ -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(