In my plugin I iterate through 8 different line layers and add only certain lines to a list. This list I add to a new vector layer because these lines are the only ones I care about. However, I need to know which lines in the new layer were the same as the old ones. when building the original list I make a dictionary and keep track of which lines are associated with certain other features.
Here is my code that attempts to go through and find the lines in the new layer that are the same as the original list but I get no matches
self.final_lines.dataProvider().addFeatures(final_lines) # final lines is list of lines from different sources
QgsProject.instance().addMapLayer(self.final_lines)
self.final_lines_features = [feat for feat in self.final_lines.getFeatures()]
for line in final_lines:
for lin in self.final_lines_features:
if line.geometry() == lin.geometry():
print(f'geometries are equal for {line.id()} in list and {lin.id()} in final layer')
if line == lin:
print(f'features are equal for {line.id()} in list and {lin.id()} in final layer')
else:
print(f'features are NOT equal for {line.id()} in list and {lin.id()} in final layer')
This code prints nothing out. So I'm guessing I need to do something special when adding the lines to the final layer instead of just adding them as I do here, but I'm not sure what to do.