1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-24 05:17:16 +02:00

Adding path bending distance trigger to config #587

#667
This commit is contained in:
Patrik J. Braun 2023-07-28 20:58:16 +02:00
parent f01766ba49
commit 9dbc196c27
2 changed files with 11 additions and 3 deletions

View File

@ -578,6 +578,15 @@ export class ClientMapConfig {
new PathThemeConfig('var(--bs-secondary)')
)])
];
@ConfigProperty({
type: 'unsignedInt',
tags: {
name: $localize`Bend long path trigger`,
priority: ConfigPriority.underTheHood
} as TAGS,
description: $localize`Map will bend the path if two points are this far apart on latititude axes. This intended to bend flight if only the end and the start points are given.`,
})
bendLongPathsTrigger: number = 1;
}
@SubConfigClass({tags: {client: true}, softReadonly: true})

View File

@ -524,14 +524,13 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
private addArchForLongDistancePaths(parsedGPX: { name: string, path: LatLngLiteral[]; markers: LatLngLiteral[] }) {
const DISTANCE_TRIGGER = 0.5;
for (let i = 0; i < parsedGPX.path.length - 1; ++i) {
const dst = (a: LatLngLiteral, b: LatLngLiteral) => {
return Math.sqrt(Math.pow(a.lat - b.lat, 2) +
Math.pow(a.lng - b.lng, 2));
};
if (Math.abs(parsedGPX.path[i].lng - parsedGPX.path[i + 1].lng) > DISTANCE_TRIGGER) {
if (Math.abs(parsedGPX.path[i].lng - parsedGPX.path[i + 1].lng) > Config.Map.bendLongPathsTrigger) {
const s = parsedGPX.path[i];
const e = parsedGPX.path[i + 1];
const k = `${s.lat.toFixed(2)},${s.lng.toFixed(2)},${e.lat.toFixed(2)},${e.lng.toFixed(2)}`;
@ -545,7 +544,7 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
const d = dst(s, e); //start end distance
const newPoints: LatLngLiteral[] = [];
const N = Math.round(d / DISTANCE_TRIGGER); // number of new points
const N = Math.round(d / Config.Map.bendLongPathsTrigger); // number of new points
const m: LatLngLiteral = { //mid point
lat: (s.lat + e.lat) / 2,
lng: (s.lng + e.lng) / 2,