Skip to content

Commit

Permalink
Feat: adding viewAngle and rotation. #216
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-angermann committed Feb 7, 2024
1 parent 7226455 commit f327c87
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions projects/services-map-state/src/lib/map-state.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('MapStateService', () => {
const stateTime = new Date().toISOString(); // this is passed on new MapState()
const state = new MapState(4, { lat: 48, lon: 11 });
state.time = stateTime;
state.rotation = 20;


service.setMapState(state);
Expand All @@ -34,6 +35,8 @@ describe('MapStateService', () => {
expect(sta.center.lon).toEqual(11);
expect(sta.zoom).toEqual(4);
expect(sta.time).toEqual(stateTime);
expect(sta.rotation).toEqual(20);
expect(sta.viewAngle).toEqual(0);
});
}));

Expand Down
6 changes: 3 additions & 3 deletions projects/services-map-state/src/lib/map-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export class MapStateService {
}
this.lastAction.next('setState');
if (state instanceof MapState) {
const newState = new MapState(state.zoom, state.center, state.options, state.extent, state.time);
const newState = new MapState(state.zoom, state.center, state.options, state.extent, state.time, state.viewAngle, state.rotation);
this.mapState.next(newState);
} else {
const stateOptions: IMapStateOptions = { ...{ notifier: 'user' }, ...state.options };
const newState = new MapState(state.zoom, state.center, stateOptions, state.extent, state.time);
const newState = new MapState(state.zoom, state.center, stateOptions, state.extent, state.time, state.viewAngle, state.rotation);
this.mapState.next(newState);
}
}
Expand All @@ -44,7 +44,7 @@ export class MapStateService {
this.lastAction.next('setExtent');
const state = this.getMapState().getValue();
state.options.notifier = notifier;
const newState = new MapState(state.zoom, state.center, state.options, extent, state.time);
const newState = new MapState(state.zoom, state.center, state.options, extent, state.time, state.viewAngle, state.rotation);
this.mapState.next(newState);
}

Expand Down
12 changes: 11 additions & 1 deletion projects/services-map-state/src/lib/types/map-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export interface IMapState {
extent?: TGeoExtent;
/** iso 8601 Datestring */
time?: string;
/** from nadir in degrees */
viewAngle?: number;
/** from north in degrees */
rotation?: number;
}

/**
Expand All @@ -33,8 +37,12 @@ export class MapState implements IMapState {
extent: TGeoExtent;
/** iso 8601 Datestring */
time: string;
/** from nadir in degrees */
viewAngle: number;
/** from north in degrees */
rotation: number;

constructor(zoom: number, center: IMapCenter, options?: IMapStateOptions, extent: TGeoExtent = [-180.0, -90.0, 180.0, 90.0], time: string = new Date().toISOString()) {
constructor(zoom: number, center: IMapCenter, options?: IMapStateOptions, extent: TGeoExtent = [-180.0, -90.0, 180.0, 90.0], time: string = new Date().toISOString(), viewAngle: number = 0, rotation: number = 0) {
const defaultOptions = {
maxzoom: 0,
minzoom: 0,
Expand All @@ -44,6 +52,8 @@ export class MapState implements IMapState {
this.center = center;
this.extent = extent;
this.time = time;
this.viewAngle = viewAngle;
this.rotation = rotation;
this.options = Object.assign(defaultOptions, options);
}

Expand Down

0 comments on commit f327c87

Please sign in to comment.