2#import <NCLocationWindow.h>
12 NCLocationWindow *_locationWindow;
27 NSLog(
@"=== LocationWindowCommon Methods ===");
29 [
self demonstrateSetSublocationId];
30 [
self demonstrateCoordinateConversion];
31 [
self demonstrateMapFeatureSelection];
32 [
self demonstrateZoomProperties];
38- (void)demonstrateSetSublocationId {
39 NSLog(
@"--- setSublocationId Method ---");
41 if (_locationWindow == nil) {
42 NSLog(
@"LocationWindow not available yet");
48 [_locationWindow setSublocationId:1];
49 NSLog(
@"Set sublocation ID to 1 (first floor)");
54 [_locationWindow setSublocationId:2];
55 NSLog(
@"Set sublocation ID to 2 (second floor)");
60 [_locationWindow setSublocationId:0];
61 NSLog(
@"Set sublocation ID to 0 (ground floor)");
65 NSArray<NSNumber *> *sublocationIds = @[@1, @2, @3, @0, @5];
66 for (NSNumber *idNumber in sublocationIds) {
67 [_locationWindow setSublocationId:idNumber.intValue];
68 NSLog(
@"Switched to sublocation ID: %d", idNumber.intValue);
75- (void)demonstrateCoordinateConversion {
76 NSLog(
@"--- Coordinate Conversion Methods ---");
78 if (_locationWindow == nil) {
79 NSLog(
@"LocationWindow not available yet");
85 NCPoint *screenPoint = [[NCPoint alloc] initWithX:100.0 y:200.0];
86 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
87 NSLog(
@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
88 screenPoint.x, screenPoint.y, metersPoint.x, metersPoint.y);
93 NCPoint *screenPoint2 = [[NCPoint alloc] initWithX:500.0 y:300.0];
94 NCPoint *metersPoint2 = [_locationWindow screenPositionToMeters:screenPoint2];
95 NSLog(
@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
96 screenPoint2.x, screenPoint2.y, metersPoint2.x, metersPoint2.y);
101 NCPoint *metersPoint3 = [[NCPoint alloc] initWithX:50.0 y:75.0];
102 NCPoint *screenPoint3 = [_locationWindow metersToScreenPosition:metersPoint3 clipToViewport:YES];
103 NSLog(
@"Meters position (%.1f, %.1f) converted to screen with clipping: (%.1f, %.1f)",
104 metersPoint3.x, metersPoint3.y, screenPoint3.x, screenPoint3.y);
109 NCPoint *metersPoint4 = [[NCPoint alloc] initWithX:150.0 y:200.0];
110 NCPoint *screenPoint4 = [_locationWindow metersToScreenPosition:metersPoint4 clipToViewport:NO];
111 NSLog(
@"Meters position (%.1f, %.1f) converted to screen without clipping: (%.1f, %.1f)",
112 metersPoint4.x, metersPoint4.y, screenPoint4.x, screenPoint4.y);
116 NSArray<NCPoint *> *testScreenPoints = @[
117 [[NCPoint alloc] initWithX:0.0 y:0.0],
118 [[NCPoint alloc] initWithX:250.0 y:250.0],
119 [[NCPoint alloc] initWithX:1000.0 y:600.0]
122 for (
int i = 0; i < testScreenPoints.count; i++) {
123 NCPoint *screenPoint = testScreenPoints[i];
124 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
125 NCPoint *backToScreen = [_locationWindow metersToScreenPosition:metersPoint clipToViewport:NO];
126 NSLog(
@"Test %d: Screen (%.1f, %.1f) -> Meters (%.1f, %.1f) -> Screen (%.1f, %.1f)",
127 i, screenPoint.x, screenPoint.y,
128 metersPoint.x, metersPoint.y,
129 backToScreen.x, backToScreen.y);
136- (void)demonstrateMapFeatureSelection {
137 NSLog(
@"--- Map Feature Selection Methods ---");
139 if (_locationWindow == nil) {
140 NSLog(
@"LocationWindow not available yet");
146 NSString *featureId =
"room_101";
147 BOOL selected = [_locationWindow selectMapFeature:featureId];
148 NSLog(
@"Selected map feature %@: %@", featureId, selected ?
@"YES" :
@"NO");
153 NSString *featureId2 =
"office_205";
154 BOOL selected2 = [_locationWindow selectMapFeature:featureId2];
155 NSLog(
@"Selected map feature %@: %@", featureId2, selected2 ?
@"YES" :
@"NO");
160 NSArray<NSString *> *selectedFeatures = [_locationWindow selectedMapFeatures];
161 NSLog(
@"Currently selected map features: %lu features", (
unsigned long)selectedFeatures.count);
162 for (NSString *feature in selectedFeatures) {
163 NSLog(
@" - %@", feature);
169 BOOL deselected = [_locationWindow deselectMapFeature:featureId];
170 NSLog(
@"Deselected map feature %@: %@", featureId, deselected ?
@"YES" :
@"NO");
175 BOOL deselected2 = [_locationWindow deselectMapFeature:featureId2];
176 NSLog(
@"Deselected map feature %@: %@", featureId2, deselected2 ?
@"YES" :
@"NO");
181 [_locationWindow deselectAllMapFeatures];
182 NSLog(
@"Deselected all map features");
187 NSArray<NSString *> *remainingFeatures = [_locationWindow selectedMapFeatures];
188 NSLog(
@"Remaining selected features after deselect all: %lu features", (
unsigned long)remainingFeatures.count);
192 NSArray<NSString *> *testFeatureIds = @[@"room_101", @"office_205", @"meeting_room_301", @"cafe_401"];
195 for (NSString *featureId in testFeatureIds) {
196 BOOL success = [_locationWindow selectMapFeature:featureId];
197 NSLog(
@"Selected feature %@: %@", featureId, success ?
@"YES" :
@"NO");
201 NSArray<NSString *> *allSelected = [_locationWindow selectedMapFeatures];
202 NSLog(
@"All selected features: %lu features", (
unsigned long)allSelected.count);
205 [_locationWindow deselectAllMapFeatures];
206 NSLog(
@"Deselected all features at once");
212- (void)demonstrateZoomProperties {
213 NSLog(
@"--- Zoom Properties ---");
215 if (_locationWindow == nil) {
216 NSLog(
@"LocationWindow not available yet");
222 double currentZoom = [_locationWindow zoomFactor];
223 NSLog(
@"Current zoom factor: %.1f", currentZoom);
228 [_locationWindow setZoomFactor:150.0];
229 NSLog(
@"Set zoom factor to 150.0");
234 double minZoomFactor = [_locationWindow minZoomFactor];
235 NSLog(
@"Minimum zoom factor: %.1f", minZoomFactor);
240 [_locationWindow setMinZoomFactor:50.0];
241 NSLog(
@"Set minimum zoom factor to 50.0");
246 double maxZoomFactor = [_locationWindow maxZoomFactor];
247 NSLog(
@"Maximum zoom factor: %.1f", maxZoomFactor);
252 [_locationWindow setMaxZoomFactor:300.0];
253 NSLog(
@"Set maximum zoom factor to 300.0");
257 NSArray<NSNumber *> *testZoomFactors = @[@100.0, @125.0, @150.0, @200.0, @250.0];
258 for (NSNumber *zoom in testZoomFactors) {
259 [_locationWindow setZoomFactor:zoom.doubleValue];
260 NSLog(
@"Changed zoom factor to: %.1f", [_locationWindow zoomFactor]);
264 NSLog(
@"Testing zoom limits...");
265 [_locationWindow setZoomFactor:[_locationWindow minZoomFactor]];
266 NSLog(
@"Set to minimum zoom: %.1f", [_locationWindow zoomFactor]);
268 [_locationWindow setZoomFactor:[_locationWindow maxZoomFactor]];
269 NSLog(
@"Set to maximum zoom: %.1f", [_locationWindow zoomFactor]);
272 [_locationWindow setZoomFactor:100.0];
273 NSLog(
@"Reset zoom factor to default: %.1f", [_locationWindow zoomFactor]);
280 NSLog(
@"=== LocationWindowCommon Example ===");
283 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
288 [
self demonstrateLocationWindowCommonMethods];
290 NSLog(
@"=== Example completed ===");
299int main(
int argc,
const char * argv[]) {
302 [example runExample];
305 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];