예제 #1
0
 protected CartoProcessEngineBase(string name, IProcessingContext context,
                                  IProcessingFeedback feedback)
 {
     Name     = name ?? nameof(CartoProcess);
     Context  = context ?? throw new ArgumentNullException(nameof(context));
     Feedback = feedback ?? throw new ArgumentNullException(nameof(feedback));
 }
예제 #2
0
        public override void Execute(IProcessingContext context, IProcessingFeedback feedback)
        {
            using (var engine = new AlignMarkersEngine(this, context, feedback))
            {
                engine.Execute();

                engine.ReportProcessComplete("{0} features aligned", engine.FeaturesAligned);
            }
        }
예제 #3
0
        public override void Execute(IProcessingContext context, IProcessingFeedback feedback)
        {
            using (var engine = new CalculateControlPointsEngine(this, context, feedback))
            {
                engine.Execute();

                engine.ReportProcessComplete("{0}/{1} control points added/removed",
                                             engine.ControlPointsAdded,
                                             engine.ControlPointsRemoved);
            }
        }
예제 #4
0
        public override void Execute(IProcessingContext context, IProcessingFeedback feedback)
        {
            using (var engine = new CreateAnnoMasksEngine(this, context, feedback))
            {
                // TODO engine.TransferDerivedFeatureSelection ?

                engine.Execute();

                engine.ReportProcessComplete("{0} masks created", engine.MasksCreated);
            }
        }
예제 #5
0
        private static void ReportProcessCompleted([NotNull] IProcessingFeedback feedback,
                                                   [NotNull] IGdbProcess process,
                                                   TimeSpan duration)
        {
            var sb = new StringBuilder();

            string what = process is IGroupGdbProcess ? "Process Group" : "GdbProcess";

            sb.AppendFormat("{0} '{1}' completed in ", what, process.Name);
            sb.AppendDuration(duration);

            feedback.ReportInfo(sb.ToString());
        }
예제 #6
0
 public CreateAnnoMasksEngine(CreateAnnoMasks config, IProcessingContext context,
                              IProcessingFeedback feedback)
     : base(config.Name, context, feedback)
 {
     _inputDataset      = OpenRequiredDataset(config.InputDataset, nameof(config.InputDataset));
     _outputMaskDataset = OpenRequiredDataset(config.OutputMaskDataset, nameof(config.OutputMaskDataset));
     _relationshipClass = OpenAssociation(config.OutputAssociation);
     _maskAttributes    = ProcessingUtils.CreateFieldSetter(
         config.MaskAttributes, _outputMaskDataset.FeatureClass, nameof(config.MaskAttributes));
     _maskMargin                = ImplicitValue.Create(config.MaskMargin, nameof(config.MaskMargin));
     _maskMargin.Environment    = new StandardEnvironment().RegisterConversionFunctions();
     _simplificationToleranceMu = config.SimplificationTolerance;                 // TODO convert mm to mu
     _maskOutlineType           = config.MaskOutlineType;
     _fillHoles = config.FillHoles;
 }
예제 #7
0
        private static void ReportProcessStarting([NotNull] IProcessingFeedback feedback,
                                                  [NotNull] IGdbProcess process,
                                                  int current, int total)
        {
            var sb = new StringBuilder();

            sb.Append("Executing ");
            sb.Append(process is IGroupGdbProcess ? "Process Group" : "GdbProcess");
            sb.AppendFormat(" '{0}'", process.Name);

            if (total > 1 && 0 < current && current <= total)
            {
                sb.AppendFormat(" ({0} of {1})", current, total);
            }

            feedback.ReportInfo(sb.ToString());
        }
