Skip to content

Commit 579a725

Browse files
authored
Consult the .gdb workspace suffix only as a last resort (#1911)
The geodatabase short circuit ran before the dataset was looked at, so a raster in a plain folder named "*.gdb" whose dataset named a real .tif stopped resolving, where it used to load. The factory check still returns immediately, but the suffix is now consulted only after the joined path fails to name a GeoTIFF, so a readable raster still wins and only an unopenable dataset falls through to it. Pinned with a test, and the comment no longer claims parity with resolveDataSource, whose own suffix check sits in a branch that could not have resolved anyway.
1 parent 20f5e4f commit 579a725

2 files changed

Lines changed: 44 additions & 11 deletions

File tree

apps/geolibre-desktop/src/lib/arcgis-project-import.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,20 +447,28 @@ function resolveRasterSource(
447447
const dataset = stringValue(connection.dataset);
448448
if (!workspace && !dataset) return { reason: "missing-source" };
449449
if (isNetworkPath(workspace)) return { reason: "network-path" };
450-
// Recognized by either the factory or the workspace path, the way a
451-
// geodatabase feature class is (see {@link resolveDataSource}), but reported
452-
// under its own reason: the desktop build's Add Data -> File Geodatabase
453-
// source lists only feature classes that carry geometry, so pointing a
454-
// raster at it would send the user somewhere that cannot open their data.
455-
if (
456-
stringValue(connection.workspaceFactory).toLowerCase().includes("filegdb") ||
457-
extension(workspace) === "gdb"
458-
) {
450+
// Reported under its own reason rather than the feature class one: the
451+
// desktop build's Add Data -> File Geodatabase source lists only feature
452+
// classes that carry geometry, so pointing a raster at it would send the
453+
// user somewhere that cannot open their data.
454+
if (stringValue(connection.workspaceFactory).toLowerCase().includes("filegdb")) {
459455
return { reason: "file-geodatabase-raster" };
460456
}
461-
if (!workspace || !dataset) return { reason: "missing-source" };
457+
// Past this point the factory did not name a geodatabase, so only the
458+
// workspace suffix is left to go on -- and it is consulted last, after the
459+
// joined path fails. A readable GeoTIFF is therefore still loaded from a
460+
// plain folder that happens to be named "*.gdb"; only a dataset the app
461+
// cannot open falls through to the suffix, where naming the geodatabase
462+
// beats a bare "format".
463+
const looksLikeGeodatabase = extension(workspace) === "gdb";
464+
if (!workspace || !dataset) {
465+
return looksLikeGeodatabase
466+
? { reason: "file-geodatabase-raster" }
467+
: { reason: "missing-source" };
468+
}
462469
const path = resolveRelativePath(joinPath(workspace, dataset), projectPath);
463-
return ["tif", "tiff"].includes(extension(path)) ? { path } : { reason: "format" };
470+
if (["tif", "tiff"].includes(extension(path))) return { path };
471+
return looksLikeGeodatabase ? { reason: "file-geodatabase-raster" } : { reason: "format" };
464472
}
465473

466474
function resolveDataSource(

tests/arcgis-project-import.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,31 @@ describe("ArcGIS Pro project import", () => {
248248
);
249249
});
250250

251+
it("still loads a GeoTIFF from a plain folder whose name ends in .gdb", () => {
252+
// The workspace suffix is a last resort, not a short circuit: a readable
253+
// dataset wins over a folder that merely looks like a geodatabase. ArcGIS
254+
// reserves .gdb for real geodatabases, so this is unlikely -- but the
255+
// suffix check must not cost a raster that would otherwise have loaded.
256+
const mapx = {
257+
type: "CIMMap",
258+
name: "Elevation",
259+
defaultExtent: { xmin: -80, ymin: 30, xmax: -70, ymax: 40, spatialReference: { wkid: 4326 } },
260+
layerDefinitions: [
261+
{
262+
type: "CIMRasterLayer",
263+
name: "DEM",
264+
dataConnection: {
265+
workspaceConnectionString: "DATABASE=C:\\data\\rasters.gdb",
266+
dataset: "dem.tif",
267+
},
268+
},
269+
],
270+
};
271+
const result = importArcgisProject(JSON.stringify(mapx), "C:\\projects\\main.mapx");
272+
assert.deepEqual(result.warnings, []);
273+
assert.equal(result.rasters[0].sourcePath, "C:/data/rasters.gdb/dem.tif");
274+
});
275+
251276
it("reports a geodatabase raster with no dataset name as a geodatabase", () => {
252277
// The geodatabase check deliberately precedes the missing-dataset guard,
253278
// so this matches what the vector resolver already did for the same

0 commit comments

Comments
 (0)