1#import <Foundation/Foundation.h>
2#import <NavigineSDK/NavigineSDK.h>
20@implementation LocationWindowCameraExample
31 NSLog(
@"=== LocationWindowCamera Example ===");
34 [
self getCurrentCamera];
35 [
self setCameraPosition];
36 [
self addCameraListener];
38 [
self moveToWithAnimation];
39 [
self removeCameraListener];
46 NSLog(
@"Set zoom factor to 100.0 pixels per meter");
52 NSLog(
@"Set minimum zoom factor to 10.0 pixels per meter");
58 NSLog(
@"Set maximum zoom factor to 1000.0 pixels per meter");
62- (void)getCurrentCamera {
66 NSLog(
@"Current camera position:");
67 NSLog(
@" Point: (%.2f, %.2f)", currentCamera.
point.
x, currentCamera.
point.
y);
68 NSLog(
@" Zoom: %.2f", currentCamera.
zoom);
69 NSLog(
@" Rotation: %.2f°", currentCamera.
rotation);
70 NSLog(
@" Tilt: %.2f° (0° = straight downward / map from above)", currentCamera.
tilt);
74- (void)setCameraPosition {
77 NCPoint *newPoint = [[
NCPoint alloc] initWithX:100.0 y:200.0];
78 NCCamera *newCamera = [[
NCCamera alloc] initWithPoint:newPoint zoom:50.0 rotation:0.0 tilt:0.0];
79 NSLog(
@"Created camera with point (%.2f, %.2f), zoom 50.0, rotation 0°, tilt 0°", newPoint.
x, newPoint.
y);
84 NSLog(
@"Camera properties:");
85 NSLog(
@" Point: (%.2f, %.2f)", newCamera.
point.
x, newCamera.
point.
y);
86 NSLog(
@" Zoom: %.2f", newCamera.
zoom);
87 NSLog(
@" Rotation: %.2f°", newCamera.
rotation);
88 NSLog(
@" Tilt: %.2f°", newCamera.
tilt);
94 NSLog(
@"Set camera position to (%.2f, %.2f) with zoom 50.0, rotation 0°, tilt 0°", newPoint.
x, newPoint.
y);
99 NCPoint *rotatedPoint = [[
NCPoint alloc] initWithX:150.0 y:250.0];
100 NCCamera *rotatedCamera = [[
NCCamera alloc] initWithPoint:rotatedPoint zoom:75.0 rotation:45.0 tilt:0.0];
102 NSLog(
@"Set camera position to (%.2f, %.2f) with zoom 75.0 and rotation 45°", rotatedPoint.
x, rotatedPoint.
y);
105 NCCamera *tiltedCamera = [[
NCCamera alloc] initWithPoint:rotatedPoint zoom:75.0 rotation:45.0 tilt:40.0];
107 NSLog(
@"Set camera with tilt %.2f° for a perspective view", tiltedCamera.
tilt);
110 NSArray *testCameras = @[
111 [[
NCCamera alloc] initWithPoint:[[
NCPoint alloc] initWithX:0.0 y:0.0] zoom:10.0 rotation:0.0 tilt:0.0],
112 [[
NCCamera alloc] initWithPoint:[[
NCPoint alloc] initWithX:50.0 y:75.0] zoom:500.0 rotation:0.0 tilt:0.0],
113 [[
NCCamera alloc] initWithPoint:[[
NCPoint alloc] initWithX:100.0 y:150.0] zoom:100.0 rotation:30.0 tilt:0.0],
116 for (
int i = 0; i < testCameras.count; i++) {
117 NCCamera *camera = testCameras[i];
119 NSLog(
@"Test camera %d: Point (%.2f, %.2f), Zoom %.2f, Rotation %.2f°, Tilt %.2f°", i, camera.
point.
x, camera.
point.
y, camera.
zoom, camera.
rotation, camera.
tilt);
123- (void)addCameraListener {
127 [_locationWindow addCameraListener:_cameraListener];
128 NSLog(
@"Added camera listener");
132 NSArray *listeners = @[
138 for (
int i = 0; i < listeners.count; i++) {
139 [_locationWindow addCameraListener:listeners[i]];
140 NSLog(
@"Added camera listener %d", i);
143 for (
int i = 0; i < listeners.count; i++) {
144 [_locationWindow removeCameraListener:listeners[i]];
145 NSLog(
@"Removed camera listener %d", i);
149- (void)flyToPosition {
152 NCPoint *targetPoint = [[
NCPoint alloc] initWithX:150.0 y:250.0];
153 NCCamera *targetCamera = [[
NCCamera alloc] initWithPoint:targetPoint zoom:75.0 rotation:45.0 tilt:30.0];
156 [_locationWindow flyToWithCamera:targetCamera duration:2000 callback:callback];
157 NSLog(
@"Started fly to animation to point (%.2f, %.2f)", targetPoint.
x, targetPoint.
y);
162 NCPoint *targetPoint2 = [[
NCPoint alloc] initWithX:300.0 y:400.0];
163 NCCamera *targetCamera2 = [[
NCCamera alloc] initWithPoint:targetPoint2 zoom:25.0 rotation:180.0 tilt:0.0];
166 [_locationWindow flyToWithCamera:targetCamera2 duration:3000 callback:callback2];
167 NSLog(
@"Started fly to animation to point (%.2f, %.2f) with 3 second duration", targetPoint2.
x, targetPoint2.
y);
171 NSArray *flyToTests = @[
172 @{@"point": [[
NCPoint alloc] initWithX:50.0 y:50.0], @"zoom": @100.0, @"rotation": @0.0, @"duration": @1000},
173 @{@"point": [[
NCPoint alloc] initWithX:200.0 y:300.0], @"zoom": @200.0, @"rotation": @90.0, @"duration": @1500},
174 @{@"point": [[
NCPoint alloc] initWithX:400.0 y:100.0], @"zoom": @50.0, @"rotation": @270.0, @"duration": @2500},
177 for (
int i = 0; i < flyToTests.count; i++) {
178 NSDictionary *test = flyToTests[i];
179 NCPoint *point = test[@"point"];
180 double zoom = [test[@"zoom"] doubleValue];
181 double rotation = [test[@"rotation"] doubleValue];
182 int duration = [test[@"duration"] intValue];
184 NCCamera *camera = [[
NCCamera alloc] initWithPoint:point zoom:zoom rotation:rotation tilt:0.0];
186 [_locationWindow flyToWithCamera:camera duration:duration callback:testCallback];
187 NSLog(
@"Fly to test %d: Point (%.2f, %.2f), Zoom %.2f, Rotation %.2f°, Duration %dms", i, point.
x, point.
y, zoom, rotation, duration);
191- (void)moveToWithAnimation {
194 NCPoint *targetPoint = [[
NCPoint alloc] initWithX:200.0 y:300.0];
195 NCCamera *targetCamera = [[
NCCamera alloc] initWithPoint:targetPoint zoom:100.0 rotation:90.0 tilt:0.0];
198 [_locationWindow moveToWithCamera:targetCamera duration:1500 animationType:NCAnimationTypeLinear callback:callback];
199 NSLog(
@"Started move to with linear animation");
205 [_locationWindow moveToWithCamera:targetCamera duration:1500 animationType:NCAnimationTypeCubic callback:callback2];
206 NSLog(
@"Started move to with cubic animation");
212 [_locationWindow moveToWithCamera:targetCamera duration:1500 animationType:NCAnimationTypeSine callback:callback3];
213 NSLog(
@"Started move to with sine animation");
218 NCPoint *instantPoint = [[
NCPoint alloc] initWithX:300.0 y:400.0];
219 NCCamera *instantCamera = [[
NCCamera alloc] initWithPoint:instantPoint zoom:25.0 rotation:180.0 tilt:0.0];
222 [_locationWindow moveToWithCamera:instantCamera duration:0 animationType:NCAnimationTypeNone callback:instantCallback];
223 NSLog(
@"Executed instant move to position (%.2f, %.2f)", instantPoint.
x, instantPoint.
y);
228 NSArray *animationTypes = @[
229 @(NCAnimationTypeLinear),
230 @(NCAnimationTypeCubic),
231 @(NCAnimationTypeQuint),
232 @(NCAnimationTypeSine),
233 @(NCAnimationTypeNone),
237 for (
int i = 0; i < animationTypes.count; i++) {
240 [_locationWindow moveToWithCamera:targetCamera duration:1000 animationType:animationType callback:testCallback];
241 NSLog(
@"Move to test with animation type %d", (
int)animationType);
245- (void)removeCameraListener {
248 [_locationWindow removeCameraListener:_cameraListener];
250 NSLog(
@"Removed camera listener");
259 NSLog(
@"LocationWindowCamera example cleanup completed");
268@implementation CameraListenerImpl
272 NSString *reasonString =
@"";
274 case NCCameraUpdateReasonUser:
275 reasonString =
@"User";
277 case NCCameraUpdateReasonAnimation:
278 reasonString =
@"Animation";
280 case NCCameraUpdateReasonProgrammatic:
281 reasonString =
@"Programmatic";
284 NSLog(
@"Camera position changed - Reason: %@, Finished: %@", reasonString, finished ?
@"Yes" :
@"No");
294@implementation CameraCallbackImpl
297- (void)onMoveFinishedWithCompleted:(BOOL)completed {
298 NSLog(
@"Camera move animation %@", completed ?
@"completed" :
@"cancelled");
305int main(
int argc,
const char * argv[]) {