Skip to content

Commit

Permalink
Processa distribution para fauna
Browse files Browse the repository at this point in the history
Closes #57
  • Loading branch information
Phenome committed Jan 10, 2024
1 parent c972bfc commit 41ea648
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/fauna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,27 @@ type FaunaJson = Record<
export const processaFauna = (dwcJson: FaunaJson): FaunaJson => {
return Object.fromEntries(
Object.entries(dwcJson).reduce((entries, [id, taxon]) => {
// const _distribution = taxon.distribution as Record<
// string,
// Record<string, string>
// >[]
const distribution = taxon.distribution as {
locality: string
countryCode: string
establishmentMeans: string
}[]
if (
!['ESPECIE', 'VARIEDADE', 'FORMA', 'SUB_ESPECIE'].includes(
taxon.taxonRank as string
)
) {
return entries
}
// if (distribution) {
// taxon.distribution = {
// origin: distribution[0]?.establishmentMeans,
// Endemism: distribution[0]?.occurrenceRemarks.endemism,
// phytogeographicDomains:
// distribution[0]?.occurrenceRemarks.phytogeographicDomain,
// occurrence: distribution.map(({ locationID }) => locationID).sort(),
// vegetationType: (
// taxon.speciesprofile as Record<string, Record<string, string>>[]
// )?.[0]?.lifeForm?.vegetationType
// }
// }
if (distribution) {
taxon.distribution = {
origin: distribution[0]?.establishmentMeans,
occurrence: distribution[0]?.locality
?.split(';')
.map((l) => `BR-${l}`),
countryCode: distribution[0]?.countryCode?.split(';')
}
}
if (taxon.resourcerelationship) {
const resourcerelationship = taxon.resourcerelationship as Record<
string,
Expand Down

0 comments on commit 41ea648

Please sign in to comment.