Exemplo n.º 1
0
        public ResultSet PointToPoint(PointToPointModel pointToPointModel)
        {
            var router = Engine.Instance;

            // Get transport mode
            var transportMode = this.ResolveVehicleEnum(pointToPointModel.TransportMode);

            if (!router.SupportsTransportMode(transportMode))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent("Tranport mode not supported."),
                    ReasonPhrase = string.Format("Transport mode {0} is not supported.", transportMode.ToString())
                });
            }

            // resolve both points; find the closest routable point.
            try
            {
                var route = router.CalculatePointToPoint(
                    transportMode, pointToPointModel.ToStartGeoCoordinate(), pointToPointModel.ToEndCoordinate());

                return route.Results;
            }
            catch (RoutingException e)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent("Routing error"),
                    ReasonPhrase = e.Message
                });
            }
        }
Exemplo n.º 2
0
        public ResultSet PointToPoint(PointToPointModel pointToPointModel)
        {
            var router = Engine.Instance;

            // Get transport mode
            var transportMode = this.ResolveVehicleEnum(pointToPointModel.TransportMode);

            if (!router.SupportsTransportMode(transportMode))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent("Tranport mode not supported."),
                    ReasonPhrase = string.Format("Transport mode {0} is not supported.", transportMode.ToString())
                });
            }

            // resolve both points; find the closest routable point.
            try
            {
                var route = router.CalculatePointToPoint(
                    transportMode, pointToPointModel.ToStartGeoCoordinate(), pointToPointModel.ToEndCoordinate());

                return(route.Results);
            }
            catch (RoutingException e)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent("Routing error"),
                    ReasonPhrase = e.Message
                });
            }
        }
Exemplo n.º 3
0
        public void PointToPoint(PointToPointModel model)
        {
            var e = new double[model.Elevations.Length + 2];

            e[0] = model.Elevations.Length - 1;
            e[1] = model.Distance / e[0];
            model.Elevations.CopyTo(e, 2);
#if DEBUG
            if (UseOriginal)
            {
                var itm = new Original();
                itm.point_to_pointMDH(e, model.Transmitter.Height, model.Receiver.Height, model.GroundDielectric, model.GroundConductivity, model.SurfaceRefractivity, model.Frequency,
                                      (int)model.Climate, (int)model.Polarization, (int)model.Variability.Mode, model.Variability.Time, model.Variability.Location, model.Variability.Confidence,
                                      out var dbloss, out var propmode, out var deltaH, out var errnum);
                model.DbLoss         = dbloss;
                model.PropMode       = (PropMode)propmode;
                model.DeltaH         = deltaH;
                model.ErrorIndicator = errnum;
            }
            else
#endif
            {
                var itm = new Refactored();
                itm.point_to_pointMDH(e, model.Transmitter.Height, model.Receiver.Height, model.GroundDielectric, model.GroundConductivity, model.SurfaceRefractivity, model.Frequency,
                                      model.Climate, model.Polarization, model.Variability.Mode, model.Variability.Time, model.Variability.Location, model.Variability.Confidence,
                                      out var dbloss, out var propmode, out var deltaH, out var errnum);
                model.DbLoss         = dbloss;
                model.PropMode       = propmode;
                model.DeltaH         = deltaH;
                model.ErrorIndicator = errnum;
            }
        }
Exemplo n.º 4
0
        public void PointToPointModelTests()
        {
            var model = new PointToPointModel(new double[2], 1);

            Assert.ThrowsException <ArgumentNullException>(() => model.Elevations = null);
            Assert.ThrowsException <ArgumentException>(() => model.Elevations     = new double[0]);
            Assert.ThrowsException <ArgumentException>(() => model.Elevations     = new double[1]);
            model.Elevations = new double[2];
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => model.Distance = int.MinValue);
            model.Distance = 1;
        }
Exemplo n.º 5
0
 static IEnumerable <PointToPointModel> GetPointToPointModels()
 {
     foreach (var elevations in GetElevations())
     {
         foreach (var height in new[] { 2, 5, 10, 50 })
         {
             foreach (var frequency in new[] { 50, 107.7, 500, 915, 1000, 2400, 5000 })
             {
                 foreach (VariabilityMode mode in Enum.GetValues(typeof(VariabilityMode)))
                 {
                     foreach (var percent in new[] { 0.01, 0.1, 0.5, 0.9, 0.99 })
                     {
                         foreach (RadioClimate climate in Enum.GetValues(typeof(RadioClimate)))
                         {
                             foreach (Polarization polarization in Enum.GetValues(typeof(Polarization)))
                             {
                                 foreach (GroundQuality ground in Enum.GetValues(typeof(GroundQuality)))
                                 {
                                     var model = new PointToPointModel(elevations, 2000)
                                     {
                                         Climate       = climate,
                                         GroundQuality = ground,
                                         Frequency     = frequency,
                                         Polarization  = polarization
                                     };
                                     model.Variability.Mode       = mode;
                                     model.Variability.Confidence = Math.Max(0.01, percent * 0.9);
                                     model.Variability.Location   = percent;
                                     model.Variability.Time       = Math.Max(0.01, percent * 0.8);
                                     model.Transmitter.Height     = height;
                                     model.Receiver.Height        = height * 0.8;
                                     yield return(model);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 public static GeoCoordinate ToEndCoordinate(this PointToPointModel pointToPointModel)
 {
     return(new GeoCoordinate(pointToPointModel.ToLatitude, pointToPointModel.ToLongitude));
 }
Exemplo n.º 7
0
 public static GeoCoordinate ToStartGeoCoordinate(this PointToPointModel pointToPointModel)
 {
     return(new GeoCoordinate(pointToPointModel.FromLatitude, pointToPointModel.FromLongitude));
 }