@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
32 lines • 1.43 kB
JavaScript
import path from "node:path";
import { datasourceConfig } from "../../../src/datasources/index.js";
import { hasOwnProperty } from "../../../src/index.js";
/** Takes vector import options or existing datasource and creates full import config */
export function genVectorConfig(projectClient, options, newDstPath) {
const src = hasOwnProperty(options, "src") && typeof options.src === "string"
? options.src
: "";
// Add explodeMulti if undefined, to support ExternalVectorDatasource. Code smell that this is added for external datasource
const explodeMulti = hasOwnProperty(options, "explodeMulti") &&
typeof options.explodeMulti === "boolean"
? options.explodeMulti
: true;
// merge to ensure keep at least classKeys
const propertiesToKeep = hasOwnProperty(options, "propertiesToKeep") &&
Array.isArray(options.propertiesToKeep)
? Array.from(new Set(options.propertiesToKeep.concat(options.classKeys)))
: [];
const config = {
...options,
src,
dstPath: newDstPath || datasourceConfig.defaultDstPath,
propertiesToKeep,
layerName: options.layerName ||
path.basename(src, "." + path.basename(src).split(".").pop()),
package: projectClient.package,
gp: projectClient.geoprocessing,
explodeMulti,
};
return config;
}
//# sourceMappingURL=genVectorConfig.js.map