@ca-plant-list/ca-plant-list 0.4.22 → 0.4.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/basepagerenderer.js +10 -4
- package/lib/ebook/images.js +3 -3
- package/lib/ebook/pages/{page_list_families.js → pageListFamilies.js} +1 -1
- package/lib/ebook/pages/{page_list_flowers.js → pageListFlowers.js} +2 -2
- package/lib/ebook/pages/page_list_species.js +1 -1
- package/lib/ebook/pages/taxonpage.js +1 -1
- package/lib/ebook/pages/tocpage.js +2 -2
- package/lib/ebook/plantbook.js +3 -3
- package/lib/externalsites.js +86 -37
- package/lib/flowercolor.js +2 -2
- package/lib/genera.js +4 -4
- package/lib/html.js +7 -8
- package/lib/htmltaxon.js +106 -27
- package/lib/index.d.ts +51 -16
- package/lib/index.js +3 -3
- package/lib/pagerenderer.js +6 -6
- package/lib/taxonomy/families.js +104 -0
- package/lib/{taxa.js → taxonomy/taxa.js} +18 -18
- package/lib/{taxon.js → taxonomy/taxon.js} +9 -108
- package/lib/taxonomy/taxonomy.js +17 -0
- package/lib/tools/calflora.js +2 -2
- package/lib/tools/calscape.js +3 -3
- package/lib/tools/cch2.js +3 -3
- package/lib/tools/fna.js +2 -2
- package/lib/tools/inat.js +3 -3
- package/lib/tools/jepsoneflora.js +1 -1
- package/lib/tools/rpi.js +3 -3
- package/lib/tools/supplementaltext.js +1 -1
- package/lib/types.js +10 -0
- package/lib/utils/inat-tools.js +2 -2
- package/lib/web/pageFamily.js +146 -0
- package/lib/web/pagetaxon.js +20 -56
- package/package.json +1 -1
- package/scripts/build-ebook.js +4 -4
- package/scripts/build-site.js +3 -3
- package/scripts/cpl-photos.js +1 -1
- package/scripts/cpl-tools.js +1 -1
- package/scripts/inatobsphotos.js +2 -2
- package/scripts/inattaxonphotos.js +2 -2
- package/lib/families.js +0 -243
- package/lib/jepson.js +0 -17
package/lib/index.d.ts
CHANGED
@@ -6,9 +6,26 @@ export type NativeStatusCode = "N" | "NC" | "U" | "X";
|
|
6
6
|
|
7
7
|
type PhotoRights = "CC0" | "CC BY" | "CC BY-NC" | "C" | null;
|
8
8
|
|
9
|
-
type RefSourceCode =
|
9
|
+
type RefSourceCode =
|
10
|
+
| "calflora"
|
11
|
+
| "calscape"
|
12
|
+
| "cch"
|
13
|
+
| "fna"
|
14
|
+
| "inat"
|
15
|
+
| "jepson"
|
16
|
+
| "rpi";
|
17
|
+
|
18
|
+
type TaxaColDef<T> = {
|
19
|
+
title: string;
|
20
|
+
class?: string;
|
21
|
+
data: (taxon: T) => string | number;
|
22
|
+
};
|
10
23
|
|
11
|
-
|
24
|
+
type TaxonomyData = {
|
25
|
+
"jepson id": string;
|
26
|
+
};
|
27
|
+
|
28
|
+
export type TaxonData = TaxonomyData & {
|
12
29
|
bloom_end: string;
|
13
30
|
bloom_start: string;
|
14
31
|
calrecnum: string;
|
@@ -22,7 +39,6 @@ export type TaxonData = {
|
|
22
39
|
flower_color: string;
|
23
40
|
GRank: string;
|
24
41
|
"inat id": string;
|
25
|
-
"jepson id": string;
|
26
42
|
life_cycle: string;
|
27
43
|
"RPI ID": string;
|
28
44
|
SRank: string;
|
@@ -32,6 +48,14 @@ export type TaxonData = {
|
|
32
48
|
|
33
49
|
// Classes
|
34
50
|
|
51
|
+
export class BasePageRenderer {
|
52
|
+
static renderBasePages<T extends Taxon>(
|
53
|
+
outputDir: string,
|
54
|
+
taxa: Taxa<T>,
|
55
|
+
familyCols?: TaxaColDef<T>[],
|
56
|
+
): void;
|
57
|
+
}
|
58
|
+
|
35
59
|
export class Config {
|
36
60
|
constructor(dataDir: string);
|
37
61
|
getConfigValue(
|
@@ -45,7 +69,10 @@ export class Config {
|
|
45
69
|
}
|
46
70
|
|
47
71
|
export class CSV {
|
48
|
-
static
|
72
|
+
static readFile(
|
73
|
+
fileName: string,
|
74
|
+
delimeter?: string,
|
75
|
+
): Record<string, string>[];
|
49
76
|
}
|
50
77
|
|
51
78
|
export class ErrorLog {
|
@@ -66,10 +93,6 @@ export class Exceptions {
|
|
66
93
|
hasException(name: string, cat: string, subcat: string): boolean;
|
67
94
|
}
|
68
95
|
|
69
|
-
export class ExternalSites {
|
70
|
-
static getCCH2ObsLink(taxon: Taxon, config: Config): URL | undefined;
|
71
|
-
}
|
72
|
-
|
73
96
|
export class Family {
|
74
97
|
getName(): string;
|
75
98
|
}
|
@@ -87,8 +110,8 @@ export class Files {
|
|
87
110
|
|
88
111
|
export class Genera {}
|
89
112
|
|
90
|
-
export class Genus {
|
91
|
-
getTaxa():
|
113
|
+
export class Genus<T extends Taxon> {
|
114
|
+
getTaxa(): T[];
|
92
115
|
}
|
93
116
|
|
94
117
|
export class HTML {
|
@@ -100,14 +123,19 @@ export class HTML {
|
|
100
123
|
attrs?: Record<string, string> | string,
|
101
124
|
openInNewWindow?: boolean,
|
102
125
|
): string;
|
126
|
+
static getToolTip(
|
127
|
+
text: string,
|
128
|
+
tooltip: string,
|
129
|
+
options?: { icon: boolean },
|
130
|
+
): string;
|
103
131
|
static textElement(
|
104
132
|
elName: string,
|
105
|
-
text: string,
|
133
|
+
text: string | number,
|
106
134
|
attrs?: Record<string, string>,
|
107
135
|
): string;
|
108
136
|
static wrap(
|
109
137
|
elName: string,
|
110
|
-
text: string,
|
138
|
+
text: string | number,
|
111
139
|
attrs?: string | Record<string, string> | undefined,
|
112
140
|
): string;
|
113
141
|
}
|
@@ -118,6 +146,13 @@ export class HTMLTaxon {
|
|
118
146
|
href: URL | string | undefined,
|
119
147
|
label: string,
|
120
148
|
): void;
|
149
|
+
static addObsLink(
|
150
|
+
links: string[],
|
151
|
+
taxon: Taxon,
|
152
|
+
config: Config,
|
153
|
+
sourceCode: RefSourceCode,
|
154
|
+
label?: string,
|
155
|
+
): void;
|
121
156
|
static addRefLink(
|
122
157
|
links: string[],
|
123
158
|
taxon: Taxon,
|
@@ -167,22 +202,22 @@ export class Taxon {
|
|
167
202
|
constructor(data: TaxonData, genera: Genera);
|
168
203
|
getBaseFileName(): string;
|
169
204
|
getCalfloraID(): string;
|
170
|
-
|
205
|
+
getCalfloraName(): string;
|
171
206
|
getCESA(): string;
|
172
207
|
getCNDDBRank(): string;
|
173
208
|
getCommonNames(): string[];
|
174
209
|
getFamily(): Family;
|
175
210
|
getFileName(): string;
|
176
211
|
getFESA(): string;
|
177
|
-
getGenus(): Genus
|
212
|
+
getGenus<T extends Taxon>(): Genus<T>;
|
178
213
|
getGenusName(): string;
|
179
214
|
getGlobalRank(): string;
|
180
215
|
getINatID(): string;
|
181
|
-
|
216
|
+
getINatName(): string;
|
182
217
|
getJepsonID(): string;
|
183
218
|
getName(): string;
|
184
219
|
getPhotos(): Photo[];
|
220
|
+
getRPIRank(): string;
|
185
221
|
getRPIRankAndThreat(): string;
|
186
|
-
getRPITaxonLink(): string;
|
187
222
|
getSynonyms(): string[];
|
188
223
|
}
|
package/lib/index.js
CHANGED
@@ -4,15 +4,15 @@ import { CSV } from "./csv.js";
|
|
4
4
|
import { ErrorLog } from "./errorlog.js";
|
5
5
|
import { Exceptions } from "./exceptions.js";
|
6
6
|
import { ExternalSites } from "./externalsites.js";
|
7
|
-
import { Families } from "./families.js";
|
7
|
+
import { Families } from "./taxonomy/families.js";
|
8
8
|
import { Files } from "./files.js";
|
9
9
|
import { HTML } from "./html.js";
|
10
10
|
import { HTMLTaxon } from "./htmltaxon.js";
|
11
11
|
import { Jekyll } from "./jekyll.js";
|
12
12
|
import { PlantBook } from "./ebook/plantbook.js";
|
13
13
|
import { Program } from "./program.js";
|
14
|
-
import { Taxa } from "./taxa.js";
|
15
|
-
import { Taxon } from "./taxon.js";
|
14
|
+
import { Taxa } from "./taxonomy/taxa.js";
|
15
|
+
import { Taxon } from "./taxonomy/taxon.js";
|
16
16
|
|
17
17
|
export {
|
18
18
|
BasePageRenderer,
|
package/lib/pagerenderer.js
CHANGED
@@ -22,7 +22,7 @@ class PageRenderer extends BasePageRenderer {
|
|
22
22
|
/**
|
23
23
|
* @param {string} outputDir
|
24
24
|
* @param {import('./config.js').Config} config
|
25
|
-
* @param {import("./
|
25
|
+
* @param {import("./types.js").Taxa} taxa
|
26
26
|
*/
|
27
27
|
static render(outputDir, config, taxa) {
|
28
28
|
super.renderBasePages(outputDir, taxa);
|
@@ -38,13 +38,13 @@ class PageRenderer extends BasePageRenderer {
|
|
38
38
|
/**
|
39
39
|
* @param {string} outputDir
|
40
40
|
* @param {import('./config.js').Config} config
|
41
|
-
* @param {import("./
|
41
|
+
* @param {import("./types.js").Taxa} taxa
|
42
42
|
*/
|
43
43
|
static renderLists(outputDir, config, taxa) {
|
44
44
|
/**
|
45
45
|
* @param {ListInfo[]} listInfo
|
46
46
|
* @param {Object<string,string>} attributes
|
47
|
-
* @param {import("./
|
47
|
+
* @param {import("./types.js").TaxaColDef[]} [columns]
|
48
48
|
* @returns {string}
|
49
49
|
*/
|
50
50
|
function getListArray(listInfo, attributes = {}, columns) {
|
@@ -117,7 +117,7 @@ class PageRenderer extends BasePageRenderer {
|
|
117
117
|
return html;
|
118
118
|
}
|
119
119
|
|
120
|
-
/** @typedef {{name:string,filename:string,include:function(import("./
|
120
|
+
/** @typedef {{name:string,filename:string,include:function(import("./types.js").Taxon):boolean,columns?:import("./types.js").TaxaColDef[],listInfo?:ListInfo[]}} ListInfo */
|
121
121
|
/** @type {{title:string,listInfo:ListInfo[]}[]} */
|
122
122
|
const sections = [
|
123
123
|
{
|
@@ -227,8 +227,8 @@ class PageTaxonList extends GenericPage {
|
|
227
227
|
|
228
228
|
/**
|
229
229
|
*
|
230
|
-
* @param {import("./
|
231
|
-
* @param {import("./
|
230
|
+
* @param {import("./types.js").Taxon[]} taxa
|
231
|
+
* @param {import("./types.js").TaxaColDef[]|undefined} columns
|
232
232
|
*/
|
233
233
|
render(taxa, columns) {
|
234
234
|
let html = this.getDefaultIntro();
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import { Files } from "../files.js";
|
2
|
+
import { Config } from "../config.js";
|
3
|
+
import { Taxonomy } from "./taxonomy.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @typedef {{id:string,section:string,taxa?:import("../types.js").Taxon[]}} FamilyData
|
7
|
+
*/
|
8
|
+
|
9
|
+
export class Family extends Taxonomy {
|
10
|
+
#name;
|
11
|
+
#data;
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @param {string} name
|
15
|
+
* @param {FamilyData} data
|
16
|
+
*/
|
17
|
+
constructor(name, data) {
|
18
|
+
super({ "jepson id": data.id });
|
19
|
+
this.#name = name;
|
20
|
+
this.#data = data;
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @param {import("../types.js").Taxon} taxon
|
25
|
+
*/
|
26
|
+
addTaxon(taxon) {
|
27
|
+
if (!this.#data.taxa) {
|
28
|
+
this.#data.taxa = [];
|
29
|
+
}
|
30
|
+
this.#data.taxa.push(taxon);
|
31
|
+
Sections.addTaxon(this.getSectionName(), taxon);
|
32
|
+
}
|
33
|
+
|
34
|
+
getBaseFileName() {
|
35
|
+
return this.getName();
|
36
|
+
}
|
37
|
+
|
38
|
+
getFileName(ext = "html") {
|
39
|
+
return this.getBaseFileName() + "." + ext;
|
40
|
+
}
|
41
|
+
|
42
|
+
getName() {
|
43
|
+
return this.#name;
|
44
|
+
}
|
45
|
+
|
46
|
+
getSectionName() {
|
47
|
+
return this.#data.section;
|
48
|
+
}
|
49
|
+
|
50
|
+
getTaxa() {
|
51
|
+
return this.#data.taxa;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
export class Families {
|
56
|
+
#families;
|
57
|
+
|
58
|
+
constructor() {
|
59
|
+
const dataDir = Config.getPackageDir() + "/data";
|
60
|
+
|
61
|
+
this.#families = JSON.parse(Files.read(dataDir + "/families.json"));
|
62
|
+
for (const [k, v] of Object.entries(this.#families)) {
|
63
|
+
this.#families[k] = new Family(k, v);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @returns {Family[]}
|
69
|
+
*/
|
70
|
+
getFamilies() {
|
71
|
+
return Object.values(this.#families).sort((a, b) =>
|
72
|
+
a.getName().localeCompare(b.getName()),
|
73
|
+
);
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* @param {string} familyName
|
78
|
+
*/
|
79
|
+
getFamily(familyName) {
|
80
|
+
return this.#families[familyName];
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
export class Sections {
|
85
|
+
/** @type {Object<string,import("../types.js").Taxon[]>} */
|
86
|
+
static #sections = {};
|
87
|
+
|
88
|
+
/**
|
89
|
+
* @param {string} name
|
90
|
+
* @param {import("../types.js").Taxon} taxon
|
91
|
+
*/
|
92
|
+
static addTaxon(name, taxon) {
|
93
|
+
let section = this.#sections[name];
|
94
|
+
if (!section) {
|
95
|
+
section = [];
|
96
|
+
this.#sections[name] = section;
|
97
|
+
}
|
98
|
+
section.push(taxon);
|
99
|
+
}
|
100
|
+
|
101
|
+
static getSections() {
|
102
|
+
return this.#sections;
|
103
|
+
}
|
104
|
+
}
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import * as fs from "node:fs";
|
2
2
|
import path from "node:path";
|
3
3
|
|
4
|
-
import { Config } from "
|
5
|
-
import { CSV } from "
|
6
|
-
import { Genera } from "
|
4
|
+
import { Config } from "../config.js";
|
5
|
+
import { CSV } from "../csv.js";
|
6
|
+
import { Genera } from "../genera.js";
|
7
7
|
import { Taxon } from "./taxon.js";
|
8
8
|
import { Families } from "./families.js";
|
9
|
-
import { FlowerColor } from "
|
10
|
-
import { TaxaCSV } from "
|
11
|
-
import { ErrorLog } from "
|
12
|
-
import { Program } from "
|
13
|
-
import { Photo } from "
|
9
|
+
import { FlowerColor } from "../flowercolor.js";
|
10
|
+
import { TaxaCSV } from "../tools/taxacsv.js";
|
11
|
+
import { ErrorLog } from "../errorlog.js";
|
12
|
+
import { Program } from "../program.js";
|
13
|
+
import { Photo } from "../photo.js";
|
14
14
|
|
15
15
|
/**
|
16
16
|
* @typedef {{Current: string;Former: string;Type: string;}} SynonymData
|
@@ -40,11 +40,11 @@ class Taxa {
|
|
40
40
|
#isSubset;
|
41
41
|
|
42
42
|
/**
|
43
|
-
* @param {Object<string,import("
|
43
|
+
* @param {Object<string,import("../index.js").TaxonData>|true} inclusionList
|
44
44
|
* @param {ErrorLog} errorLog
|
45
45
|
* @param {boolean} showFlowerErrors
|
46
|
-
* @param {function(import("
|
47
|
-
* @param {import("
|
46
|
+
* @param {function(import("../index.js").TaxonData,Genera):Taxon} taxonFactory
|
47
|
+
* @param {import("../index.js").TaxonData[]} [extraTaxa=[]]
|
48
48
|
* @param {SynonymData[]} [extraSynonyms=[]]
|
49
49
|
* @param {boolean} includePhotos
|
50
50
|
*/
|
@@ -114,9 +114,9 @@ class Taxa {
|
|
114
114
|
*/
|
115
115
|
#loadPhotosFromFile(dataDir, filename) {
|
116
116
|
if (!fs.existsSync(path.join(dataDir, filename))) return;
|
117
|
-
/** @type {import("
|
117
|
+
/** @type {import("../utils/inat-tools.js").InatCsvPhoto[]} */
|
118
118
|
const csvPhotos = CSV.parseFile(dataDir, filename).map((row) => {
|
119
|
-
/** @type {import("
|
119
|
+
/** @type {import("../utils/inat-tools.js").InatLicenseCode} */
|
120
120
|
let licenseCode = "cc-by";
|
121
121
|
if (row.licenseCode === "cc-by-nc-sa") licenseCode = "cc-by-nc-sa";
|
122
122
|
else if (row.licenseCode === "cc-by-nc") licenseCode = "cc-by-nc";
|
@@ -224,7 +224,7 @@ class Taxa {
|
|
224
224
|
|
225
225
|
/**
|
226
226
|
* @param {SynonymData[]} synCSV
|
227
|
-
* @param {Object<string,import("
|
227
|
+
* @param {Object<string,import("../index.js").TaxonData>|boolean} inclusionList
|
228
228
|
*/
|
229
229
|
#loadSyns(synCSV, inclusionList) {
|
230
230
|
for (const syn of synCSV) {
|
@@ -245,9 +245,9 @@ class Taxa {
|
|
245
245
|
}
|
246
246
|
|
247
247
|
/**
|
248
|
-
* @param {import("
|
249
|
-
* @param {Object<string,import("
|
250
|
-
* @param {function(import("
|
248
|
+
* @param {import("../index.js").TaxonData[]} taxaCSV
|
249
|
+
* @param {Object<string,import("../index.js").TaxonData>|true} inclusionList
|
250
|
+
* @param {function(import("../index.js").TaxonData,Genera):Taxon} taxonFactory
|
251
251
|
* @param {Genera} genera
|
252
252
|
* @param {boolean} showFlowerErrors
|
253
253
|
*/
|
@@ -255,7 +255,7 @@ class Taxa {
|
|
255
255
|
for (const row of taxaCSV) {
|
256
256
|
const name = row["taxon_name"];
|
257
257
|
|
258
|
-
/** @type {import("
|
258
|
+
/** @type {import("../index.js").TaxonData|{status?:import("../index.js").NativeStatusCode}} */
|
259
259
|
let taxon_overrides = {};
|
260
260
|
if (inclusionList !== true) {
|
261
261
|
taxon_overrides = inclusionList[name];
|
@@ -1,16 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import { RarePlants } from "./rareplants.js";
|
1
|
+
import { Taxonomy } from "./taxonomy.js";
|
3
2
|
|
4
|
-
class Taxon {
|
3
|
+
class Taxon extends Taxonomy {
|
5
4
|
#genera;
|
6
5
|
#name;
|
7
6
|
#genus;
|
8
7
|
#commonNames;
|
9
8
|
#status;
|
10
|
-
#jepsonID;
|
11
9
|
#calRecNum;
|
12
|
-
/**@type {string|undefined} */
|
13
|
-
#cfSyn;
|
14
10
|
#iNatID;
|
15
11
|
/**@type {string|undefined} */
|
16
12
|
#iNatSyn;
|
@@ -29,14 +25,15 @@ class Taxon {
|
|
29
25
|
#rankGlobal;
|
30
26
|
/** @type {string[]} */
|
31
27
|
#synonyms = [];
|
32
|
-
/** @type {import("
|
28
|
+
/** @type {import("../photo.js").Photo[]}*/
|
33
29
|
#photos = [];
|
34
30
|
|
35
31
|
/**
|
36
|
-
* @param {import("
|
37
|
-
* @param {import("
|
32
|
+
* @param {import("../index.js").TaxonData} data
|
33
|
+
* @param {import("../genera.js").Genera} genera
|
38
34
|
*/
|
39
35
|
constructor(data, genera) {
|
36
|
+
super(data);
|
40
37
|
this.#genera = genera;
|
41
38
|
const name = data["taxon_name"];
|
42
39
|
const commonNames = data["common name"];
|
@@ -50,7 +47,6 @@ class Taxon {
|
|
50
47
|
? commonNames.split(",").map((t) => t.trim())
|
51
48
|
: [];
|
52
49
|
this.#status = data["status"];
|
53
|
-
this.#jepsonID = data["jepson id"];
|
54
50
|
this.#calRecNum = data["calrecnum"];
|
55
51
|
this.#iNatID = data["inat id"];
|
56
52
|
this.#cch2id = data.cch2_id;
|
@@ -82,10 +78,6 @@ class Taxon {
|
|
82
78
|
addSynonym(syn, type) {
|
83
79
|
this.#synonyms.push(syn);
|
84
80
|
switch (type) {
|
85
|
-
case "CF":
|
86
|
-
// Synonym is in Calflora format.
|
87
|
-
this.#cfSyn = syn;
|
88
|
-
break;
|
89
81
|
case "INAT":
|
90
82
|
// Synonyms should be in Jepson format, but store iNatName in iNat format (no var or subsp, space after x).
|
91
83
|
this.#iNatSyn = syn;
|
@@ -94,14 +86,14 @@ class Taxon {
|
|
94
86
|
}
|
95
87
|
|
96
88
|
/**
|
97
|
-
* @param {import("
|
89
|
+
* @param {import("../photo.js").Photo} photo
|
98
90
|
*/
|
99
91
|
addPhoto(photo) {
|
100
92
|
this.#photos = this.#photos.concat([photo]);
|
101
93
|
}
|
102
94
|
|
103
95
|
/**
|
104
|
-
* @returns {import("
|
96
|
+
* @returns {import("../photo.js").Photo[]}
|
105
97
|
*/
|
106
98
|
getPhotos() {
|
107
99
|
return this.#photos;
|
@@ -127,9 +119,6 @@ class Taxon {
|
|
127
119
|
}
|
128
120
|
|
129
121
|
getCalfloraName() {
|
130
|
-
if (this.#cfSyn) {
|
131
|
-
return this.#cfSyn;
|
132
|
-
}
|
133
122
|
return this.getName().replace(" subsp.", " ssp.").replace("×", "X");
|
134
123
|
}
|
135
124
|
|
@@ -137,20 +126,6 @@ class Taxon {
|
|
137
126
|
return this.#calRecNum;
|
138
127
|
}
|
139
128
|
|
140
|
-
getCalfloraTaxonLink() {
|
141
|
-
const calfloraID = this.getCalfloraID();
|
142
|
-
if (!calfloraID) {
|
143
|
-
return;
|
144
|
-
}
|
145
|
-
const link = HTML.getLink(
|
146
|
-
"https://www.calflora.org/app/taxon?crn=" + calfloraID,
|
147
|
-
"Calflora",
|
148
|
-
{},
|
149
|
-
true,
|
150
|
-
);
|
151
|
-
return this.#cfSyn ? link + " (" + this.#cfSyn + ")" : link;
|
152
|
-
}
|
153
|
-
|
154
129
|
getCalscapeCommonName() {
|
155
130
|
return this.#calscapeCN;
|
156
131
|
}
|
@@ -235,33 +210,6 @@ class Taxon {
|
|
235
210
|
return this.#rankGlobal ?? "";
|
236
211
|
}
|
237
212
|
|
238
|
-
/**
|
239
|
-
*
|
240
|
-
* @param {boolean|string|undefined} href
|
241
|
-
* @param {boolean} includeRPI
|
242
|
-
*/
|
243
|
-
getHTMLLink(href = true, includeRPI = true) {
|
244
|
-
href = href ? "./" + this.getFileName() : undefined;
|
245
|
-
let className = this.isNative() ? "native" : "non-native";
|
246
|
-
let isRare = false;
|
247
|
-
if (includeRPI && this.isRare()) {
|
248
|
-
isRare = true;
|
249
|
-
className += " rare";
|
250
|
-
}
|
251
|
-
const attributes = { class: className };
|
252
|
-
const link = HTML.wrap(
|
253
|
-
"span",
|
254
|
-
HTML.getLink(href, this.getName()),
|
255
|
-
attributes,
|
256
|
-
);
|
257
|
-
if (isRare) {
|
258
|
-
return HTML.getToolTip(link, this.getRPIRankAndThreatTooltip(), {
|
259
|
-
icon: false,
|
260
|
-
});
|
261
|
-
}
|
262
|
-
return link;
|
263
|
-
}
|
264
|
-
|
265
213
|
getINatID() {
|
266
214
|
return this.#iNatID;
|
267
215
|
}
|
@@ -278,27 +226,6 @@ class Taxon {
|
|
278
226
|
return this.#iNatSyn;
|
279
227
|
}
|
280
228
|
|
281
|
-
getINatTaxonLink() {
|
282
|
-
const iNatID = this.getINatID();
|
283
|
-
if (!iNatID) {
|
284
|
-
return "";
|
285
|
-
}
|
286
|
-
const link = HTML.getLink(
|
287
|
-
"https://www.inaturalist.org/taxa/" + iNatID,
|
288
|
-
"iNaturalist",
|
289
|
-
{},
|
290
|
-
true,
|
291
|
-
);
|
292
|
-
return this.#iNatSyn ? link + " (" + this.#iNatSyn + ")" : link;
|
293
|
-
}
|
294
|
-
|
295
|
-
/**
|
296
|
-
* @returns {string}
|
297
|
-
*/
|
298
|
-
getJepsonID() {
|
299
|
-
return this.#jepsonID;
|
300
|
-
}
|
301
|
-
|
302
229
|
getLifeCycle() {
|
303
230
|
return this.#lifeCycle;
|
304
231
|
}
|
@@ -328,38 +255,12 @@ class Taxon {
|
|
328
255
|
return this.#rankRPI;
|
329
256
|
}
|
330
257
|
|
331
|
-
/**
|
332
|
-
* @deprecated
|
333
|
-
*/
|
334
|
-
getRPIRankAndThreatTooltip() {
|
335
|
-
return RarePlants.getRPIRankAndThreatDescriptions(
|
336
|
-
this.getRPIRankAndThreat(),
|
337
|
-
).join("<br>");
|
338
|
-
}
|
339
|
-
|
340
|
-
/**
|
341
|
-
* @deprecated
|
342
|
-
*/
|
343
|
-
getRPITaxonLink() {
|
344
|
-
const rpiID = this.getRPIID();
|
345
|
-
if (!rpiID) {
|
346
|
-
return "";
|
347
|
-
}
|
348
|
-
const link = HTML.getLink(
|
349
|
-
"https://rareplants.cnps.org/Plants/Details/" + rpiID,
|
350
|
-
"CNPS Rare Plant Inventory",
|
351
|
-
{},
|
352
|
-
true,
|
353
|
-
);
|
354
|
-
return link;
|
355
|
-
}
|
356
|
-
|
357
258
|
getStatus() {
|
358
259
|
return this.#status;
|
359
260
|
}
|
360
261
|
|
361
262
|
/**
|
362
|
-
* @param {import("
|
263
|
+
* @param {import("../config.js").Config} config
|
363
264
|
* @returns {string}
|
364
265
|
*/
|
365
266
|
getStatusDescription(config) {
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export class Taxonomy {
|
2
|
+
#data;
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @param {import("../index.js").TaxonomyData} data
|
6
|
+
*/
|
7
|
+
constructor(data) {
|
8
|
+
this.#data = data;
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @returns {string}
|
13
|
+
*/
|
14
|
+
getJepsonID() {
|
15
|
+
return this.#data["jepson id"];
|
16
|
+
}
|
17
|
+
}
|
package/lib/tools/calflora.js
CHANGED
@@ -25,7 +25,7 @@ export class Calflora {
|
|
25
25
|
/**
|
26
26
|
* @param {string} toolsDataDir
|
27
27
|
* @param {string} dataDir
|
28
|
-
* @param {import("../
|
28
|
+
* @param {import("../types.js").Taxa} taxa
|
29
29
|
* @param {import("../exceptions.js").Exceptions} exceptions
|
30
30
|
* @param {import("../errorlog.js").ErrorLog} errorLog
|
31
31
|
* @param {boolean} update
|
@@ -175,7 +175,7 @@ export class Calflora {
|
|
175
175
|
}
|
176
176
|
|
177
177
|
/**
|
178
|
-
* @param {import("../
|
178
|
+
* @param {import("../types.js").Taxa} taxa
|
179
179
|
* @param {import("../exceptions.js").Exceptions} exceptions
|
180
180
|
* @param {import("../errorlog.js").ErrorLog} errorLog
|
181
181
|
*/
|
package/lib/tools/calscape.js
CHANGED
@@ -2,13 +2,13 @@ import path from "node:path";
|
|
2
2
|
import xlsx from "exceljs";
|
3
3
|
import { Files } from "../files.js";
|
4
4
|
import { TaxaCSV } from "./taxacsv.js";
|
5
|
-
import { Taxon } from "../taxon.js";
|
5
|
+
import { Taxon } from "../taxonomy/taxon.js";
|
6
6
|
|
7
7
|
export class Calscape {
|
8
8
|
/**
|
9
9
|
* @param {string} toolsDataDir
|
10
10
|
* @param {string} dataDir
|
11
|
-
* @param {import("../
|
11
|
+
* @param {import("../types.js").Taxa} taxa
|
12
12
|
* @param {import("../exceptions.js").Exceptions} exceptions
|
13
13
|
* @param {import("../errorlog.js").ErrorLog} errorLog
|
14
14
|
* @param {boolean} update
|
@@ -58,7 +58,7 @@ export class Calscape {
|
|
58
58
|
}
|
59
59
|
|
60
60
|
/**
|
61
|
-
* @param {import("../
|
61
|
+
* @param {import("../types.js").Taxa} taxa
|
62
62
|
* @param {import("../exceptions.js").Exceptions} exceptions
|
63
63
|
* @param {import("../errorlog.js").ErrorLog} errorLog
|
64
64
|
*/
|
package/lib/tools/cch2.js
CHANGED
@@ -15,7 +15,7 @@ export class CCH2 {
|
|
15
15
|
* @param {string} toolsDataDir
|
16
16
|
* @param {string} dataDir
|
17
17
|
* @param {import("../exceptions.js").Exceptions} exceptions
|
18
|
-
* @param {import("../
|
18
|
+
* @param {import("../types.js").Taxa} taxa
|
19
19
|
* @param {import("../errorlog.js").ErrorLog} errorLog
|
20
20
|
* @param {boolean} update
|
21
21
|
*/
|
@@ -61,7 +61,7 @@ export class CCH2 {
|
|
61
61
|
|
62
62
|
/**
|
63
63
|
* @param {import("../exceptions.js").Exceptions} exceptions
|
64
|
-
* @param {import("../
|
64
|
+
* @param {import("../types.js").Taxa} taxa
|
65
65
|
* @param {import("../errorlog.js").ErrorLog} errorLog
|
66
66
|
* @param {CCHTaxa} cchTaxa
|
67
67
|
*/
|
@@ -106,7 +106,7 @@ export class CCH2 {
|
|
106
106
|
|
107
107
|
/**
|
108
108
|
* @param {string} toolsDataPath
|
109
|
-
* @param {import("../
|
109
|
+
* @param {import("../types.js").Taxa} taxa
|
110
110
|
* @returns {Promise<CCHTaxa>}
|
111
111
|
*/
|
112
112
|
async function getCCHTaxa(toolsDataPath, taxa) {
|