diff --git a/PreCourlis/processing/import_points_algorithm.py b/PreCourlis/processing/import_points_algorithm.py index c33b16bed5c0d8e86ca0d8f21881ceb154a09c68..81bf60ddbe1c07c994f703b2bab7c27eba5e3589 100644 --- a/PreCourlis/processing/import_points_algorithm.py +++ b/PreCourlis/processing/import_points_algorithm.py @@ -13,7 +13,7 @@ from PreCourlis.processing.precourlis_algorithm import PreCourlisAlgorithm class ImportPointsAlgorithm(PreCourlisAlgorithm): TRACKS = "TRACKS" - TRACKS_FIELD_SEC_NAME = "TRACKS_FIELD_SEC_NAME" + TRACKS_FIELD_SEC_ID = "TRACKS_FIELD_SEC_ID" AXIS = "AXIS" SOURCE_POINTS = "SOURCE_POINTS" SOURCE_FIELD_Z = "SOURCE_FIELD_Z" @@ -31,10 +31,10 @@ class ImportPointsAlgorithm(PreCourlisAlgorithm): ) self.addParameter( QgsProcessingParameterField( - self.TRACKS_FIELD_SEC_NAME, - self.tr("Tracks section name field"), + self.TRACKS_FIELD_SEC_ID, + self.tr("Tracks unique identifier field"), parentLayerParameterName=self.TRACKS, - defaultValue="sec_name", + defaultValue="sec_id", ) ) self.addParameter( @@ -89,7 +89,7 @@ class ImportPointsAlgorithm(PreCourlisAlgorithm): alg_params = { "SOURCE_POINTS": parameters[self.SOURCE_POINTS], "TARGET_PROFILES": parameters[self.TRACKS], - "TARGET_PROFILES_FIELD_SEC_NAME": parameters[self.TRACKS_FIELD_SEC_NAME], + "TARGET_PROFILES_FIELD_SEC_ID": parameters[self.TRACKS_FIELD_SEC_ID], "BUFFER_DISTANCE": parameters[self.BUFFER_DISTANCE], "OUTPUT": QgsProcessing.TEMPORARY_OUTPUT, } @@ -109,10 +109,10 @@ class ImportPointsAlgorithm(PreCourlisAlgorithm): # import_prepared_points alg_params = { "TRACKS": parameters[self.TRACKS], - "TRACKS_FIELD_SEC_NAME": parameters[self.TRACKS_FIELD_SEC_NAME], + "TRACKS_FIELD_SEC_ID": parameters[self.TRACKS_FIELD_SEC_ID], "AXIS": parameters[self.AXIS], "SOURCE_POINTS": joined_points, - "SOURCE_FIELD_SEC_NAME": "sec_name", + "SOURCE_FIELD_SEC_ID": parameters[self.TRACKS_FIELD_SEC_ID], "SOURCE_FIELD_Z": parameters[self.SOURCE_FIELD_Z], "OUTPUT": parameters[self.OUTPUT], } diff --git a/PreCourlis/processing/import_prepared_points_algorithm.py b/PreCourlis/processing/import_prepared_points_algorithm.py index 0eb2dc66fa2509fdd161f192da84ffad8a1bc666..71a5033b2260d6694ae1e096e06d72c8ab620293 100644 --- a/PreCourlis/processing/import_prepared_points_algorithm.py +++ b/PreCourlis/processing/import_prepared_points_algorithm.py @@ -20,10 +20,10 @@ from PreCourlis.processing.precourlis_algorithm import PreCourlisAlgorithm class ImportPreparedPointsAlgorithm(PreCourlisAlgorithm): TRACKS = "TRACKS" - TRACKS_FIELD_SEC_NAME = "TRACKS_FIELD_SEC_NAME" + TRACKS_FIELD_SEC_ID = "TRACKS_FIELD_SEC_ID" AXIS = "AXIS" SOURCE_POINTS = "SOURCE_POINTS" - SOURCE_FIELD_SEC_NAME = "SOURCE_FIELD_SEC_NAME" + SOURCE_FIELD_SEC_ID = "SOURCE_FIELD_SEC_ID" SOURCE_FIELD_Z = "SOURCE_FIELD_Z" OUTPUT = "OUTPUT" @@ -38,10 +38,10 @@ class ImportPreparedPointsAlgorithm(PreCourlisAlgorithm): ) self.addParameter( QgsProcessingParameterField( - self.TRACKS_FIELD_SEC_NAME, - self.tr("Tracks section name field"), + self.TRACKS_FIELD_SEC_ID, + self.tr("Tracks identifier field"), parentLayerParameterName=self.TRACKS, - defaultValue="sec_name", + defaultValue="sec_id", ) ) self.addParameter( @@ -62,10 +62,10 @@ class ImportPreparedPointsAlgorithm(PreCourlisAlgorithm): ) self.addParameter( QgsProcessingParameterField( - self.SOURCE_FIELD_SEC_NAME, - self.tr("Source section name field"), + self.SOURCE_FIELD_SEC_ID, + self.tr("Source tracks identifier field"), parentLayerParameterName=self.SOURCE_POINTS, - defaultValue=None, + defaultValue="sec_id", ) ) self.addParameter( @@ -88,8 +88,8 @@ class ImportPreparedPointsAlgorithm(PreCourlisAlgorithm): def processAlgorithm(self, parameters, context, feedback): tracks_source = self.parameterAsSource(parameters, self.TRACKS, context) - tracks_field_sec_name = self.parameterAsString( - parameters, self.TRACKS_FIELD_SEC_NAME, context + tracks_field_sec_id = self.parameterAsString( + parameters, self.TRACKS_FIELD_SEC_ID, context ) axis_source = self.parameterAsSource(parameters, self.AXIS, context) @@ -98,8 +98,8 @@ class ImportPreparedPointsAlgorithm(PreCourlisAlgorithm): source_points_source = self.parameterAsSource( parameters, self.SOURCE_POINTS, context ) - source_field_sec_name = self.parameterAsString( - parameters, self.SOURCE_FIELD_SEC_NAME, context + source_field_sec_id = self.parameterAsString( + parameters, self.SOURCE_FIELD_SEC_ID, context ) source_field_z = self.parameterAsString( parameters, self.SOURCE_FIELD_Z, context @@ -123,7 +123,7 @@ class ImportPreparedPointsAlgorithm(PreCourlisAlgorithm): request = QgsFeatureRequest() request.setFilterExpression( - f"{source_field_sec_name} = '{track.attribute(tracks_field_sec_name)}'" + f"{source_field_sec_id} = '{track.attribute(tracks_field_sec_id)}'" ) source_points_features = list(source_points_source.getFeatures(request)) @@ -158,7 +158,6 @@ class ImportPreparedPointsAlgorithm(PreCourlisAlgorithm): intersection_point = intersection.constGet().clone() abs_long = axis.geometry().lineLocatePoint(intersection) - # sec_name = track.attribute(tracks_field_sec_name) sec_name = "{}_{:04.3f}".format("P" if abs_long >= 0 else "N", abs_long) axis_x = intersection_point.x() axis_y = intersection_point.y() diff --git a/PreCourlis/processing/join_points_to_profiles_algorithm.py b/PreCourlis/processing/join_points_to_profiles_algorithm.py index accee381969d35f9c2e1609cb1052b3acf64ab7b..fcfe1bed1a6aa59658c531e3ac8d60032d5c8e9c 100644 --- a/PreCourlis/processing/join_points_to_profiles_algorithm.py +++ b/PreCourlis/processing/join_points_to_profiles_algorithm.py @@ -18,7 +18,7 @@ from PreCourlis.processing.precourlis_algorithm import PreCourlisAlgorithm class JoinPointsToProfilesAlgorithm(PreCourlisAlgorithm): SOURCE_POINTS = "SOURCE_POINTS" TARGET_PROFILES = "TARGET_PROFILES" - TARGET_PROFILES_FIELD_SEC_NAME = "TARGET_PROFILES_FIELD_SEC_NAME" + TARGET_PROFILES_FIELD_SEC_ID = "TARGET_PROFILES_FIELD_SEC_ID" BUFFER_DISTANCE = "BUFFER_DISTANCE" OUTPUT = "OUTPUT" @@ -41,10 +41,10 @@ class JoinPointsToProfilesAlgorithm(PreCourlisAlgorithm): ) self.addParameter( QgsProcessingParameterField( - self.TARGET_PROFILES_FIELD_SEC_NAME, - self.tr("Target profiles section name field"), + self.TARGET_PROFILES_FIELD_SEC_ID, + self.tr("Target profiles unique identifier field"), parentLayerParameterName=self.TARGET_PROFILES, - defaultValue="sec_name", + defaultValue="sec_id", optional=True, ) ) @@ -70,8 +70,8 @@ class JoinPointsToProfilesAlgorithm(PreCourlisAlgorithm): feedback = QgsProcessingMultiStepFeedback(3, model_feedback) outputs = {} - target_profiles_field_sec_name = self.parameterAsFields( - parameters, self.TARGET_PROFILES_FIELD_SEC_NAME, context + target_profiles_field_sec_id = self.parameterAsFields( + parameters, self.TARGET_PROFILES_FIELD_SEC_ID, context ) source_points_source = self.parameterAsSource( @@ -122,7 +122,7 @@ class JoinPointsToProfilesAlgorithm(PreCourlisAlgorithm): "INPUT": parameters[self.SOURCE_POINTS], "PREDICATE": [0], "JOIN": outputs["Buffer"]["OUTPUT"], - "JOIN_FIELDS": target_profiles_field_sec_name, + "JOIN_FIELDS": target_profiles_field_sec_id, "METHOD": 0, "DISCARD_NONMATCHING": False, "PREFIX": "", diff --git a/test/processing/test_import_points.py b/test/processing/test_import_points.py index 79aebc0bfb29938b1bb931b23ba2c0004bcfd862..b63d3ac2b090a5ebf120eca68bb6c888f52a5b73 100644 --- a/test/processing/test_import_points.py +++ b/test/processing/test_import_points.py @@ -13,10 +13,10 @@ class TestImportPointsAlgorithm(TestCase): ALGORITHM_ID = "precourlis:import_points" DEFAULT_PARAMS = { "TRACKS": TRACKS_PATH, - "TRACKS_FIELD_SEC_NAME": "sec_name", + "TRACKS_FIELD_SEC_ID": "sec_name", "AXIS": AXIS_PATH, "SOURCE_POINTS": SOURCE_POINTS_PATH, - "SOURCE_FIELD_SEC_NAME": "sec_name", + "SOURCE_FIELD_SEC_ID": "sec_name", "SOURCE_FIELD_Z": "ELEVATION", "BUFFER_DISTANCE": 1.0, } diff --git a/test/processing/test_import_prepared_points.py b/test/processing/test_import_prepared_points.py index 2c19ce937ba8b5459da72fa1503bf59bb071db00..9cedd9b0a4b4ca8cd9ebeae8952bc4b86c241b1c 100644 --- a/test/processing/test_import_prepared_points.py +++ b/test/processing/test_import_prepared_points.py @@ -13,10 +13,10 @@ class TestImportPreparedPointsAlgorithm(TestCase): ALGORITHM_ID = "precourlis:import_prepared_points" DEFAULT_PARAMS = { "TRACKS": TRACKS_PATH, - "TRACKS_FIELD_SEC_NAME": "sec_name", + "TRACKS_FIELD_SEC_ID": "sec_name", "AXIS": AXIS_PATH, "SOURCE_POINTS": SOURCE_POINTS_PATH, - "SOURCE_FIELD_SEC_NAME": "sec_name", + "SOURCE_FIELD_SEC_ID": "sec_name", "SOURCE_FIELD_Z": "ELEVATION", } diff --git a/test/processing/test_join_points_to_profiles_algorithm.py b/test/processing/test_join_points_to_profiles_algorithm.py index ad74141b52eb1aa7189f27a7be0325d889ea70fb..c8be1a401222dead25c1b7999c425a0431417416 100644 --- a/test/processing/test_join_points_to_profiles_algorithm.py +++ b/test/processing/test_join_points_to_profiles_algorithm.py @@ -14,7 +14,7 @@ class TestJoinPointsToProfilesAlgorithm(TestCase): DEFAULT_PARAMS = { "SOURCE_POINTS": SOURCE_POINTS_PATH, "TARGET_PROFILES": TARGET_PROFILES_PATH, - # "TARGET_PROFILES_FIELD_SEC_NAME": "sec_name", + "TARGET_PROFILES_FIELD_SEC_ID": "sec_name", "BUFFER_DISTANCE": 1.0, }