Basically, the distance and travel time of a given route are calculated and returned as a result list. Furthermore, the internal costs could be indicated but this is only relevant in comparison to alternative routes. Last but not least the boolean value of caused violations are delivered by the result object. Please notice, this is a simple but fast route calculation. The next figure shows the output of a simple routing.
The method is called "calculateRouteInfo". Following arguments are available:
The following code sample illustrates how to calculate a basic route information calling the above name method. To keep the sample simple, the argument "exceptionPaths" is not used.
Step 1: Instantiate xRoute client. Use the provided package utils.
String XROUTE_WS_URL = "http://localhost:50030/xroute/ws/XRoute"; XRouteRemoteInterface xRouteClient = XRouteUtils.makeClient(XROUTE_WS_URL);
Step 1: Instantiate xRoute client. Use the application settings (app.config).
XRouteWSService xRouteClient = new XRouteWSService();
Step 2: Define two waypoints.
Point startPoint = new Point(); startPoint.setPoint(new PlainPoint(681593, 6371793, null)); WaypointDesc wpdStart = new WaypointDesc(); wpdStart.setCoords(new Point[] { startPoint }); wpdStart.setLinkType(LinkType.NEXT_SEGMENT); Point destPoint = new Point(); destPoint.setPoint(new PlainPoint(678909, 6395906, null)); WaypointDesc wpdDest = new WaypointDesc(); wpdDest.setCoords(new Point[] { destPoint }); wpdDest.setLinkType(LinkType.NEXT_SEGMENT); WaypointDesc[] waypointDescs = new WaypointDesc[] { wpdStart, wpdDest };
Step 2: Define two waypoints.
Point startPoint = new Point(); startPoint.point = new PlainPoint { x = 681593, y = 6371793 } ; WaypointDesc wpdStart = new WaypointDesc(); wpdStart.wrappedCoords = new Point[] { startPoint }; wpdStart.linkType = LinkType.NEXT_SEGMENT; Point destPoint = new Point(); destPoint.point = new PlainPoint { x = 678909, y = 6395906 } ; WaypointDesc wpdDest = new WaypointDesc(); wpdDest.wrappedCoords = new Point[] { destPoint }; wpdDest.linkType = LinkType.NEXT_SEGMENT; WaypointDesc[] waypointDescs = new WaypointDesc[] { wpdStart, wpdDest };
Step 3: Create CallerContext for specific profile settings.
CallerContextProperty profile = new CallerContextProperty(); profile.setKey("Profile"); profile.setValue("truckfast"); CallerContextProperty[] callerContextProperties = new CallerContextProperty[] { profile }; CallerContext ctx = new CallerContext(); ctx.setProperties(callerContextProperties); xRouteClient.setCallerContext(ctx);
Step 3: Create CallerContext for specific profile settings.
CallerContextProperty[] props = new CallerContextProperty[1]; props[0] = new CallerContextProperty { key = "Profile", value = "truckfast" }; CallerContext ctx = new CallerContext(); ctx.wrappedProperties = props ;
Step 4: Validate whether routing has violations.
RoutingOption hasViolations = new RoutingOption(); hasViolations.setParameter(RoutingParameter.ALLOW_SEGMENT_VIOLATIONS); hasViolations.setValue("true"); RoutingOption[] options = new RoutingOption[] { hasViolations };
Step 4: Validate whether routing has violations.
RoutingOption hasViolations = new RoutingOption { parameter = RoutingParameter.ALLOW_SEGMENT_VIOLATIONS, value = "true" }; RoutingOption[] routingOptions = { hasViolations };
Step 5: Execute CalculateRouteInfo()
routeInfo = xRouteClient.calculateRouteInfo(waypointDescs, options, null);
Step 5: Execute CalculateRouteInfo()
routeInfo = xRouteClient.calculateRouteInfo(waypointDescs, null, null, ctx);
Copyright © 2024 PTV Logistics GmbH All rights reserved. | Imprint