private void ImportData() { var info = new ImportInfo { inputFilename = importDataPanel.FullFilename, outputFilename = importDataPanel.GetOutputFilename(), fieldIndex = importDataPanel.fieldDropdown.value, site = importDataPanel.Site, newSiteName = importDataPanel.SiteName, group = importDataPanel.Group, newGroupName = importDataPanel.GroupName, layer = importDataPanel.Layer, newLayerName = importDataPanel.LayerName, newLayerColor = importDataPanel.LayerColor, level = importDataPanel.Level, year = importDataPanel.Year, month = importDataPanel.Month, units = importDataPanel.Units, resolution = importDataPanel.Resolution, needsResampling = importDataPanel.NeedsResampling, metadata = importDataPanel.GetMetadata(), OnFinishImport = OnFinishImport }; InitInfoCategories(info); var dataImporter = new GameObject("DataImporter").AddComponent <DataImporter>(); dataImporter.Import(info); wizardDlg.CloseDialog(DialogAction.Ok); }
private void OnLoadFiles(string[] paths) { if (paths == null || paths.Length == 0 || string.IsNullOrWhiteSpace(paths[0])) { if (FullFilename == null) { wizardDlg.CloseDialog(DialogAction.Cancel); } return; } FullFilename = paths[0]; var filename = Path.GetFileName(FullFilename); fileLabel.text = filename; interpreter = Interpreter.Get(FullFilename); fileInfo = interpreter.GetBasicInfo(FullFilename); ShowWarningMessage(translator.Get("Invalid file"), openFile, fileInfo == null); var filename_lc = filename.ToLower(); // Try to guess the site if (string.IsNullOrWhiteSpace(siteDropdown.input.text)) { var sites = dataManager.sites; for (int i = 0; i < sites.Count; i++) { if (filename_lc.Contains(sites[i].Name.ToLower())) { siteDropdown.value = i; break; } } } // Try to guess the layer (and group) if (!layerDropdown.HasSelected) { var layer = GetLayer(filename_lc); if (layer == null && !string.IsNullOrWhiteSpace(fileInfo.suggestedLayerName)) { layer = GetLayer(fileInfo.suggestedLayerName.ToLower()); } if (layer != null) { groupDropdown.value = dataManager.groups.IndexOf(layer.Group); layerDropdown.value = layer.Group.layers.IndexOf(layer); } } // Suggest the resolution if (!resolutionDropdown.HasSelected && fileInfo.degreesPerPixel != 0) { for (int i = 0; i < resolutions.Length; i++) { if (fileInfo.degreesPerPixel.Similar(resolutions[i].ToDegrees())) { resolutionDropdown.value = i; break; } } } // Suggest the units if (string.IsNullOrWhiteSpace(unitsInput.text) && !string.IsNullOrWhiteSpace(fileInfo.suggestedUnits)) { unitsInput.text = translator.Get(fileInfo.suggestedUnits); } if (fileInfo != null) { CheckBounds(); CheckRasterSize(); CheckResolution(); } ValidateResolutionDrowndown(); UpdateProgress(); }