FieldStudiesCouncil / QGIS-Biological-Recording-Tools

QGIS plugin for biological recorders. Created with the FSC Tomorrow's Biodiversity project.
GNU General Public License v3.0
10 stars 4 forks source link

Filtering on common name not working as expected #50

Closed burkmarr closed 3 years ago

burkmarr commented 3 years ago

From an email from Patrick Cook (Butterfly Conservation)...

I’ve been importing records of Small Pearl-bordered Fritillary and Pearl-bordered Fritillary using the biological records tool. When I use the scientific names I noticed the data looks correct. However when I use the English names and try to import just the Pearl-bordered Fritillary records it also brings in Small-Pearl bordered Fritillary too, confirmed by checking the attribute table of the resulting layer. I’m guessing it doesn’t look for an exact match from the csv?

potsherd commented 3 years ago

I had a similar problem with the Taxon Metadata layer. The code in the saveComposerImage function in biorecdialog.py allows for white space at both ends of the regular expression match, as indicated by the comment in the code:

#The regular expression (~ comparison) allows for leading and trailing white space on the taxa
  strFilter = '"%s" ~ \' *%s *\'' % ("Taxon", nameReplace)

But because the re is not anchored it will also match sub-strings in the Taxon name. I think the re here should be:

`strFilter = '"%s" ~ \'^ %s $\'' % ("Taxon", nameReplace)

`