Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #334 from Esri/dev
Browse files Browse the repository at this point in the history
October, 2019 Release
  • Loading branch information
csmoore authored Oct 3, 2019
2 parents f56aeaf + ba40810 commit 8cc28af
Show file tree
Hide file tree
Showing 14 changed files with 594 additions and 163 deletions.
93 changes: 55 additions & 38 deletions source/addins/ArcMapAddinVisibility/ViewModels/LLOSViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public LLOSViewModel()
DisplayProgressBarLLOS = Visibility.Hidden;
// commands
SubmitCommand = new RelayCommand(OnSubmitCommand);

ClearGraphicsVisible = true;

}

#region Properties
Expand Down Expand Up @@ -213,10 +211,64 @@ internal override void CreateMapElement()
IsRunning = true;
IPolyline longestLine = new PolylineClass();

ReadSelectedLayerPoints();


ILayer surfaceLayer = GetLayerFromMapByName(ArcMap.Document.FocusMap, SelectedSurfaceName);
if (surfaceLayer == null)
{
System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgSurfaceLayerNotFound, VisibilityLibrary.Properties.Resources.CaptionError);
return;
}

IsValidSurface = ValidateElevationSurface();
if (!IsValidSurface)
{
return;
}

// Issue warning if layer is ImageServerLayer
if (surfaceLayer is IImageServerLayer)
{
MessageBoxResult mbr = MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgLayerIsImageService,
VisibilityLibrary.Properties.Resources.CaptionLayerIsImageService, MessageBoxButton.YesNo);

if (mbr == MessageBoxResult.No)
{
System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgTryAgain, VisibilityLibrary.Properties.Resources.MsgCalcCancelled);
return;
}
}

// Determine if selected surface is projected or geographic
var geoDataset = surfaceLayer as IGeoDataset;
if (geoDataset == null)
{
System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgTryAgain, VisibilityLibrary.Properties.Resources.CaptionError);
return;
}

SelectedSurfaceSpatialRef = geoDataset.SpatialReference;

if (SelectedSurfaceSpatialRef is IGeographicCoordinateSystem)
{
MessageBox.Show(VisibilityLibrary.Properties.Resources.LLOSUserPrompt, VisibilityLibrary.Properties.Resources.LLOSUserPromptCaption);
return;
}

if (ArcMap.Document.FocusMap.SpatialReference.FactoryCode != geoDataset.SpatialReference.FactoryCode)
{
MessageBox.Show(VisibilityLibrary.Properties.Resources.LOSDataFrameMatch, VisibilityLibrary.Properties.Resources.LOSSpatialReferenceCaption);
SetErrorTemplate(false);
return;
}

if (!CanCreateElement || ArcMap.Document == null || ArcMap.Document.FocusMap == null || string.IsNullOrWhiteSpace(SelectedSurfaceName))
return;

SetErrorTemplate(true);
ReadSelectedLayerPoints();


if ((LLOS_ObserversInExtent.Any() || ObserverAddInPoints.Any())
&& LLOS_TargetsInExtent.Any() || TargetAddInPoints.Any())
{
Expand All @@ -228,42 +280,7 @@ internal override void CreateMapElement()
if (surface == null)
return;

ILayer surfaceLayer = GetLayerFromMapByName(ArcMap.Document.FocusMap, SelectedSurfaceName);

// Issue warning if layer is ImageServerLayer
if (surfaceLayer is IImageServerLayer)
{
MessageBoxResult mbr = MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgLayerIsImageService,
VisibilityLibrary.Properties.Resources.CaptionLayerIsImageService, MessageBoxButton.YesNo);

if (mbr == MessageBoxResult.No)
{
System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgTryAgain, VisibilityLibrary.Properties.Resources.MsgCalcCancelled);
return;
}
}

// Determine if selected surface is projected or geographic
var geoDataset = surfaceLayer as IGeoDataset;
if (geoDataset == null)
{
System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgTryAgain, VisibilityLibrary.Properties.Resources.CaptionError);
return;
}

SelectedSurfaceSpatialRef = geoDataset.SpatialReference;

if (SelectedSurfaceSpatialRef is IGeographicCoordinateSystem)
{
MessageBox.Show(VisibilityLibrary.Properties.Resources.LLOSUserPrompt, VisibilityLibrary.Properties.Resources.LLOSUserPromptCaption);
return;
}

if (ArcMap.Document.FocusMap.SpatialReference.FactoryCode != geoDataset.SpatialReference.FactoryCode)
{
MessageBox.Show(VisibilityLibrary.Properties.Resources.LOSDataFrameMatch, VisibilityLibrary.Properties.Resources.LOSSpatialReferenceCaption);
return;
}

SelectedSurfaceSpatialRef = geoDataset.SpatialReference;

Expand Down
Loading

0 comments on commit 8cc28af

Please sign in to comment.