Loading...
Searching...
No Matches
LocationWindowCommonExample.m
Go to the documentation of this file.
2#import <NCLocationWindow.h>
3#import <NCGlobalPoint.h>
4#import <NCScreenPoint.h>
5#import <NCBoundingBox.h>
6#import <NCCamera.h>
7#import <NCScreenRect.h>
8#import <NCVisibleRegion.h>
10#import <NCDebugFlag.h>
11#import <NCRouteLayer.h>
12#import <NCRouteEndpoint.h>
15#import <NCRouteProgress.h>
16#import <NCRouteView.h>
18#import <UIKit/UIKit.h>
19
26
27@interface DemoSublocationChangeListener : NSObject <NCSublocationChangeListener>
28@end
29
30@implementation DemoSublocationChangeListener
31// [objc_SublocationChangeListener_onActiveSublocationChanged]
32- (void)onActiveSublocationChanged:(int32_t)sublocationId {
33 NSLog(@"Active sublocation changed to: %d", sublocationId);
34}
35// [objc_SublocationChangeListener_onActiveSublocationChanged]
36@end
37
38@interface DemoRouteLayerListener : NSObject <NCRouteLayerListener>
39@end
40
41@implementation DemoRouteLayerListener
42- (void)onRouteChanged:(NCRouteLayerStatus)status route:(id<NCRouteView>)route {
43 NSLog(@"Route status: %ld", (long)status);
44}
45
46- (void)onRouteAdvanced:(NCRouteProgress *)progress {
47 NSLog(@"Remaining distance: %f, time: %fs", progress.remainingDistance, progress.remainingTime);
48}
49
50- (void)onRouteTargetReached {
51 NSLog(@"Route target reached");
52}
53@end
54
55@interface DemoRouteViewListener : NSObject <NCRouteViewListener>
56@property (nonatomic, weak) NCRouteLayer *routeLayer;
57@end
58
59@implementation DemoRouteViewListener
60- (void)onRouteViewsChanged {
61 NSLog(@"Route views changed");
62}
63
64- (void)onSelectedRouteChanged:(id<NCRouteView>)route {
65 NSLog(@"Selected route changed");
66}
67
68- (void)onRouteViewTap:(id<NCRouteView>)route {
69 [self.routeLayer selectRoute:route];
70}
71@end
72
73@implementation LocationWindowCommonExample {
74 NCLocationWindow *_locationWindow;
77 DemoRouteLayerListener *_routeLayerListener;
78 DemoRouteViewListener *_routeViewListener;
79}
80
81- (instancetype)init {
82 self = [super init];
83 if (self) {
85 }
86 return self;
87}
88
93 NSLog(@"=== LocationWindowCommon Methods ===");
94
95 [self demonstrateSetSublocationId];
96 [self demonstrateOperatingMode];
97 [self demonstrateSublocationQueries];
98 [self demonstrateSublocationChangeListener];
99 [self demonstrateUserLocationLayer];
100 [self demonstrateRouteLayer];
101 [self demonstrateCoordinateConversion];
102 [self demonstrateMapFeatureSelection];
103 [self demonstrateApplyLayerFilter];
104 [self demonstrateDebugFlags];
105 [self demonstrateZoomProperties];
106}
107
111- (void)demonstrateDebugFlags {
112 NSLog(@"--- Debug flags ---");
113
114 // [objc_DebugFlag_enum]
115 NSArray<NSNumber *> *allFlags = @[
116 @(NCDebugFlagNone),
117 @(NCDebugFlagInfos),
118 @(NCDebugFlagStats),
119 @(NCDebugFlagLabels),
120 @(NCDebugFlagDrawAllLabels),
121 @(NCDebugFlagSelectionBuffer)
122 ];
123 NSLog(@"Debug flag enum values: %lu", (unsigned long)allFlags.count);
124 // [objc_DebugFlag_enum]
125
126 // [objc_LocationWindow_setDebugFlag]
127 [NCLocationWindow setDebugFlag:NCDebugFlagInfos on:YES];
128 [NCLocationWindow setDebugFlag:NCDebugFlagStats on:NO];
129 NSLog(@"Updated debug flags on LocationWindow");
130 // [objc_LocationWindow_setDebugFlag]
131
132 // [objc_LocationWindow_getDebugFlag]
133 BOOL infosOn = [NCLocationWindow getDebugFlag:NCDebugFlagInfos];
134 NSLog(@"Debug flag INFOS enabled: %@", infosOn ? @"YES" : @"NO");
135 // [objc_LocationWindow_getDebugFlag]
136}
137
138
142- (void)demonstrateOperatingMode {
143 NSLog(@"--- Operating Mode ---");
144
145 if (_locationWindow == nil) {
146 NSLog(@"LocationWindow not available yet");
147 return;
148 }
149
150 // [objc_OperatingMode_enum]
151 NSArray<NSNumber *> *modes = @[@(NCOperatingModeIndoorOnly), @(NCOperatingModeOutdoor), @(NCOperatingModeOutdoorIndoor)];
152 NSLog(@"Operating modes: %lu", (unsigned long)modes.count);
153 // [objc_OperatingMode_enum]
154
155 // [objc_LocationWindow_setOperatingMode]
156 [_locationWindow setOperatingMode:NCOperatingModeOutdoorIndoor];
157 NSLog(@"Set operating mode to OUTDOOR_INDOOR");
158 // [objc_LocationWindow_setOperatingMode]
159
160 // [objc_LocationWindow_getOperatingMode]
161 NCOperatingMode currentMode = [_locationWindow getOperatingMode];
162 NSLog(@"Current operating mode: %ld", (long)currentMode);
163 // [objc_LocationWindow_getOperatingMode]
164
165 // [objc_MapTheme_enum]
166 NSArray<NSNumber *> *themes = @[@(NCMapThemeLight), @(NCMapThemeDark)];
167 NSLog(@"Map themes: %lu", (unsigned long)themes.count);
168 // [objc_MapTheme_enum]
169
170 // [objc_LocationWindow_setMapTheme]
171 [_locationWindow setMapTheme:NCMapThemeDark];
172 NSLog(@"Set map theme to DARK");
173 // [objc_LocationWindow_setMapTheme]
174
175 // [objc_LocationWindow_getMapTheme]
176 NCMapTheme currentTheme = [_locationWindow getMapTheme];
177 NSLog(@"Current map theme: %ld", (long)currentTheme);
178 // [objc_LocationWindow_getMapTheme]
179
180 // [objc_TileKind_enum]
181 NSArray<NSNumber *> *kinds = @[@(NCTileKindVector), @(NCTileKindRaster)];
182 NSLog(@"Tile kinds: %lu", (unsigned long)kinds.count);
183 // [objc_TileKind_enum]
184
185 // [objc_TileSchema_enum]
186 NSArray<NSNumber *> *schemas = @[@(NCTileSchemaShortbread), @(NCTileSchemaOpenMapTiles), @(NCTileSchemaMapboxStreets)];
187 NSLog(@"Tile schemas: %lu", (unsigned long)schemas.count);
188 // [objc_TileSchema_enum]
189
190 // [objc_HttpTileSource_record]
191 NCHttpTileSource *http = [[NCHttpTileSource alloc]
192 initWithUrlTemplate:@"https://api.maptiler.com/tiles/v3-openmaptiles/{z}/{x}/{y}.pbf"
193 headers:nil
194 queryParameters:@{@"key": @"YOUR_MAPTILER_KEY"}];
195 // [objc_HttpTileSource_record]
196
197 // [objc_MbtilesTileSource_record]
198 NCMbtilesTileSource *offline = [[NCMbtilesTileSource alloc]
199 initWithPath:@"/path/to/map.mbtiles"];
200 // [objc_MbtilesTileSource_record]
201
202 // [objc_TileProvider_record]
203 NCTileProvider *osmHttp = [[NCTileProvider alloc]
204 initWithSchema:NCTileSchemaOpenMapTiles
205 http:http
206 mbtiles:nil
207 minZoom:0
208 maxZoom:14
209 attribution:nil
210 kind:NCTileKindVector];
211 NCTileProvider *mbtiles = [[NCTileProvider alloc]
212 initWithSchema:NCTileSchemaShortbread
213 http:nil
214 mbtiles:offline
215 minZoom:0
216 maxZoom:14
217 attribution:nil
218 kind:NCTileKindVector];
219 // [objc_TileProvider_record]
220
221 // [objc_LocationWindow_setTileProvider]
222 [_locationWindow setTileProvider:osmHttp];
223 [_locationWindow setTileProvider:nil];
224 NCHttpTileSource *imageryHttp = [[NCHttpTileSource alloc]
225 initWithUrlTemplate:@"https://tile.openstreetmap.org/{z}/{x}/{y}.png"
226 headers:nil
227 queryParameters:nil];
228 NCTileProvider *imagery = [[NCTileProvider alloc]
229 initWithSchema:NCTileSchemaShortbread
230 http:imageryHttp
231 mbtiles:nil
232 minZoom:0
233 maxZoom:19
234 attribution:@"© OpenStreetMap contributors"
235 kind:NCTileKindRaster];
236 [_locationWindow setTileProvider:imagery];
237 // [objc_LocationWindow_setTileProvider]
238
239 // [objc_AttributionAlignment_record]
241 initWithHorizontalAlignment:NCAttributionHorizontalAlignmentRight
242 verticalAlignment:NCAttributionVerticalAlignmentBottom];
243 // [objc_AttributionAlignment_record]
244
245 // [objc_LocationWindow_setAttributionAlignment]
246 [_locationWindow setAttributionAlignment:alignment];
247 // [objc_LocationWindow_setAttributionAlignment]
248
249 // [objc_LocationWindow_getAttribution]
250 NSString *attribution = [_locationWindow getAttribution];
251 NSLog(@"Attribution: %@", attribution);
252 // [objc_LocationWindow_getAttribution]
253}
254
258- (void)demonstrateSetSublocationId {
259 NSLog(@"--- setSublocationId Method ---");
260
261 if (_locationWindow == nil) {
262 NSLog(@"LocationWindow not available yet");
263 return;
264 }
265
266 // [objc_LocationWindow_setSublocationId]
267 // Set sublocation ID to switch between floors
268 [_locationWindow setSublocationId:1];
269 NSLog(@"Set sublocation ID to 1 (first floor)");
270 // [objc_LocationWindow_setSublocationId]
271
272 // [objc_LocationWindow_setSublocationId_2]
273 // Set sublocation ID to another floor
274 [_locationWindow setSublocationId:2];
275 NSLog(@"Set sublocation ID to 2 (second floor)");
276 // [objc_LocationWindow_setSublocationId_2]
277
278 // [objc_LocationWindow_setSublocationId_3]
279 // Set sublocation ID to ground floor
280 [_locationWindow setSublocationId:0];
281 NSLog(@"Set sublocation ID to 0 (ground floor)");
282 // [objc_LocationWindow_setSublocationId_3]
283
284 // Test with different sublocation IDs
285 NSArray<NSNumber *> *sublocationIds = @[@1, @2, @3, @0, @5];
286 for (NSNumber *idNumber in sublocationIds) {
287 [_locationWindow setSublocationId:idNumber.intValue];
288 NSLog(@"Switched to sublocation ID: %d", idNumber.intValue);
289 }
290}
291
295- (void)demonstrateSublocationQueries {
296 NSLog(@"--- getSublocationId & getEnclosingCamera ---");
297
298 if (_locationWindow == nil) {
299 NSLog(@"LocationWindow not available yet");
300 return;
301 }
302
303 // [objc_LocationWindow_getSublocationId]
304 NSNumber *currentId = [_locationWindow getSublocationId];
305 if (currentId != nil) {
306 NSLog(@"Current sublocation id: %@", currentId);
307 } else {
308 NSLog(@"Current sublocation id is not set");
309 }
310 // [objc_LocationWindow_getSublocationId]
311
312 // [objc_LocationWindow_getEnclosingCamera]
313 NCBoundingBox *boundingBox = [[NCBoundingBox alloc] initWithBottomLeft:[[NCGlobalPoint alloc] initWithLatitude:55.75 longitude:37.61]
314 topRight:[[NCGlobalPoint alloc] initWithLatitude:55.76 longitude:37.63]];
315 NCCamera *camera = [_locationWindow getEnclosingCamera:boundingBox];
316 NSLog(@"Camera that fits bounding box: %@", camera);
317 // [objc_LocationWindow_getEnclosingCamera]
318
319 // [objc_LocationWindow_setFocusRect]
320 NCScreenRect *focus = [[NCScreenRect alloc] initWithTopLeft:[[NCScreenPoint alloc] initWithX:0 y:0]
321 bottomRight:[[NCScreenPoint alloc] initWithX:1000 y:1600]];
322 [_locationWindow setFocusRect:focus];
323 // [objc_LocationWindow_setFocusRect]
324
325 // [objc_LocationWindow_getEnclosingCameraWithFocus]
326 NCCamera *padded = [_locationWindow getEnclosingCameraWithFocus:boundingBox
327 focusRect:focus
328 azimuth:nil
329 tilt:nil];
330 NSLog(@"Camera that fits bounding box in focus rect: %@", padded);
331 // [objc_LocationWindow_getEnclosingCameraWithFocus]
332}
333
337- (void)demonstrateSublocationChangeListener {
338 NSLog(@"--- Sublocation Change Listener ---");
339
340 if (_locationWindow == nil) {
341 NSLog(@"LocationWindow not available yet");
342 return;
343 }
344
345 DemoSublocationChangeListener *listener = [[DemoSublocationChangeListener alloc] init];
346
347 // [objc_LocationWindow_addSublocationChangeListener]
348 [_locationWindow addSublocationChangeListener:listener];
349 NSLog(@"Added sublocation change listener");
350 // [objc_LocationWindow_addSublocationChangeListener]
351
352 [_locationWindow setSublocationId:1];
353 [_locationWindow setSublocationId:2];
354
355 // [objc_LocationWindow_removeSublocationChangeListener]
356 [_locationWindow removeSublocationChangeListener:listener];
357 NSLog(@"Removed sublocation change listener");
358 // [objc_LocationWindow_removeSublocationChangeListener]
359}
360
364- (void)demonstrateUserLocationLayer {
365 NSLog(@"--- UserLocationLayer ---");
366
367 if (_userLocationLayer == nil) {
368 NSLog(@"UserLocationLayer not available yet");
369 return;
370 }
371
372 // [objc_UserLocationLayer_setVisible]
374 NSLog(@"User location layer set visible");
375 // [objc_UserLocationLayer_setVisible]
376
377 // [objc_UserLocationLayer_isVisible]
378 BOOL visible = [_userLocationLayer isVisible];
379 NSLog(@"User location layer is visible: %@", visible ? @"YES" : @"NO");
380 // [objc_UserLocationLayer_isVisible]
381
382 // [objc_UserLocationLayer_setAnchor]
383 NCScreenPoint *anchor = [[NCScreenPoint alloc] initWithX:100.0f y:200.0f];
385 NSLog(@"Set user location anchor to: (%.1f, %.1f)", anchor.x, anchor.y);
386 // [objc_UserLocationLayer_setAnchor]
387
388 // [objc_UserLocationLayer_anchorEnabled]
389 BOOL anchorEnabled = [_userLocationLayer anchorEnabled];
390 NSLog(@"Anchor enabled: %@", anchorEnabled ? @"YES" : @"NO");
391 // [objc_UserLocationLayer_anchorEnabled]
392
393 // [objc_UserLocationLayer_setHeadingModeActive]
395 NSLog(@"Heading-up mode enabled");
396 // [objc_UserLocationLayer_setHeadingModeActive]
397
398 // [objc_UserLocationLayer_headingModeActive]
399 BOOL headingModeActive = [_userLocationLayer headingModeActive];
400 NSLog(@"Heading-up mode active: %@", headingModeActive ? @"YES" : @"NO");
401 // [objc_UserLocationLayer_headingModeActive]
402
403 // [objc_UserLocationLayer_setFollowMode]
404 [_userLocationLayer setFollowMode:NCUserLocationFollowModeHEADING];
405 NSLog(@"Follow mode set to heading");
406 // [objc_UserLocationLayer_setFollowMode]
407
408 // [objc_UserLocationLayer_followMode]
410 NSLog(@"Follow mode: %ld", (long)followMode);
411 // [objc_UserLocationLayer_followMode]
412
413 // [objc_UserLocationLayer_setArrowBitmap]
414 UIImage *arrow = [UIImage imageWithContentsOfFile:@"/path/to/arrow.png"];
415 if (arrow != nil) {
417 }
419 NSLog(@"Custom arrow bitmap cleared");
420 // [objc_UserLocationLayer_setArrowBitmap]
421
422 // [objc_UserLocationLayer_setAccuracyColor]
423 [_userLocationLayer setAccuracyColor:[UIColor colorWithRed:0.19 green:0.67 blue:0.85 alpha:0.26]];
424 NSLog(@"Accuracy circle color updated");
425 // [objc_UserLocationLayer_setAccuracyColor]
426
427 // [objc_UserLocationLayer_resetAnchor]
429 NSLog(@"Anchor reset to default");
430 // [objc_UserLocationLayer_resetAnchor]
431}
432
436- (void)demonstrateRouteLayer {
437 NSLog(@"--- RouteLayer ---");
438
439 if (_routeLayer == nil) {
440 NSLog(@"RouteLayer not available yet");
441 return;
442 }
443
444 // [objc_RouteLayer_setVisible]
446 NSLog(@"Route layer set visible");
447 // [objc_RouteLayer_setVisible]
448
449 // [objc_RouteLayer_isVisible]
450 BOOL visible = [_routeLayer isVisible];
451 NSLog(@"Route layer is visible: %d", visible);
452 // [objc_RouteLayer_isVisible]
453
454 // [objc_RouteLayer_setTraveledColor]
455 [_routeLayer setTraveledColor:[UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:0.7]];
456 NSLog(@"Traveled color updated");
457 // [objc_RouteLayer_setTraveledColor]
458
459 // [objc_RouteLayer_setRemainingColor]
460 [_routeLayer setRemainingColor:[UIColor colorWithRed:0.19 green:0.67 blue:0.85 alpha:1.0]];
461 NSLog(@"Remaining color updated");
462 // [objc_RouteLayer_setRemainingColor]
463
464 // [objc_RouteLayer_setWidth]
465 [_routeLayer setWidth:8.0f];
466 NSLog(@"Route width updated");
467 // [objc_RouteLayer_setWidth]
468
469 // [objc_RouteLayer_setRemainingStyle]
470 [_routeLayer setRemainingStyle:NCRouteRemainingStyleDotted];
471 NSLog(@"Remaining style set to DOTTED");
472 // [objc_RouteLayer_setRemainingStyle]
473
474 // [objc_RouteLayer_remainingStyle]
476 NSLog(@"Remaining style: %ld", (long)remainingStyle);
477 // [objc_RouteLayer_remainingStyle]
478
479 // [objc_RouteLayer_setRemainingPointSize]
481 NSLog(@"Remaining point size updated");
482 // [objc_RouteLayer_setRemainingPointSize]
483
484 // [objc_RouteLayer_setRemainingPlacement]
485 [_routeLayer setRemainingPlacement:NCPlacementSpaced];
486 NSLog(@"Remaining placement updated");
487 // [objc_RouteLayer_setRemainingPlacement]
488
489 // [objc_RouteLayer_setRemainingPlacementSpacing]
491 NSLog(@"Remaining placement spacing updated");
492 // [objc_RouteLayer_setRemainingPlacementSpacing]
493
494 // [objc_RouteLayer_setRemainingPlacementMinRatio]
496 NSLog(@"Remaining placement min ratio updated");
497 // [objc_RouteLayer_setRemainingPlacementMinRatio]
498
499 // [objc_RouteLayer_setRemainingCollisionEnabled]
501 NSLog(@"Remaining collision disabled");
502 // [objc_RouteLayer_setRemainingCollisionEnabled]
503
504 // [objc_RouteLayer_setRemainingDashLength]
506 NSLog(@"Remaining dash length updated");
507 // [objc_RouteLayer_setRemainingDashLength]
508
509 // [objc_RouteLayer_setRemainingGapLength]
511 NSLog(@"Remaining gap length updated");
512 // [objc_RouteLayer_setRemainingGapLength]
513
514 NCRouteEndpoint *from = [[NCRouteEndpoint alloc]
515 initWithPoint:[[NCGlobalPoint alloc] initWithLatitude:55.751244 longitude:37.618423]
516 sublocationId:@1]; // nil for outdoor point
517 NCRouteEndpoint *to = [[NCRouteEndpoint alloc]
518 initWithPoint:[[NCGlobalPoint alloc] initWithLatitude:55.751700 longitude:37.619000]
519 sublocationId:@2]; // nil for outdoor point
520
521 // [objc_RouteLayer_setRoute]
522 [_routeLayer setRouteFrom:from to:to];
523 NSLog(@"Static route applied");
524 // [objc_RouteLayer_setRoute]
525
526 // [objc_RouteLayer_setTarget]
528 NSLog(@"Guidance target applied");
529 // [objc_RouteLayer_setTarget]
530
531 // [objc_RouteLayer_routes]
532 NSArray<id<NCRouteView>> *routes = [_routeLayer routes];
533 NSLog(@"Visible routes: %lu", (unsigned long)routes.count);
534 // [objc_RouteLayer_routes]
535
536 // [objc_RouteLayer_selectedRoute]
537 id<NCRouteView> selectedRoute = [_routeLayer selectedRoute];
538 if (selectedRoute != nil) {
539 NSLog(@"Selected route length: %f", [selectedRoute length]);
540 }
541 // [objc_RouteLayer_selectedRoute]
542
543 // [objc_RouteLayer_selectRoute]
544 if (routes.count > 0) {
545 [_routeLayer selectRoute:routes.firstObject];
546 }
547 // [objc_RouteLayer_selectRoute]
548
549 // [objc_RouteLayer_addRouteLayerListener]
551 [_routeLayer addRouteLayerListener:_routeLayerListener];
552 // [objc_RouteLayer_addRouteLayerListener]
553
554 // [objc_RouteLayer_addRouteViewListener]
556 _routeViewListener.routeLayer = _routeLayer;
557 [_routeLayer addRouteViewListener:_routeViewListener];
558 // [objc_RouteLayer_addRouteViewListener]
559
560 // [objc_RouteLayer_clear]
562 NSLog(@"Route layer cleared");
563 // [objc_RouteLayer_clear]
564}
565
569- (void)demonstrateCoordinateConversion {
570 NSLog(@"--- Coordinate Conversion Methods ---");
571
572 if (_locationWindow == nil) {
573 NSLog(@"LocationWindow not available yet");
574 return;
575 }
576
577 // [objc_LocationWindow_screenPositionToGlobal]
578 NCScreenPoint *screenPoint = [[NCScreenPoint alloc] initWithX:100.0 y:200.0];
579 NCGlobalPoint *globalPoint = [_locationWindow screenPositionToGlobal:screenPoint];
580 NSLog(@"Screen position (%.1f, %.1f) converted to WGS84: (%.6f, %.6f)",
581 screenPoint.x, screenPoint.y, globalPoint.latitude, globalPoint.longitude);
582 // [objc_LocationWindow_screenPositionToGlobal]
583
584 // [objc_LocationWindow_getVisibleRegion]
585 NCVisibleRegion *visibleRegion = [_locationWindow visibleRegion];
586 NSLog(@"Viewport top-left: %@", visibleRegion.topLeft);
587 // [objc_LocationWindow_getVisibleRegion]
588
589 // [objc_LocationWindow_getFocusRegion]
590 NCVisibleRegion *focusRegion = [_locationWindow focusRegion];
591 NSLog(@"Focus-rect top-left: %@", focusRegion.topLeft);
592 // [objc_LocationWindow_getFocusRegion]
593
594 // [objc_LocationWindow_globalToScreenPosition]
595 NCGlobalPoint *globalPoint2 = [[NCGlobalPoint alloc] initWithLatitude:55.7558 longitude:37.6176];
596 NCScreenPoint *screenPoint2 = [_locationWindow globalToScreenPosition:globalPoint2 clipToViewport:YES];
597 NSLog(@"WGS84 (%.6f, %.6f) converted to screen with clipping: (%.1f, %.1f)",
598 globalPoint2.latitude, globalPoint2.longitude, screenPoint2.x, screenPoint2.y);
599 // [objc_LocationWindow_globalToScreenPosition]
600
601 NSArray<NCScreenPoint *> *testScreenPoints = @[
602 [[NCScreenPoint alloc] initWithX:0.0 y:0.0],
603 [[NCScreenPoint alloc] initWithX:250.0 y:250.0],
604 [[NCScreenPoint alloc] initWithX:1000.0 y:600.0]
605 ];
606
607 for (int i = 0; i < testScreenPoints.count; i++) {
608 NCScreenPoint *sp = testScreenPoints[i];
609 NCGlobalPoint *gp = [_locationWindow screenPositionToGlobal:sp];
610 NCScreenPoint *backToScreen = [_locationWindow globalToScreenPosition:gp clipToViewport:NO];
611 NSLog(@"Test %d: Screen (%.1f, %.1f) -> WGS84 (%.6f, %.6f) -> Screen (%.1f, %.1f)",
612 i, sp.x, sp.y, gp.latitude, gp.longitude, backToScreen.x, backToScreen.y);
613 }
614}
615
619- (void)demonstrateMapFeatureSelection {
620 NSLog(@"--- Map Feature Selection Methods ---");
621
622 if (_locationWindow == nil) {
623 NSLog(@"LocationWindow not available yet");
624 return;
625 }
626
627 // [objc_LocationWindow_selectMapFeature]
628 // Select map feature by ID
629 NSString *featureId = "room_101";
630 BOOL selected = [_locationWindow selectMapFeature:featureId];
631 NSLog(@"Selected map feature %@: %@", featureId, selected ? @"YES" : @"NO");
632 // [objc_LocationWindow_selectMapFeature]
633
634 // [objc_LocationWindow_selectMapFeature_2]
635 // Select another map feature
636 NSString *featureId2 = "office_205";
637 BOOL selected2 = [_locationWindow selectMapFeature:featureId2];
638 NSLog(@"Selected map feature %@: %@", featureId2, selected2 ? @"YES" : @"NO");
639 // [objc_LocationWindow_selectMapFeature_2]
640
641 // [objc_LocationWindow_getSelectedMapFeatures]
642 // Get list of selected map features
643 NSArray<NSString *> *selectedFeatures = [_locationWindow selectedMapFeatures];
644 NSLog(@"Currently selected map features: %lu features", (unsigned long)selectedFeatures.count);
645 for (NSString *feature in selectedFeatures) {
646 NSLog(@" - %@", feature);
647 }
648 // [objc_LocationWindow_getSelectedMapFeatures]
649
650 // [objc_LocationWindow_deselectMapFeature]
651 // Deselect specific map feature
652 BOOL deselected = [_locationWindow deselectMapFeature:featureId];
653 NSLog(@"Deselected map feature %@: %@", featureId, deselected ? @"YES" : @"NO");
654 // [objc_LocationWindow_deselectMapFeature]
655
656 // [objc_LocationWindow_deselectMapFeature_2]
657 // Deselect another map feature
658 BOOL deselected2 = [_locationWindow deselectMapFeature:featureId2];
659 NSLog(@"Deselected map feature %@: %@", featureId2, deselected2 ? @"YES" : @"NO");
660 // [objc_LocationWindow_deselectMapFeature_2]
661
662 // [objc_LocationWindow_deselectAllMapFeatures]
663 // Deselect all map features
664 [_locationWindow deselectAllMapFeatures];
665 NSLog(@"Deselected all map features");
666 // [objc_LocationWindow_deselectAllMapFeatures]
667
668 // [objc_LocationWindow_getSelectedMapFeatures_2]
669 // Verify all features are deselected
670 NSArray<NSString *> *remainingFeatures = [_locationWindow selectedMapFeatures];
671 NSLog(@"Remaining selected features after deselect all: %lu features", (unsigned long)remainingFeatures.count);
672 // [objc_LocationWindow_getSelectedMapFeatures_2]
673
674 // Test multiple feature selection and deselection
675 NSArray<NSString *> *testFeatureIds = @[@"room_101", @"office_205", @"meeting_room_301", @"cafe_401"];
676
677 // Select multiple features
678 for (NSString *featureId in testFeatureIds) {
679 BOOL success = [_locationWindow selectMapFeature:featureId];
680 NSLog(@"Selected feature %@: %@", featureId, success ? @"YES" : @"NO");
681 }
682
683 // Check selected features
684 NSArray<NSString *> *allSelected = [_locationWindow selectedMapFeatures];
685 NSLog(@"All selected features: %lu features", (unsigned long)allSelected.count);
686
687 // Deselect all at once
688 [_locationWindow deselectAllMapFeatures];
689 NSLog(@"Deselected all features at once");
690}
691
695- (void)demonstrateApplyLayerFilter {
696 NSLog(@"--- applyLayerFilter Method ---");
697
698 if (_locationWindow == nil) {
699 NSLog(@"LocationWindow not available yet");
700 return;
701 }
702
703 // [objc_MapFilterCondition_constructor]
704 // Create filter condition: show only venues with category "Toilet" or "Cafe"
705 NCMapFilterCondition *condition = [[NCMapFilterCondition alloc] initWithProperty:@"category" values:@[@"Toilet", @"Cafe"]];
706 // [objc_MapFilterCondition_constructor]
707
708 // [objc_LocationWindow_applyLayerFilter]
709 // Apply filter to venues layer
710 NSArray<NCMapFilterCondition *> *conditions = @[[[NCMapFilterCondition alloc] initWithProperty:@"category" values:@[@"Toilet", @"Cafe"]]];
711 [_locationWindow applyLayerFilterWithLayer:@"venues" conditions:conditions];
712 NSLog(@"Applied layer filter: show venues with category Toilet or Cafe");
713 // [objc_LocationWindow_applyLayerFilter]
714
715 // Reset filter (show all venues)
716 [_locationWindow applyLayerFilterWithLayer:@"venues" conditions:@[]];
717 NSLog(@"Reset layer filter: show all venues");
718}
719
723- (void)demonstrateZoomProperties {
724 NSLog(@"--- Zoom Properties ---");
725
726 if (_locationWindow == nil) {
727 NSLog(@"LocationWindow not available yet");
728 return;
729 }
730
731 // [objc_LocationWindow_getZoomFactor]
732 // Get current zoom factor
733 double currentZoom = [_locationWindow zoomFactor];
734 NSLog(@"Current zoom factor: %.1f", currentZoom);
735 // [objc_LocationWindow_getZoomFactor]
736
737 // [objc_LocationWindow_setZoomFactor]
738 // Set zoom factor
739 [_locationWindow setZoomFactor:150.0];
740 NSLog(@"Set zoom factor to 150.0");
741 // [objc_LocationWindow_setZoomFactor]
742
743 // [objc_LocationWindow_getMinZoomFactor]
744 // Get minimum zoom factor
745 double minZoomFactor = [_locationWindow minZoomFactor];
746 NSLog(@"Minimum zoom factor: %.1f", minZoomFactor);
747 // [objc_LocationWindow_getMinZoomFactor]
748
749 // [objc_LocationWindow_setMinZoomFactor]
750 // Set minimum zoom factor
751 [_locationWindow setMinZoomFactor:50.0];
752 NSLog(@"Set minimum zoom factor to 50.0");
753 // [objc_LocationWindow_setMinZoomFactor]
754
755 // [objc_LocationWindow_getMaxZoomFactor]
756 // Get maximum zoom factor
757 double maxZoomFactor = [_locationWindow maxZoomFactor];
758 NSLog(@"Maximum zoom factor: %.1f", maxZoomFactor);
759 // [objc_LocationWindow_getMaxZoomFactor]
760
761 // [objc_LocationWindow_setMaxZoomFactor]
762 // Set maximum zoom factor
763 [_locationWindow setMaxZoomFactor:300.0];
764 NSLog(@"Set maximum zoom factor to 300.0");
765 // [objc_LocationWindow_setMaxZoomFactor]
766
767 // Test zoom factor changes
768 NSArray<NSNumber *> *testZoomFactors = @[@100.0, @125.0, @150.0, @200.0, @250.0];
769 for (NSNumber *zoom in testZoomFactors) {
770 [_locationWindow setZoomFactor:zoom.doubleValue];
771 NSLog(@"Changed zoom factor to: %.1f", [_locationWindow zoomFactor]);
772 }
773
774 // Test zoom limits
775 NSLog(@"Testing zoom limits...");
776 [_locationWindow setZoomFactor:[_locationWindow minZoomFactor]];
777 NSLog(@"Set to minimum zoom: %.1f", [_locationWindow zoomFactor]);
778
779 [_locationWindow setZoomFactor:[_locationWindow maxZoomFactor]];
780 NSLog(@"Set to maximum zoom: %.1f", [_locationWindow zoomFactor]);
781
782 // Reset to default
783 [_locationWindow setZoomFactor:100.0];
784 NSLog(@"Reset zoom factor to default: %.1f", [_locationWindow zoomFactor]);
785}
786
790- (void)runExample {
791 NSLog(@"=== LocationWindowCommon Example ===");
792
793 // Simulate LocationWindow initialization
794 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
795 // TODO: User will implement LocationWindow initialization here
796 // self->_locationWindow = [self getLocationWindow];
797
798 // Run demonstrations
799 [self demonstrateLocationWindowCommonMethods];
800
801 NSLog(@"=== Example completed ===");
802 });
803}
804
805@end
806
810int main(int argc, const char * argv[]) {
811 @autoreleasepool {
813 [example runExample];
814
815 // Keep the program running for a bit to see the output
816 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
817 }
818 return 0;
819}