/// <summary>
        /// Override this event to collect observer points based on tool mode
        /// </summary>
        /// <param name="obj">MapPointToolMode</param>
        internal override async void OnNewMapPointEvent(object obj)
        {
            if (!IsActiveTab)
            {
                return;
            }

            var point = obj as MapPoint;

            if (point == null || !(await IsValidPoint(point, true)))
            {
                return;
            }

            // ok, we have a point
            if (ToolMode == MapPointToolMode.Observer)
            {
                // in tool mode "Observer" we add observer points
                // otherwise ignore

                var guid = await AddGraphicToMap(point, ColorFactory.Blue, true, 5.0);

                var addInPoint = new AddInPoint()
                {
                    Point = point, GUID = guid
                };
                Application.Current.Dispatcher.Invoke(() =>
                {
                    ObserverAddInPoints.Insert(0, addInPoint);
                });
            }
        }
        /// <summary>
        /// Override this event to collect observer points based on tool mode
        /// </summary>
        /// <param name="obj">MapPointToolMode</param>
        internal override void OnNewMapPointEvent(object obj)
        {
            if (!IsActiveTab)
            {
                return;
            }

            var point = obj as IPoint;

            if (point == null || !IsValidPoint(point, true))
            {
                return;
            }

            // ok, we have a point
            if (ToolMode == MapPointToolMode.Observer)
            {
                // in tool mode "Observer" we add observer points
                // otherwise ignore

                var color = new RgbColorClass()
                {
                    Blue = 255
                } as IColor;
                var guid       = AddGraphicToMap(point, color, true);
                var addInPoint = new AddInPoint()
                {
                    Point = point, GUID = guid
                };
                ObserverAddInPoints.Insert(0, addInPoint);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Method to handle the display coordinate type change
        /// Need to update the list boxes
        /// </summary>
        /// <param name="obj">null, not used</param>
        internal virtual void OnDisplayCoordinateTypeChanged(object obj)
        {
            var list          = ObserverAddInPoints.ToList();
            var inExtentList  = ObserverInExtentPoints.ToList();
            var outExtentList = ObserverOutExtentPoints.ToList();

            ObserverAddInPoints.Clear();
            ObserverInExtentPoints.Clear();
            ObserverOutExtentPoints.Clear();

            foreach (var item in list)
            {
                ObserverAddInPoints.Add(item);
            }

            foreach (var item in inExtentList)
            {
                ObserverInExtentPoints.Add(item);
            }

            foreach (var item in outExtentList)
            {
                ObserverOutExtentPoints.Add(item);
            }
            RaisePropertyChanged(() => HasMapGraphics);
        }
        /// <summary>
        /// Override to add aditional items in the class to reset tool
        /// </summary>
        /// <param name="toolReset"></param>
        internal override async Task Reset(bool toolReset)
        {
            try
            {
                await base.Reset(toolReset);

                if (MapView.Active == null || MapView.Active.Map == null)
                {
                    return;
                }

                // reset surface names OC
                await ResetSurfaceNames();

                Application.Current.Dispatcher.Invoke(() =>
                {
                    // reset observer points
                    ObserverAddInPoints.Clear();
                    ObserverInExtentPoints.Clear();
                    ObserverOutExtentPoints.Clear();
                    ClearTempGraphics();
                });
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Override to add aditional items in the class to reset tool
        /// </summary>
        /// <param name="toolReset"></param>
        internal override async Task Reset(bool toolReset)
        {
            try
            {
                await base.Reset(toolReset);

                if (MapView.Active == null || MapView.Active.Map == null)
                {
                    return;
                }

                // reset surface names OC
                await ResetSurfaceNames();

                Application.Current.Dispatcher.Invoke(() =>
                {
                    // reset observer points
                    ObserverAddInPoints.Clear();

                    ClearTempGraphics();
                });
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Here we need to create the lines of sight and determine is a target can be seen or not
        /// </summary>
        internal override async Task CreateMapElement()
        {
            try
            {
                await ReadSelectedLayers();

                if (string.IsNullOrWhiteSpace(SelectedSurfaceName))
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgSurfaceLayerNotFound,
                                                                     VisibilityLibrary.Properties.Resources.CaptionError);
                }

                if (!CanCreateElement || MapView.Active == null || MapView.Active.Map == null)
                {
                    return;
                }

                if ((LLOS_ObserversInExtent.Any() || ObserverAddInPoints.Any()) &&
                    LLOS_TargetsInExtent.Any() || TargetAddInPoints.Any())
                {
                    bool success = await ExecuteVisibilityLLOS();

                    if (!success)
                    {
                        MessageBox.Show("LLOS computations did not complete correctly.\nPlease check your parameters and try again.",
                                        VisibilityLibrary.Properties.Resources.CaptionError);
                    }
                }
                else
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(VisibilityLibrary.Properties.Resources.OutOfExtentMsg, VisibilityLibrary.Properties.Resources.OutOfExtentHeader);
                }

                DeactivateTool(VisibilityMapTool.ToolId);
                OnMapPointToolDeactivated(null);

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                //await base.CreateMapElement();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(VisibilityLibrary.Properties.Resources.ExceptionSomethingWentWrong,
                                                                 VisibilityLibrary.Properties.Resources.CaptionError);
            }
            finally
            {
                IsRunning = false;
                ClearLLOSCollections();
            }
        }
        /// <summary>
        /// Method used to check to see if a point is contained by an envelope
        /// </summary>
        /// <param name="point">IPoint</param>
        /// <param name="env">IEnvelope</param>
        /// <returns></returns>
        //TODO update to Pro
        //internal bool IsPointWithinExtent(MapPoint point, IEnvelope env)
        //{
        //    var relationOp = env as IRelationalOperator;

        //    if (relationOp == null)
        //        return false;

        //    return relationOp.Contains(point);
        //}

        /// <summary>
        /// Method to get a z offset distance in the correct units for the map
        /// </summary>
        /// <param name="map">IMap</param>
        /// <param name="offset">the input offset</param>
        /// <param name="zFactor">ISurface z factor</param>
        /// <param name="distanceType">the "from" distance unit type</param>
        /// <returns></returns>
        // Update to Pro
        //internal double GetOffsetInZUnits(IMap map, double offset, double zFactor, DistanceTypes distanceType)
        //{
        //    if (map.SpatialReference == null)
        //        return offset;

        //    double offsetInMapUnits = 0.0;
        //    DistanceTypes distanceTo = DistanceTypes.Meters; // default to meters

        //    var pcs = map.SpatialReference as IProjectedCoordinateSystem;

        //    if (pcs != null)
        //    {
        //        // need to convert the offset from the input distance type to the spatial reference linear type
        //        // then apply the zFactor
        //        distanceTo = GetDistanceType(pcs.CoordinateUnit.FactoryCode);
        //    }

        //    offsetInMapUnits = GetDistanceFromTo(distanceType, distanceTo, offset);

        //    var result = offsetInMapUnits / zFactor;

        //    return result;
        //}

        /// <summary>
        /// Method to get a ISurface from a map with layer name
        /// </summary>
        /// <param name="map">IMap that contains surface layer</param>
        /// <param name="name">Name of the layer that you are looking for</param>
        /// <returns>ISurface</returns>
        //TODO udpate to Pro
        //public ISurface GetSurfaceFromMapByName(IMap map, string name)
        //{
        //    for (int x = 0; x < map.LayerCount; x++)
        //    {
        //        var layer = map.get_Layer(x);

        //        if (layer == null || layer.Name != name)
        //            continue;

        //        var tin = layer as ITinLayer;
        //        if (tin != null)
        //        {
        //            return tin.Dataset as ISurface;
        //        }

        //        var rasterSurface = new RasterSurfaceClass() as IRasterSurface;
        //        ISurface surface = null;

        //        var mosaicLayer = layer as IMosaicLayer;
        //        var rasterLayer = layer as IRasterLayer;

        //        if (mosaicLayer != null && mosaicLayer.PreviewLayer != null && mosaicLayer.PreviewLayer.Raster != null)
        //        {
        //            rasterSurface.PutRaster(mosaicLayer.PreviewLayer.Raster, 0);
        //        }
        //        else if (rasterLayer != null && rasterLayer.Raster != null)
        //        {
        //            rasterSurface.PutRaster(rasterLayer.Raster, 0);
        //        }

        //        surface = rasterSurface as ISurface;

        //        if (surface != null)
        //            return surface;
        //    }

        //    return null;
        //}
        /// <summary>
        /// returns ILayer if found in the map layer collection
        /// </summary>
        /// <param name="map">IMap</param>
        /// <param name="name">string name of layer</param>
        /// <returns></returns>
        ///
        //TODO update to Pro
        //public ILayer GetLayerFromMapByName(IMap map, string name)
        //{
        //    for (int x = 0; x < map.LayerCount; x++)
        //    {
        //        var layer = map.get_Layer(x);

        //        if (layer == null || layer.Name != name)
        //            continue;

        //        return layer;
        //    }

        //    return null;
        //}

        /// <summary>
        /// Method to get all the names of the raster/tin layers that support ISurface
        /// we use this method to populate a combobox for input selection of surface layer
        /// </summary>
        /// <param name="map">IMap</param>
        /// <returns></returns>
        ///
        //TODO update to Pro
        //public List<string> GetSurfaceNamesFromMap(IMap map, bool IncludeTinLayers = false)
        //{
        //    var list = new List<string>();

        //    for (int x = 0; x < map.LayerCount; x++)
        //    {
        //        try
        //        {
        //            var layer = map.get_Layer(x);

        //            if (layer == null)
        //                continue;

        //            var tin = layer as ITinLayer;

        //            if (tin != null)
        //            {
        //                if (IncludeTinLayers)
        //                    list.Add(layer.Name);

        //                continue;
        //            }

        //            var rasterSurface = new RasterSurfaceClass() as IRasterSurface;
        //            ISurface surface = null;

        //            var ml = layer as IMosaicLayer;

        //            if (ml != null)
        //            {
        //                if (ml.PreviewLayer != null && ml.PreviewLayer.Raster != null)
        //                {
        //                    rasterSurface.PutRaster(ml.PreviewLayer.Raster, 0);

        //                    surface = rasterSurface as ISurface;
        //                    if (surface != null)
        //                        list.Add(layer.Name);
        //                }
        //                continue;
        //            }

        //            var rasterLayer = layer as IRasterLayer;
        //            if (rasterLayer != null && rasterLayer.Raster != null)
        //            {
        //                rasterSurface.PutRaster(rasterLayer.Raster, 0);

        //                surface = rasterSurface as ISurface;
        //                if (surface != null)
        //                    list.Add(layer.Name);
        //                continue;
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            Console.WriteLine(ex);
        //        }
        //    }

        //    return list;
        //}

        /// <summary>
        /// Override to add aditional items in the class to reset tool
        /// </summary>
        /// <param name="toolReset"></param>
        internal override void Reset(bool toolReset)
        {
            base.Reset(toolReset);

            // TODO update to Pro
            //if (ArcMap.Document == null || ArcMap.Document.FocusMap == null)
            //    return;

            //// reset surface names OC
            //ResetSurfaceNames(ArcMap.Document.FocusMap);

            // reset observer points
            ObserverAddInPoints.Clear();

            ClearTempGraphics();
        }
        /// <summary>
        /// Override this event to collect observer points based on tool mode
        /// </summary>
        /// <param name="obj">MapPointToolMode</param>
        internal override async void OnNewMapPointEvent(object obj)
        {
            if (!IsActiveTab)
            {
                return;
            }

            var point = obj as MapPoint;

            // ok, we have a point
            if (point != null && ToolMode == MapPointToolMode.Observer)
            {
                if (IsMapClick)
                {
                    if (!(await IsValidPoint(point, true)))
                    {
                        IsMapClick = false;
                        return;
                    }
                }
                // in tool mode "Observer" we add observer points
                // otherwise ignore

                var guid = await AddGraphicToMap(point, ColorFactory.Instance.BlueRGB, true, 5.0);

                var addInPoint = new AddInPoint()
                {
                    Point = point, GUID = guid
                };
                bool isValid = await IsValidPoint(point, false);

                Application.Current.Dispatcher.Invoke(() =>
                {
                    if (!isValid)
                    {
                        ObserverOutExtentPoints.Insert(0, addInPoint);
                    }
                    else
                    {
                        ObserverInExtentPoints.Insert(0, addInPoint);
                    }

                    ObserverAddInPoints.Insert(0, addInPoint);
                });
                IsMapClick = false;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Override this event to collect observer points based on tool mode
        /// </summary>
        /// <param name="obj">MapPointToolMode</param>
        internal override void OnNewMapPointEvent(object obj)
        {
            if (!IsActiveTab)
            {
                return;
            }

            var point = obj as IPoint;

            // ok, we have a point
            if (ToolMode == MapPointToolMode.Observer)
            {
                if (IsMapClick)
                {
                    if (!(IsValidPoint(point, true)))
                    {
                        IsMapClick = false;
                        return;
                    }
                }
                // in tool mode "Observer" we add observer points
                // otherwise ignore

                var color = new RgbColorClass()
                {
                    Blue = 255
                } as IColor;
                var guid       = AddGraphicToMap(point, color, true);
                var addInPoint = new AddInPoint()
                {
                    Point = point, GUID = guid
                };
                bool isValid = IsValidPoint(point, false);
                if (!isValid)
                {
                    ObserverOutExtentPoints.Insert(0, addInPoint);
                }
                else
                {
                    ObserverInExtentPoints.Insert(0, addInPoint);
                }

                ObserverAddInPoints.Insert(0, addInPoint);
                IsMapClick = false;
            }
        }
        private void DeletePoints(List <AddInPoint> observers)
        {
            if (observers == null || !observers.Any())
            {
                return;
            }

            // remove graphics from map
            var guidList = observers.Select(x => x.GUID).ToList();

            RemoveGraphics(guidList);

            foreach (var point in observers)
            {
                ObserverAddInPoints.Remove(point);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Override this event to collect observer points based on tool mode
        /// Setting the observer point to blue since the output is green / red
        /// </summary>
        /// <param name="obj"></param>
        internal override void OnNewMapPointEvent(object obj)
        {
            base.OnNewMapPointEvent(obj);

            if (!IsActiveTab)
            {
                return;
            }

            var point = obj as MapPoint;

            if (point == null)
            {
                return;
            }

            EnableOkCancelClearBtns(ObserverAddInPoints.Any());
        }
Esempio n. 12
0
        /// <summary>
        /// Override to add aditional items in the class to reset tool
        /// </summary>
        /// <param name="toolReset"></param>
        internal override void Reset(bool toolReset)
        {
            base.Reset(toolReset);

            if (ArcMap.Document == null || ArcMap.Document.FocusMap == null)
            {
                return;
            }

            // reset surface names OC
            ResetSurfaceNames(ArcMap.Document.FocusMap);

            // reset observer points
            ObserverAddInPoints.Clear();
            ObserverInExtentPoints.Clear();
            ObserverOutExtentPoints.Clear();

            ClearTempGraphics();
        }
Esempio n. 13
0
        internal override void OnDeleteAllPointsCommand(object obj)
        {
            base.OnDeleteAllPointsCommand(obj);

            EnableOkCancelClearBtns(ObserverAddInPoints.Any());
        }
 internal virtual void OnDeleteAllPointsCommand(object obj)
 {
     DeletePoints(ObserverAddInPoints.ToList());
 }
        /// <summary>
        /// Override this event to collect observer points based on tool mode
        /// </summary>
        /// <param name="obj">MapPointToolMode</param>
        internal override async void OnNewMapPointEvent(object obj)
        {
            if (!IsActiveTab)
            {
                return;
            }

            //if (string.IsNullOrEmpty(SelectedSurfaceName))
            //{
            //    MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgSurfaceLayerNotFound,
            //        VisibilityLibrary.Properties.Resources.CaptionError, MessageBoxButton.OK);
            //    return;
            //}

            //IsElevationSurfaceValid = ValidateElevationSurface(MapView.Active.Map, SelectedSurfaceName);
            //if (!await IsElevationSurfaceValid)
            //{
            //    MessageBox.Show(VisibilityLibrary.Properties.Resources.LOSDataFrameMatch, VisibilityLibrary.Properties.Resources.LOSSpatialReferenceCaption);
            //    SelectedSurfaceTooltip = VisibilityLibrary.Properties.Resources.LOSDataFrameMatch;
            //    SetErrorTemplate(false);
            //    return;
            //}

            var point = obj as MapPoint;

            // ok, we have a point
            if (point != null && ToolMode == MapPointToolMode.Observer)
            {
                if (IsMapClick)
                {
                    if (!(await IsValidPoint(point, true)))
                    {
                        IsMapClick = false;
                        return;
                    }
                }
                // in tool mode "Observer" we add observer points
                // otherwise ignore

                var guid = await AddGraphicToMap(point, ColorFactory.Instance.BlueRGB, true, 5.0);

                var addInPoint = new AddInPoint()
                {
                    Point = point, GUID = guid
                };
                bool isValid = await IsValidPoint(point, false);

                Application.Current.Dispatcher.Invoke(() =>
                {
                    if (!isValid)
                    {
                        ObserverOutExtentPoints.Insert(0, addInPoint);
                    }
                    else
                    {
                        ObserverInExtentPoints.Insert(0, addInPoint);
                    }

                    ObserverAddInPoints.Insert(0, addInPoint);
                });
                IsMapClick = false;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Where all of the work is done.  Override from TabBaseViewModel
        /// </summary>
        internal override async Task CreateMapElement()
        {
            try
            {
                IsRunning = true;

                if (string.IsNullOrEmpty(SelectedSurfaceName))
                {
                    MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgSurfaceLayerNotFound,
                                    VisibilityLibrary.Properties.Resources.CaptionError, MessageBoxButton.OK);
                    return;
                }


                IsElevationSurfaceValid = ValidateElevationSurface(MapView.Active.Map, SelectedSurfaceName);
                if (!await IsElevationSurfaceValid)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(VisibilityLibrary.Properties.Resources.LOSDataFrameMatch, VisibilityLibrary.Properties.Resources.LOSSpatialReferenceCaption);
                    SetErrorTemplate(false);
                    return;
                }
                else
                {
                    SetErrorTemplate(true);
                }

                await ReadSelectedLayers();

                if (!CanCreateElement || MapView.Active == null || MapView.Active.Map == null || string.IsNullOrWhiteSpace(SelectedSurfaceName))
                {
                    return;
                }

                if (RLOS_ObserversInExtent.Any() || ObserverAddInPoints.Any())
                {
                    bool success = await ExecuteVisibilityRLOS();

                    if (!success)
                    {
                        MessageBox.Show("RLOS computations did not complete correctly.\nPlease check your parameters and try again.",
                                        VisibilityLibrary.Properties.Resources.CaptionError);
                    }
                }
                else
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(VisibilityLibrary.Properties.Resources.OutOfExtentMsg, VisibilityLibrary.Properties.Resources.OutOfExtentHeader);
                }

                DeactivateTool(VisibilityMapTool.ToolId);
                OnMapPointToolDeactivated(null);

                //await base.CreateMapElement();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(VisibilityLibrary.Properties.Resources.ExceptionSomethingWentWrong,
                                                                 VisibilityLibrary.Properties.Resources.CaptionError);
            }
            finally
            {
                IsRunning = false;
                if (ObserverAddInPoints.Count == 0)
                {
                    IsRLOSValidSelection = false;
                }
                else
                {
                    IsRLOSValidSelection = true;
                }

                ClearRLOSCollections();
                ValidateRLOS_LayerSelection();
            }
        }
Esempio n. 17
0
        private async Task <bool> ExecuteVisibilityLLOS()
        {
            bool success = false;

            try
            {
                // Check surface spatial reference
                var surfaceSR = await GetSpatialReferenceFromLayer(SelectedSurfaceName);

                if (surfaceSR == null || !surfaceSR.IsProjected)
                {
                    MessageBox.Show(VisibilityLibrary.Properties.Resources.RLOSUserPrompt, VisibilityLibrary.Properties.Resources.RLOSUserPromptCaption);

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        TargetAddInPoints.Clear();
                        ObserverAddInPoints.Clear();
                        ObserverInExtentPoints.Clear();
                        TargetInExtentPoints.Clear();
                        ObserverOutExtentPoints.Clear();
                        TargetOutExtentPoints.Clear();
                        ClearTempGraphics();
                    });

                    await Reset(true);

                    return(false);
                }

                if (string.IsNullOrEmpty(SelectedSurfaceName))
                {
                    MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgSurfaceLayerNotFound,
                                    VisibilityLibrary.Properties.Resources.CaptionError, MessageBoxButton.OK);
                    return(true);
                }

                //Validate Dataframe Spatial reference with surface spatial reference
                IsElevationSurfaceValid = ValidateElevationSurface(MapView.Active.Map, SelectedSurfaceName);
                if (!await IsElevationSurfaceValid)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(VisibilityLibrary.Properties.Resources.LOSDataFrameMatch, VisibilityLibrary.Properties.Resources.LOSSpatialReferenceCaption);
                    SetErrorTemplate(false);
                    return(true);
                }
                else
                {
                    SetErrorTemplate(true);
                }

                var observerPoints = new ObservableCollection <AddInPoint>(LLOS_ObserversInExtent.Select(x => x.AddInPoint).Union(ObserverInExtentPoints));
                var targetPoints   = new ObservableCollection <AddInPoint>(LLOS_TargetsInExtent.Select(x => x.AddInPoint).Union(TargetInExtentPoints));
                // Warn if Image Service layer
                Layer surfaceLayer = GetLayerFromMapByName(SelectedSurfaceName);
                if (surfaceLayer is ImageServiceLayer)
                {
                    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(false);
                    }
                }



                await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
                {
                    using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(CoreModule.CurrentProject.DefaultGeodatabasePath))))
                    {
                        executionCounter              = 0;
                        int featureDataSetSuffix      = 0;
                        var enterpriseDefinitionNames = geodatabase.GetDefinitions <FeatureDatasetDefinition>().Where(i => i.GetName().StartsWith(VisibilityLibrary.Properties.Resources.LLOSFeatureDatasetName)).Select(i => i.GetName()).ToList();
                        foreach (var defName in enterpriseDefinitionNames)
                        {
                            int n;
                            bool isNumeric = int.TryParse(Regex.Match(defName, @"\d+$").Value, out n);
                            if (isNumeric)
                            {
                                featureDataSetSuffix = featureDataSetSuffix < n ? n : featureDataSetSuffix;
                            }
                        }
                        featureDataSetSuffix = enterpriseDefinitionNames.Count > 0 ? featureDataSetSuffix + 1 : 0;

                        var observerLyrSuffix   = GetLayerSuffix(VisibilityLibrary.Properties.Resources.LLOSObserversLayerName, geodatabase);
                        var targetLyrSuffix     = GetLayerSuffix(VisibilityLibrary.Properties.Resources.LLOSTargetsLayerName, geodatabase);
                        var sightLinesLyrSuffix = GetLayerSuffix(VisibilityLibrary.Properties.Resources.LLOSSightLinesLayerName, geodatabase);
                        var outputLyrSuffix     = GetLayerSuffix(VisibilityLibrary.Properties.Resources.LLOSOutputLayerName, geodatabase);

                        executionCounter = new List <int> {
                            featureDataSetSuffix, observerLyrSuffix, targetLyrSuffix, sightLinesLyrSuffix, outputLyrSuffix
                        }.Max();
                    }
                });

                //Create Feature dataset
                success = await FeatureClassHelper.CreateFeatureDataset(FeatureDatasetName);

                if (!success)
                {
                    return(false);
                }

                success = await FeatureClassHelper.CreateLayer(FeatureDatasetName, ObserversLayerName, "POINT", true, true);

                if (!success)
                {
                    return(false);
                }

                // add fields for observer offset

                await FeatureClassHelper.AddFieldToLayer(ObserversLayerName, VisibilityLibrary.Properties.Resources.OffsetFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(ObserversLayerName, VisibilityLibrary.Properties.Resources.OffsetWithZFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(ObserversLayerName, VisibilityLibrary.Properties.Resources.TarIsVisFieldName, "SHORT");

                success = await FeatureClassHelper.CreateLayer(FeatureDatasetName, TargetsLayerName, "POINT", true, true);

                if (!success)
                {
                    return(false);
                }

                // add fields for target offset

                await FeatureClassHelper.AddFieldToLayer(TargetsLayerName, VisibilityLibrary.Properties.Resources.OffsetFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(TargetsLayerName, VisibilityLibrary.Properties.Resources.OffsetWithZFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(TargetsLayerName, VisibilityLibrary.Properties.Resources.NumOfObserversFieldName, "SHORT");

                // add observer points to feature layer
                await FeatureClassHelper.CreatingFeatures(ObserversLayerName, observerPoints, GetAsMapZUnits(surfaceSR, ObserverOffset.Value));

                // add target points to feature layer
                await FeatureClassHelper.CreatingFeatures(TargetsLayerName, targetPoints, GetAsMapZUnits(surfaceSR, TargetOffset.Value));

                // update with surface information
                success = await FeatureClassHelper.AddSurfaceInformation(ObserversLayerName, SelectedSurfaceName, VisibilityLibrary.Properties.Resources.ZFieldName);

                if (!success)
                {
                    return(false);
                }

                success = await FeatureClassHelper.AddSurfaceInformation(TargetsLayerName, SelectedSurfaceName, VisibilityLibrary.Properties.Resources.ZFieldName);

                if (!success)
                {
                    return(false);
                }

                await FeatureClassHelper.UpdateShapeWithZ(ObserversLayerName, VisibilityLibrary.Properties.Resources.ZFieldName, GetAsMapZUnits(surfaceSR, ObserverOffset.Value));

                await FeatureClassHelper.UpdateShapeWithZ(TargetsLayerName, VisibilityLibrary.Properties.Resources.ZFieldName, GetAsMapZUnits(surfaceSR, TargetOffset.Value));

                // create sight lines
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                success = await FeatureClassHelper.CreateSightLines(ObserversLayerName,
                                                                    TargetsLayerName,
                                                                    CoreModule.CurrentProject.DefaultGeodatabasePath + System.IO.Path.DirectorySeparatorChar + FeatureDatasetName + System.IO.Path.DirectorySeparatorChar + SightLinesLayerName,
                                                                    VisibilityLibrary.Properties.Resources.OffsetWithZFieldName,
                                                                    VisibilityLibrary.Properties.Resources.OffsetWithZFieldName);

                if (!success)
                {
                    return(false);
                }

                // LOS
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                success = await FeatureClassHelper.CreateLOS(SelectedSurfaceName,
                                                             CoreModule.CurrentProject.DefaultGeodatabasePath + System.IO.Path.DirectorySeparatorChar + FeatureDatasetName + System.IO.Path.DirectorySeparatorChar + SightLinesLayerName,
                                                             CoreModule.CurrentProject.DefaultGeodatabasePath + System.IO.Path.DirectorySeparatorChar + FeatureDatasetName + System.IO.Path.DirectorySeparatorChar + OutputLayerName);

                if (!success)
                {
                    return(false);
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                // join fields with sight lines

                await FeatureClassHelper.JoinField(CoreModule.CurrentProject.DefaultGeodatabasePath + System.IO.Path.DirectorySeparatorChar + FeatureDatasetName + System.IO.Path.DirectorySeparatorChar + SightLinesLayerName,
                                                   "OID",
                                                   CoreModule.CurrentProject.DefaultGeodatabasePath + System.IO.Path.DirectorySeparatorChar + FeatureDatasetName + System.IO.Path.DirectorySeparatorChar + OutputLayerName,
                                                   "SourceOID",
                                                   new string[] { "TarIsVis" });

                // gather results for updating observer and target layers
                var sourceOIDs = await FeatureClassHelper.GetSourceOIDs(OutputLayerName);

                //if (sourceOIDs.Count > 0)
                //{
                var visStats = await FeatureClassHelper.GetVisibilityStats(sourceOIDs, SightLinesLayerName);

                await FeatureClassHelper.UpdateLayersWithVisibilityStats(visStats, ObserversLayerName, TargetsLayerName);

                //}

                var observersLayer  = GetLayerFromMapByName(ObserversLayerName) as FeatureLayer;
                var targetsLayer    = GetLayerFromMapByName(TargetsLayerName) as FeatureLayer;
                var sightLinesLayer = GetLayerFromMapByName(SightLinesLayerName) as FeatureLayer;
                var outputLayer     = GetLayerFromMapByName(OutputLayerName) as FeatureLayer;

                var observerOutOfExtent = new ObservableCollection <AddInPoint>(LLOS_ObserversOutOfExtent.Select(x => x.AddInPoint).Union(ObserverOutExtentPoints));
                // add observer points present out of extent to feature layer
                await FeatureClassHelper.CreatingFeatures(ObserversLayerName, observerOutOfExtent, GetAsMapZUnits(surfaceSR, TargetOffset.Value), VisibilityLibrary.Properties.Resources.TarIsVisFieldName);

                var targetOutOfExtent = new ObservableCollection <AddInPoint>(LLOS_TargetsOutOfExtent.Select(x => x.AddInPoint).Union(TargetOutExtentPoints));
                // add target points present out of extent to feature layer
                await FeatureClassHelper.CreatingFeatures(TargetsLayerName, targetOutOfExtent, GetAsMapZUnits(surfaceSR, TargetOffset.Value), VisibilityLibrary.Properties.Resources.NumOfObserversFieldName);

                if (observersLayer != null && targetsLayer != null && sightLinesLayer != null && outputLayer != null)
                {
                    await FeatureClassHelper.CreateObserversRenderer(GetLayerFromMapByName(ObserversLayerName) as FeatureLayer);

                    await FeatureClassHelper.CreateTargetsRenderer(GetLayerFromMapByName(TargetsLayerName) as FeatureLayer);

                    await FeatureClassHelper.CreateTargetLayerLabels(GetLayerFromMapByName(TargetsLayerName) as FeatureLayer);

                    await FeatureClassHelper.CreateVisCodeRenderer(GetLayerFromMapByName(SightLinesLayerName) as FeatureLayer,
                                                                   VisibilityLibrary.Properties.Resources.TarIsVisFieldName,
                                                                   1,
                                                                   0,
                                                                   ColorFactory.Instance.WhiteRGB,
                                                                   ColorFactory.Instance.BlackRGB,
                                                                   6.0,
                                                                   6.0);

                    await FeatureClassHelper.CreateVisCodeRenderer(GetLayerFromMapByName(OutputLayerName) as FeatureLayer,
                                                                   VisibilityLibrary.Properties.Resources.VisCodeFieldName,
                                                                   1,
                                                                   2,
                                                                   ColorFactory.Instance.GreenRGB,
                                                                   ColorFactory.Instance.RedRGB,
                                                                   5.0,
                                                                   3.0);

                    //await Reset(true);

                    //string groupName = "LLOS Group";
                    //if (executionCounter > 0)
                    //    groupName = string.Format("{0}_{1}", groupName, executionCounter.ToString());

                    //await FeatureClassHelper.CreateGroupLayer(layerList, groupName);

                    // for now we are not resetting after a run of the tool
                    //await Reset(true);


                    List <Layer> lyrList = new List <Layer>();
                    lyrList.Add(observersLayer);
                    lyrList.Add(targetsLayer);
                    lyrList.Add(outputLayer);
                    lyrList.Add(sightLinesLayer);

                    await FeatureClassHelper.MoveLayersToGroupLayer(lyrList, FeatureDatasetName);

                    var envelope = await QueuedTask.Run(() => outputLayer.QueryExtent());
                    await ZoomToExtent(envelope);

                    var surfaceEnvelope = await GetSurfaceEnvelope();
                    await DisplayOutOfExtentMsg(surfaceEnvelope);

                    success = true;
                }
                else
                {
                    success = false;
                }
            }
            catch (Exception ex)
            {
                success = false;
                Debug.Print(ex.Message);
            }

            return(success);
        }
Esempio n. 18
0
        private async Task <bool> ExecuteVisibilityLLOS()
        {
            bool success = false;

            try
            {
                // Check surface spatial reference
                var surfaceSR = await GetSpatialReferenceFromLayer(SelectedSurfaceName);

                if (surfaceSR == null || !surfaceSR.IsProjected)
                {
                    MessageBox.Show(VisibilityLibrary.Properties.Resources.RLOSUserPrompt, VisibilityLibrary.Properties.Resources.RLOSUserPromptCaption);

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        TargetAddInPoints.Clear();
                        ObserverAddInPoints.Clear();
                        ClearTempGraphics();
                    });

                    await Reset(true);

                    return(false);
                }

                // Warn if Image Service layer
                Layer surfaceLayer = GetLayerFromMapByName(SelectedSurfaceName);
                if (surfaceLayer is ImageServiceLayer)
                {
                    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(false);
                    }
                }

                success = await FeatureClassHelper.CreateLayer(ObserversLayerName, "POINT", true, true);

                // add fields for observer offset

                await FeatureClassHelper.AddFieldToLayer(ObserversLayerName, VisibilityLibrary.Properties.Resources.OffsetFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(ObserversLayerName, VisibilityLibrary.Properties.Resources.OffsetWithZFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(ObserversLayerName, VisibilityLibrary.Properties.Resources.TarIsVisFieldName, "SHORT");

                success = await FeatureClassHelper.CreateLayer(TargetsLayerName, "POINT", true, true);

                if (!success)
                {
                    return(false);
                }

                // add fields for target offset

                await FeatureClassHelper.AddFieldToLayer(TargetsLayerName, VisibilityLibrary.Properties.Resources.OffsetFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(TargetsLayerName, VisibilityLibrary.Properties.Resources.OffsetWithZFieldName, "DOUBLE");

                await FeatureClassHelper.AddFieldToLayer(TargetsLayerName, VisibilityLibrary.Properties.Resources.NumOfObserversFieldName, "SHORT");

                // add observer points to feature layer
                await FeatureClassHelper.CreatingFeatures(ObserversLayerName, ObserverAddInPoints, GetAsMapZUnits(surfaceSR, ObserverOffset.Value));

                // add target points to feature layer
                await FeatureClassHelper.CreatingFeatures(TargetsLayerName, TargetAddInPoints, GetAsMapZUnits(surfaceSR, TargetOffset.Value));

                // update with surface information
                success = await FeatureClassHelper.AddSurfaceInformation(ObserversLayerName, SelectedSurfaceName, VisibilityLibrary.Properties.Resources.ZFieldName);

                if (!success)
                {
                    return(false);
                }

                success = await FeatureClassHelper.AddSurfaceInformation(TargetsLayerName, SelectedSurfaceName, VisibilityLibrary.Properties.Resources.ZFieldName);

                if (!success)
                {
                    return(false);
                }

                await FeatureClassHelper.UpdateShapeWithZ(ObserversLayerName, VisibilityLibrary.Properties.Resources.ZFieldName, GetAsMapZUnits(surfaceSR, ObserverOffset.Value));

                await FeatureClassHelper.UpdateShapeWithZ(TargetsLayerName, VisibilityLibrary.Properties.Resources.ZFieldName, GetAsMapZUnits(surfaceSR, TargetOffset.Value));

                // create sight lines
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                success = await FeatureClassHelper.CreateSightLines(ObserversLayerName,
                                                                    TargetsLayerName,
                                                                    CoreModule.CurrentProject.DefaultGeodatabasePath + "\\" + SightLinesLayerName,
                                                                    VisibilityLibrary.Properties.Resources.OffsetWithZFieldName,
                                                                    VisibilityLibrary.Properties.Resources.OffsetWithZFieldName);

                if (!success)
                {
                    return(false);
                }

                // LOS
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                success = await FeatureClassHelper.CreateLOS(SelectedSurfaceName,
                                                             CoreModule.CurrentProject.DefaultGeodatabasePath + "\\" + SightLinesLayerName,
                                                             CoreModule.CurrentProject.DefaultGeodatabasePath + "\\" + OutputLayerName);

                if (!success)
                {
                    return(false);
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                // join fields with sight lines

                await FeatureClassHelper.JoinField(CoreModule.CurrentProject.DefaultGeodatabasePath + "\\" + SightLinesLayerName,
                                                   "OID",
                                                   CoreModule.CurrentProject.DefaultGeodatabasePath + "\\" + OutputLayerName,
                                                   "SourceOID",
                                                   new string[] { "TarIsVis" });

                // gather results for updating observer and target layers
                var sourceOIDs = await FeatureClassHelper.GetSourceOIDs(OutputLayerName);

                //if (sourceOIDs.Count > 0)
                //{
                var visStats = await FeatureClassHelper.GetVisibilityStats(sourceOIDs, SightLinesLayerName);

                await FeatureClassHelper.UpdateLayersWithVisibilityStats(visStats, ObserversLayerName, TargetsLayerName);

                //}

                var observersLayer  = GetLayerFromMapByName(ObserversLayerName) as FeatureLayer;
                var targetsLayer    = GetLayerFromMapByName(TargetsLayerName) as FeatureLayer;
                var sightLinesLayer = GetLayerFromMapByName(SightLinesLayerName) as FeatureLayer;
                var outputLayer     = GetLayerFromMapByName(OutputLayerName) as FeatureLayer;

                if (observersLayer != null && targetsLayer != null && sightLinesLayer != null && outputLayer != null)
                {
                    await FeatureClassHelper.CreateObserversRenderer(GetLayerFromMapByName(ObserversLayerName) as FeatureLayer);

                    await FeatureClassHelper.CreateTargetsRenderer(GetLayerFromMapByName(TargetsLayerName) as FeatureLayer);

                    await FeatureClassHelper.CreateTargetLayerLabels(GetLayerFromMapByName(TargetsLayerName) as FeatureLayer);

                    await FeatureClassHelper.CreateVisCodeRenderer(GetLayerFromMapByName(SightLinesLayerName) as FeatureLayer,
                                                                   VisibilityLibrary.Properties.Resources.TarIsVisFieldName,
                                                                   1,
                                                                   0,
                                                                   ColorFactory.Instance.WhiteRGB,
                                                                   ColorFactory.Instance.BlackRGB,
                                                                   6.0,
                                                                   6.0);

                    await FeatureClassHelper.CreateVisCodeRenderer(GetLayerFromMapByName(OutputLayerName) as FeatureLayer,
                                                                   VisibilityLibrary.Properties.Resources.VisCodeFieldName,
                                                                   1,
                                                                   2,
                                                                   ColorFactory.Instance.GreenRGB,
                                                                   ColorFactory.Instance.RedRGB,
                                                                   5.0,
                                                                   3.0);

                    //await Reset(true);

                    //string groupName = "LLOS Group";
                    //if (executionCounter > 0)
                    //    groupName = string.Format("{0}_{1}", groupName, executionCounter.ToString());

                    //await FeatureClassHelper.CreateGroupLayer(layerList, groupName);

                    // for now we are not resetting after a run of the tool
                    //await Reset(true);
                    var envelope = await QueuedTask.Run(() => outputLayer.QueryExtent());
                    await ZoomToExtent(envelope);

                    executionCounter++;

                    success = true;
                }
                else
                {
                    success = false;
                }
            }
            catch (Exception ex)
            {
                success = false;
                Debug.Print(ex.Message);
            }

            return(success);
        }
Esempio n. 19
0
        /// <summary>
        /// Here we need to create the lines of sight and determine is a target can be seen or not
        /// Visualize the visible targets with GREEN circles
        /// Visualize the non visible targets with RED circles
        /// Visualize the number of observers that can see a target with a label #
        /// Visualize an observer that can see no targets with a RED circle on top of a BLUE circle
        /// Visualize an observer that can see at least one target with a GREEN circle on top of a BLUE circle
        /// </summary>
        internal override void CreateMapElement()
        {
            try
            {
                IsRunning = true;
                IPolyline longestLine = new PolylineClass();

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

                if ((LLOS_ObserversInExtent.Any() || ObserverAddInPoints.Any()) &&
                    LLOS_TargetsInExtent.Any() || TargetAddInPoints.Any())
                {
                    // take your observer and target points and get lines of sight
                    var observerPoints = new ObservableCollection <AddInPoint>(LLOS_ObserversInExtent.Select(x => x.AddInPoint).Union(ObserverInExtentPoints));
                    var targetPoints   = new ObservableCollection <AddInPoint>(LLOS_TargetsInExtent.Select(x => x.AddInPoint).Union(TargetInExtentPoints));
                    var surface        = GetSurfaceFromMapByName(ArcMap.Document.FocusMap, SelectedSurfaceName);

                    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;

                    var geoBridge = (IGeoDatabaseBridge2) new GeoDatabaseHelperClass();

                    IPoint    pointObstruction = null;
                    IPolyline polyVisible      = null;
                    IPolyline polyInvisible    = null;
                    bool      targetIsVisible  = false;

                    double finalObserverOffset = GetOffsetInZUnits(ObserverOffset.Value, surface.ZFactor, OffsetUnitType);
                    double finalTargetOffset   = GetOffsetInZUnits(TargetOffset.Value, surface.ZFactor, OffsetUnitType);

                    var DictionaryTargetObserverCount = new Dictionary <IPoint, int>();

                    foreach (var observerPoint in observerPoints)
                    {
                        // keep track of visible targets for this observer
                        var CanSeeAtLeastOneTarget = false;

                        var z1 = surface.GetElevation(observerPoint.Point) + finalObserverOffset;

                        if (double.IsNaN(z1))
                        {
                            System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.LLOSPointsOutsideOfSurfaceExtent, VisibilityLibrary.Properties.Resources.MsgCalcCancelled);
                            return;
                        }

                        foreach (var targetPoint in targetPoints)
                        {
                            var z2 = surface.GetElevation(targetPoint.Point) + finalTargetOffset;

                            if (double.IsNaN(z2))
                            {
                                System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.LLOSPointsOutsideOfSurfaceExtent, VisibilityLibrary.Properties.Resources.MsgCalcCancelled);
                                return;
                            }

                            var fromPoint = new PointClass()
                            {
                                Z = z1, X = observerPoint.Point.X, Y = observerPoint.Point.Y, ZAware = true
                            } as IPoint;
                            var toPoint = new PointClass()
                            {
                                Z = z2, X = targetPoint.Point.X, Y = targetPoint.Point.Y, ZAware = true
                            } as IPoint;

                            geoBridge.GetLineOfSight(surface, fromPoint, toPoint,
                                                     out pointObstruction, out polyVisible, out polyInvisible, out targetIsVisible, false, false);

                            var pcol = new PolylineClass() as IPointCollection;
                            pcol.AddPoint(fromPoint);
                            pcol.AddPoint(toPoint);
                            IPolyline pcolPolyline = pcol as IPolyline;

                            longestLine = (longestLine != null && longestLine.Length < pcolPolyline.Length) ? pcolPolyline : longestLine;

                            // set the flag if we can see at least one target
                            if (targetIsVisible)
                            {
                                CanSeeAtLeastOneTarget = true;

                                // update target observer count
                                UpdateTargetObserverCount(DictionaryTargetObserverCount, targetPoint.Point);
                            }

                            // First Add "SightLine" so it appears behind others
                            // Black = Not visible -or- White = Visible
                            if (targetIsVisible)
                            {
                                AddGraphicToMap(pcolPolyline, new RgbColorClass()
                                {
                                    RGB = 0xFFFFFF
                                }, false,
                                                size: 6); //  white line
                            }
                            else
                            {
                                AddGraphicToMap(pcolPolyline, new RgbColorClass()
                                {
                                    RGB = 0x000000
                                }, false,
                                                size: 6); //  black line
                            }
                            if (polyVisible != null)
                            {
                                AddGraphicToMap(polyVisible, new RgbColorClass()
                                {
                                    Green = 255
                                }, size: 5);
                            }

                            if (polyInvisible != null)
                            {
                                AddGraphicToMap(polyInvisible, new RgbColorClass()
                                {
                                    Red = 255
                                }, size: 3);
                            }

                            if (polyVisible == null && polyInvisible == null)
                            {
                                if (targetIsVisible)
                                {
                                    AddGraphicToMap(pcol as IPolyline, new RgbColorClass()
                                    {
                                        Green = 255
                                    }, size: 3);
                                }
                                else
                                {
                                    AddGraphicToMap(pcol as IPolyline, new RgbColorClass()
                                    {
                                        Red = 255
                                    }, size: 3);
                                }
                            }
                        }

                        // visualize observer

                        // add blue dot
                        AddGraphicToMap(observerPoint.Point, new RgbColorClass()
                        {
                            Blue = 255
                        }, size: 10);

                        if (CanSeeAtLeastOneTarget)
                        {
                            // add green dot
                            AddGraphicToMap(observerPoint.Point, new RgbColorClass()
                            {
                                Green = 255
                            });
                        }
                        else
                        {
                            // add red dot
                            AddGraphicToMap(observerPoint.Point, new RgbColorClass()
                            {
                                Red = 255
                            });
                        }
                    }

                    VisualizeTargets(DictionaryTargetObserverCount, targetPoints);

                    if ((ObserverInExtentPoints.Any() || LLOS_ObserversInExtent.Any()) &&
                        (TargetInExtentPoints.Any() || LLOS_TargetsInExtent.Any()))
                    {
                        ZoomToExtent(longestLine);
                    }

                    DisplayOutOfExtentMsg();

                    //display points present out of extent
                    var colorObserver = new RgbColorClass()
                    {
                        Blue = 255
                    };
                    var colorTarget = new RgbColorClass()
                    {
                        Red = 255
                    };
                    var colorObserverBorder = new RgbColorClass()
                    {
                        Red = 255, Blue = 255, Green = 255
                    };
                    var colorTargetBorder = new RgbColorClass()
                    {
                        Red = 0, Blue = 0, Green = 0
                    };
                    var observerOutOfExtent = new ObservableCollection <AddInPoint>(LLOS_ObserversOutOfExtent.Select(x => x.AddInPoint).Union(ObserverOutExtentPoints));
                    foreach (var point in observerOutOfExtent)
                    {
                        AddGraphicToMap(point.Point, colorObserver, markerStyle: esriSimpleMarkerStyle.esriSMSX, size: 10, borderColor: colorObserverBorder);
                    }
                    var targetOutOfExtent = new ObservableCollection <AddInPoint>(LLOS_TargetsOutOfExtent.Select(x => x.AddInPoint).Union(TargetOutExtentPoints));
                    foreach (var point in targetOutOfExtent)
                    {
                        AddGraphicToMap(point.Point, colorTarget, markerStyle: esriSimpleMarkerStyle.esriSMSX, size: 10, borderColor: colorTargetBorder);
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.OutOfExtentMsg, VisibilityLibrary.Properties.Resources.OutOfExtentHeader);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                System.Windows.Forms.MessageBox.Show(VisibilityLibrary.Properties.Resources.ExceptionSomethingWentWrong,
                                                     VisibilityLibrary.Properties.Resources.CaptionError);
            }
            finally
            {
                IsRunning = false;
                ClearLLOSCollections();
                ValidateLLOS_LayerSelection();
            }
        }