Skip to content

Commit

Permalink
Fixed settings
Browse files Browse the repository at this point in the history
  • Loading branch information
panaaj committed Mar 2, 2024
1 parent 86c9fe2 commit b890c40
Show file tree
Hide file tree
Showing 10 changed files with 942 additions and 695 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signalk/freeboard-sk",
"version": "2.6.0",
"version": "2.6.0-rc2",
"description": "Openlayers chart plotter implementation for Signal K",
"keywords": [
"signalk-webapp",
Expand Down
23 changes: 17 additions & 6 deletions src/app/app.info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ const FreeboardConfig = {
beyond24: '5m'
},
s57Options: {
graphicsStyle:'Paper',
boundaries:'Plain',
colors:4,
shallowDepth:2,
graphicsStyle: 'Paper',
boundaries: 'Plain',
colors: 4,
shallowDepth: 2,
safetyDepth: 3,
deepDepth:6
deepDepth: 6
},
resourceSets: {}, // additional resources
signalk: {
Expand Down Expand Up @@ -278,7 +278,7 @@ export class AppInfo extends Info {
this.name = 'Freeboard-SK';
this.shortName = 'Freeboard';
this.description = `Signal K Chart Plotter.`;
this.version = '2.6.0';
this.version = '2.6.0-rc2';
this.url = 'https://github.com/signalk/freeboard-sk';
this.logo = './assets/img/app_logo.png';

Expand Down Expand Up @@ -730,6 +730,17 @@ export class AppInfo extends Info {
}
}

if (typeof settings.selections.s57Options === 'undefined') {
settings.selections.s57Options = {
graphicsStyle: 'Paper',
boundaries: 'Plain',
colors: 4,
shallowDepth: 2,
safetyDepth: 3,
deepDepth: 6
};
}

if (typeof settings.plugins === 'undefined') {
settings.plugins = {};
}
Expand Down
25 changes: 14 additions & 11 deletions src/app/lib/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,30 @@ export class State {
}
}

//merge new default values in storedvalue
merge(storedValue:any,defaultValue:any):any {
// merge new default values in storedvalue
// eslint-disable-next-line @typescript-eslint/no-explicit-any
merge(storedValue: any, defaultValue: any): any {
Object.keys(defaultValue).forEach((key) => {
if (!storedValue[key]) {
storedValue[key]=defaultValue[key]
storedValue[key] = defaultValue[key];
} else {
if( typeof storedValue[key] === 'object' &&
!Array.isArray(storedValue[key]) &&
storedValue[key] !== null) {
storedValue[key]=this.merge(storedValue[key],defaultValue[key])
if (
typeof storedValue[key] === 'object' &&
!Array.isArray(storedValue[key]) &&
storedValue[key] !== null
) {
storedValue[key] = this.merge(storedValue[key], defaultValue[key]);
}
}
})
return storedValue
});
return storedValue;
}

//** load app config **
loadConfig(defaultValue = {}) {
const config = this.ls.read('config');
return config ? this.merge(config,defaultValue) : defaultValue;
// return config ? config : defaultValue;
//return config ? this.merge(config,defaultValue) : defaultValue;
return config ? config : defaultValue;
}

//** load app data **
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/map/fb-map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { ModifyEvent } from 'ol/interaction/Modify';
import { DrawEvent } from 'ol/interaction/Draw';
import { Coordinate } from 'ol/coordinate';
import { ResourceSets, SKNotification } from 'src/app/types';
import { S57Service} from './ol/lib/s57.service';
import { S57Service } from './ol/lib/s57.service';

interface IResource {
id: string;
Expand Down Expand Up @@ -327,7 +327,7 @@ export class FBMapComponent implements OnInit, OnDestroy {
this.app.settings$.subscribe((r: SettingsMessage) => {
if (r.action === 'save' && r.setting === 'config') {
this.fbMap.movingMap = this.app.config.map.moveMap;
this.s57Service.SetOptions(this.app.config.selections.s57Options)
this.s57Service.SetOptions(this.app.config.selections.s57Options);
this.renderMapContents();
if (!this.app.config.selections.trailFromServer) {
this.dfeat.trail = [];
Expand Down
17 changes: 10 additions & 7 deletions src/app/modules/map/ol/lib/resources/layer-charts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import WMTSCapabilities from 'ol/format/WMTSCapabilities';
import { MapComponent } from '../map.component';
import { osmLayer } from '../util';
import { MapService } from '../map.service';
import { VectorLayerStyleFactory } from '../vectorLayerStyleFactory'
import { VectorLayerStyleFactory } from '../vectorLayerStyleFactory';

import DataTile from 'ol/source/DataTile';
import WebGLTileLayer from 'ol/layer/WebGLTile';
Expand All @@ -34,7 +34,8 @@ import { apply, applyStyle, applyBackground } from 'ol-mapbox-style';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class FreeboardChartLayerComponent
implements OnInit, OnDestroy, OnChanges {
implements OnInit, OnDestroy, OnChanges
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected layers: Map<string, any> = new Map();

Expand Down Expand Up @@ -161,7 +162,6 @@ export class FreeboardChartLayerComponent
});
}


async parseCharts(charts: Array<[string, SKChart, boolean]> = this.charts) {
const map = this.mapComponent.getMap();

Expand Down Expand Up @@ -201,11 +201,14 @@ export class FreeboardChartLayerComponent
} else if (
charts[i][1].format === 'pbf' ||
charts[i][1].format === 'mvt'
) {
let styleFactory = this.vectorLayerStyleFactory.CreateVectorLayerStyler(charts[i][1])
) {
let styleFactory =
this.vectorLayerStyleFactory.CreateVectorLayerStyler(
charts[i][1]
);
layer = styleFactory.CreateLayer();
styleFactory.ApplyStyle(layer as VectorTileLayer)
layer.setZIndex(this.zIndex + parseInt(i))
styleFactory.ApplyStyle(layer as VectorTileLayer);
layer.setZIndex(this.zIndex + parseInt(i));
} else {
// raster tile
let source; // select source type
Expand Down
Loading

0 comments on commit b890c40

Please sign in to comment.