Exemplo n.º 1
0
        private void SetCoverageAreas(string observerPointsFeatureClassName, bool needToRecalcDistance)
        {
            _logger.DebugEx("> SetCoverageAreas START");

            var observerPointsFeatureClass = GdbAccess.Instance.GetFeatureClass(_gdb, observerPointsFeatureClassName);

            var observationPoints = GetObservationPoints(observerPointsFeatureClassName);

            if (observationPoints == null || observationPoints.Count() == 0)
            {
                _logger.ErrorEx($"> SetCoverageAreas END. Observation points are not found");
                return;
            }

            var observObjPolygons = new Dictionary <int, IPolygon>();

            foreach (var pointModel in observationPoints)
            {
                var    point     = observerPointsFeatureClass.GetFeature(pointModel.Objectid);
                IPoint pointGeom = point.Shape as IPoint;
                pointGeom.Project(VisibilityManager.CurrentMap.SpatialReference);

                var      realMaxDistance   = needToRecalcDistance ? EsriTools.GetMaxDistance(pointModel.OuterRadius.Value, pointModel.AngelMaxH.Value, pointModel.RelativeHeight.Value) : pointModel.OuterRadius.Value;
                var      realMinDistance   = needToRecalcDistance ? EsriTools.GetMinDistance(pointModel.InnerRadius.Value, pointModel.AngelMinH.Value, pointModel.RelativeHeight.Value) : pointModel.InnerRadius.Value;
                IPolygon visibilityPolygon = null;

                if (realMaxDistance < realMinDistance)
                {
                    _logger.WarnEx("> SetCoverageAreas END. Observation point doesn`t has a coverage area");
                }
                else
                {
                    visibilityPolygon = EsriTools.GetCoverageArea(
                        pointGeom,
                        pointModel.AzimuthStart.Value,
                        pointModel.AzimuthEnd.Value,
                        realMinDistance,
                        realMaxDistance);
                }

                _coverageAreaData.Add(new CoverageAreaData
                {
                    ObjId   = -1,
                    PointId = pointModel.Objectid,
                    Polygon = visibilityPolygon
                });
            }

            var totalArea = EsriTools.GetTotalPolygon(_coverageAreaData.Select(area => { return(area.Polygon); }).ToList());

            _coverageAreaData.Add(new CoverageAreaData
            {
                ObjId   = -1,
                PointId = -1,
                Polygon = totalArea
            });

            _logger.DebugEx("> SetCoverageAreas END");
        }