예제 #8
0
        public static bool Execute([NotNull] IProcessingContext context,
                                   [NotNull] IProcessingFeedback feedback,
                                   [NotNull] IEnumerable <IGdbProcess> processes,
                                   [CanBeNull] string actionName)
        {
            Assert.ArgumentNotNull(context, nameof(context));
            Assert.ArgumentNotNull(feedback, nameof(feedback));
            Assert.ArgumentNotNull(processes, nameof(processes));

            IGdbTransaction transaction = context.GetTransaction();
            IWorkspace      workspace   = context.GetWorkspace();

            // TODO - Consider: transient processes: execute a list of ProcessDescriptors;
            // TODO - for each descriptor, instantiate and configure a GdbProcess.

            return(transaction.Execute(
                       workspace,
                       () => Execute(context, feedback, processes),
                       actionName ?? GetActionName(processes)));
        }
예제 #9
0
            public CalculateControlPointsEngine(CalculateControlPoints config,
                                                IProcessingContext context,
                                                IProcessingFeedback feedback)
                : base(config.Name, context, feedback)
            {
                _inputDataset =
                    OpenRequiredDataset(config.InputDataset, nameof(config.InputDataset));

                _maximumAngle = config.MaximumAngle;

                if (!(0 <= _maximumAngle && _maximumAngle <= 180))
                {
                    throw ConfigError(
                              $"{nameof(config.MaximumAngle)} is {config.MaximumAngle}, not between 0 and 180");
                }

                _controlPointIdValue = ProcessingUtils.Clip(
                    config.ControlPointIdValue, 1, int.MaxValue,
                    nameof(config.ControlPointIdValue));

                _simplificationTolerance = ProcessingUtils.Clip(
                    config.SimplificationTolerance, 0, double.MaxValue,
                    nameof(config.SimplificationTolerance));                     // TODO convert Millimeters (Points) to MapUnits -- how?
            }
예제 #10
0
 public abstract void Execute(IProcessingContext context, IProcessingFeedback feedback);
예제 #11
0
            public AlignMarkersEngine(AlignMarkers config, IProcessingContext context, IProcessingFeedback feedback)
                : base(config.Name, context, feedback)
            {
                _inputDataset =
                    OpenRequiredDataset(config.InputDataset, nameof(config.InputDataset));

                _referenceDatasets = OpenDatasets(config.ReferenceDatasets);

                _searchDistance = ProcessingUtils.Clip(
                    config.SearchDistance, 0, double.MaxValue,
                    nameof(config.SearchDistance));

                _markerFieldSetter = ProcessingUtils.CreateFieldSetter(
                    config.MarkerAttributes, _inputDataset.FeatureClass,
                    nameof(config.MarkerAttributes));
            }
예제 #12
0
        private static void Execute([NotNull] IProcessingContext context,
                                    [NotNull] IProcessingFeedback feedback,
                                    [NotNull] IEnumerable <IGdbProcess> processes)
        {
            int current = 0, total = processes.Count();

            try
            {
                foreach (IGdbProcess process in processes)
                {
                    current += 1;

                    if (feedback.CancellationPending)
                    {
                        throw new OperationCanceledException();
                    }

                    ReportProcessStarting(feedback, process, current, total);

                    if (process is IGroupGdbProcess)
                    {
                        feedback.CurrentGroup   = process.Name;
                        feedback.CurrentProcess = null;
                    }
                    else
                    {
                        feedback.CurrentGroup   = null;
                        feedback.CurrentProcess = process.Name;

                        _msg.Debug(GetParameterDescription(process));
                    }

                    try
                    {
                        DateTime startTime = DateTime.Now;

                        using (_msg.IncrementIndentation())
                        {
                            process.Execute(context, feedback);
                        }

                        TimeSpan duration = DateTime.Now - startTime;
                        ReportProcessCompleted(feedback, process, duration);
                    }
                    catch (OperationCanceledException)
                    {
                        throw;                         // rethrow (but catch all other exceptions)
                    }
                    catch (Exception ex)
                    {
                        feedback.ReportError(
                            string.Format("Error executing {0} {1}: {2}",
                                          process is IGroupGdbProcess
                                                                              ? "Process Group"
                                                                              : "GdbProcess", process.Name,
                                          ex.Message), ex);
                    }
                }

                feedback.ReportCompleted();
            }
            catch (OperationCanceledException)
            {
                feedback.ReportStopped();
            }
        }