diff --git a/src/data/plants.js b/src/data/plants.js index c70a6c9..2cc2a93 100644 --- a/src/data/plants.js +++ b/src/data/plants.js @@ -48,26 +48,57 @@ const flowerBeds = [ ]; const daylilies = [ - new Daylily("You Had Me At Merlot", { - daylilyDatabaseId: "194128", - daylilyDatabaseUrl: "https://daylilydatabase.org/detail.php?id=194128", + new Daylily("Joan Derifield", { + gardenOrgId: "4765", + }).add(geo.offset(lotCorner), geo.east(geo.ft(112)), geo.south(geo.ft(12))), + new Daylily("Predatory Flamingo", { + gardenOrgId: "61201", + }).add(geo.offset(lotCorner), geo.east(geo.ft(112)), geo.south(geo.ft(14))), + new Daylily("You Had Me at Hello", { + gardenOrgId: "235117", }).add(geo.offset(lotCorner), geo.east(geo.ft(28)), geo.south(geo.ft(45))), new Daylily("Mapping North Dakota", { - daylilyDatabaseId: "158640", - daylilyDatabaseUrl: "https://daylilydatabase.org/detail.php?id=158640", + gardenOrgId: "56003", }).add(geo.offset(lotCorner), geo.east(geo.ft(28)), geo.south(geo.ft(47))), - new Daylily("Daylily", { - daylilyDatabaseId: "", - daylilyDatabaseUrl: "", - }).add(geo.offset(lotCorner), geo.east(geo.ft(31)), geo.south(geo.ft(47))), + new Daylily("Daylily").add(geo.offset(lotCorner), geo.east(geo.ft(31)), geo.south(geo.ft(47))), ]; const trees = [ - new Tree("Japanese Empress Elm", { - species: "Japanese Empress Elm", + new Tree("Northern Empress Japanese Elm", { + species: "Northern Empress Japanese Elm", canopyDiameterMeters: 6, heightMeters: 7, }).add(geo.offset(lotCorner), geo.east(geo.ft(9)), geo.south(geo.ft(16))), + new Tree("Hot Wings Maple", { + species: "Hot Wings Maple", + canopyDiameterMeters: 5, + heightMeters: 5, + gardenOrgId: "536120", + }).add(geo.offset(lotCorner), geo.east(geo.ft(60)), geo.south(geo.ft(40))), + new Tree("Prairie Expedition American Elm", { + species: "Prairie Expedition American Elm", + canopyDiameterMeters: 5, + heightMeters: 5, + gardenOrgId: "736267", + }).add(geo.offset(lotCorner), geo.east(geo.ft(95)), geo.south(geo.ft(15))), + new Tree("Dwarf Korean Lilac", { + species: "Dwarf Korean Lilac", + canopyDiameterMeters: 1.75, + heightMeters: 2.5, + gardenOrgId: "79137", + }).add(geo.offset(lotCorner), geo.east(geo.ft(3)), geo.south(geo.ft(3))), + new Tree("Dwarf Korean Lilac", { + species: "Dwarf Korean Lilac", + canopyDiameterMeters: 1.75, + heightMeters: 2.5, + gardenOrgId: "79137", + }).add(geo.offset(lotCorner), geo.east(geo.ft(3)), geo.south(geo.ft(20))), + new Tree("Dwarf Korean Lilac", { + species: "Dwarf Korean Lilac", + canopyDiameterMeters: 1.75, + heightMeters: 2.5, + gardenOrgId: "79137", + }).add(geo.offset(lotCorner), geo.east(geo.ft(3)), geo.south(geo.ft(37))), new Tree("Boulevard Linden", { species: "Boulevard Linden", canopyDiameterMeters: 3, diff --git a/src/lib/feature-types.js b/src/lib/feature-types.js index 6a1b4f9..b328166 100644 --- a/src/lib/feature-types.js +++ b/src/lib/feature-types.js @@ -127,9 +127,19 @@ export const featureTypes = { genus: "string", species: "string", cultivar: "string", + gardenOrgId: "string", plantedDate: "date", note: "string", }, + externalLinks: [ + { + label: "Garden.org", + url: (details) => + details.gardenOrgId + ? `https://garden.org/plants/view/${encodeURIComponent(details.gardenOrgId)}/` + : null, + }, + ], style: { color: "#3d7140", weight: 2, @@ -170,17 +180,9 @@ export const featureTypes = { cultivar: "string", bloomColor: "string", bloomSeason: "string", - daylilyDatabaseId: "string", - daylilyDatabaseUrl: "url", plantedDate: "date", note: "string", }, - externalLinks: [ - { - label: "Daylily database", - url: (details) => details.daylilyDatabaseUrl ?? null, - }, - ], style: { color: "#9f5e1d", weight: 2, @@ -267,8 +269,8 @@ export function listFeatureTypeSchemas() { label: definition.label, parentKind: definition.parentKind ?? null, geometryType: definition.geometryType, - detailFields: { ...definition.detailFields }, - externalLinks: (definition.externalLinks ?? []).map((link) => ({ + detailFields: getInheritedDetailFields(kind), + externalLinks: getInheritedExternalLinks(kind).map((link) => ({ label: link.label, })), })); @@ -280,12 +282,34 @@ export function resolveFeatureStyle(kind, details = {}) { } export function resolveFeatureLinks(kind, details = {}) { - const { externalLinks = [] } = getFeatureType(kind); - - return externalLinks + return getInheritedExternalLinks(kind) .map((link) => ({ label: link.label, url: link.url(details), })) .filter((link) => link.url); } + +function getFeatureTypeLineage(kind) { + const lineage = []; + let currentKind = kind; + + while (currentKind) { + const definition = getFeatureType(currentKind); + lineage.unshift(definition); + currentKind = definition.parentKind; + } + + return lineage; +} + +function getInheritedDetailFields(kind) { + return Object.assign( + {}, + ...getFeatureTypeLineage(kind).map((definition) => definition.detailFields ?? {}), + ); +} + +function getInheritedExternalLinks(kind) { + return getFeatureTypeLineage(kind).flatMap((definition) => definition.externalLinks ?? []); +} diff --git a/src/main.js b/src/main.js index c9b06ab..69668b0 100644 --- a/src/main.js +++ b/src/main.js @@ -188,7 +188,7 @@ function extendBounds(bounds, coordinates) { function buildPopupContent(properties) { const { kind, label, name, startDate, endDate, details, parentId, groupIds } = properties; const entries = Object.entries(details ?? {}).filter( - ([key, value]) => value !== null && value !== undefined && !key.endsWith("Url"), + ([key, value]) => value !== null && value !== undefined && shouldShowDetailField(key), ); const lifecycleEntries = []; const relationshipEntries = []; @@ -221,12 +221,16 @@ function buildPopupContent(properties) { .map(([key, value]) => `