private void Split() { var args = new UpdatingTaskProgressEventArgs(TaskState.Updating); featureSource.Open(); Collection <Feature> allFeatures = featureSource.GetAllFeatures(featureSource.GetDistinctColumnNames()); var columns = featureSource.GetColumns(); featureSource.Close(); var featuresGroups = allFeatures.GroupBy(tmpFeature => tmpFeature.ColumnValues[splitColumnName]).ToArray(); int i = 0; int count = exportConfigs.Count; foreach (var config in exportConfigs) { try { string folderName = outputPath; string fileName = config.Value; if (String.IsNullOrEmpty(fileName)) { fileName = String.Format(CultureInfo.InvariantCulture, "{0}_{1}.shp", layerName, config.Key); } fileName = Path.ChangeExtension(fileName, ".shp"); string finalShapeFilePath = Path.Combine(folderName, fileName); var featureGroup = featuresGroups.FirstOrDefault(group => group.Key == config.Key || (config.Key.Equals("<Blank>", StringComparison.Ordinal) && group.Key.Equals(string.Empty, StringComparison.Ordinal))); if (featureGroup != null) { var info = new FileExportInfo(featureGroup, columns, finalShapeFilePath, wkt); Export(info); } args.Current = ++i; args.UpperBound = count; args.Message = String.Format(CultureInfo.InvariantCulture, "Building... ({0}/{1})", args.Current, args.UpperBound); OnUpdatingProgress(args); isCanceled = args.TaskState == TaskState.Canceled; if (isCanceled) { break; } } catch (Exception ex) { var errorArgs = new UpdatingTaskProgressEventArgs(TaskState.Error); errorArgs.Error = new ExceptionInfo(ex.Message, ex.StackTrace, ex.Source); GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex)); OnUpdatingProgress(errorArgs); continue; } } }
private Collection <Feature> GetFeaturesToExplode(FeatureSource featureSource) { featureSource.Open(); var allFeatures = featureSource.GetAllFeatures(featureSource.GetDistinctColumnNames()); columns = featureSource.GetColumns(); featureSource.Close(); return(allFeatures); }
private IEnumerable <Feature> GetFeaturesFromTempFile() { featureSource.Open(); var allFeatures = featureSource.GetAllFeatures(featureSource.GetDistinctColumnNames()); featureSource.Close(); return(allFeatures.Where(f => { var shape = f.GetShape(); return shape is AreaBaseShape || shape is LineBaseShape; })); }