Skip to content

Commit

Permalink
Merge pull request #122 from ricardogsilva/121-remove-distance_thresh…
Browse files Browse the repository at this point in the history
…old-processing-param-#121

Removed distance_threshold processing parameter
  • Loading branch information
ricardogsilva authored Oct 17, 2024
2 parents a64ce4c + e43ae78 commit ae5dafa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 50 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Improved user guide

### Removed
- Removed distance_threshold processing parameter - it was not used in the main plugin dialog



## [2.0.0-rc6] - 2024-10-16
Expand Down
16 changes: 6 additions & 10 deletions src/qgis_conefor/coneforinputsprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def generate_connection_file_with_centroid_distances(
start_progress: int = 0,
info_callback: Optional[Callable[[str], None]] = log,
cancelled_callback: Optional[Callable[[], bool]] = None,
distance_threshold: Optional[int] = None,
) -> Optional[Path]:
data = []
measurer = get_measurer(crs)
Expand All @@ -237,10 +236,9 @@ def generate_connection_file_with_centroid_distances(
pair_feat_id = pair_feat[node_id_field_name]
pair_centroid = pair_feat.geometry().centroid().asPoint()
centroid_distance = measurer.measureLine([feat_centroid, pair_centroid])
if distance_threshold is None or centroid_distance <= distance_threshold:
data.append((feat_id, pair_feat_id, centroid_distance))
current_progress += progress_step
progress_callback(int(current_progress))
data.append((feat_id, pair_feat_id, centroid_distance))
current_progress += progress_step
progress_callback(int(current_progress))
else:
# this `else` block belongs to the inner `for` block and
# it gets executed if the `for` loop is able to run until
Expand Down Expand Up @@ -278,7 +276,6 @@ def generate_connection_file_with_edge_distances(
start_progress: int = 0,
info_callback: Optional[Callable[[str], None]] = log,
cancelled_callback: Optional[Callable[[], bool]] = None,
distance_threshold: Optional[int] = None,
) -> Optional[Path]:
data = []
if crs.isGeographic():
Expand Down Expand Up @@ -310,10 +307,9 @@ def generate_connection_file_with_edge_distances(
if transformer is not None:
pair_feat_geom.transform(transformer)
edge_distance = feat_geom.distance(pair_feat_geom)
if distance_threshold is None or edge_distance <= distance_threshold:
data.append((feat_id, pair_feat_id, edge_distance))
current_progress += progress_step
progress_callback(int(current_progress))
data.append((feat_id, pair_feat_id, edge_distance))
current_progress += progress_step
progress_callback(int(current_progress))
else:
# this `else` block belongs to the inner `for` block and
# it gets executed if the `for` loop is able to run until
Expand Down
40 changes: 0 additions & 40 deletions src/qgis_conefor/processing/algorithms/coneforinputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ConeforInputsBase(base.Base):
"nodes_to_add_attribute",
"Which attribute to use for the 'nodes to add' Conefor feature"
)
INPUT_DISTANCE_THRESHOLD = ("distance_threshold", "Distance threshold")
INPUT_OUTPUT_DIRECTORY = ("output_dir", "Output directory for generated Conefor input files")
OUTPUT_CONEFOR_NODES_FILE_PATH = ("output_path", "Conefor nodes file")
OUTPUT_CONEFOR_CONNECTIONS_FILE_PATH = ("output_connections_path", "Conefor connections file")
Expand Down Expand Up @@ -114,7 +113,6 @@ def _generate_connection_file_by_centroid_distance(
source: qgis.core.QgsProcessingFeatureSource,
output_dir: Path,
filename_fragment: str,
distance_threshold: Optional[int],
feedback: qgis.core.QgsProcessingFeedback,
progress_step: float,
start_progress: int = 0,
Expand All @@ -133,7 +131,6 @@ def _generate_connection_file_by_centroid_distance(
progress_step=progress_step,
info_callback=feedback.pushInfo,
cancelled_callback=feedback.isCanceled,
distance_threshold=distance_threshold,
)
)

Expand Down Expand Up @@ -185,15 +182,6 @@ def initAlgorithm(self, configuration=None):
optional=True,
)
)
self.addParameter(
qgis.core.QgsProcessingParameterNumber(
name=self.INPUT_DISTANCE_THRESHOLD[0],
description=self.tr(self.INPUT_DISTANCE_THRESHOLD[1]),
type=qgis.core.QgsProcessingParameterNumber.Integer,
optional=True,
minValue=0,
)
)
self.addParameter(
qgis.core.QgsProcessingParameterFolderDestination(
name=self.INPUT_OUTPUT_DIRECTORY[0],
Expand Down Expand Up @@ -229,12 +217,6 @@ def processAlgorithm(self, parameters, context, feedback):
node_id_field_name = None
else:
node_id_field_name = raw_node_id_field_name
raw_distance_threshold = self.parameterAsString(
parameters, self.INPUT_DISTANCE_THRESHOLD[0], context)
if raw_distance_threshold == "":
connections_distance_threshold = None
else:
connections_distance_threshold = int(raw_distance_threshold)
output_dir = Path(
self.parameterAsFile(
parameters,
Expand All @@ -259,7 +241,6 @@ def processAlgorithm(self, parameters, context, feedback):
feedback.pushInfo(f"{node_id_field_name=}")
feedback.pushInfo(f"{node_attribute_field_name=}")
feedback.pushInfo(f"{nodes_to_add_field_name=}")
feedback.pushInfo(f"{connections_distance_threshold=}")
feedback.pushInfo(f"{output_dir=}")

result = {
Expand Down Expand Up @@ -325,7 +306,6 @@ def processAlgorithm(self, parameters, context, feedback):
source,
output_dir,
results_name_fragment,
connections_distance_threshold,
feedback,
start_progress=(100 - remaining_progress),
progress_step=progress_step,
Expand Down Expand Up @@ -422,15 +402,6 @@ def initAlgorithm(self, configuration=None):
defaultValue=NodeConnectionType.EDGE_DISTANCE.value
)
)
self.addParameter(
qgis.core.QgsProcessingParameterNumber(
name=self.INPUT_DISTANCE_THRESHOLD[0],
description=self.tr(self.INPUT_DISTANCE_THRESHOLD[1]),
type=qgis.core.QgsProcessingParameterNumber.Integer,
optional=True,
minValue=0,
)
)
self.addParameter(
qgis.core.QgsProcessingParameterFolderDestination(
name=self.INPUT_OUTPUT_DIRECTORY[0],
Expand Down Expand Up @@ -480,12 +451,6 @@ def processAlgorithm(self, parameters, context, feedback):
]
)
feedback.pushInfo(f"{connections_distance_method.value=} ")
raw_distance_threshold = self.parameterAsString(
parameters, self.INPUT_DISTANCE_THRESHOLD[0], context)
if raw_distance_threshold == "":
connections_distance_threshold = None
else:
connections_distance_threshold = int(raw_distance_threshold)
output_dir = Path(
self.parameterAsFile(
parameters,
Expand Down Expand Up @@ -514,7 +479,6 @@ def processAlgorithm(self, parameters, context, feedback):
feedback.pushInfo(f"{node_id_field_name=}")
feedback.pushInfo(f"{nodes_to_add_field_name=}")
feedback.pushInfo(f"{connections_distance_method=}")
feedback.pushInfo(f"{connections_distance_threshold=}")
feedback.pushInfo(f"{output_dir=}")

result = {
Expand Down Expand Up @@ -600,7 +564,6 @@ def processAlgorithm(self, parameters, context, feedback):
source,
output_dir,
results_name_fragment,
connections_distance_threshold,
feedback,
start_progress=(100 - remaining_progress),
progress_step=progress_step,
Expand All @@ -611,7 +574,6 @@ def processAlgorithm(self, parameters, context, feedback):
source,
output_dir,
results_name_fragment,
connections_distance_threshold,
feedback,
start_progress=(100 - remaining_progress),
progress_step=progress_step,
Expand All @@ -630,7 +592,6 @@ def _generate_connection_file_by_edge_distance(
source: qgis.core.QgsProcessingFeatureSource,
output_dir: Path,
filename_fragment: str,
distance_threshold: Optional[int],
feedback: qgis.core.QgsProcessingFeedback,
start_progress: float,
progress_step: float,
Expand All @@ -647,7 +608,6 @@ def _generate_connection_file_by_edge_distance(
progress_step=progress_step,
info_callback=feedback.pushInfo,
cancelled_callback=feedback.isCanceled,
distance_threshold=distance_threshold
)
)

Expand Down

0 comments on commit ae5dafa

Please sign in to comment.