18@implementation DemoSublocationChangeListener
20- (void)onActiveSublocationChanged:(int32_t)sublocationId {
21 NSLog(
@"Active sublocation changed to: %d", sublocationId);
26@implementation LocationWindowCommonExample {
27 NCLocationWindow *_locationWindow;
44 NSLog(
@"=== LocationWindowCommon Methods ===");
46 [
self demonstrateSetSublocationId];
47 [
self demonstrateSublocationQueries];
48 [
self demonstrateSublocationChangeListener];
49 [
self demonstrateUserLocationView];
50 [
self demonstrateUserLocationLayer];
51 [
self demonstrateCoordinateConversion];
52 [
self demonstrateMapFeatureSelection];
53 [
self demonstrateZoomProperties];
59- (void)demonstrateSetSublocationId {
60 NSLog(
@"--- setSublocationId Method ---");
62 if (_locationWindow == nil) {
63 NSLog(
@"LocationWindow not available yet");
69 [_locationWindow setSublocationId:1];
70 NSLog(
@"Set sublocation ID to 1 (first floor)");
75 [_locationWindow setSublocationId:2];
76 NSLog(
@"Set sublocation ID to 2 (second floor)");
81 [_locationWindow setSublocationId:0];
82 NSLog(
@"Set sublocation ID to 0 (ground floor)");
86 NSArray<NSNumber *> *sublocationIds = @[@1, @2, @3, @0, @5];
87 for (NSNumber *idNumber in sublocationIds) {
88 [_locationWindow setSublocationId:idNumber.intValue];
89 NSLog(
@"Switched to sublocation ID: %d", idNumber.intValue);
96- (void)demonstrateSublocationQueries {
97 NSLog(
@"--- getSublocationId & getEnclosingCamera ---");
99 if (_locationWindow == nil) {
100 NSLog(
@"LocationWindow not available yet");
105 NSNumber *currentId = [_locationWindow getSublocationId];
106 if (currentId != nil) {
107 NSLog(
@"Current sublocation id: %@", currentId);
109 NSLog(
@"Current sublocation id is not set");
115 topRight:[[
NCPoint alloc] initWithX:20.0 y:30.0]];
116 NCCamera *camera = [_locationWindow getEnclosingCamera:boundingBox];
117 NSLog(
@"Camera that fits bounding box: %@", camera);
124- (void)demonstrateSublocationChangeListener {
125 NSLog(
@"--- Sublocation Change Listener ---");
127 if (_locationWindow == nil) {
128 NSLog(
@"LocationWindow not available yet");
135 [_locationWindow addSublocationChangeListener:listener];
136 NSLog(
@"Added sublocation change listener");
139 [_locationWindow setSublocationId:1];
140 [_locationWindow setSublocationId:2];
143 [_locationWindow removeSublocationChangeListener:listener];
144 NSLog(
@"Removed sublocation change listener");
151- (void)demonstrateUserLocationView {
152 NSLog(
@"--- UserLocationView ---");
155 NSLog(
@"UserLocationView not available yet");
161 NSLog(
@"Arrow icon object: %@", arrow);
166 NSLog(
@"Accuracy circle object: %@", accuracyCircle);
173- (void)demonstrateUserLocationLayer {
174 NSLog(
@"--- UserLocationLayer ---");
177 NSLog(
@"UserLocationLayer not available yet");
183 NSLog(
@"User location layer set visible");
188 NSLog(
@"User location layer is visible: %@", visible ?
@"YES" :
@"NO");
192 NCScreenPoint *anchor = [[NCScreenPoint alloc] initWithX:100.0f y:200.0f];
194 NSLog(
@"Set user location anchor to: (%.1f, %.1f)", anchor.x, anchor.y);
199 NSLog(
@"Anchor enabled: %@", anchorEnabled ?
@"YES" :
@"NO");
204 NSLog(
@"Anchor reset to default");
211- (void)demonstrateCoordinateConversion {
212 NSLog(
@"--- Coordinate Conversion Methods ---");
214 if (_locationWindow == nil) {
215 NSLog(
@"LocationWindow not available yet");
222 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
223 NSLog(
@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
224 screenPoint.
x, screenPoint.
y, metersPoint.
x, metersPoint.
y);
229 NCPoint *screenPoint2 = [[
NCPoint alloc] initWithX:500.0 y:300.0];
230 NCPoint *metersPoint2 = [_locationWindow screenPositionToMeters:screenPoint2];
231 NSLog(
@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
232 screenPoint2.
x, screenPoint2.
y, metersPoint2.
x, metersPoint2.
y);
238 NCPoint *screenPoint3 = [_locationWindow metersToScreenPosition:metersPoint3 clipToViewport:YES];
239 NSLog(
@"Meters position (%.1f, %.1f) converted to screen with clipping: (%.1f, %.1f)",
240 metersPoint3.
x, metersPoint3.
y, screenPoint3.
x, screenPoint3.
y);
245 NCPoint *metersPoint4 = [[
NCPoint alloc] initWithX:150.0 y:200.0];
246 NCPoint *screenPoint4 = [_locationWindow metersToScreenPosition:metersPoint4 clipToViewport:NO];
247 NSLog(
@"Meters position (%.1f, %.1f) converted to screen without clipping: (%.1f, %.1f)",
248 metersPoint4.
x, metersPoint4.
y, screenPoint4.
x, screenPoint4.
y);
252 NSArray<NCPoint *> *testScreenPoints = @[
253 [[
NCPoint alloc] initWithX:0.0 y:0.0],
254 [[
NCPoint alloc] initWithX:250.0 y:250.0],
255 [[
NCPoint alloc] initWithX:1000.0 y:600.0]
258 for (
int i = 0; i < testScreenPoints.count; i++) {
259 NCPoint *screenPoint = testScreenPoints[i];
260 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
261 NCPoint *backToScreen = [_locationWindow metersToScreenPosition:metersPoint clipToViewport:NO];
262 NSLog(
@"Test %d: Screen (%.1f, %.1f) -> Meters (%.1f, %.1f) -> Screen (%.1f, %.1f)",
263 i, screenPoint.
x, screenPoint.
y,
264 metersPoint.
x, metersPoint.
y,
265 backToScreen.
x, backToScreen.
y);
272- (void)demonstrateMapFeatureSelection {
273 NSLog(
@"--- Map Feature Selection Methods ---");
275 if (_locationWindow == nil) {
276 NSLog(
@"LocationWindow not available yet");
282 NSString *featureId =
"room_101";
283 BOOL selected = [_locationWindow selectMapFeature:featureId];
284 NSLog(
@"Selected map feature %@: %@", featureId, selected ?
@"YES" :
@"NO");
289 NSString *featureId2 =
"office_205";
290 BOOL selected2 = [_locationWindow selectMapFeature:featureId2];
291 NSLog(
@"Selected map feature %@: %@", featureId2, selected2 ?
@"YES" :
@"NO");
296 NSArray<NSString *> *selectedFeatures = [_locationWindow selectedMapFeatures];
297 NSLog(
@"Currently selected map features: %lu features", (
unsigned long)selectedFeatures.count);
298 for (NSString *feature in selectedFeatures) {
299 NSLog(
@" - %@", feature);
305 BOOL deselected = [_locationWindow deselectMapFeature:featureId];
306 NSLog(
@"Deselected map feature %@: %@", featureId, deselected ?
@"YES" :
@"NO");
311 BOOL deselected2 = [_locationWindow deselectMapFeature:featureId2];
312 NSLog(
@"Deselected map feature %@: %@", featureId2, deselected2 ?
@"YES" :
@"NO");
317 [_locationWindow deselectAllMapFeatures];
318 NSLog(
@"Deselected all map features");
323 NSArray<NSString *> *remainingFeatures = [_locationWindow selectedMapFeatures];
324 NSLog(
@"Remaining selected features after deselect all: %lu features", (
unsigned long)remainingFeatures.count);
328 NSArray<NSString *> *testFeatureIds = @[@"room_101", @"office_205", @"meeting_room_301", @"cafe_401"];
331 for (NSString *featureId in testFeatureIds) {
332 BOOL success = [_locationWindow selectMapFeature:featureId];
333 NSLog(
@"Selected feature %@: %@", featureId, success ?
@"YES" :
@"NO");
337 NSArray<NSString *> *allSelected = [_locationWindow selectedMapFeatures];
338 NSLog(
@"All selected features: %lu features", (
unsigned long)allSelected.count);
341 [_locationWindow deselectAllMapFeatures];
342 NSLog(
@"Deselected all features at once");
348- (void)demonstrateZoomProperties {
349 NSLog(
@"--- Zoom Properties ---");
351 if (_locationWindow == nil) {
352 NSLog(
@"LocationWindow not available yet");
358 double currentZoom = [_locationWindow zoomFactor];
359 NSLog(
@"Current zoom factor: %.1f", currentZoom);
364 [_locationWindow setZoomFactor:150.0];
365 NSLog(
@"Set zoom factor to 150.0");
370 double minZoomFactor = [_locationWindow minZoomFactor];
371 NSLog(
@"Minimum zoom factor: %.1f", minZoomFactor);
376 [_locationWindow setMinZoomFactor:50.0];
377 NSLog(
@"Set minimum zoom factor to 50.0");
382 double maxZoomFactor = [_locationWindow maxZoomFactor];
383 NSLog(
@"Maximum zoom factor: %.1f", maxZoomFactor);
388 [_locationWindow setMaxZoomFactor:300.0];
389 NSLog(
@"Set maximum zoom factor to 300.0");
393 NSArray<NSNumber *> *testZoomFactors = @[@100.0, @125.0, @150.0, @200.0, @250.0];
394 for (NSNumber *zoom in testZoomFactors) {
395 [_locationWindow setZoomFactor:zoom.doubleValue];
396 NSLog(
@"Changed zoom factor to: %.1f", [_locationWindow zoomFactor]);
400 NSLog(
@"Testing zoom limits...");
401 [_locationWindow setZoomFactor:[_locationWindow minZoomFactor]];
402 NSLog(
@"Set to minimum zoom: %.1f", [_locationWindow zoomFactor]);
404 [_locationWindow setZoomFactor:[_locationWindow maxZoomFactor]];
405 NSLog(
@"Set to maximum zoom: %.1f", [_locationWindow zoomFactor]);
408 [_locationWindow setZoomFactor:100.0];
409 NSLog(
@"Reset zoom factor to default: %.1f", [_locationWindow zoomFactor]);
416 NSLog(
@"=== LocationWindowCommon Example ===");
419 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
424 [
self demonstrateLocationWindowCommonMethods];
426 NSLog(
@"=== Example completed ===");
435int main(
int argc,
const char * argv[]) {
438 [example runExample];
441 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];