|
327 | 327 | }); |
328 | 328 | console.debug(`Created ${jgiGoldOrgObjs.length} markers.`); |
329 | 329 |
|
330 | | - // Fetch the EMSL MONet JSON (not CSV) file and create a marker for each element of its top-level array. |
| 330 | + // Fetch the EMSL MONet JSON (not CSV) file and create a marker for each BERtron entity represented within it. |
331 | 331 | const monetResponse = await fetch( |
332 | 332 | `${baseUrlForData}/emsl/map/monet_samples_schema-9-16-2025.json`, |
333 | 333 | ); |
334 | 334 | const monetObjs = await monetResponse.json(); |
335 | 335 | const monetMarkers = []; |
336 | 336 | console.debug("Fetching and parsing finished.", { data: monetObjs }); |
337 | 337 | monetObjs.forEach((obj) => { |
338 | | - const latLon = getLatLon(obj); |
339 | | - const identifier = `Project: ${obj["proposal_id"]}, Sampling set: ${obj["sampling_set"]}`; |
340 | | - const url = `https://sc-data.emsl.pnnl.gov/?projectId=${obj["proposal_id"]}`; |
| 338 | + // If the object lacks a `coordinates` field (which the BERtron schema says is possible), |
| 339 | + // omit the object from the map and display a warning on the JavaScript console. |
| 340 | + if (!obj.hasOwnProperty("coordinates")) { |
| 341 | + console.warn("Omitting object lacking coordinates:", obj); |
| 342 | + return; // skips to the next iteration |
| 343 | + } |
| 344 | + |
| 345 | + // If the object lacks an `id` field (which the BERtron schema says is possible), |
| 346 | + // use a generic value. |
| 347 | + const identifier = obj.hasOwnProperty("id") ? obj["id"] : "Sample"; |
| 348 | + |
| 349 | + // At this point, we know the object has a `coordinates` field, so we access it. |
| 350 | + const coordinates = obj["coordinates"]; |
| 351 | + const latLon = getLatLon(coordinates); |
| 352 | + |
| 353 | + const url = obj["uri"]; |
341 | 354 | const popupHtml = `<div class="vstack gap-3 marker-popup"><img src="./img/emsl-100x100.png" alt="Logo"/><div>EMSL MONet Sample<br/><a href="${url}" target="_blank" title="View project" class="identifier">${identifier}</a></div></div>`; |
342 | 355 | const icon = L.icon({ |
343 | 356 | iconUrl: "./img/emsl-marker.png", |
|
0 commit comments