diff --git a/file_manager/n100/file_manager_buildings.py b/file_manager/n100/file_manager_buildings.py index 5d4b600a..d494a9f2 100644 --- a/file_manager/n100/file_manager_buildings.py +++ b/file_manager/n100/file_manager_buildings.py @@ -107,13 +107,6 @@ class Building_N100(Enum): reflecting the specific needs and naming conventions of river data management within the project. """ - displacement_feature_asker__displacement_feature_asker__n100 = ( - file_manager.generate_file_name_gdb( - script_source_name=displacement_feature_asker, - description="displacement_feature_asker", - ) - ) - ################################################# ########### BUILDING DATA PREPARATION ########### ################################################# diff --git a/generalization/n100/building/building_polygon_displacement_rbc.py b/generalization/n100/building/building_polygon_displacement_rbc.py index 5807f171..13796712 100644 --- a/generalization/n100/building/building_polygon_displacement_rbc.py +++ b/generalization/n100/building/building_polygon_displacement_rbc.py @@ -86,9 +86,7 @@ def propagate_displacement_building_polygons(): such as roads or other structures. """ - print( - "Before executing this function, ensure to switch to the new displacement feature" - ) + print("MAKE SURE TO SWITCH TO NEW DISPLACEMENT FEATURE (AFTER ROAD GENERALIZATION") print("Propogate displacement ...") # Copying layer so no changes are made to the original diff --git a/generalization/n100/building/calculating_values.py b/generalization/n100/building/calculating_values.py index 88238671..9686b927 100644 --- a/generalization/n100/building/calculating_values.py +++ b/generalization/n100/building/calculating_values.py @@ -243,18 +243,33 @@ def table_management(): fields_to_add = [["angle", "LONG"], ["hierarchy", "LONG"], ["invisibility", "LONG"]] fields_to_calculate = [["angle", "0"], ["hierarchy", "0"], ["invisibility", "0"]] - # Add fields - arcpy.management.AddFields( - in_table=Building_N100.table_management__bygningspunkt_pre_resolve_building_conflicts__n100.value, - field_description=fields_to_add, + # Feature class to check fields existence + point_feature_class = ( + Building_N100.table_management__bygningspunkt_pre_resolve_building_conflicts__n100.value ) - # Calculate fields - arcpy.management.CalculateFields( - in_table=Building_N100.table_management__bygningspunkt_pre_resolve_building_conflicts__n100.value, - expression_type="PYTHON3", - fields=fields_to_calculate, - ) + # Check if fields already exist + existing_fields = arcpy.ListFields(point_feature_class) + existing_field_names = [field.name.lower() for field in existing_fields] + fields_to_add_names = [field[0].lower() for field in fields_to_add] + + if not all( + field_name in existing_field_names for field_name in fields_to_add_names + ): + # Add fields + arcpy.management.AddFields( + in_table=point_feature_class, + field_description=fields_to_add, + ) + + # Calculate fields + arcpy.management.CalculateFields( + in_table=point_feature_class, + expression_type="PYTHON3", + fields=fields_to_calculate, + ) + else: + print("Fields already exist. Skipping adding and calculating fields.") code_block_hierarchy = """def determineHierarchy(symbol_val):\n if symbol_val in [1, 2, 3]:\n diff --git a/generalization/n100/building/create_simplified_building_polygons.py b/generalization/n100/building/create_simplified_building_polygons.py index 987e78e5..e6b3f896 100644 --- a/generalization/n100/building/create_simplified_building_polygons.py +++ b/generalization/n100/building/create_simplified_building_polygons.py @@ -33,14 +33,10 @@ def main(): 3. `joining_and_adding_fields`: Reduces clusters to one point for each cluster. """ - print( - "The Order here was removed it seems like, not sure which is the intended model. But needs to be looked at" - ) aggregate_polygons() simplify_buildings_1() simplify_polygons() simplify_buildings_2() - join_and_add_fields()