Skip to content

Commit

Permalink
List species found that do not match properties
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscant committed Feb 27, 2024
1 parent c6062c0 commit dde7e0d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
32 changes: 32 additions & 0 deletions mkdistmaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ let taxonLookupCurrent = false

const propertiesLookup = []
let propertiesLookupName = false
const speciesNotMatchedToProperties = []

// Get version from last git commit
const gitdescr = execSync('git describe --tags --long')
Expand Down Expand Up @@ -616,6 +617,8 @@ let lineno = 0
let records = 0
let empties = 0
const boxes = {} // gets a prop for each square, eg A10, NY51, and SD23L or NC1234
let excluded = 0
let included = 0

function updateSpeciesesGrids (TaxonName, box, Year, isGenus, fileSpecieses, inTotal, makeAllSpeciesMapTaxon, MoreInfo) {
// console.log('updateSpeciesesGrids', TaxonName, box, MoreInfo)
Expand Down Expand Up @@ -700,6 +703,29 @@ function processLine (file, row, fileSpecieses) {
}
}

function taxonmatchbasicwildcard (v) {
// console.log(TaxonName, v)
// console.log(TaxonName.substring(0, v.length - 1), v.substring(0, v.length - 1))
// console.log(TaxonName.substring(v.length - 1), v.substring(v.length - 1))
// exit
if (v.endsWith('*')) { if (TaxonName.substring(0, v.length - 1) === v.substring(0, v.length - 1)) return true }
if (v.startsWith('*')) { if (TaxonName.substring(v.length - 1) === v.substring(v.length - 1)) return true }
}
if (config.excludes) {
if (config.excludes.find(taxonmatchbasicwildcard)) {
excluded++
return
}
included++
}
if (config.includes) {
if (!config.includes.find(taxonmatchbasicwildcard)) {
excluded++
return
}
included++
}

records++

// Get other data fields
Expand Down Expand Up @@ -991,6 +1017,8 @@ async function importComplete (rowCount) {

console.log('Records:', records.toLocaleString('en'))
console.log('Empty rows:', empties)
console.log('Excluded rows:', excluded)
console.log('Included rows:', included)
console.log('Boxes:', Object.keys(boxes).length)

const dtEnd = new Date()
Expand Down Expand Up @@ -1260,6 +1288,8 @@ async function makeGeojson (rowCount) {
geojson.properties[field] = property[field]
}
}
} else if (speciesNotMatchedToProperties.indexOf(MapName) === -1) {
speciesNotMatchedToProperties.push(MapName)
}

geojson.features = []
Expand Down Expand Up @@ -1420,6 +1450,8 @@ async function makeGeojson (rowCount) {
}
}
console.log('Properties not matched:', propertiesNotMatched)
speciesNotMatchedToProperties.sort()
console.log('Species not matched to properties:', speciesNotMatchedToProperties.length, speciesNotMatchedToProperties.join(', '))
}
/// ////////////////////////////////////////////////////////////////////////////////////
// If called from command line, then run now.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mkdistmaps",
"version": "2.7.3",
"version": "2.7.4",
"description": "Make Distribution Maps from CSV file(s)",
"exports": "./mkdistmaps.js",
"type": "module",
Expand Down

0 comments on commit dde7e0d

Please sign in to comment.