/// <summary> /// Handles the projection mismatch by implementing the selected mismatch behavior. /// </summary> private TestingResult HandleProjectionMismatch( ILayerSource layer, ISpatialReference mapProj, out ILayerSource newLayer) { newLayer = null; if (layer.LayerType == LayerType.WmsLayer) { return(TestingResult.Ok); } // user should be prompted if (!_usePreviousAnswerMismatch && _context.Config.ShowProjectionMismatchDialog) { var model = new ProjectionMismatchModel(layer, true, mapProj); if (!_context.Container.Run <ProjectionMismatchPresenter, ProjectionMismatchModel>(model)) { return(TestingResult.CancelOperation); } _usePreviousAnswerMismatch = model.UseAnswerLater; _context.Config.ProjectionMismatch = model.MismatchBehavior; _context.Config.ShowProjectionMismatchDialog = !model.DontShow; } var behavior = _context.Config.ProjectionMismatch; switch (behavior) { case ProjectionMismatch.Reproject: var result = _reprojectingService.Reproject(layer, out newLayer, mapProj, _report); if (result == TestingResult.Ok || result == TestingResult.Substituted) { var oper = result == TestingResult.Ok ? ProjectionOperation.Reprojected : ProjectionOperation.Substituted; string newName = newLayer == null ? "" : newLayer.Filename; _report.AddFile(layer.Filename, layer.Projection.Name, oper, newName); return(newName == layer.Filename ? TestingResult.Ok : TestingResult.Substituted); } _report.AddFile(layer.Filename, layer.Projection.Name, ProjectionOperation.FailedToReproject, ""); return(TestingResult.Error); case ProjectionMismatch.IgnoreMismatch: _report.AddFile(layer.Filename, layer.Projection.Name, ProjectionOperation.MismatchIgnored, ""); return(TestingResult.Ok); case ProjectionMismatch.SkipFile: _report.AddFile(layer.Filename, layer.Projection.Name, ProjectionOperation.Skipped, ""); return(TestingResult.SkipFile); } throw new ApplicationException("Invalid ProjectionMismatch setting: " + behavior); }
/// <summary> /// Handles the empty layer projection by implementing selected projection absence behavior. /// </summary> private TestingResult HandleEmptyLayerProjection(ILayerSource layer, ISpatialReference mapProj) { bool projectProjectionExists = !mapProj.IsEmpty; // user should be prompted if (!_usePreviousAnswerAbsence && _context.Config.ShowProjectionAbsenceDialog) { var model = new ProjectionMismatchModel(layer, false, mapProj); if (!_context.Container.Run <ProjectionMismatchPresenter, ProjectionMismatchModel>(model)) { return(TestingResult.CancelOperation); } _usePreviousAnswerAbsence = model.UseAnswerLater; _context.Config.ProjectionAbsence = model.AbsenceBehavior; _context.Config.ShowProjectionAbsenceDialog = !model.DontShow; } // when there is no projection in project, it can't be assign for layer var behavior = _context.Config.ProjectionAbsence; if (!projectProjectionExists && _context.Config.ProjectionAbsence == ProjectionAbsence.AssignFromProject) { behavior = ProjectionAbsence.IgnoreAbsence; } switch (behavior) { case ProjectionAbsence.AssignFromProject: _report.AddFile(layer.Filename, layer.Projection.Name, ProjectionOperation.Assigned, ""); layer.AssignProjection(mapProj); return(TestingResult.Ok); case ProjectionAbsence.IgnoreAbsence: _report.AddFile(layer.Filename, layer.Projection.Name, ProjectionOperation.AbsenceIgnored, ""); return(TestingResult.Ok); case ProjectionAbsence.SkipFile: _report.AddFile(layer.Filename, layer.Projection.Name, ProjectionOperation.Skipped, ""); return(TestingResult.SkipFile); } return(TestingResult.Ok); }