4#import <NCScreenPoint.h>
20@implementation DemoSublocationChangeListener
22- (void)onActiveSublocationChanged:(int32_t)sublocationId {
23 NSLog(
@"Active sublocation changed to: %d", sublocationId);
28@implementation LocationWindowCommonExample {
29 NCLocationWindow *_locationWindow;
45 NSLog(
@"=== LocationWindowCommon Methods ===");
47 [
self demonstrateSetSublocationId];
48 [
self demonstrateOperatingMode];
49 [
self demonstrateSublocationQueries];
50 [
self demonstrateSublocationChangeListener];
51 [
self demonstrateUserLocationLayer];
52 [
self demonstrateCoordinateConversion];
53 [
self demonstrateMapFeatureSelection];
54 [
self demonstrateApplyLayerFilter];
55 [
self demonstrateDebugFlags];
56 [
self demonstrateZoomProperties];
62- (void)demonstrateDebugFlags {
63 NSLog(
@"--- Debug flags ---");
66 NSArray<NSNumber *> *allFlags = @[
71 @(NCDebugFlagDrawAllLabels),
72 @(NCDebugFlagSelectionBuffer)
74 NSLog(
@"Debug flag enum values: %lu", (
unsigned long)allFlags.count);
80 NSLog(
@"Updated debug flags on LocationWindow");
85 NSLog(
@"Debug flag INFOS enabled: %@", infosOn ?
@"YES" :
@"NO");
93- (void)demonstrateOperatingMode {
94 NSLog(
@"--- Operating Mode ---");
96 if (_locationWindow == nil) {
97 NSLog(
@"LocationWindow not available yet");
102 NSArray<NSNumber *> *modes = @[@(NCOperatingModeIndoorOnly), @(NCOperatingModeOutdoor), @(NCOperatingModeOutdoorIndoor)];
103 NSLog(
@"Operating modes: %lu", (
unsigned long)modes.count);
107 [_locationWindow setOperatingMode:NCOperatingModeOutdoorIndoor];
108 NSLog(
@"Set operating mode to OUTDOOR_INDOOR");
113 NSLog(
@"Current operating mode: %ld", (
long)currentMode);
118 initWithHorizontalAlignment:NCAttributionHorizontalAlignmentRight
119 verticalAlignment:NCAttributionVerticalAlignmentBottom];
123 [_locationWindow setAttributionAlignment:alignment];
127 NSString *attribution = [_locationWindow getAttribution];
128 NSLog(
@"Attribution: %@", attribution);
135- (void)demonstrateSetSublocationId {
136 NSLog(
@"--- setSublocationId Method ---");
138 if (_locationWindow == nil) {
139 NSLog(
@"LocationWindow not available yet");
145 [_locationWindow setSublocationId:1];
146 NSLog(
@"Set sublocation ID to 1 (first floor)");
151 [_locationWindow setSublocationId:2];
152 NSLog(
@"Set sublocation ID to 2 (second floor)");
157 [_locationWindow setSublocationId:0];
158 NSLog(
@"Set sublocation ID to 0 (ground floor)");
162 NSArray<NSNumber *> *sublocationIds = @[@1, @2, @3, @0, @5];
163 for (NSNumber *idNumber in sublocationIds) {
164 [_locationWindow setSublocationId:idNumber.intValue];
165 NSLog(
@"Switched to sublocation ID: %d", idNumber.intValue);
172- (void)demonstrateSublocationQueries {
173 NSLog(
@"--- getSublocationId & getEnclosingCamera ---");
175 if (_locationWindow == nil) {
176 NSLog(
@"LocationWindow not available yet");
181 NSNumber *currentId = [_locationWindow getSublocationId];
182 if (currentId != nil) {
183 NSLog(
@"Current sublocation id: %@", currentId);
185 NSLog(
@"Current sublocation id is not set");
191 topRight:[[
NCGlobalPoint alloc] initWithLatitude:55.76 longitude:37.63]];
192 NCCamera *camera = [_locationWindow getEnclosingCamera:boundingBox];
193 NSLog(
@"Camera that fits bounding box: %@", camera);
200- (void)demonstrateSublocationChangeListener {
201 NSLog(
@"--- Sublocation Change Listener ---");
203 if (_locationWindow == nil) {
204 NSLog(
@"LocationWindow not available yet");
211 [_locationWindow addSublocationChangeListener:listener];
212 NSLog(
@"Added sublocation change listener");
215 [_locationWindow setSublocationId:1];
216 [_locationWindow setSublocationId:2];
219 [_locationWindow removeSublocationChangeListener:listener];
220 NSLog(
@"Removed sublocation change listener");
227- (void)demonstrateUserLocationLayer {
228 NSLog(
@"--- UserLocationLayer ---");
231 NSLog(
@"UserLocationLayer not available yet");
237 NSLog(
@"User location layer set visible");
242 NSLog(
@"User location layer is visible: %@", visible ?
@"YES" :
@"NO");
246 NCScreenPoint *anchor = [[NCScreenPoint alloc] initWithX:100.0f y:200.0f];
248 NSLog(
@"Set user location anchor to: (%.1f, %.1f)", anchor.x, anchor.y);
253 NSLog(
@"Anchor enabled: %@", anchorEnabled ?
@"YES" :
@"NO");
258 NSLog(
@"Anchor reset to default");
265- (void)demonstrateCoordinateConversion {
266 NSLog(
@"--- Coordinate Conversion Methods ---");
268 if (_locationWindow == nil) {
269 NSLog(
@"LocationWindow not available yet");
274 NCScreenPoint *screenPoint = [[NCScreenPoint alloc] initWithX:100.0 y:200.0];
275 NCGlobalPoint *globalPoint = [_locationWindow screenPositionToGlobal:screenPoint];
276 NSLog(
@"Screen position (%.1f, %.1f) converted to WGS84: (%.6f, %.6f)",
282 NCScreenPoint *screenPoint2 = [_locationWindow globalToScreenPosition:globalPoint2 clipToViewport:YES];
283 NSLog(
@"WGS84 (%.6f, %.6f) converted to screen with clipping: (%.1f, %.1f)",
287 NSArray<NCScreenPoint *> *testScreenPoints = @[
288 [[NCScreenPoint alloc] initWithX:0.0 y:0.0],
289 [[NCScreenPoint alloc] initWithX:250.0 y:250.0],
290 [[NCScreenPoint alloc] initWithX:1000.0 y:600.0]
293 for (
int i = 0; i < testScreenPoints.count; i++) {
294 NCScreenPoint *sp = testScreenPoints[i];
295 NCGlobalPoint *gp = [_locationWindow screenPositionToGlobal:sp];
296 NCScreenPoint *backToScreen = [_locationWindow globalToScreenPosition:gp clipToViewport:NO];
297 NSLog(
@"Test %d: Screen (%.1f, %.1f) -> WGS84 (%.6f, %.6f) -> Screen (%.1f, %.1f)",
305- (void)demonstrateMapFeatureSelection {
306 NSLog(
@"--- Map Feature Selection Methods ---");
308 if (_locationWindow == nil) {
309 NSLog(
@"LocationWindow not available yet");
315 NSString *featureId =
"room_101";
316 BOOL selected = [_locationWindow selectMapFeature:featureId];
317 NSLog(
@"Selected map feature %@: %@", featureId, selected ?
@"YES" :
@"NO");
322 NSString *featureId2 =
"office_205";
323 BOOL selected2 = [_locationWindow selectMapFeature:featureId2];
324 NSLog(
@"Selected map feature %@: %@", featureId2, selected2 ?
@"YES" :
@"NO");
329 NSArray<NSString *> *selectedFeatures = [_locationWindow selectedMapFeatures];
330 NSLog(
@"Currently selected map features: %lu features", (
unsigned long)selectedFeatures.count);
331 for (NSString *feature in selectedFeatures) {
332 NSLog(
@" - %@", feature);
338 BOOL deselected = [_locationWindow deselectMapFeature:featureId];
339 NSLog(
@"Deselected map feature %@: %@", featureId, deselected ?
@"YES" :
@"NO");
344 BOOL deselected2 = [_locationWindow deselectMapFeature:featureId2];
345 NSLog(
@"Deselected map feature %@: %@", featureId2, deselected2 ?
@"YES" :
@"NO");
350 [_locationWindow deselectAllMapFeatures];
351 NSLog(
@"Deselected all map features");
356 NSArray<NSString *> *remainingFeatures = [_locationWindow selectedMapFeatures];
357 NSLog(
@"Remaining selected features after deselect all: %lu features", (
unsigned long)remainingFeatures.count);
361 NSArray<NSString *> *testFeatureIds = @[@"room_101", @"office_205", @"meeting_room_301", @"cafe_401"];
364 for (NSString *featureId in testFeatureIds) {
365 BOOL success = [_locationWindow selectMapFeature:featureId];
366 NSLog(
@"Selected feature %@: %@", featureId, success ?
@"YES" :
@"NO");
370 NSArray<NSString *> *allSelected = [_locationWindow selectedMapFeatures];
371 NSLog(
@"All selected features: %lu features", (
unsigned long)allSelected.count);
374 [_locationWindow deselectAllMapFeatures];
375 NSLog(
@"Deselected all features at once");
381- (void)demonstrateApplyLayerFilter {
382 NSLog(
@"--- applyLayerFilter Method ---");
384 if (_locationWindow == nil) {
385 NSLog(
@"LocationWindow not available yet");
396 NSArray<NCMapFilterCondition *> *conditions = @[[[
NCMapFilterCondition alloc] initWithProperty:@"category" values:@[@"Toilet", @"Cafe"]]];
397 [_locationWindow applyLayerFilterWithLayer:@"venues" conditions:conditions];
398 NSLog(
@"Applied layer filter: show venues with category Toilet or Cafe");
402 [_locationWindow applyLayerFilterWithLayer:@"venues" conditions:@[]];
403 NSLog(
@"Reset layer filter: show all venues");
409- (void)demonstrateZoomProperties {
410 NSLog(
@"--- Zoom Properties ---");
412 if (_locationWindow == nil) {
413 NSLog(
@"LocationWindow not available yet");
419 double currentZoom = [_locationWindow zoomFactor];
420 NSLog(
@"Current zoom factor: %.1f", currentZoom);
425 [_locationWindow setZoomFactor:150.0];
426 NSLog(
@"Set zoom factor to 150.0");
431 double minZoomFactor = [_locationWindow minZoomFactor];
432 NSLog(
@"Minimum zoom factor: %.1f", minZoomFactor);
437 [_locationWindow setMinZoomFactor:50.0];
438 NSLog(
@"Set minimum zoom factor to 50.0");
443 double maxZoomFactor = [_locationWindow maxZoomFactor];
444 NSLog(
@"Maximum zoom factor: %.1f", maxZoomFactor);
449 [_locationWindow setMaxZoomFactor:300.0];
450 NSLog(
@"Set maximum zoom factor to 300.0");
454 NSArray<NSNumber *> *testZoomFactors = @[@100.0, @125.0, @150.0, @200.0, @250.0];
455 for (NSNumber *zoom in testZoomFactors) {
456 [_locationWindow setZoomFactor:zoom.doubleValue];
457 NSLog(
@"Changed zoom factor to: %.1f", [_locationWindow zoomFactor]);
461 NSLog(
@"Testing zoom limits...");
462 [_locationWindow setZoomFactor:[_locationWindow minZoomFactor]];
463 NSLog(
@"Set to minimum zoom: %.1f", [_locationWindow zoomFactor]);
465 [_locationWindow setZoomFactor:[_locationWindow maxZoomFactor]];
466 NSLog(
@"Set to maximum zoom: %.1f", [_locationWindow zoomFactor]);
469 [_locationWindow setZoomFactor:100.0];
470 NSLog(
@"Reset zoom factor to default: %.1f", [_locationWindow zoomFactor]);
477 NSLog(
@"=== LocationWindowCommon Example ===");
480 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
485 [
self demonstrateLocationWindowCommonMethods];
487 NSLog(
@"=== Example completed ===");
496int main(
int argc,
const char * argv[]) {
499 [example runExample];
502 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];