Loading...
Searching...
No Matches
LocationManagerExample.m
Go to the documentation of this file.
1#import <Foundation/Foundation.h>
2#import "NCNavigineSdk.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"
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_getBuildingName]
318 // Get sublocation building name
319 NSString *buildingName = [sublocation getBuildingName];
320 NSLog(@"Sublocation building name: %@", buildingName);
321 // [objc_Sublocation_getBuildingName]
322
323 // [objc_Sublocation_getReferencePoints]
324 // Get reference points
325 NSArray<NCReferencePoint *> *referencePoints = [sublocation getReferencePoints];
326 NSLog(@"Number of reference points: %lu", (unsigned long)referencePoints.count);
327 // [objc_Sublocation_getReferencePoints]
328
329 // [objc_Sublocation_getVenues]
330 // Get venues
331 NSArray<NCVenue *> *venues = [sublocation getVenues];
332 NSLog(@"Number of venues: %lu", (unsigned long)venues.count);
333 // [objc_Sublocation_getVenues]
334
335 // [objc_Sublocation_getZones]
336 // Get zones
337 NSArray<NCZone *> *zones = [sublocation getZones];
338 NSLog(@"Number of zones: %lu", (unsigned long)zones.count);
339 // [objc_Sublocation_getZones]
340
341 // [objc_Sublocation_getBeacons]
342 // Get beacons
343 NSArray<NCBeacon *> *beacons = [sublocation getBeacons];
344 NSLog(@"Number of beacons: %lu", (unsigned long)beacons.count);
345 // [objc_Sublocation_getBeacons]
346
347 // [objc_Sublocation_getWifis]
348 // Get WiFi access points
349 NSArray<NCWifi *> *wifis = [sublocation getWifis];
350 NSLog(@"Number of WiFi access points: %lu", (unsigned long)wifis.count);
351 // [objc_Sublocation_getWifis]
352
353 // [objc_Sublocation_getEddystones]
354 // Get Eddystone beacons
355 NSArray<NCEddystone *> *eddystones = [sublocation getEddystones];
356 NSLog(@"Number of Eddystone beacons: %lu", (unsigned long)eddystones.count);
357 // [objc_Sublocation_getEddystones]
358
359 // [objc_Sublocation_getGraph]
360 // Get graph
361 NCGraph *graph = [sublocation getGraph];
362 if (graph != nil) {
363 [self demonstrateGraphUsage:graph];
364 }
365 // [objc_Sublocation_getGraph]
366
367 // [objc_Sublocation_getGraph_withTag]
368 // Get graph by tag
369 NCGraph *graphByTag = [sublocation getGraph:@"main"];
370 if (graphByTag != nil) {
371 NSLog(@"Found graph with tag \"main\"");
372 [self demonstrateGraphUsage:graphByTag];
373 }
374 // [objc_Sublocation_getGraph_withTag]
375
376 // [objc_Sublocation_getVenueById]
377 // Get venue by ID
378 if (venues.count > 0) {
379 NCVenue *venueById = [sublocation getVenueById:[venues.firstObject getId]];
380 if (venueById != nil) {
381 NSLog(@"Found venue by ID: %d", [venueById getId]);
382 [self demonstrateVenueUsage:venueById];
383 }
384 }
385 // [objc_Sublocation_getVenueById]
386
387 // [objc_Sublocation_getZoneById]
388 // Get zone by ID
389 if (zones.count > 0) {
390 NCZone *zoneById = [sublocation getZoneById:[zones.firstObject getId]];
391 if (zoneById != nil) {
392 NSLog(@"Found zone by ID: %d", [zoneById getId]);
393 [self demonstrateZoneUsage:zoneById];
394 }
395 }
396 // [objc_Sublocation_getZoneById]
397
398 // [objc_Sublocation_globalToLocal]
399 // Convert global coordinates to local coordinates
400 NCGlobalPoint *globalPoint = [[NCGlobalPoint alloc] initWithLat:55.7558 lon:37.6176]; // Moscow coordinates
401 NCLocationPoint *localPoint = [sublocation globalToLocal:globalPoint];
402 NSLog(@"Global point %.6f, %.6f converted to local: %.2f, %.2f",
403 [globalPoint getLat], [globalPoint getLon], [localPoint getX], [localPoint getY]);
404 // [objc_Sublocation_globalToLocal]
405
406 // [objc_Sublocation_localToGlobal]
407 // Convert local coordinates to global coordinates
408 NCLocationPoint *localPoint2 = [[NCLocationPoint alloc] initWithX:100.0 y:200.0];
409 NCGlobalPoint *globalPoint2 = [sublocation localToGlobal:localPoint2];
410 NSLog(@"Local point %.2f, %.2f converted to global: %.6f, %.6f",
411 [localPoint2 getX], [localPoint2 getY], [globalPoint2 getLat], [globalPoint2 getLon]);
412 // [objc_Sublocation_localToGlobal]
413
414 // [objc_Sublocation_getImage]
415 // Get sublocation image
416 NCImageWrapper *image = [sublocation getImage:@1024]; // max texture size 1024
417 if (image != nil) {
418 NSLog(@"Sublocation image obtained with max texture size 1024");
419 }
420 // [objc_Sublocation_getImage]
421}
422
426- (void)demonstrateVenueUsage:(NCVenue *)venue {
427 if (venue == nil) {
428 NSLog(@"Venue is null");
429 return;
430 }
431
432 // [objc_Venue_getId]
433 // Get venue ID
434 int32_t venueId = [venue getId];
435 NSLog(@"Venue ID: %d", venueId);
436 // [objc_Venue_getId]
437
438 // [objc_Venue_getLocationId]
439 // Get venue location ID
440 int32_t locationId = [venue getLocationId];
441 NSLog(@"Venue location ID: %d", locationId);
442 // [objc_Venue_getLocationId]
443
444 // [objc_Venue_getSublocationId]
445 // Get venue sublocation ID
446 int32_t sublocationId = [venue getSublocationId];
447 NSLog(@"Venue sublocation ID: %d", sublocationId);
448 // [objc_Venue_getSublocationId]
449
450 // [objc_Venue_getName]
451 // Get venue name
452 NSString *venueName = [venue getName];
453 NSLog(@"Venue name: %@", venueName);
454 // [objc_Venue_getName]
455
456 // [objc_Venue_getPhone]
457 // Get venue phone
458 NSString *phone = [venue getPhone];
459 NSLog(@"Venue phone: %@", phone);
460 // [objc_Venue_getPhone]
461
462 // [objc_Venue_getDescript]
463 // Get venue description
464 NSString *venueDescription = [venue getDescript];
465 NSLog(@"Venue description: %@", venueDescription);
466 // [objc_Venue_getDescript]
467
468 // [objc_Venue_getAlias]
469 // Get venue alias
470 NSString *alias = [venue getAlias];
471 NSLog(@"Venue alias: %@", alias);
472 // [objc_Venue_getAlias]
473
474 // [objc_Venue_getCategoryId]
475 // Get category ID
476 int32_t categoryId = [venue getCategoryId];
477 NSLog(@"Venue category ID: %d", categoryId);
478 // [objc_Venue_getCategoryId]
479
480 // [objc_Venue_getImageUrl]
481 // Get venue image URL
482 NSString *imageUrl = [venue getImageUrl];
483 if (imageUrl != nil) {
484 NSLog(@"Venue image URL: %@", imageUrl);
485 }
486 // [objc_Venue_getImageUrl]
487
488 // [objc_Venue_getPoint]
489 // Get venue point
490 NCPoint *point = [venue getPoint];
491 if (point != nil) {
492 [self demonstratePointUsage:point];
493 }
494 // [objc_Venue_getPoint]
495}
496
500- (void)demonstrateZoneUsage:(NCZone *)zone {
501 if (zone == nil) {
502 NSLog(@"Zone is null");
503 return;
504 }
505
506 // [objc_Zone_getId]
507 // Get zone ID
508 int32_t zoneId = [zone getId];
509 NSLog(@"Zone ID: %d", zoneId);
510 // [objc_Zone_getId]
511
512 // [objc_Zone_getLocationId]
513 // Get zone location ID
514 int32_t locationId = [zone getLocationId];
515 NSLog(@"Zone location ID: %d", locationId);
516 // [objc_Zone_getLocationId]
517
518 // [objc_Zone_getSublocationId]
519 // Get zone sublocation ID
520 int32_t sublocationId = [zone getSublocationId];
521 NSLog(@"Zone sublocation ID: %d", sublocationId);
522 // [objc_Zone_getSublocationId]
523
524 // [objc_Zone_getName]
525 // Get zone name
526 NSString *zoneName = [zone getName];
527 NSLog(@"Zone name: %@", zoneName);
528 // [objc_Zone_getName]
529
530 // [objc_Zone_getDescript]
531 // Get zone description
532 NSString *zoneDescription = [zone getDescript];
533 NSLog(@"Zone description: %@", zoneDescription);
534 // [objc_Zone_getDescript]
535
536 // [objc_Zone_getCategoryId]
537 // Get category ID
538 int32_t categoryId = [zone getCategoryId];
539 NSLog(@"Zone category ID: %d", categoryId);
540 // [objc_Zone_getCategoryId]
541
542 // [objc_Zone_getAlias]
543 // Get zone alias
544 NSString *alias = [zone getAlias];
545 NSLog(@"Zone alias: %@", alias);
546 // [objc_Zone_getAlias]
547
548 // [objc_Zone_getColor]
549 // Get zone color
550 NSString *color = [zone getColor];
551 NSLog(@"Zone color: %@", color);
552 // [objc_Zone_getColor]
553
554 // [objc_Zone_getPolygon]
555 // Get zone polygon
556 NSArray<NCPoint *> *polygon = [zone getPolygon];
557 NSLog(@"Zone polygon points: %lu", (unsigned long)polygon.count);
558 // [objc_Zone_getPolygon]
559}
560
564- (void)demonstrateBeaconUsage:(NCBeacon *)beacon {
565 if (beacon == nil) {
566 NSLog(@"Beacon is null");
567 return;
568 }
569
570 // [objc_Beacon_getPoint]
571 // Get beacon point
572 NCPoint *point = [beacon getPoint];
573 if (point != nil) {
574 [self demonstratePointUsage:point];
575 }
576 // [objc_Beacon_getPoint]
577
578 // [objc_Beacon_getLocationId]
579 // Get beacon location ID
580 int32_t locationId = [beacon getLocationId];
581 NSLog(@"Beacon location ID: %d", locationId);
582 // [objc_Beacon_getLocationId]
583
584 // [objc_Beacon_getSublocationId]
585 // Get beacon sublocation ID
586 int32_t sublocationId = [beacon getSublocationId];
587 NSLog(@"Beacon sublocation ID: %d", sublocationId);
588 // [objc_Beacon_getSublocationId]
589
590 // [objc_Beacon_getName]
591 // Get beacon name
592 NSString *beaconName = [beacon getName];
593 NSLog(@"Beacon name: %@", beaconName);
594 // [objc_Beacon_getName]
595
596 // [objc_Beacon_getMajor]
597 // Get beacon major
598 int32_t major = [beacon getMajor];
599 NSLog(@"Beacon major: %d", major);
600 // [objc_Beacon_getMajor]
601
602 // [objc_Beacon_getMinor]
603 // Get beacon minor
604 int32_t minor = [beacon getMinor];
605 NSLog(@"Beacon minor: %d", minor);
606 // [objc_Beacon_getMinor]
607
608 // [objc_Beacon_getUuid]
609 // Get beacon UUID
610 NSString *uuid = [beacon getUuid];
611 NSLog(@"Beacon UUID: %@", uuid);
612 // [objc_Beacon_getUuid]
613
614 // [objc_Beacon_getPower]
615 // Get beacon power
616 NSNumber *power = [beacon getPower];
617 if (power != nil) {
618 NSLog(@"Beacon power: %d", [power intValue]);
619 }
620 // [objc_Beacon_getPower]
621
622 // [objc_Beacon_getStatus]
623 // Get beacon status
624 NCTransmitterStatus status = [beacon getStatus];
625 NSLog(@"Beacon status: %ld", (long)status);
626 // [objc_Beacon_getStatus]
627}
628
632- (void)demonstrateWifiUsage:(NCWifi *)wifi {
633 if (wifi == nil) {
634 NSLog(@"WiFi is null");
635 return;
636 }
637
638 // [objc_Wifi_getPoint]
639 // Get WiFi point
640 NCPoint *point = [wifi getPoint];
641 if (point != nil) {
642 [self demonstratePointUsage:point];
643 }
644 // [objc_Wifi_getPoint]
645
646 // [objc_Wifi_getLocationId]
647 // Get WiFi location ID
648 int32_t locationId = [wifi getLocationId];
649 NSLog(@"WiFi location ID: %d", locationId);
650 // [objc_Wifi_getLocationId]
651
652 // [objc_Wifi_getSublocationId]
653 // Get WiFi sublocation ID
654 int32_t sublocationId = [wifi getSublocationId];
655 NSLog(@"WiFi sublocation ID: %d", sublocationId);
656 // [objc_Wifi_getSublocationId]
657
658 // [objc_Wifi_getName]
659 // Get WiFi name
660 NSString *wifiName = [wifi getName];
661 NSLog(@"WiFi name: %@", wifiName);
662 // [objc_Wifi_getName]
663
664 // [objc_Wifi_getMac]
665 // Get WiFi MAC address
666 NSString *mac = [wifi getMac];
667 NSLog(@"WiFi MAC: %@", mac);
668 // [objc_Wifi_getMac]
669
670 // [objc_Wifi_getStatus]
671 // Get WiFi status
672 NCTransmitterStatus status = [wifi getStatus];
673 NSLog(@"WiFi status: %ld", (long)status);
674 // [objc_Wifi_getStatus]
675}
676
680- (void)demonstrateEddystoneUsage:(NCEddystone *)eddystone {
681 if (eddystone == nil) {
682 NSLog(@"Eddystone is null");
683 return;
684 }
685
686 // [objc_Eddystone_getPoint]
687 // Get Eddystone point
688 NCPoint *point = [eddystone getPoint];
689 if (point != nil) {
690 [self demonstratePointUsage:point];
691 }
692 // [objc_Eddystone_getPoint]
693
694 // [objc_Eddystone_getLocationId]
695 // Get Eddystone location ID
696 int32_t locationId = [eddystone getLocationId];
697 NSLog(@"Eddystone location ID: %d", locationId);
698 // [objc_Eddystone_getLocationId]
699
700 // [objc_Eddystone_getSublocationId]
701 // Get Eddystone sublocation ID
702 int32_t sublocationId = [eddystone getSublocationId];
703 NSLog(@"Eddystone sublocation ID: %d", sublocationId);
704 // [objc_Eddystone_getSublocationId]
705
706 // [objc_Eddystone_getName]
707 // Get Eddystone name
708 NSString *eddystoneName = [eddystone getName];
709 NSLog(@"Eddystone name: %@", eddystoneName);
710 // [objc_Eddystone_getName]
711
712 // [objc_Eddystone_getNamespaceId]
713 // Get Eddystone namespace ID
714 NSString *namespaceId = [eddystone getNamespaceId];
715 NSLog(@"Eddystone namespace ID: %@", namespaceId);
716 // [objc_Eddystone_getNamespaceId]
717
718 // [objc_Eddystone_getInstanceId]
719 // Get Eddystone instance ID
720 NSString *instanceId = [eddystone getInstanceId];
721 NSLog(@"Eddystone instance ID: %@", instanceId);
722 // [objc_Eddystone_getInstanceId]
723
724 // [objc_Eddystone_getPower]
725 // Get Eddystone power
726 NSNumber *power = [eddystone getPower];
727 if (power != nil) {
728 NSLog(@"Eddystone power: %d", [power intValue]);
729 }
730 // [objc_Eddystone_getPower]
731
732 // [objc_Eddystone_getStatus]
733 // Get Eddystone status
734 NCTransmitterStatus status = [eddystone getStatus];
735 NSLog(@"Eddystone status: %ld", (long)status);
736 // [objc_Eddystone_getStatus]
737}
738
742- (void)demonstratePointUsage:(NCPoint *)point {
743 if (point == nil) {
744 NSLog(@"Point is null");
745 return;
746 }
747
748 // [objc_Point_getX]
749 // Get X coordinate
750 double x = [point getX];
751 NSLog(@"Point X: %f", x);
752 // [objc_Point_getX]
753
754 // [objc_Point_getY]
755 // Get Y coordinate
756 double y = [point getY];
757 NSLog(@"Point Y: %f", y);
758 // [objc_Point_getY]
759}
760
764- (void)demonstrateGraphUsage:(NCGraph *)graph {
765 if (graph == nil) {
766 NSLog(@"Graph is null");
767 return;
768 }
769
770 // [objc_Graph_getVertices]
771 // Get graph vertices
772 NSArray<NCGraphVertex *> *vertices = [graph getVertices];
773 NSLog(@"Number of graph vertices: %lu", (unsigned long)vertices.count);
774 // [objc_Graph_getVertices]
775
776 // [objc_Graph_getEdges]
777 // Get graph edges
778 NSArray<NCGraphEdge *> *edges = [graph getEdges];
779 NSLog(@"Number of graph edges: %lu", (unsigned long)edges.count);
780 // [objc_Graph_getEdges]
781}
782
786- (void)demonstrateGraphVertexUsage:(NCGraphVertex *)vertex {
787 if (vertex == nil) {
788 NSLog(@"GraphVertex is null");
789 return;
790 }
791
792 // [objc_GraphVertex_getId]
793 // Get vertex ID
794 int32_t vertexId = [vertex getId];
795 NSLog(@"Vertex ID: %d", vertexId);
796 // [objc_GraphVertex_getId]
797
798 // [objc_GraphVertex_getPoint]
799 // Get vertex point
800 NCPoint *point = [vertex getPoint];
801 if (point != nil) {
802 [self demonstratePointUsage:point];
803 }
804 // [objc_GraphVertex_getPoint]
805
806 // [objc_GraphVertex_getName]
807 // Get vertex name
808 NSString *name = [vertex getName];
809 NSLog(@"Vertex name: %@", name);
810 // [objc_GraphVertex_getName]
811
812 // [objc_GraphVertex_getIsExternal]
813 // Get vertex external flag
814 BOOL isExternal = [vertex getIsExternal];
815 NSLog(@"Vertex is external: %@", isExternal ? @"YES" : @"NO");
816 // [objc_GraphVertex_getIsExternal]
817
818 // [objc_GraphVertex_getIsElevation]
819 // Get vertex elevation flag
820 BOOL isElevation = [vertex getIsElevation];
821 NSLog(@"Vertex is elevation: %@", isElevation ? @"YES" : @"NO");
822 // [objc_GraphVertex_getIsElevation]
823}
824
828- (void)demonstrateGraphEdgeUsage:(NCGraphEdge *)edge {
829 if (edge == nil) {
830 NSLog(@"GraphEdge is null");
831 return;
832 }
833
834 // [objc_GraphEdge_getWeight]
835 // Get edge weight
836 float weight = [edge getWeight];
837 NSLog(@"Edge weight: %f", weight);
838 // [objc_GraphEdge_getWeight]
839
840 // [objc_GraphEdge_getDst]
841 // Get destination vertex ID
842 int32_t dst = [edge getDst];
843 NSLog(@"Edge destination ID: %d", dst);
844 // [objc_GraphEdge_getDst]
845
846 // [objc_GraphEdge_getSrc]
847 // Get source vertex ID
848 int32_t src = [edge getSrc];
849 NSLog(@"Edge source ID: %d", src);
850 // [objc_GraphEdge_getSrc]
851
852 // [objc_GraphEdge_getWeightCoef]
853 // Get edge weight coefficient
854 int32_t weightCoef = [edge getWeightCoef];
855 NSLog(@"Edge weight coefficient: %d", weightCoef);
856 // [objc_GraphEdge_getWeightCoef]
857}
858
862- (void)demonstrateElevationGraphUsage:(NCElevationGraph *)elevationGraph {
863 if (elevationGraph == nil) {
864 NSLog(@"ElevationGraph is null");
865 return;
866 }
867
868 // [objc_ElevationGraph_getEdges]
869 // Get elevation graph edges
870 NSArray<NCGraphEdge *> *edges = [elevationGraph getEdges];
871 NSLog(@"Number of elevation graph edges: %lu", (unsigned long)edges.count);
872
873 // Demonstrate each edge
874 for (int i = 0; i < edges.count; i++) {
875 NCGraphEdge *edge = edges[i];
876 NSLog(@"Elevation graph edge %d:", i + 1);
877 [self demonstrateGraphEdgeUsage:edge];
878 }
879 // [objc_ElevationGraph_getEdges]
880}
881
885- (void)demonstrateTransmitterStatus {
886 // [objc_TransmitterStatus_values]
887 // Get all transmitter status values
888 NSLog(@"Available transmitter statuses:");
889 NSLog(@" - NCTransmitterStatusActive: %ld", (long)NCTransmitterStatusActive);
890 NSLog(@" - NCTransmitterStatusInactive: %ld", (long)NCTransmitterStatusInactive);
891 // [objc_TransmitterStatus_values]
892}
893
897- (void)cleanup {
898 if (self.locationManager != nil) {
899 // [objc_LocationManager_removeLocationListener]
900 // Remove location listener
901 [self.locationManager removeLocationListener:self];
902 // [objc_LocationManager_removeLocationListener]
903 }
904}
905
909- (void)runExample {
910 NSLog(@"=== LocationManager Example ===");
911
912 [self demonstrateLocationManagerMethods];
913 [self demonstrateTransmitterStatus];
914
915 // Wait a bit for location to load
916 [NSThread sleepForTimeInterval:2.0];
917
918 [self cleanup];
919 NSLog(@"=== Example completed ===");
920}
921
922#pragma mark - NCLocationListener
923
924// [objc_LocationListener_onLocationLoaded]
925- (void)onLocationLoaded:(NCLocation *)location {
926 NSLog(@"Location loaded successfully");
927 self.currentLocation = location;
928 if (location != nil) {
929 [self demonstrateLocationUsage:location];
930 }
931}
932// [objc_LocationListener_onLocationLoaded]
933
934// [objc_LocationListener_onLocationUploaded]
935- (void)onLocationUploaded:(int32_t)locationId {
936 NSLog(@"Location uploaded: %d", locationId);
937}
938// [objc_LocationListener_onLocationUploaded]
939
940// [objc_LocationListener_onLocationFailed]
941- (void)onLocationFailed:(int32_t)locationId error:(NSError *)error {
942 NSLog(@"Failed to load location %d: %@", locationId, error.localizedDescription);
943}
944// [objc_LocationListener_onLocationFailed]
945
946@end
947
951int main(int argc, const char * argv[]) {
952 @autoreleasepool {
953 LocationManagerExample *example = [[LocationManagerExample alloc] init];
954 [example runExample];
955 }
956 return 0;
957}