Пример #1
0
 /// <summary>
 /// When accessing PTV xServer in the cloud, inject the default token
 /// when no user or password is provided through the configuration file.
 /// </summary>
 private static void SetDefaultPtvXServerInternetToken()
 {
     if (XServerUrl.IsXServerInternet(XServerUrl.Complete(Settings.Default.XUrl, "XMap")) && !String.IsNullOrEmpty(DefaultXServerInternetToken.Value) && String.IsNullOrEmpty(Settings.Default.XToken))
     {
         Settings.Default["XToken"] = DefaultXServerInternetToken.Value; // overwrite settings with default access token
     }
 }
        /// <summary>
        /// Factory for the  of the xServer generated client class granting access to the xRoute server.
        /// If xServers are used on an Azure environment, authentication data has to be integrated when
        /// requests are made.
        /// </summary>
        /// <param name="xUrl">The xServer base url. </param>
        /// <returns></returns>
        public static XRouteWSClient CreateXRouteClient(string xUrl)
        {
            string completeXServerUrl = XServerUrl.Complete(xUrl, "XRoute");

            var binding = new BasicHttpBinding
            {
                ReceiveTimeout         = new TimeSpan(0, 0, 30),
                SendTimeout            = new TimeSpan(0, 0, 30),
                OpenTimeout            = new TimeSpan(0, 0, 30),
                CloseTimeout           = new TimeSpan(0, 0, 30),
                MaxReceivedMessageSize = int.MaxValue
            };

            var endpoint = new EndpointAddress(completeXServerUrl);
            var client   = new XRouteWSClient(binding, endpoint);

            if (!XServerUrl.IsXServerInternet(completeXServerUrl))
            {
                return(client);
            }

            binding.Security.Mode = BasicHttpSecurityMode.Transport;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            client.ClientCredentials.SetConfiguredToken();

            return(client);
        }
Пример #3
0
        /// <summary> Initializes a new instance of the <see cref="RoutingUseCase"/> class. Adds two way points and calculates the route. </summary>
        /// <param name="wpfMap"> The map on which the route calculation is to be displayed. </param>
        public RoutingUseCase(WpfMap wpfMap)
        {
            InitializeComponent();

            // save the map
            _wpfMap = wpfMap;

            #region doc:register mouse handler
            _wpfMap.MouseRightButtonDown += wpfMap_MapMouseRightButtonDown;
            ContextMenuService.SetContextMenu(_wpfMap, cm);
            #endregion //doc:register mouse handler

            #region doc:Add ShapeLayers
            routingLayer = new ShapeLayer("Routing")
            {
                SpatialReferenceId = "PTV_MERCATOR"
            };
            wayPointLayer = new ShapeLayer("WayPoints")
            {
                SpatialReferenceId = "PTV_MERCATOR"
            };

            wayPoints.CollectionChanged += points_CollectionChanged;

            // add before labels (if available)
            var idx = _wpfMap.Layers.IndexOf(_wpfMap.Layers["Labels"]);
            if (idx < 0)
            {
                _wpfMap.Layers.Add(routingLayer);
                _wpfMap.Layers.Add(wayPointLayer);
            }
            else
            {
                _wpfMap.Layers.Insert(idx, routingLayer);
                _wpfMap.Layers.Add(wayPointLayer);
            }
            #endregion //doc:Add ShapeLayers

            if (XServerUrl.IsDecartaBackend(XServerUrl.Complete(Properties.Settings.Default.XUrl, "XRoute")))
            {
                return;
            }

            // insert way points of Karlsruhe-Berlin
            clickPoint = new PlainPoint {
                x = 934448.8, y = 6269219.7
            };
            SetStart_Click(null, null);
            clickPoint = new PlainPoint {
                x = 1491097.3, y = 6888163.5
            };
            SetEnd_Click(null, null);

            // calculate the route
            CalculateRoute();
        }
Пример #4
0
        /// <summary>
        /// Factory for the  of the xServer generated client class granting access to the xRoute server.
        /// If xServers are used on an Azure environment, authentication data has to be integrated when
        /// requests are made.
        /// </summary>
        /// <param name="xUrl">The xServer base url. </param>
        /// <param name="user"> User name. </param>
        /// <param name="password"> Password. </param>
        /// <returns> xRoute API based on Web Services. </returns>
        public static XRouteWSClient CreateXRouteClient(string xUrl, string user, string password)
        {
            var completeXServerUrl = XServerUrl.Complete(xUrl, "XRoute");

            var binding = new BasicHttpBinding
            {
                ReceiveTimeout         = new TimeSpan(0, 0, 30),
                SendTimeout            = new TimeSpan(0, 0, 30),
                OpenTimeout            = new TimeSpan(0, 0, 30),
                CloseTimeout           = new TimeSpan(0, 0, 30),
                MaxReceivedMessageSize = int.MaxValue
            };

            var endpoint = new EndpointAddress(completeXServerUrl);
            var client   = new XRouteWSClient(binding, endpoint);

            if (!XServerUrl.IsXServerInternet(completeXServerUrl))
            {
                return(client);
            }

            binding.Security.Mode = BasicHttpSecurityMode.Transport;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            client.ClientCredentials.UserName.UserName      = user;
            client.ClientCredentials.UserName.Password      = password;

            // increase message size
            (client.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize       = 4 << 20;
            (client.Endpoint.Binding as BasicHttpBinding).ReaderQuotas.MaxBytesPerRead = 4 << 20;

            // set timeouts
            client.Endpoint.Binding.SendTimeout    = TimeSpan.FromMilliseconds(5000);
            client.Endpoint.Binding.ReceiveTimeout = TimeSpan.FromMilliseconds(10000);

            return(client);
        }
Пример #5
0
 public string AdjustedUrl(string moduleName = "xmap")
 {
     return(XServerUrl.Complete(baseUrl, moduleName));
 }