97 if (asyncRouteManager ==
null) {
98 System.err.println(
"AsyncRouteManager not initialized");
103 Point destinationPoint =
new Point(100.0, 100.0);
104 LocationPoint destinationLocationPoint =
new LocationPoint(destinationPoint, 12345, 1);
107 RouteOptions routeOptions =
new RouteOptions(2.0, 5.0, 2.0);
111 RouteSession session = asyncRouteManager.createRouteSession(destinationLocationPoint, routeOptions);
112 System.out.println(
"Created route session with default graph tag");
117 RouteSession sessionWithTag = asyncRouteManager.createRouteSessionWithTag(destinationLocationPoint, routeOptions,
"main");
118 System.out.println(
"Created route session with 'main' graph tag");
122 currentSession = session;
125 if (asyncRouteListener !=
null) {
128 session.addRouteListener(asyncRouteListener);
137 if (routePath ==
null) {
138 System.err.println(
"RoutePath is null");
144 double length = routePath.getLength();
145 System.out.println(
"Route length: " + length +
" meters");
150 List<LocationPoint> points = routePath.getPoints();
151 System.out.println(
"Number of route points: " + points.size());
152 for (
int i = 0; i < points.size() && i < 3; i++) {
153 System.out.println(
"Point " + (i + 1) +
": " + points.get(i));
159 List<RouteEvent> events = routePath.getEvents();
160 System.out.println(
"Number of route events: " + events.size());
161 for (
int i = 0; i < events.size() && i < 3; i++) {
168 RoutePath head = routePath.head(10.0);
170 System.out.println(
"Route head length: " + head.getLength() +
" meters");
176 RoutePath tail = routePath.tail(10.0);
178 System.out.println(
"Route tail length: " + tail.getLength() +
" meters");
235 if (locationPoint ==
null) {
236 System.err.println(
"LocationPoint is null");
242 Point point = locationPoint.getPoint();
243 System.out.println(
"Location point: (" + point.getX() +
", " + point.getY() +
")");
248 int locationId = locationPoint.getLocationId();
249 System.out.println(
"Location ID: " + locationId);
254 int sublocationId = locationPoint.getSublocationId();
255 System.out.println(
"Sublocation ID: " + sublocationId);
260 Point newPoint =
new Point(25.0, 35.0);
261 LocationPoint newLocationPoint =
new LocationPoint(newPoint, 12345, 2);
262 System.out.println(
"Created new location point: " + newLocationPoint.getPoint().getX() +
", " + newLocationPoint.getPoint().getY());
298 System.out.println(
"=== Route Options ===");
302 RouteOptions routeOptions =
new RouteOptions(3.0, 7.0, 2.5);
303 System.out.println(
"Created route options with smoothRadius: " + routeOptions.getSmoothRadius() +
304 ", maxProjectionDistance: " + routeOptions.getMaxProjectionDistance() +
305 ", maxAdvance: " + routeOptions.getMaxAdvance());
309 RouteOptions[] optionsList = {
310 new RouteOptions(0.0, 5.0, 2.0),
311 new RouteOptions(2.0, 10.0, 1.0),
312 new RouteOptions(1.0, 3.0, 3.0),
315 for (
int i = 0; i < optionsList.length; i++) {
316 RouteOptions options = optionsList[i];
317 System.out.println(
"Options " + (i + 1) +
": smoothRadius=" + options.getSmoothRadius() +
318 ", maxProjectionDistance=" + options.getMaxProjectionDistance() +
319 ", maxAdvance=" + options.getMaxAdvance());
327 System.out.println(
"=== Advanced Async Routing Features ===");
329 if (asyncRouteManager ==
null) {
334 List<LocationPoint> destinations =
new ArrayList<>();
335 destinations.add(
new LocationPoint(
new Point(50.0, 50.0), 12345, 1));
336 destinations.add(
new LocationPoint(
new Point(100.0, 100.0), 12345, 1));
337 destinations.add(
new LocationPoint(
new Point(150.0, 150.0), 12345, 1));
340 RouteOptions[] optionsList = {
341 new RouteOptions(2.0, 5.0, 2.0),
342 new RouteOptions(3.0, 7.0, 1.5),
343 new RouteOptions(1.0, 3.0, 2.5),
347 List<RouteSession> sessions =
new ArrayList<>();
348 for (
int i = 0; i < destinations.size(); i++) {
349 RouteSession session = asyncRouteManager.createRouteSession(destinations.get(i), optionsList[i]);
350 sessions.add(session);
351 System.out.println(
"Created session " + (i + 1) +
" for destination: " +
352 destinations.get(i).getPoint().getX() +
", " + destinations.get(i).getPoint().getY());
354 if (asyncRouteListener !=
null) {
355 session.addRouteListener(asyncRouteListener);
360 }
catch (InterruptedException e) {
361 Thread.currentThread().interrupt();
368 }
catch (InterruptedException e) {
369 Thread.currentThread().interrupt();
373 for (
int i = 0; i < sessions.size(); i++) {
376 asyncRouteManager.cancelRouteSession(sessions.get(i));
377 System.out.println(
"Cancelled session " + (i + 1));
382 }
catch (InterruptedException e) {
383 Thread.currentThread().interrupt();
392 System.out.println(
"=== RouteStatus Enum Usage ===");
396 System.out.println(
"Available RouteStatus values:");
397 for (RouteStatus status : RouteStatus.values()) {
398 System.out.println(
" - " + status.name() +
": " + status.toString());
402 RouteStatus testStatus = RouteStatus.NEW_ROUTE;
403 if (testStatus == RouteStatus.NEW_ROUTE) {
404 System.out.println(
"Router is ready for navigation");
405 }
else if (testStatus == RouteStatus.MISSING_GRAPH) {
406 System.out.println(
"Router is missing the route graph");
407 }
else if (testStatus == RouteStatus.MISSING_POSITION) {
408 System.out.println(
"Router is missing the current position");
409 }
else if (testStatus == RouteStatus.MISSING_PROJECTION) {
410 System.out.println(
"Current position is off the route graph");
411 }
else if (testStatus == RouteStatus.MISSING_ROUTE) {
412 System.out.println(
"Router unable to find the route to the destination point");
421 System.out.println(
"=== Route Session Management ===");
423 if (asyncRouteManager ==
null || asyncRouteListener ==
null) {
428 Point destinationPoint =
new Point(75.0, 75.0);
429 LocationPoint destinationLocationPoint =
new LocationPoint(destinationPoint, 12345, 1);
430 RouteOptions routeOptions =
new RouteOptions(2.0, 5.0, 2.0);
433 RouteSession defaultSession = asyncRouteManager.createRouteSession(destinationLocationPoint, routeOptions);
434 System.out.println(
"Created session with default tag");
437 RouteSession taggedSession = asyncRouteManager.createRouteSessionWithTag(destinationLocationPoint, routeOptions,
"elevator");
438 System.out.println(
"Created session with 'elevator' tag");
441 defaultSession.addRouteListener(asyncRouteListener);
442 taggedSession.addRouteListener(asyncRouteListener);
448 }
catch (InterruptedException e) {
449 Thread.currentThread().interrupt();
455 defaultSession.removeRouteListener(asyncRouteListener);
456 taggedSession.removeRouteListener(asyncRouteListener);
457 System.out.println(
"Removed listeners from sessions");
461 asyncRouteManager.cancelRouteSession(defaultSession);
462 asyncRouteManager.cancelRouteSession(taggedSession);
463 System.out.println(
"Cancelled both sessions");