Loading...
Searching...
No Matches
LocationManagerExample.m
Go to the documentation of this file.
1#import <Foundation/Foundation.h>
2#import "NCNavigineSdk.h"
3#import "NCLocationManager.h"
4#import "NCLocationListener.h"
5#import "NCLocation.h"
6#import "NCCategory.h"
7#import "NCSublocation.h"
8#import "NCVenue.h"
9#import "NCZone.h"
10#import "NCBeacon.h"
11#import "NCWifi.h"
12#import "NCEddystone.h"
13#import "NCPoint.h"
14#import "NCGraph.h"
15#import "NCGraphVertex.h"
16#import "NCGraphEdge.h"
17#import "NCElevationGraph.h"
18#import "NCTransmitterStatus.h"
19
24@interface LocationManagerExample : NSObject <NCLocationListener>
25
26@property (nonatomic, strong) NCNavigineSdk *sdk;
27@property (nonatomic, strong) NCLocationManager *locationManager;
28@property (nonatomic, strong) NCLocation *currentLocation;
29
30@end
31
32@implementation LocationManagerExample
33
34- (instancetype)init {
35 self = [super init];
36 if (self) {
37 [self initializeSdk];
38 }
39 return self;
40}
41
45- (void)initializeSdk {
46 @try {
47 // [objc_NavigineSdk_getInstance]
48 // Get SDK instance
49 self.sdk = [NCNavigineSdk getInstance];
50 // [objc_NavigineSdk_getInstance]
51
52 // [objc_NavigineSdk_setUserHash]
53 // Set user hash
54 [self.sdk setUserHash:@"USER-HASH-HERE"];
55 // [objc_NavigineSdk_setUserHash]
56
57 // [objc_NavigineSdk_setServer]
58 // Set server URL (optional)
59 [self.sdk setServer:@"https://custom.navigine.com"];
60 // [objc_NavigineSdk_setServer]
61
62 // [objc_NavigineSdk_getLocationManager]
63 // Get LocationManager for working with locations
64 self.locationManager = [self.sdk getLocationManager];
65 // [objc_NavigineSdk_getLocationManager]
66
67 if (self.locationManager != nil) {
68 NSLog(@"LocationManager successfully initialized");
69 }
70 } @catch (NSException *exception) {
71 NSLog(@"Error initializing SDK: %@", exception.reason);
72 }
73}
74
78- (void)demonstrateLocationManagerMethods {
79 if (self.locationManager == nil) {
80 NSLog(@"LocationManager not initialized");
81 return;
82 }
83
84 // [objc_LocationManager_addLocationListener]
85 // Add location listener
86 [self.locationManager addLocationListener:self];
87 // [objc_LocationManager_addLocationListener]
88
89 // [objc_LocationManager_setLocationId]
90 // Set location ID to load
91 [self.locationManager setLocationId:12345];
92 // [objc_LocationManager_setLocationId]
93
94 // [objc_LocationManager_getLocationId]
95 // Get current location ID
96 int32_t currentLocationId = [self.locationManager getLocationId];
97 NSLog(@"Current location ID: %d", currentLocationId);
98 // [objc_LocationManager_getLocationId]
99
100 // [objc_LocationManager_setLocationUpdateInterval]
101 // Set location update interval (in seconds)
102 [self.locationManager setLocationUpdateInterval:600]; // 10 minutes
103 // [objc_LocationManager_setLocationUpdateInterval]
104
105 // [objc_LocationManager_commitChanges]
106 // Commit changes
107 [self.locationManager commitChanges];
108 // [objc_LocationManager_commitChanges]
109
110 // [objc_LocationManager_revertChanges]
111 // Revert changes (if needed)
112 // [self.locationManager revertChanges];
113 // [objc_LocationManager_revertChanges]
114}
115
119- (void)demonstrateLocationUsage:(NCLocation *)location {
120 if (location == nil) {
121 NSLog(@"Location is null");
122 return;
123 }
124
125 // [objc_Location_getId]
126 // Get location ID
127 int32_t locationId = [location getId];
128 NSLog(@"Location ID: %d", locationId);
129 // [objc_Location_getId]
130
131 // [objc_Location_getVersion]
132 // Get location version
133 int32_t version = [location getVersion];
134 NSLog(@"Location version: %d", version);
135 // [objc_Location_getVersion]
136
137 // [objc_Location_getName]
138 // Get location name
139 NSString *name = [location getName];
140 NSLog(@"Location name: %@", name);
141 // [objc_Location_getName]
142
143 // [objc_Location_getDescript]
144 // Get location description
145 NSString *description = [location getDescript];
146 NSLog(@"Location description: %@", description);
147 // [objc_Location_getDescript]
148
149 // [objc_Location_getModified]
150 // Check if location is modified
151 BOOL isModified = [location getModified];
152 NSLog(@"Location modified: %@", isModified ? @"YES" : @"NO");
153 // [objc_Location_getModified]
154
155 // [objc_Location_getGraphTags]
156 // Get available graph tags
157 NSArray<NSString *> *graphTags = [location getGraphTags];
158 NSLog(@"Available graph tags: %@", graphTags);
159 // [objc_Location_getGraphTags]
160
161 // [objc_Location_getElevationGraph]
162 // Get elevation graph by tag
163 if (graphTags.count > 0) {
164 NCElevationGraph *elevationGraph = [location getElevationGraph:graphTags[0]];
165 if (elevationGraph != nil) {
166 [self demonstrateElevationGraphUsage:elevationGraph];
167 }
168 }
169 // [objc_Location_getElevationGraph]
170
171 // [objc_Location_getCategories]
172 // Get all categories
173 NSArray<NCCategory *> *categories = [location getCategories];
174 NSLog(@"Number of categories: %lu", (unsigned long)categories.count);
175 // [objc_Location_getCategories]
176
177 // [objc_Location_getCategoryById]
178 // Get category by ID
179 if (categories.count > 0) {
180 NCCategory *category = [location getCategoryById:[categories[0] getId]];
181 if (category != nil) {
182 [self demonstrateCategoryUsage:category];
183 }
184 }
185 // [objc_Location_getCategoryById]
186
187 // [objc_Location_getSublocations]
188 // Get all sublocations
189 NSArray<NCSublocation *> *sublocations = [location getSublocations];
190 NSLog(@"Number of sublocations: %lu", (unsigned long)sublocations.count);
191 // [objc_Location_getSublocations]
192
193 // [objc_Location_getSublocationById]
194 // Get sublocation by ID
195 if (sublocations.count > 0) {
196 NCSublocation *sublocation = [location getSublocationById:[sublocations[0] getId]];
197 if (sublocation != nil) {
198 [self demonstrateSublocationUsage:sublocation];
199 }
200 }
201 // [objc_Location_getSublocationById]
202}
203
207- (void)demonstrateCategoryUsage:(NCCategory *)category {
208 if (category == nil) {
209 NSLog(@"Category is null");
210 return;
211 }
212
213 // [objc_Category_getId]
214 // Get category ID
215 int32_t categoryId = [category getId];
216 NSLog(@"Category ID: %d", categoryId);
217 // [objc_Category_getId]
218
219 // [objc_Category_getName]
220 // Get category name
221 NSString *categoryName = [category getName];
222 NSLog(@"Category name: %@", categoryName);
223 // [objc_Category_getName]
224
225 // [objc_Category_getImageUrl]
226 // Get category image URL
227 NSString *imageUrl = [category getImageUrl];
228 if (imageUrl != nil) {
229 NSLog(@"Category image URL: %@", imageUrl);
230 }
231 // [objc_Category_getImageUrl]
232}
233
237- (void)demonstrateSublocationUsage:(NCSublocation *)sublocation {
238 if (sublocation == nil) {
239 NSLog(@"Sublocation is null");
240 return;
241 }
242
243 // [objc_Sublocation_getId]
244 // Get sublocation ID
245 int32_t sublocationId = [sublocation getId];
246 NSLog(@"Sublocation ID: %d", sublocationId);
247 // [objc_Sublocation_getId]
248
249 // [objc_Sublocation_getName]
250 // Get sublocation name
251 NSString *sublocationName = [sublocation getName];
252 NSLog(@"Sublocation name: %@", sublocationName);
253 // [objc_Sublocation_getName]
254
255 // [objc_Sublocation_getDescript]
256 // Get sublocation description
257 NSString *sublocationDescription = [sublocation getDescript];
258 NSLog(@"Sublocation description: %@", sublocationDescription);
259 // [objc_Sublocation_getDescript]
260
261 // [objc_Sublocation_getCategoryId]
262 // Get category ID
263 int32_t categoryId = [sublocation getCategoryId];
264 NSLog(@"Sublocation category ID: %d", categoryId);
265 // [objc_Sublocation_getCategoryId]
266
267 // [objc_Sublocation_getLocation]
268 // Get location ID
269 int32_t locationId = [sublocation getLocation];
270 NSLog(@"Sublocation location ID: %d", locationId);
271 // [objc_Sublocation_getLocation]
272
273 // [objc_Sublocation_getWidth]
274 // Get sublocation width in meters
275 double width = [sublocation getWidth];
276 NSLog(@"Sublocation width: %.2f meters", width);
277 // [objc_Sublocation_getWidth]
278
279 // [objc_Sublocation_getHeight]
280 // Get sublocation height in meters
281 double height = [sublocation getHeight];
282 NSLog(@"Sublocation height: %.2f meters", height);
283 // [objc_Sublocation_getHeight]
284
285 // [objc_Sublocation_getAltitude]
286 // Get sublocation altitude in meters
287 NSNumber *altitude = [sublocation getAltitude];
288 if (altitude != nil) {
289 NSLog(@"Sublocation altitude: %.2f meters", [altitude doubleValue]);
290 }
291 // [objc_Sublocation_getAltitude]
292
293 // [objc_Sublocation_getAzimuth]
294 // Get sublocation azimuth in degrees
295 double azimuth = [sublocation getAzimuth];
296 NSLog(@"Sublocation azimuth: %.2f degrees", azimuth);
297 // [objc_Sublocation_getAzimuth]
298
299 // [objc_Sublocation_getOriginPoint]
300 // Get sublocation origin point in WGS84 coordinates
301 NCGlobalPoint *originPoint = [sublocation getOriginPoint];
302 NSLog(@"Sublocation origin point: %.6f, %.6f", [originPoint getLat], [originPoint getLon]);
303 // [objc_Sublocation_getOriginPoint]
304
305 // [objc_Sublocation_getLevelId]
306 // Get sublocation level ID
307 NSString *levelId = [sublocation getLevelId];
308 NSLog(@"Sublocation level ID: %@", levelId);
309 // [objc_Sublocation_getLevelId]
310
311 // [objc_Sublocation_getExternalId]
312 // Get sublocation external ID
313 NSString *externalId = [sublocation getExternalId];
314 NSLog(@"Sublocation external ID: %@", externalId);
315 // [objc_Sublocation_getExternalId]
316
317 // [objc_Sublocation_getReferencePoints]
318 // Get reference points
319 NSArray<NCReferencePoint *> *referencePoints = [sublocation getReferencePoints];
320 NSLog(@"Number of reference points: %lu", (unsigned long)referencePoints.count);
321 // [objc_Sublocation_getReferencePoints]
322
323 // [objc_Sublocation_getVenues]
324 // Get venues
325 NSArray<NCVenue *> *venues = [sublocation getVenues];
326 NSLog(@"Number of venues: %lu", (unsigned long)venues.count);
327 // [objc_Sublocation_getVenues]
328
329 // [objc_Sublocation_getZones]
330 // Get zones
331 NSArray<NCZone *> *zones = [sublocation getZones];
332 NSLog(@"Number of zones: %lu", (unsigned long)zones.count);
333 // [objc_Sublocation_getZones]
334
335 // [objc_Sublocation_getBeacons]
336 // Get beacons
337 NSArray<NCBeacon *> *beacons = [sublocation getBeacons];
338 NSLog(@"Number of beacons: %lu", (unsigned long)beacons.count);
339 // [objc_Sublocation_getBeacons]
340
341 // [objc_Sublocation_getWifis]
342 // Get WiFi access points
343 NSArray<NCWifi *> *wifis = [sublocation getWifis];
344 NSLog(@"Number of WiFi access points: %lu", (unsigned long)wifis.count);
345 // [objc_Sublocation_getWifis]
346
347 // [objc_Sublocation_getEddystones]
348 // Get Eddystone beacons
349 NSArray<NCEddystone *> *eddystones = [sublocation getEddystones];
350 NSLog(@"Number of Eddystone beacons: %lu", (unsigned long)eddystones.count);
351 // [objc_Sublocation_getEddystones]
352
353 // [objc_Sublocation_getGraph]
354 // Get graph
355 NCGraph *graph = [sublocation getGraph];
356 if (graph != nil) {
357 [self demonstrateGraphUsage:graph];
358 }
359 // [objc_Sublocation_getGraph]
360
361 // [objc_Sublocation_getGraph_withTag]
362 // Get graph by tag
363 NCGraph *graphByTag = [sublocation getGraph:@"main"];
364 if (graphByTag != nil) {
365 NSLog(@"Found graph with tag \"main\"");
366 [self demonstrateGraphUsage:graphByTag];
367 }
368 // [objc_Sublocation_getGraph_withTag]
369
370 // [objc_Sublocation_getVenueById]
371 // Get venue by ID
372 if (venues.count > 0) {
373 NCVenue *venueById = [sublocation getVenueById:[venues.firstObject getId]];
374 if (venueById != nil) {
375 NSLog(@"Found venue by ID: %d", [venueById getId]);
376 [self demonstrateVenueUsage:venueById];
377 }
378 }
379 // [objc_Sublocation_getVenueById]
380
381 // [objc_Sublocation_getZoneById]
382 // Get zone by ID
383 if (zones.count > 0) {
384 NCZone *zoneById = [sublocation getZoneById:[zones.firstObject getId]];
385 if (zoneById != nil) {
386 NSLog(@"Found zone by ID: %d", [zoneById getId]);
387 [self demonstrateZoneUsage:zoneById];
388 }
389 }
390 // [objc_Sublocation_getZoneById]
391
392 // [objc_Sublocation_globalToLocal]
393 // Convert global coordinates to local coordinates
394 NCGlobalPoint *globalPoint = [[NCGlobalPoint alloc] initWithLat:55.7558 lon:37.6176]; // Moscow coordinates
395 NCLocationPoint *localPoint = [sublocation globalToLocal:globalPoint];
396 NSLog(@"Global point %.6f, %.6f converted to local: %.2f, %.2f",
397 [globalPoint getLat], [globalPoint getLon], [localPoint getX], [localPoint getY]);
398 // [objc_Sublocation_globalToLocal]
399
400 // [objc_Sublocation_localToGlobal]
401 // Convert local coordinates to global coordinates
402 NCLocationPoint *localPoint2 = [[NCLocationPoint alloc] initWithX:100.0 y:200.0];
403 NCGlobalPoint *globalPoint2 = [sublocation localToGlobal:localPoint2];
404 NSLog(@"Local point %.2f, %.2f converted to global: %.6f, %.6f",
405 [localPoint2 getX], [localPoint2 getY], [globalPoint2 getLat], [globalPoint2 getLon]);
406 // [objc_Sublocation_localToGlobal]
407
408 // [objc_Sublocation_getImage]
409 // Get sublocation image
410 NCImageWrapper *image = [sublocation getImage:@1024]; // max texture size 1024
411 if (image != nil) {
412 NSLog(@"Sublocation image obtained with max texture size 1024");
413 }
414 // [objc_Sublocation_getImage]
415}
416
420- (void)demonstrateVenueUsage:(NCVenue *)venue {
421 if (venue == nil) {
422 NSLog(@"Venue is null");
423 return;
424 }
425
426 // [objc_Venue_getId]
427 // Get venue ID
428 int32_t venueId = [venue getId];
429 NSLog(@"Venue ID: %d", venueId);
430 // [objc_Venue_getId]
431
432 // [objc_Venue_getLocationId]
433 // Get venue location ID
434 int32_t locationId = [venue getLocationId];
435 NSLog(@"Venue location ID: %d", locationId);
436 // [objc_Venue_getLocationId]
437
438 // [objc_Venue_getSublocationId]
439 // Get venue sublocation ID
440 int32_t sublocationId = [venue getSublocationId];
441 NSLog(@"Venue sublocation ID: %d", sublocationId);
442 // [objc_Venue_getSublocationId]
443
444 // [objc_Venue_getName]
445 // Get venue name
446 NSString *venueName = [venue getName];
447 NSLog(@"Venue name: %@", venueName);
448 // [objc_Venue_getName]
449
450 // [objc_Venue_getPhone]
451 // Get venue phone
452 NSString *phone = [venue getPhone];
453 NSLog(@"Venue phone: %@", phone);
454 // [objc_Venue_getPhone]
455
456 // [objc_Venue_getDescript]
457 // Get venue description
458 NSString *venueDescription = [venue getDescript];
459 NSLog(@"Venue description: %@", venueDescription);
460 // [objc_Venue_getDescript]
461
462 // [objc_Venue_getAlias]
463 // Get venue alias
464 NSString *alias = [venue getAlias];
465 NSLog(@"Venue alias: %@", alias);
466 // [objc_Venue_getAlias]
467
468 // [objc_Venue_getCategoryId]
469 // Get category ID
470 int32_t categoryId = [venue getCategoryId];
471 NSLog(@"Venue category ID: %d", categoryId);
472 // [objc_Venue_getCategoryId]
473
474 // [objc_Venue_getImageUrl]
475 // Get venue image URL
476 NSString *imageUrl = [venue getImageUrl];
477 if (imageUrl != nil) {
478 NSLog(@"Venue image URL: %@", imageUrl);
479 }
480 // [objc_Venue_getImageUrl]
481
482 // [objc_Venue_getPoint]
483 // Get venue point
484 NCPoint *point = [venue getPoint];
485 if (point != nil) {
486 [self demonstratePointUsage:point];
487 }
488 // [objc_Venue_getPoint]
489}
490
494- (void)demonstrateZoneUsage:(NCZone *)zone {
495 if (zone == nil) {
496 NSLog(@"Zone is null");
497 return;
498 }
499
500 // [objc_Zone_getId]
501 // Get zone ID
502 int32_t zoneId = [zone getId];
503 NSLog(@"Zone ID: %d", zoneId);
504 // [objc_Zone_getId]
505
506 // [objc_Zone_getLocationId]
507 // Get zone location ID
508 int32_t locationId = [zone getLocationId];
509 NSLog(@"Zone location ID: %d", locationId);
510 // [objc_Zone_getLocationId]
511
512 // [objc_Zone_getSublocationId]
513 // Get zone sublocation ID
514 int32_t sublocationId = [zone getSublocationId];
515 NSLog(@"Zone sublocation ID: %d", sublocationId);
516 // [objc_Zone_getSublocationId]
517
518 // [objc_Zone_getName]
519 // Get zone name
520 NSString *zoneName = [zone getName];
521 NSLog(@"Zone name: %@", zoneName);
522 // [objc_Zone_getName]
523
524 // [objc_Zone_getDescript]
525 // Get zone description
526 NSString *zoneDescription = [zone getDescript];
527 NSLog(@"Zone description: %@", zoneDescription);
528 // [objc_Zone_getDescript]
529
530 // [objc_Zone_getCategoryId]
531 // Get category ID
532 int32_t categoryId = [zone getCategoryId];
533 NSLog(@"Zone category ID: %d", categoryId);
534 // [objc_Zone_getCategoryId]
535
536 // [objc_Zone_getAlias]
537 // Get zone alias
538 NSString *alias = [zone getAlias];
539 NSLog(@"Zone alias: %@", alias);
540 // [objc_Zone_getAlias]
541
542 // [objc_Zone_getColor]
543 // Get zone color
544 NSString *color = [zone getColor];
545 NSLog(@"Zone color: %@", color);
546 // [objc_Zone_getColor]
547
548 // [objc_Zone_getPolygon]
549 // Get zone polygon
550 NSArray<NCPoint *> *polygon = [zone getPolygon];
551 NSLog(@"Zone polygon points: %lu", (unsigned long)polygon.count);
552 // [objc_Zone_getPolygon]
553}
554
558- (void)demonstrateBeaconUsage:(NCBeacon *)beacon {
559 if (beacon == nil) {
560 NSLog(@"Beacon is null");
561 return;
562 }
563
564 // [objc_Beacon_getPoint]
565 // Get beacon point
566 NCPoint *point = [beacon getPoint];
567 if (point != nil) {
568 [self demonstratePointUsage:point];
569 }
570 // [objc_Beacon_getPoint]
571
572 // [objc_Beacon_getLocationId]
573 // Get beacon location ID
574 int32_t locationId = [beacon getLocationId];
575 NSLog(@"Beacon location ID: %d", locationId);
576 // [objc_Beacon_getLocationId]
577
578 // [objc_Beacon_getSublocationId]
579 // Get beacon sublocation ID
580 int32_t sublocationId = [beacon getSublocationId];
581 NSLog(@"Beacon sublocation ID: %d", sublocationId);
582 // [objc_Beacon_getSublocationId]
583
584 // [objc_Beacon_getName]
585 // Get beacon name
586 NSString *beaconName = [beacon getName];
587 NSLog(@"Beacon name: %@", beaconName);
588 // [objc_Beacon_getName]
589
590 // [objc_Beacon_getMajor]
591 // Get beacon major
592 int32_t major = [beacon getMajor];
593 NSLog(@"Beacon major: %d", major);
594 // [objc_Beacon_getMajor]
595
596 // [objc_Beacon_getMinor]
597 // Get beacon minor
598 int32_t minor = [beacon getMinor];
599 NSLog(@"Beacon minor: %d", minor);
600 // [objc_Beacon_getMinor]
601
602 // [objc_Beacon_getUuid]
603 // Get beacon UUID
604 NSString *uuid = [beacon getUuid];
605 NSLog(@"Beacon UUID: %@", uuid);
606 // [objc_Beacon_getUuid]
607
608 // [objc_Beacon_getPower]
609 // Get beacon power
610 NSNumber *power = [beacon getPower];
611 if (power != nil) {
612 NSLog(@"Beacon power: %d", [power intValue]);
613 }
614 // [objc_Beacon_getPower]
615
616 // [objc_Beacon_getStatus]
617 // Get beacon status
618 NCTransmitterStatus status = [beacon getStatus];
619 NSLog(@"Beacon status: %ld", (long)status);
620 // [objc_Beacon_getStatus]
621}
622
626- (void)demonstrateWifiUsage:(NCWifi *)wifi {
627 if (wifi == nil) {
628 NSLog(@"WiFi is null");
629 return;
630 }
631
632 // [objc_Wifi_getPoint]
633 // Get WiFi point
634 NCPoint *point = [wifi getPoint];
635 if (point != nil) {
636 [self demonstratePointUsage:point];
637 }
638 // [objc_Wifi_getPoint]
639
640 // [objc_Wifi_getLocationId]
641 // Get WiFi location ID
642 int32_t locationId = [wifi getLocationId];
643 NSLog(@"WiFi location ID: %d", locationId);
644 // [objc_Wifi_getLocationId]
645
646 // [objc_Wifi_getSublocationId]
647 // Get WiFi sublocation ID
648 int32_t sublocationId = [wifi getSublocationId];
649 NSLog(@"WiFi sublocation ID: %d", sublocationId);
650 // [objc_Wifi_getSublocationId]
651
652 // [objc_Wifi_getName]
653 // Get WiFi name
654 NSString *wifiName = [wifi getName];
655 NSLog(@"WiFi name: %@", wifiName);
656 // [objc_Wifi_getName]
657
658 // [objc_Wifi_getMac]
659 // Get WiFi MAC address
660 NSString *mac = [wifi getMac];
661 NSLog(@"WiFi MAC: %@", mac);
662 // [objc_Wifi_getMac]
663
664 // [objc_Wifi_getStatus]
665 // Get WiFi status
666 NCTransmitterStatus status = [wifi getStatus];
667 NSLog(@"WiFi status: %ld", (long)status);
668 // [objc_Wifi_getStatus]
669}
670
674- (void)demonstrateEddystoneUsage:(NCEddystone *)eddystone {
675 if (eddystone == nil) {
676 NSLog(@"Eddystone is null");
677 return;
678 }
679
680 // [objc_Eddystone_getPoint]
681 // Get Eddystone point
682 NCPoint *point = [eddystone getPoint];
683 if (point != nil) {
684 [self demonstratePointUsage:point];
685 }
686 // [objc_Eddystone_getPoint]
687
688 // [objc_Eddystone_getLocationId]
689 // Get Eddystone location ID
690 int32_t locationId = [eddystone getLocationId];
691 NSLog(@"Eddystone location ID: %d", locationId);
692 // [objc_Eddystone_getLocationId]
693
694 // [objc_Eddystone_getSublocationId]
695 // Get Eddystone sublocation ID
696 int32_t sublocationId = [eddystone getSublocationId];
697 NSLog(@"Eddystone sublocation ID: %d", sublocationId);
698 // [objc_Eddystone_getSublocationId]
699
700 // [objc_Eddystone_getName]
701 // Get Eddystone name
702 NSString *eddystoneName = [eddystone getName];
703 NSLog(@"Eddystone name: %@", eddystoneName);
704 // [objc_Eddystone_getName]
705
706 // [objc_Eddystone_getNamespaceId]
707 // Get Eddystone namespace ID
708 NSString *namespaceId = [eddystone getNamespaceId];
709 NSLog(@"Eddystone namespace ID: %@", namespaceId);
710 // [objc_Eddystone_getNamespaceId]
711
712 // [objc_Eddystone_getInstanceId]
713 // Get Eddystone instance ID
714 NSString *instanceId = [eddystone getInstanceId];
715 NSLog(@"Eddystone instance ID: %@", instanceId);
716 // [objc_Eddystone_getInstanceId]
717
718 // [objc_Eddystone_getPower]
719 // Get Eddystone power
720 NSNumber *power = [eddystone getPower];
721 if (power != nil) {
722 NSLog(@"Eddystone power: %d", [power intValue]);
723 }
724 // [objc_Eddystone_getPower]
725
726 // [objc_Eddystone_getStatus]
727 // Get Eddystone status
728 NCTransmitterStatus status = [eddystone getStatus];
729 NSLog(@"Eddystone status: %ld", (long)status);
730 // [objc_Eddystone_getStatus]
731}
732
736- (void)demonstratePointUsage:(NCPoint *)point {
737 if (point == nil) {
738 NSLog(@"Point is null");
739 return;
740 }
741
742 // [objc_Point_getX]
743 // Get X coordinate
744 double x = [point getX];
745 NSLog(@"Point X: %f", x);
746 // [objc_Point_getX]
747
748 // [objc_Point_getY]
749 // Get Y coordinate
750 double y = [point getY];
751 NSLog(@"Point Y: %f", y);
752 // [objc_Point_getY]
753}
754
758- (void)demonstrateGraphUsage:(NCGraph *)graph {
759 if (graph == nil) {
760 NSLog(@"Graph is null");
761 return;
762 }
763
764 // [objc_Graph_getVertices]
765 // Get graph vertices
766 NSArray<NCGraphVertex *> *vertices = [graph getVertices];
767 NSLog(@"Number of graph vertices: %lu", (unsigned long)vertices.count);
768 // [objc_Graph_getVertices]
769
770 // [objc_Graph_getEdges]
771 // Get graph edges
772 NSArray<NCGraphEdge *> *edges = [graph getEdges];
773 NSLog(@"Number of graph edges: %lu", (unsigned long)edges.count);
774 // [objc_Graph_getEdges]
775}
776
780- (void)demonstrateGraphVertexUsage:(NCGraphVertex *)vertex {
781 if (vertex == nil) {
782 NSLog(@"GraphVertex is null");
783 return;
784 }
785
786 // [objc_GraphVertex_getId]
787 // Get vertex ID
788 int32_t vertexId = [vertex getId];
789 NSLog(@"Vertex ID: %d", vertexId);
790 // [objc_GraphVertex_getId]
791
792 // [objc_GraphVertex_getPoint]
793 // Get vertex point
794 NCPoint *point = [vertex getPoint];
795 if (point != nil) {
796 [self demonstratePointUsage:point];
797 }
798 // [objc_GraphVertex_getPoint]
799
800 // [objc_GraphVertex_getName]
801 // Get vertex name
802 NSString *name = [vertex getName];
803 NSLog(@"Vertex name: %@", name);
804 // [objc_GraphVertex_getName]
805
806 // [objc_GraphVertex_getIsExternal]
807 // Get vertex external flag
808 BOOL isExternal = [vertex getIsExternal];
809 NSLog(@"Vertex is external: %@", isExternal ? @"YES" : @"NO");
810 // [objc_GraphVertex_getIsExternal]
811
812 // [objc_GraphVertex_getIsElevation]
813 // Get vertex elevation flag
814 BOOL isElevation = [vertex getIsElevation];
815 NSLog(@"Vertex is elevation: %@", isElevation ? @"YES" : @"NO");
816 // [objc_GraphVertex_getIsElevation]
817}
818
822- (void)demonstrateGraphEdgeUsage:(NCGraphEdge *)edge {
823 if (edge == nil) {
824 NSLog(@"GraphEdge is null");
825 return;
826 }
827
828 // [objc_GraphEdge_getWeight]
829 // Get edge weight
830 float weight = [edge getWeight];
831 NSLog(@"Edge weight: %f", weight);
832 // [objc_GraphEdge_getWeight]
833
834 // [objc_GraphEdge_getDst]
835 // Get destination vertex ID
836 int32_t dst = [edge getDst];
837 NSLog(@"Edge destination ID: %d", dst);
838 // [objc_GraphEdge_getDst]
839
840 // [objc_GraphEdge_getSrc]
841 // Get source vertex ID
842 int32_t src = [edge getSrc];
843 NSLog(@"Edge source ID: %d", src);
844 // [objc_GraphEdge_getSrc]
845
846 // [objc_GraphEdge_getWeightCoef]
847 // Get edge weight coefficient
848 int32_t weightCoef = [edge getWeightCoef];
849 NSLog(@"Edge weight coefficient: %d", weightCoef);
850 // [objc_GraphEdge_getWeightCoef]
851}
852
856- (void)demonstrateElevationGraphUsage:(NCElevationGraph *)elevationGraph {
857 if (elevationGraph == nil) {
858 NSLog(@"ElevationGraph is null");
859 return;
860 }
861
862 // [objc_ElevationGraph_getEdges]
863 // Get elevation graph edges
864 NSArray<NCGraphEdge *> *edges = [elevationGraph getEdges];
865 NSLog(@"Number of elevation graph edges: %lu", (unsigned long)edges.count);
866
867 // Demonstrate each edge
868 for (int i = 0; i < edges.count; i++) {
869 NCGraphEdge *edge = edges[i];
870 NSLog(@"Elevation graph edge %d:", i + 1);
871 [self demonstrateGraphEdgeUsage:edge];
872 }
873 // [objc_ElevationGraph_getEdges]
874}
875
879- (void)demonstrateTransmitterStatus {
880 // [objc_TransmitterStatus_values]
881 // Get all transmitter status values
882 NSLog(@"Available transmitter statuses:");
883 NSLog(@" - NCTransmitterStatusActive: %ld", (long)NCTransmitterStatusActive);
884 NSLog(@" - NCTransmitterStatusInactive: %ld", (long)NCTransmitterStatusInactive);
885 // [objc_TransmitterStatus_values]
886}
887
891- (void)cleanup {
892 if (self.locationManager != nil) {
893 // [objc_LocationManager_removeLocationListener]
894 // Remove location listener
895 [self.locationManager removeLocationListener:self];
896 // [objc_LocationManager_removeLocationListener]
897 }
898}
899
903- (void)runExample {
904 NSLog(@"=== LocationManager Example ===");
905
906 [self demonstrateLocationManagerMethods];
907 [self demonstrateTransmitterStatus];
908
909 // Wait a bit for location to load
910 [NSThread sleepForTimeInterval:2.0];
911
912 [self cleanup];
913 NSLog(@"=== Example completed ===");
914}
915
916#pragma mark - NCLocationListener
917
918// [objc_LocationListener_onLocationLoaded]
919- (void)onLocationLoaded:(NCLocation *)location {
920 NSLog(@"Location loaded successfully");
921 self.currentLocation = location;
922 if (location != nil) {
923 [self demonstrateLocationUsage:location];
924 }
925}
926// [objc_LocationListener_onLocationLoaded]
927
928// [objc_LocationListener_onLocationUploaded]
929- (void)onLocationUploaded:(int32_t)locationId {
930 NSLog(@"Location uploaded: %d", locationId);
931}
932// [objc_LocationListener_onLocationUploaded]
933
934// [objc_LocationListener_onLocationFailed]
935- (void)onLocationFailed:(int32_t)locationId error:(NSError *)error {
936 NSLog(@"Failed to load location %d: %@", locationId, error.localizedDescription);
937}
938// [objc_LocationListener_onLocationFailed]
939
940@end
941
945int main(int argc, const char * argv[]) {
946 @autoreleasepool {
947 LocationManagerExample *example = [[LocationManagerExample alloc] init];
948 [example runExample];
949 }
950 return 0;
951}