/// <summary>
        /// Gets the WSD information.
        /// </summary>
        /// <typeparam name="T">type of request</typeparam>
        /// <param name="request">The request.</param>
        /// <returns>returns Incumbent.</returns>
        public override Incumbent[] GetWSDInfo <T>(T request)
        {
            List <Incumbent> wsdInfo     = new List <Incumbent>();
            Type             requestType = typeof(T);

            if (requestType == typeof(IAvailableSpectrumRequest))
            {
                var       spectrumRequest = request as IAvailableSpectrumRequest;
                Incumbent incumbent       = new Incumbent()
                {
                    Location = spectrumRequest.MasterDeviceLocation != null?spectrumRequest.MasterDeviceLocation.ToLocation() : spectrumRequest.Location.ToLocation(),
                                   IncumbentType = Conversion.ToIncumbentType(spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.FccTvbdDeviceType : spectrumRequest.DeviceDescriptor.FccTvbdDeviceType),
                };

                if (spectrumRequest.Antenna != null)
                {
                    incumbent.Height = spectrumRequest.Antenna.Height;
                }

                wsdInfo.Add(incumbent);
            }
            else if (requestType == typeof(IBatchAvailableSpectrumRequest))
            {
                var spectrumRequest = request as IBatchAvailableSpectrumRequest;
                foreach (var receiverLocation in spectrumRequest.Locations)
                {
                    var currentIncumbent = new Incumbent()
                    {
                        Location      = receiverLocation.ToLocation(),
                        IncumbentType = Conversion.ToIncumbentType(spectrumRequest.DeviceDescriptor.FccTvbdDeviceType)
                    };

                    if (spectrumRequest.Antenna != null)
                    {
                        currentIncumbent.Height = spectrumRequest.Antenna.Height;
                    }

                    wsdInfo.Add(currentIncumbent);
                }

                if (spectrumRequest.MasterDeviceLocation != null)
                {
                    var currentIncumbent = new Incumbent()
                    {
                        Location      = spectrumRequest.MasterDeviceLocation.ToLocation(),
                        IncumbentType = Conversion.ToIncumbentType(spectrumRequest.DeviceDescriptor.FccTvbdDeviceType)
                    };

                    if (spectrumRequest.Antenna != null)
                    {
                        currentIncumbent.Height = spectrumRequest.Antenna.Height;
                    }

                    wsdInfo.Add(currentIncumbent);
                }
            }

            return(wsdInfo.ToArray());
        }
        /// <summary>
        /// Gets the WSD information.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>returns Incumbent.</returns>
        public override Incumbent IncumbentInfoForGetChannelListRequest(Parameters parameters)
        {
            Incumbent incumbent = new Incumbent();

            incumbent.IncumbentType = Conversion.ToIncumbentType(parameters.IncumbentType);
            if (parameters.Location != null)
            {
                incumbent.Location = parameters.Location.ToLocation();
            }

            incumbent.PointsArea        = parameters.PointsArea;
            incumbent.QuadrilateralArea = parameters.QuadrilateralArea;

            return(incumbent);
        }
        /// <summary>
        /// Checks the if any of the incumbents contains desired location.
        /// </summary>
        /// <param name="station">The incumbent.</param>
        /// <param name="point">The target incumbent.</param>
        /// <param name="offContourDistance">The desired external contour distance.</param>
        /// <returns>returns Incumbent.</returns>
        public static bool IsInOrAroundContour(this Incumbent station, Location point, Distance offContourDistance)
        {
            if (string.IsNullOrEmpty(station.Contour))
            {
                return(false);
            }

            var             contour       = JsonSerialization.DeserializeString <Contour>(station.Contour);
            List <Location> polygonPoints = contour.ContourPoints;

            if (GeoCalculations.IsPointInPolygon(polygonPoints, point))
            {
                return(true);
            }

            // point is not in contour
            // need to check for safe Distance from contour
            var bearingToTarget = GeoCalculations.CalculateBearing(station.Location, point);

            double distance = 0.0;
            bool   lessThanOffContourDistance = false;
            int    index;

            for (int i = (int)bearingToTarget - 90; i < (int)bearingToTarget + 90; i++)
            {
                index = i;
                if (index >= 360)
                {
                    index = i - 360;
                }
                else if (index < 0)
                {
                    index = 360 + i;
                }

                distance = GeoCalculations.GetDistance(point, polygonPoints[index]).Value / 1000.0;
                if (distance <= offContourDistance.InKm())
                {
                    lessThanOffContourDistance = true;
                    break;
                }
            }

            return(lessThanOffContourDistance);
        }
