From 3d738c9c4310abb5723197eff8e4d47fa5beb689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gunnar=20Ingi=20Stef=C3=A1nsson?= Date: Fri, 28 Jun 2024 13:08:05 +0200 Subject: [PATCH] safely handle cases where there are no scene layers --- app/components/download/create-mesh.tsx | 3 ++- app/routes/$scene/route.tsx | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/components/download/create-mesh.tsx b/app/components/download/create-mesh.tsx index c31002b..780810c 100644 --- a/app/components/download/create-mesh.tsx +++ b/app/components/download/create-mesh.tsx @@ -56,7 +56,8 @@ export default async function createMesh(scene: WebScene, extent: Extent, signal const ground = scene.ground; const layers = scene.allLayers.filter(layer => layer.type === "scene").toArray() as SceneLayer[]; - const sr = layers.at(0)!.spatialReference; + + const sr = layers.at(0)?.spatialReference ?? extent.spatialReference; const features = (await Promise.all(layers.map(layer => extractFeatures(layer, extent, signal)))).flat(); const projectedExtent = projection.project(extent, sr) as Extent; diff --git a/app/routes/$scene/route.tsx b/app/routes/$scene/route.tsx index 85e5e56..2345e06 100644 --- a/app/routes/$scene/route.tsx +++ b/app/routes/$scene/route.tsx @@ -3,14 +3,12 @@ import { Suspense, lazy } from "react"; import { redirect, useLoaderData, useRouteError } from "@remix-run/react"; import Sidebar from "~/components/sidebar/sidebar"; import invariant from "tiny-invariant"; -import SCENES from "~/data/scenes"; import { ViewUI } from "../../components/arcgis/views/scene-view/scene-view-ui"; import { CalciteAction, CalciteNavigation, CalciteNavigationLogo, CalciteNavigationUser, CalciteScrim } from "@esri/calcite-components-react"; import { SelectionAction } from "../../components/selection/selection-button"; import GraphicsLayer from "~/components/arcgis/graphics-layer"; import SelectionExtent from "../../components/selection/selection-graphic"; import WalkthroughPopover from "~/components/walk-through/walk-through-popover"; -import { load as loadProjectionEngine } from "@arcgis/core/geometry/projection"; import SelectionErrorAlert from "~/components/selection/selection-error-alert"; import { useSceneListModal } from "~/components/scene-list-modal/scene-list-modal-context"; import { useAccessorValue } from "~/hooks/reactive";