1#import <Foundation/Foundation.h>
2#import <NavigineSDK/NavigineSDK.h>
18- (void)demonstrateRoutePathUsage:(NSArray<
NCRoutePath *> *)paths;
19- (void)demonstrateRouteNodeUsage:(
NCRouteNode *)node;
23- (void)demonstrateTurnEventUsage:(
NCTurnEvent *)event;
28- (void)demonstratePointUsage:(
NCPoint *)point;
30- (void)demonstrateRoutePlanningSimulation;
36@implementation RouteManagerExample
80 NSLog(
@"LocationManager, NavigationManager and RouteManager successfully initialized");
82 }
@catch (NSException *exception) {
83 NSLog(
@"Error initializing SDK: %@", exception.reason);
100 NSLog(
@"RouteManager not initialized");
117 NSLog(
@"Current graph tag: %@", currentGraphTag);
123 NSLog(
@"Available graph tags: %@", graphTags);
135 NSLog(
@"Route created with length: %f meters", [routePath getLength]);
140 NSArray<NCLocationPoint *> *destinations = @[
141 [[
NCLocationPoint alloc] initWithPoint:[[
NCPoint alloc] initWithX:30.0 y:40.0] locationId:12345 sublocationId:1],
142 [[
NCLocationPoint alloc] initWithPoint:[[
NCPoint alloc] initWithX:70.0 y:80.0] locationId:12345 sublocationId:1]
145 NSLog(
@"Created %lu routes", (
unsigned long)routePaths.count);
173- (void)demonstrateRoutePathUsage:(NSArray<
NCRoutePath *> *)paths {
174 for (
int i = 0; i < paths.count; i++) {
176 NSLog(
@"=== Route Path %d ===", i + 1);
180 double length = [
path getLength];
181 NSLog(
@"Route length: %f meters", length);
186 double weight = [
path getWeight];
187 NSLog(
@"Route weight: %f", weight);
192 NSArray<NCRouteNode *> *nodes = [
path getNodes];
193 NSLog(
@"Route has %lu nodes", (
unsigned long)nodes.count);
194 for (
int j = 0; j < nodes.count; j++) {
202 if (headPath != nil) {
203 NSLog(
@"Head path length: %f meters", [headPath getLength]);
210 if (tailPath != nil) {
211 NSLog(
@"Tail path length: %f meters", [tailPath getLength]);
224 float weight = [
node getWeight];
225 NSLog(
@"Node weight: %f", weight);
229 float distance = [
node getDistance];
230 NSLog(
@"Node distance: %f meters", distance);
234 NSArray<NCRouteEvent *> *events = [
node getEvents];
235 NSLog(
@"Node has %lu events", (
unsigned long)events.count);
249 NSLog(
@"Event type: %ld", (
long)type);
254 if (turnEvent != nil) {
261 if (entryEvent != nil) {
268 if (exitEvent != nil) {
275 if (targetEvent != nil) {
287 NSArray<NSNumber *> *types = @[
292 NSLog(
@"Available route event types:");
293 for (NSNumber *type in types) {
294 NSLog(
@" - %ld", (
long)[type integerValue]);
301 NSArray<NSNumber *> *types = @[
310 NSLog(
@"Available turn types:");
311 for (NSNumber *type in types) {
312 NSLog(
@" - %ld", (
long)[type integerValue]);
320 NSLog(
@"Turn type: %ld", (
long)type);
324 int32_t angle = [
event getAngle];
325 NSLog(
@"Turn angle: %d", angle);
331 int64_t from = [
event getFrom];
332 NSLog(
@"Transition entry from: %lld", from);
336 int64_t to = [
event getTo];
337 NSLog(
@"Transition entry to: %lld", to);
343 int64_t from = [
event getFrom];
344 NSLog(
@"Transition exit from: %lld", from);
348 int64_t to = [
event getTo];
349 NSLog(
@"Transition exit to: %lld", to);
355 int64_t index = [
event getIndex];
356 NSLog(
@"Reached target index: %lld", index);
380 NSLog(
@"Location ID: %d", locationId);
386 NSLog(
@"Sublocation ID: %d", sublocationId);
393 NSLog(
@"Created new LocationPoint: %@", newLocationPoint);
400- (void)demonstratePointUsage:(
NCPoint *)point {
403 double x = [
point getX];
404 NSLog(
@"Point X: %f", x);
409 double y = [
point getY];
410 NSLog(
@"Point Y: %f", y);
416 NSLog(
@"Created new Point: %@", newPoint);
424 NSLog(
@"=== Advanced Routing Features ===");
431 NSArray<NSString *> *graphTags = @[@"main", @"elevator", @"stairs"];
433 for (NSString *tag in graphTags) {
439 NSLog(
@"Routing with graph tag: %@", tag);
452 NSLog(
@"Route with tag '%@' has length: %f meters", tag, [routePath getLength]);
459- (void)demonstrateRoutePlanningSimulation {
460 NSLog(
@"=== Route Planning Simulation ===");
467 NSArray<NCLocationPoint *> *targets = @[
468 [[
NCLocationPoint alloc] initWithPoint:[[
NCPoint alloc] initWithX:50.0 y:50.0] locationId:12345 sublocationId:1],
469 [[
NCLocationPoint alloc] initWithPoint:[[
NCPoint alloc] initWithX:100.0 y:100.0] locationId:12345 sublocationId:1],
470 [[
NCLocationPoint alloc] initWithPoint:[[
NCPoint alloc] initWithX:150.0 y:150.0] locationId:12345 sublocationId:1]
475 [
self.routeManager setTarget:targets[0]];
478 NSLog(
@"Set target 1: %@", targets[0]);
479 [NSThread sleepForTimeInterval:1.0];
483 for (
int i = 1; i < targets.count; i++) {
484 [
self.routeManager addTarget:targets[i]];
485 NSLog(
@"Added target %d: %@", i + 1, targets[i]);
486 [NSThread sleepForTimeInterval:1.0];
492 [
self.routeManager cancelTarget];
493 NSLog(
@"Cancelled current target");
496 [NSThread sleepForTimeInterval:1.0];
500 [
self.routeManager clearTargets];
501 NSLog(
@"Cleared all targets");
521 NSLog(
@"=== RouteManager Example ===");
523 [
self demonstrateRouteManagerMethods];
524 [
self demonstrateRouteEventTypes];
525 [
self demonstrateTurnTypes];
526 [
self demonstrateAdvancedRoutingFeatures];
527 [
self demonstrateRoutePlanningSimulation];
530 [NSThread sleepForTimeInterval:3.0];
533 NSLog(
@"=== Example completed ===");
536#pragma mark - NCRouteListener
539- (void)onPathsUpdated:(NSArray<NCRoutePath *> *)paths {
540 NSLog(
@"Routes updated successfully");
541 [
self demonstrateRoutePathUsage:paths];
550int main(
int argc,
const char * argv[]) {
553 [example runExample];