Exemple #4
0
        /// <summary>
        /// Gets the incumbents.
        /// </summary>
        /// <param name="requestParameters">The request parameters.</param>
        /// <returns>returns Incumbent[][].</returns>
        private Incumbent[] GetIncumbents(ServiceCacheRequestParameters requestParameters)
        {
            const string LogMethodName = "FCCServiceCacheHelper.GetIncumbents";

            List <Incumbent> incumbents = new List <Incumbent>();

            this.Logger.Log(TraceEventType.Information, LoggingMessageId.DatabaseCacheMessage, "Enter " + LogMethodName);
            try
            {
                var squareArea = requestParameters.SearchArea;

                this.LoadCacheData <CacheObjectTvEngdata>(ServiceCacheObjectType.TvEngData);
                if (tvengCache != null)
                {
                    IEnumerable <CacheObjectTvEngdata> engDataList = tvengCache.Where(p => (p.Latitude <= squareArea.TopLeftPoint.Latitude && p.Latitude >= squareArea.BottomRightPoint.Latitude &&
                                                                                            p.Longitude <= squareArea.BottomRightPoint.Longitude && p.Longitude >= squareArea.TopLeftPoint.Longitude));

                    foreach (CacheObjectTvEngdata engData in engDataList)
                    {
                        Incumbent incumbent = new Incumbent();
                        incumbent.Channel    = engData.Channel;
                        incumbent.CallSign   = engData.CallSign;
                        incumbent.Latitude   = engData.Latitude;
                        incumbent.Longitude  = engData.Longitude;
                        incumbent.Contour    = engData.Contour;
                        incumbent.VsdService = engData.VsdService;
                        incumbents.Add(incumbent);
                    }
                }
            }
            catch (Exception ex)
            {
                this.Logger.Log(TraceEventType.Error, LoggingMessageId.DatabaseCacheMessage, string.Format("Error in {0}: Message {1}", LogMethodName, ex.ToString()));
            }

            this.Logger.Log(TraceEventType.Information, LoggingMessageId.DatabaseCacheMessage, "Exit " + LogMethodName);

            return(incumbents.ToArray());
        }
Exemple #5
0
        /// <summary>
        /// Gets the WSD information.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>returns Incumbent.</returns>
        public override Incumbent IncumbentInfoForGetChannelListRequest(Parameters parameters)
        {
            Incumbent incumbent = new Incumbent();

            incumbent.Location = parameters.Location.ToLocation();
            //// incumbent.IncumbentType = Conversion.ToIncumbentType(parameters.IncumbentType);
            incumbent.DeviceId       = parameters.DeviceId;
            incumbent.RequestType    = parameters.RequestType;
            incumbent.MaxMasterEIRP  = parameters.MaxMasterEIRP;
            incumbent.PREFSENS       = parameters.Prefsens;
            incumbent.IsTestingStage = false;
            if (parameters.TestingStage > 0)
            {
                incumbent.TestingStage   = parameters.TestingStage;
                incumbent.IsTestingStage = true;
            }

            incumbent.PMSEAssignmentTable = parameters.PMSEAssignmentTableName;

            incumbent.StartTime = parameters.StartTime.ToDateTime("dd/MM/yyyy HH:mm");
            incumbent.UniqueId  = parameters.UniqueId;

            if (parameters.Antenna != null)
            {
                incumbent.Height     = parameters.Antenna.Height;
                incumbent.HeightType = parameters.Antenna.HeightType;
            }

            if (parameters.DeviceDescriptor != null)
            {
                incumbent.DeviceCategory = parameters.DeviceDescriptor.EtsiDeviceCategory;
                incumbent.EmissionClass  = parameters.DeviceDescriptor.EtsiEnDeviceEmissionsClass;
                incumbent.IncumbentType  = Conversion.ToIncumbentType(parameters.DeviceDescriptor.EtsiEnDeviceType);
            }

            return(incumbent);
        }
