19@implementation DemoSublocationChangeListener
21- (void)onActiveSublocationChanged:(int32_t)sublocationId {
22 NSLog(
@"Active sublocation changed to: %d", sublocationId);
27@implementation LocationWindowCommonExample {
28 NCLocationWindow *_locationWindow;
45 NSLog(
@"=== LocationWindowCommon Methods ===");
47 [
self demonstrateSetSublocationId];
48 [
self demonstrateSublocationQueries];
49 [
self demonstrateSublocationChangeListener];
50 [
self demonstrateUserLocationView];
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");
92- (void)demonstrateSetSublocationId {
93 NSLog(
@"--- setSublocationId Method ---");
95 if (_locationWindow == nil) {
96 NSLog(
@"LocationWindow not available yet");
102 [_locationWindow setSublocationId:1];
103 NSLog(
@"Set sublocation ID to 1 (first floor)");
108 [_locationWindow setSublocationId:2];
109 NSLog(
@"Set sublocation ID to 2 (second floor)");
114 [_locationWindow setSublocationId:0];
115 NSLog(
@"Set sublocation ID to 0 (ground floor)");
119 NSArray<NSNumber *> *sublocationIds = @[@1, @2, @3, @0, @5];
120 for (NSNumber *idNumber in sublocationIds) {
121 [_locationWindow setSublocationId:idNumber.intValue];
122 NSLog(
@"Switched to sublocation ID: %d", idNumber.intValue);
129- (void)demonstrateSublocationQueries {
130 NSLog(
@"--- getSublocationId & getEnclosingCamera ---");
132 if (_locationWindow == nil) {
133 NSLog(
@"LocationWindow not available yet");
138 NSNumber *currentId = [_locationWindow getSublocationId];
139 if (currentId != nil) {
140 NSLog(
@"Current sublocation id: %@", currentId);
142 NSLog(
@"Current sublocation id is not set");
148 topRight:[[
NCPoint alloc] initWithX:20.0 y:30.0]];
149 NCCamera *camera = [_locationWindow getEnclosingCamera:boundingBox];
150 NSLog(
@"Camera that fits bounding box: %@", camera);
157- (void)demonstrateSublocationChangeListener {
158 NSLog(
@"--- Sublocation Change Listener ---");
160 if (_locationWindow == nil) {
161 NSLog(
@"LocationWindow not available yet");
168 [_locationWindow addSublocationChangeListener:listener];
169 NSLog(
@"Added sublocation change listener");
172 [_locationWindow setSublocationId:1];
173 [_locationWindow setSublocationId:2];
176 [_locationWindow removeSublocationChangeListener:listener];
177 NSLog(
@"Removed sublocation change listener");
184- (void)demonstrateUserLocationView {
185 NSLog(
@"--- UserLocationView ---");
188 NSLog(
@"UserLocationView not available yet");
194 NSLog(
@"Arrow icon object: %@", arrow);
199 NSLog(
@"Accuracy circle object: %@", accuracyCircle);
206- (void)demonstrateUserLocationLayer {
207 NSLog(
@"--- UserLocationLayer ---");
210 NSLog(
@"UserLocationLayer not available yet");
216 NSLog(
@"User location layer set visible");
221 NSLog(
@"User location layer is visible: %@", visible ?
@"YES" :
@"NO");
225 NCScreenPoint *anchor = [[NCScreenPoint alloc] initWithX:100.0f y:200.0f];
227 NSLog(
@"Set user location anchor to: (%.1f, %.1f)", anchor.x, anchor.y);
232 NSLog(
@"Anchor enabled: %@", anchorEnabled ?
@"YES" :
@"NO");
237 NSLog(
@"Anchor reset to default");
244- (void)demonstrateCoordinateConversion {
245 NSLog(
@"--- Coordinate Conversion Methods ---");
247 if (_locationWindow == nil) {
248 NSLog(
@"LocationWindow not available yet");
255 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
256 NSLog(
@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
257 screenPoint.
x, screenPoint.
y, metersPoint.
x, metersPoint.
y);
262 NCPoint *screenPoint2 = [[
NCPoint alloc] initWithX:500.0 y:300.0];
263 NCPoint *metersPoint2 = [_locationWindow screenPositionToMeters:screenPoint2];
264 NSLog(
@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
265 screenPoint2.
x, screenPoint2.
y, metersPoint2.
x, metersPoint2.
y);
271 NCPoint *screenPoint3 = [_locationWindow metersToScreenPosition:metersPoint3 clipToViewport:YES];
272 NSLog(
@"Meters position (%.1f, %.1f) converted to screen with clipping: (%.1f, %.1f)",
273 metersPoint3.
x, metersPoint3.
y, screenPoint3.
x, screenPoint3.
y);
278 NCPoint *metersPoint4 = [[
NCPoint alloc] initWithX:150.0 y:200.0];
279 NCPoint *screenPoint4 = [_locationWindow metersToScreenPosition:metersPoint4 clipToViewport:NO];
280 NSLog(
@"Meters position (%.1f, %.1f) converted to screen without clipping: (%.1f, %.1f)",
281 metersPoint4.
x, metersPoint4.
y, screenPoint4.
x, screenPoint4.
y);
285 NSArray<NCPoint *> *testScreenPoints = @[
286 [[
NCPoint alloc] initWithX:0.0 y:0.0],
287 [[
NCPoint alloc] initWithX:250.0 y:250.0],
288 [[
NCPoint alloc] initWithX:1000.0 y:600.0]
291 for (
int i = 0; i < testScreenPoints.count; i++) {
292 NCPoint *screenPoint = testScreenPoints[i];
293 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
294 NCPoint *backToScreen = [_locationWindow metersToScreenPosition:metersPoint clipToViewport:NO];
295 NSLog(
@"Test %d: Screen (%.1f, %.1f) -> Meters (%.1f, %.1f) -> Screen (%.1f, %.1f)",
296 i, screenPoint.
x, screenPoint.
y,
297 metersPoint.
x, metersPoint.
y,
298 backToScreen.
x, backToScreen.
y);
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]];