Beispiel #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets direction language name for sending to ArcGIS server.
        /// </summary>
        /// <returns>Current direction language name.</returns>
        /// <remarks>ArcGIS expects underscore as languagecode/regioncode delimiter.</remarks>
        private static string _GetDirLanguage()
        {
            return(RequestBuildingHelper.GetDirectionsLanguage().Replace('-', '_'));
        }
Beispiel #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Builds request.
        /// </summary>
        /// <param name="reqData">Route solve request data.</param>
        /// <returns>Created route solve request.</returns>
        public RouteSolveRequest BuildRequest(RouteSolveRequestData reqData)
        {
            Debug.Assert(reqData != null);

            var req = new RouteSolveRequest();

            // stops
            req.Stops = _BuildStopFeatures(reqData.Route.Stops);

            // Point barriers.
            if (reqData.PointBarriers != null)
            {
                req.PointBarriers          = new RouteRecordSet();
                req.PointBarriers.Features = reqData.PointBarriers;
            }
            // Polygon barriers.
            if (reqData.PolygonBarriers != null)
            {
                req.PolygonBarriers          = new RouteRecordSet();
                req.PolygonBarriers.Features = reqData.PolygonBarriers;
            }
            // Polyline barriers.
            if (reqData.PolylineBarriers != null)
            {
                req.PolylineBarriers          = new RouteRecordSet();
                req.PolylineBarriers.Features = reqData.PolylineBarriers;
            }

            // start time
            req.StartTime = (reqData.Route.StartTime == null) ?
                            NONE_TIME_VALUE : _FormatEpochTime(reqData.Route.StartTime.Value);

            req.ReturnDirections       = true;
            req.ReturnRoutes           = false;
            req.ReturnStops            = false;
            req.ReturnBarriers         = false;
            req.OutSR                  = GeometryConst.WKID_WGS84;
            req.IgnoreInvalidLocations = _context.SolverSettings.ExcludeRestrictedStreets;
            req.OutputLines            = Enum.GetName(typeof(NAOutputLineType),
                                                      NAOutputLineType.esriNAOutputLineTrueShapeWithMeasure);
            req.FindBestSequence          = false;
            req.PreserveFirstStop         = true;
            req.PreserveLastStop          = true;
            req.UseTimeWindows            = true;
            req.AccumulateAttributeNames  = null;
            req.ImpedanceAttributeName    = _context.NetworkDescription.ImpedanceAttributeName;
            req.RestrictionAttributeNames = _FormatRestrictions();
            req.AttributeParameters       = _FormatAttrParameters();
            req.RestrictUTurns            = _GetUTurnPolicy();
            req.UseHierarchy                 = true;
            req.DirectionsLanguage           = _GetDirLanguage();
            req.OutputGeometryPrecision      = null;
            req.OutputGeometryPrecisionUnits = null;
            NANetworkAttributeUnits unit = RequestBuildingHelper.GetDirectionsLengthUnits();

            req.DirectionsLengthUnits       = unit.ToString();
            req.DirectionsTimeAttributeName = null;
            req.OutputFormat = NAOutputFormat.JSON;

            return(req);
        }