image-classifier-ts
Version:
Command line tool to auto-classify images, renaming them with appropriate labels. Uses Node and Google Vision API.
42 lines • 2.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MapDateToLocationManager = void 0;
var path = require("path");
var MapDateToLocation_1 = require("./MapDateToLocation");
var MapDateToLocationManager = /** @class */ (function () {
function MapDateToLocationManager(manualMap, autoMap, options) {
this.manualMap = manualMap;
this.autoMap = autoMap;
this.options = options;
}
MapDateToLocationManager.fromImageDirectory = function (imageDir, options) {
return new MapDateToLocationManager(MapDateToLocation_1.MapDateToLocation.parseFromCsvAtDirectory(imageDir, options), new MapDateToLocation_1.MapDateToLocation(), options);
};
/**
* Dump the auto generated map from date to location (via exit lat/longs) to disk.
* This is mainly for diagnostics, and to allow user to tune their manual file 'mapDateToLocation.csv'.
*/
MapDateToLocationManager.prototype.dumpAutoMapToDisk = function (imageDir) {
var filePath = path.join(imageDir, MapDateToLocation_1.AUTO_DATE_MAP_CSV_FILENAME);
this.autoMap.removeFromDisk(filePath);
this.autoMap.writeToCsvAtPath(filePath);
return filePath;
};
MapDateToLocationManager.prototype.getLocationForFile = function (filepath, outputter) {
// manual file takes priority (to let user adjust)
var manualLocation = this.manualMap.getLocationForFile(filepath, outputter);
if (manualLocation) {
return manualLocation.toString();
}
var autoLocation = this.autoMap.getLocationForFile(filepath, outputter);
if (autoLocation) {
// Use a separate (usually less specific) format for derived location,
// since it is less accurate:
return autoLocation.toString(this.options.derivedLocationFormat);
}
return null;
};
return MapDateToLocationManager;
}());
exports.MapDateToLocationManager = MapDateToLocationManager;
//# sourceMappingURL=MapDateToLocationManager.js.map