Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dieuska committed Feb 11, 2025
1 parent a18bd07 commit 201205a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 67 deletions.
21 changes: 16 additions & 5 deletions plugin/brdrq/brdrq_dockwidget_aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,29 @@ def onSpinboxChange(self, value):
self.horizontalSlider.setValue(index)
print("onSpinboxChange: value -> " + str(value))

# self.change_geometry()
layer_result = get_layer_by_name(self.LAYER_RESULT)
layer_result_diff = get_layer_by_name(self.LAYER_RESULT_DIFF)
layer_result_diff_min = get_layer_by_name(self.LAYER_RESULT_DIFF_MIN)
layer_result_diff_plus = get_layer_by_name(self.LAYER_RESULT_DIFF_PLUS)

if layer_result is None or layer_result_diff is None or layer_result_diff_min is None or layer_result_diff_plus is None:
self.add_results_to_grouplayer()
layer_result = get_layer_by_name(self.LAYER_RESULT)
layer_result_diff = get_layer_by_name(self.LAYER_RESULT_DIFF)
layer_result_diff_min = get_layer_by_name(self.LAYER_RESULT_DIFF_MIN)
layer_result_diff_plus = get_layer_by_name(self.LAYER_RESULT_DIFF_PLUS)

# Filter layers based on relevant distance
get_layer_by_name(self.LAYER_RESULT).setSubsetString(
layer_result.setSubsetString(
f"brdr_relevant_distance = {value}"
)
get_layer_by_name(self.LAYER_RESULT_DIFF).setSubsetString(
layer_result_diff.setSubsetString(
f"brdr_relevant_distance = {value}"
)
get_layer_by_name(self.LAYER_RESULT_DIFF_MIN).setSubsetString(
layer_result_diff_min.setSubsetString(
f"brdr_relevant_distance = {value}"
)
get_layer_by_name(self.LAYER_RESULT_DIFF_PLUS).setSubsetString(
layer_result_diff_plus.setSubsetString(
f"brdr_relevant_distance = {value}"
)
self.get_wkt()
Expand Down
66 changes: 35 additions & 31 deletions plugin/brdrq/brdrq_dockwidget_bulkaligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,41 @@ def evaluate_layer(self):
self.diffs_dict = diffs_from_dict_processresults(
self.dict_processresults, self.aligner.dict_thematic
)
self.add_results_to_grouplayer()

# set list with predicted values
self.listWidget_predictions.clear()
# TODO, loop over predictions en voeg toe met boodschap
items = []
items_with_name = []
best_index = 0
best_score = 0
list_predictions = [k for k in (self.dict_evaluated_predictions[key]).keys()]
print(str(list_predictions))
for k in list_predictions:
print(str(k))
items.append(str(k))
score = self.props_dict_evaluated_predictions[key][k][PREDICTION_SCORE]
evaluation = self.props_dict_evaluated_predictions[key][k][
EVALUATION_FIELD_NAME
]
items_with_name.append(f"{str(k)}: {str(evaluation)} (score: {str(score)})")
if score > best_score:
best_score = score
best_index = list_predictions.index(k)
print("best index: " + str(best_index))
self.listWidget_predictions.setFocus()
self.listWidget_predictions.addItems(items_with_name)
if len(items) > 0:
self.listWidget_predictions.setCurrentRow(best_index)
print ("best-index: "+str(items[best_index]))
self.doubleSpinBox.setValue(round(float(items[best_index]), self.settingsDialog.DECIMAL))
else:
self.textEdit_output.setText("No predictions")
self.progressBar.setValue(100)
return

def add_results_to_grouplayer(self):
fcs = self.aligner.get_results_as_geojson(
resulttype=AlignerResultType.PROCESSRESULTS, formula=self.formula
)
Expand Down Expand Up @@ -322,39 +356,9 @@ def evaluate_layer(self):
self.workinggroupname,
self.tempfolder,
)

# set list with predicted values
self.listWidget_predictions.clear()
# TODO, loop over predictions en voeg toe met boodschap
items = []
items_with_name = []
best_index = 0
best_score = 0
list_predictions = [k for k in (self.dict_evaluated_predictions[key]).keys()]
print(str(list_predictions))
for k in list_predictions:
print(str(k))
items.append(str(k))
score = self.props_dict_evaluated_predictions[key][k][PREDICTION_SCORE]
evaluation = self.props_dict_evaluated_predictions[key][k][
EVALUATION_FIELD_NAME
]
items_with_name.append(f"{str(k)}: {str(evaluation)} (score: {str(score)})")
if score > best_score:
best_score = score
best_index = list_predictions.index(k)
print("best index: " + str(best_index))
self.listWidget_predictions.setFocus()
self.listWidget_predictions.addItems(items_with_name)
if len(items) > 0:
self.listWidget_predictions.setCurrentRow(best_index)
print ("best-index: "+str(items[best_index]))
self.doubleSpinBox.setValue(round(float(items[best_index]), self.settingsDialog.DECIMAL))
else:
self.textEdit_output.setText("No predictions")
self.progressBar.setValue(100)
return


def prepareFeatureList(self):
#self.clearUserInterface()
# Add the selected features to the list widget
Expand Down
65 changes: 34 additions & 31 deletions plugin/brdrq/brdrq_dockwidget_featurealigner.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,43 @@ def _onFeatureChange(self, currentItem):
# do alignment/prediction
self._align()

self.add_results_to_grouplayer()

# set list with predicted values
self.listWidget_predictions.clear()
# TODO, loop over predictions en voeg toe met boodschap
items = []
items_with_name = []
best_index = 0
best_score = 0
list_predictions = [k for k in (self.dict_evaluated_predictions[key]).keys()]
print(str(list_predictions))
for k in list_predictions:
print(str(k))
items.append(str(k))
score = self.props_dict_evaluated_predictions[key][k][PREDICTION_SCORE]
evaluation = self.props_dict_evaluated_predictions[key][k][
EVALUATION_FIELD_NAME
]
items_with_name.append(f"{str(k)}: {str(evaluation)} (score: {str(score)})")
if score > best_score:
best_score = score
best_index = list_predictions.index(k)
print("best index: " + str(best_index))
self.listWidget_predictions.setFocus()
self.listWidget_predictions.addItems(items_with_name)
if len(items) > 0:
self.listWidget_predictions.setCurrentRow(best_index)
print ("best-index: "+str(items[best_index]))
self.doubleSpinBox.setValue(round(float(items[best_index]), self.settingsDialog.DECIMAL))
else:
self.textEdit_output.setText("No predictions")
return

def add_results_to_grouplayer(self):
fcs = self.aligner.get_results_as_geojson(
resulttype=AlignerResultType.PROCESSRESULTS, formula=self.formula
)

geojson_to_layer(
self.LAYER_RESULT_DIFF,
fcs["result_diff"],
Expand Down Expand Up @@ -282,36 +315,6 @@ def _onFeatureChange(self, currentItem):
self.GROUP_LAYER,
self.tempfolder,
)

# set list with predicted values
self.listWidget_predictions.clear()
# TODO, loop over predictions en voeg toe met boodschap
items = []
items_with_name = []
best_index = 0
best_score = 0
list_predictions = [k for k in (self.dict_evaluated_predictions[key]).keys()]
print(str(list_predictions))
for k in list_predictions:
print(str(k))
items.append(str(k))
score = self.props_dict_evaluated_predictions[key][k][PREDICTION_SCORE]
evaluation = self.props_dict_evaluated_predictions[key][k][
EVALUATION_FIELD_NAME
]
items_with_name.append(f"{str(k)}: {str(evaluation)} (score: {str(score)})")
if score > best_score:
best_score = score
best_index = list_predictions.index(k)
print("best index: " + str(best_index))
self.listWidget_predictions.setFocus()
self.listWidget_predictions.addItems(items_with_name)
if len(items) > 0:
self.listWidget_predictions.setCurrentRow(best_index)
print ("best-index: "+str(items[best_index]))
self.doubleSpinBox.setValue(round(float(items[best_index]), self.settingsDialog.DECIMAL))
else:
self.textEdit_output.setText("No predictions")
return

def onListItemActivated(self, currentItem):
Expand Down

0 comments on commit 201205a

Please sign in to comment.