Exemple #6
0
        /// <summary>
        /// Gets the WSD information.
        /// </summary>
        /// <typeparam name="T">type of request</typeparam>
        /// <param name="request">The request.</param>
        /// <returns>returns Incumbent.</returns>
        public override Incumbent[] GetWSDInfo <T>(T request)
        {
            List <Incumbent> wsdInfo     = new List <Incumbent>();
            Type             requestType = typeof(T);

            if (requestType == typeof(IAvailableSpectrumRequest))
            {
                var       spectrumRequest  = request as IAvailableSpectrumRequest;
                Incumbent currentIncumbent = new Incumbent()
                {
                    Location = spectrumRequest.MasterDeviceLocation != null?spectrumRequest.MasterDeviceLocation.ToLocation() : spectrumRequest.Location.ToLocation(),
                                   DeviceCategory         = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiDeviceCategory : spectrumRequest.DeviceDescriptor.EtsiDeviceCategory,
                                   EmissionClass          = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiEnDeviceEmissionsClass : spectrumRequest.DeviceDescriptor.EtsiEnDeviceEmissionsClass,
                                   Capabilities           = spectrumRequest.Capabilities,
                                   MasterDeviceDescriptor = spectrumRequest.MasterDeviceDescriptors,
                                   DeviceDescriptor       = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors : spectrumRequest.DeviceDescriptor,
                                   IncumbentType          = Conversion.ToIncumbentType(spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiEnDeviceType : spectrumRequest.DeviceDescriptor.EtsiEnDeviceType),
                };

                if (spectrumRequest.Antenna != null)
                {
                    currentIncumbent.Height     = spectrumRequest.Antenna.Height;
                    currentIncumbent.HeightType = spectrumRequest.Antenna.HeightType;
                }

                wsdInfo.Add(currentIncumbent);
            }
            else if (requestType == typeof(IBatchAvailableSpectrumRequest))
            {
                var spectrumRequest = request as IBatchAvailableSpectrumRequest;
                foreach (var receiverLocation in spectrumRequest.Locations)
                {
                    var currentIncumbent = new Incumbent()
                    {
                        Location               = receiverLocation.ToLocation(),
                        DeviceCategory         = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiDeviceCategory : spectrumRequest.DeviceDescriptor.EtsiDeviceCategory,
                        EmissionClass          = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiEnDeviceEmissionsClass : spectrumRequest.DeviceDescriptor.EtsiEnDeviceEmissionsClass,
                        Capabilities           = spectrumRequest.Capabilities,
                        MasterDeviceDescriptor = spectrumRequest.MasterDeviceDescriptors,
                        DeviceDescriptor       = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors : spectrumRequest.DeviceDescriptor,
                        IncumbentType          = Conversion.ToIncumbentType(spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiEnDeviceType : spectrumRequest.DeviceDescriptor.EtsiEnDeviceType)
                    };

                    if (spectrumRequest.Antenna != null)
                    {
                        currentIncumbent.Height     = spectrumRequest.Antenna.Height;
                        currentIncumbent.HeightType = spectrumRequest.Antenna.HeightType;
                    }

                    wsdInfo.Add(currentIncumbent);
                }

                if (spectrumRequest.MasterDeviceLocation != null)
                {
                    var currentIncumbent = new Incumbent()
                    {
                        Location               = spectrumRequest.MasterDeviceLocation.ToLocation(),
                        DeviceCategory         = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiDeviceCategory : spectrumRequest.DeviceDescriptor.EtsiDeviceCategory,
                        EmissionClass          = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiEnDeviceEmissionsClass : spectrumRequest.DeviceDescriptor.EtsiEnDeviceEmissionsClass,
                        Capabilities           = spectrumRequest.Capabilities,
                        MasterDeviceDescriptor = spectrumRequest.MasterDeviceDescriptors,
                        DeviceDescriptor       = spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors : spectrumRequest.DeviceDescriptor,
                        IncumbentType          = Conversion.ToIncumbentType(spectrumRequest.MasterDeviceDescriptors != null ? spectrumRequest.MasterDeviceDescriptors.EtsiEnDeviceType : spectrumRequest.DeviceDescriptor.EtsiEnDeviceType)
                    };

                    if (spectrumRequest.Antenna != null)
                    {
                        currentIncumbent.Height     = spectrumRequest.Antenna.Height;
                        currentIncumbent.HeightType = spectrumRequest.Antenna.HeightType;
                    }

                    wsdInfo.Add(currentIncumbent);
                }
            }

            return(wsdInfo.ToArray());
        }