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);
73- (void)setCameraPosition {
76 NCPoint *newPoint = [[
NCPoint alloc] initWithX:100.0 y:200.0];
77 NCCamera *newCamera = [[
NCCamera alloc] initWithPoint:newPoint zoom:50.0 rotation:0.0];
78 NSLog(
@"Created camera with point (%.2f, %.2f), zoom 50.0, rotation 0°", newPoint.
x, newPoint.
y);
83 NSLog(
@"Camera properties:");
84 NSLog(
@" Point: (%.2f, %.2f)", newCamera.
point.
x, newCamera.
point.
y);
85 NSLog(
@" Zoom: %.2f", newCamera.
zoom);
86 NSLog(
@" Rotation: %.2f°", newCamera.
rotation);
92 NSLog(
@"Set camera position to (%.2f, %.2f) with zoom 50.0 and rotation 0°", newPoint.
x, newPoint.
y);
97 NCPoint *rotatedPoint = [[
NCPoint alloc] initWithX:150.0 y:250.0];
98 NCCamera *rotatedCamera = [[
NCCamera alloc] initWithPoint:rotatedPoint zoom:75.0 rotation:45.0];
100 NSLog(
@"Set camera position to (%.2f, %.2f) with zoom 75.0 and rotation 45°", rotatedPoint.
x, rotatedPoint.
y);
104 NSArray *testCameras = @[
105 [[
NCCamera alloc] initWithPoint:[[
NCPoint alloc] initWithX:0.0 y:0.0] zoom:10.0 rotation:0.0],
106 [[
NCCamera alloc] initWithPoint:[[
NCPoint alloc] initWithX:50.0 y:75.0] zoom:500.0 rotation:0.0],
107 [[
NCCamera alloc] initWithPoint:[[
NCPoint alloc] initWithX:100.0 y:150.0] zoom:100.0 rotation:30.0],
110 for (
int i = 0; i < testCameras.count; i++) {
111 NCCamera *camera = testCameras[i];
113 NSLog(
@"Test camera %d: Point (%.2f, %.2f), Zoom %.2f, Rotation %.2f°", i, camera.
point.
x, camera.
point.
y, camera.
zoom, camera.
rotation);
117- (void)addCameraListener {
121 [_locationWindow addCameraListener:_cameraListener];
122 NSLog(
@"Added camera listener");
126 NSArray *listeners = @[
132 for (
int i = 0; i < listeners.count; i++) {
133 [_locationWindow addCameraListener:listeners[i]];
134 NSLog(
@"Added camera listener %d", i);
137 for (
int i = 0; i < listeners.count; i++) {
138 [_locationWindow removeCameraListener:listeners[i]];
139 NSLog(
@"Removed camera listener %d", i);
143- (void)flyToPosition {
146 NCPoint *targetPoint = [[
NCPoint alloc] initWithX:150.0 y:250.0];
147 NCCamera *targetCamera = [[
NCCamera alloc] initWithPoint:targetPoint zoom:75.0 rotation:45.0];
150 [_locationWindow flyToWithCamera:targetCamera duration:2000 callback:callback];
151 NSLog(
@"Started fly to animation to point (%.2f, %.2f)", targetPoint.
x, targetPoint.
y);
156 NCPoint *targetPoint2 = [[
NCPoint alloc] initWithX:300.0 y:400.0];
157 NCCamera *targetCamera2 = [[
NCCamera alloc] initWithPoint:targetPoint2 zoom:25.0 rotation:180.0];
160 [_locationWindow flyToWithCamera:targetCamera2 duration:3000 callback:callback2];
161 NSLog(
@"Started fly to animation to point (%.2f, %.2f) with 3 second duration", targetPoint2.
x, targetPoint2.
y);
165 NSArray *flyToTests = @[
166 @{@"point": [[
NCPoint alloc] initWithX:50.0 y:50.0], @"zoom": @100.0, @"rotation": @0.0, @"duration": @1000},
167 @{@"point": [[
NCPoint alloc] initWithX:200.0 y:300.0], @"zoom": @200.0, @"rotation": @90.0, @"duration": @1500},
168 @{@"point": [[
NCPoint alloc] initWithX:400.0 y:100.0], @"zoom": @50.0, @"rotation": @270.0, @"duration": @2500},
171 for (
int i = 0; i < flyToTests.count; i++) {
172 NSDictionary *test = flyToTests[i];
173 NCPoint *point = test[@"point"];
174 double zoom = [test[@"zoom"] doubleValue];
175 double rotation = [test[@"rotation"] doubleValue];
176 int duration = [test[@"duration"] intValue];
178 NCCamera *camera = [[
NCCamera alloc] initWithPoint:point zoom:zoom rotation:rotation];
180 [_locationWindow flyToWithCamera:camera duration:duration callback:testCallback];
181 NSLog(
@"Fly to test %d: Point (%.2f, %.2f), Zoom %.2f, Rotation %.2f°, Duration %dms", i, point.
x, point.
y, zoom, rotation, duration);
185- (void)moveToWithAnimation {
188 NCPoint *targetPoint = [[
NCPoint alloc] initWithX:200.0 y:300.0];
189 NCCamera *targetCamera = [[
NCCamera alloc] initWithPoint:targetPoint zoom:100.0 rotation:90.0];
192 [_locationWindow moveToWithCamera:targetCamera duration:1500 animationType:NCAnimationTypeLinear callback:callback];
193 NSLog(
@"Started move to with linear animation");
199 [_locationWindow moveToWithCamera:targetCamera duration:1500 animationType:NCAnimationTypeCubic callback:callback2];
200 NSLog(
@"Started move to with cubic animation");
206 [_locationWindow moveToWithCamera:targetCamera duration:1500 animationType:NCAnimationTypeSine callback:callback3];
207 NSLog(
@"Started move to with sine animation");
212 NCPoint *instantPoint = [[
NCPoint alloc] initWithX:300.0 y:400.0];
213 NCCamera *instantCamera = [[
NCCamera alloc] initWithPoint:instantPoint zoom:25.0 rotation:180.0];
216 [_locationWindow moveToWithCamera:instantCamera duration:0 animationType:NCAnimationTypeNone callback:instantCallback];
217 NSLog(
@"Executed instant move to position (%.2f, %.2f)", instantPoint.
x, instantPoint.
y);
222 NSArray *animationTypes = @[
223 @(NCAnimationTypeLinear),
224 @(NCAnimationTypeCubic),
225 @(NCAnimationTypeQuint),
226 @(NCAnimationTypeSine),
227 @(NCAnimationTypeNone),
231 for (
int i = 0; i < animationTypes.count; i++) {
234 [_locationWindow moveToWithCamera:targetCamera duration:1000 animationType:animationType callback:testCallback];
235 NSLog(
@"Move to test with animation type %d", (
int)animationType);
239- (void)removeCameraListener {
242 [_locationWindow removeCameraListener:_cameraListener];
244 NSLog(
@"Removed camera listener");
253 NSLog(
@"LocationWindowCamera example cleanup completed");
262@implementation CameraListenerImpl
266 NSString *reasonString =
@"";
268 case NCCameraUpdateReasonUser:
269 reasonString =
@"User";
271 case NCCameraUpdateReasonAnimation:
272 reasonString =
@"Animation";
274 case NCCameraUpdateReasonProgrammatic:
275 reasonString =
@"Programmatic";
278 NSLog(
@"Camera position changed - Reason: %@, Finished: %@", reasonString, finished ?
@"Yes" :
@"No");
288@implementation CameraCallbackImpl
291- (void)onMoveFinishedWithCompleted:(BOOL)completed {
292 NSLog(
@"Camera move animation %@", completed ?
@"completed" :
@"cancelled");
299int main(
int argc,
const char * argv[]) {