Lock file maintenance #161

Merged
bot merged 2 commits from renovate/lock-file-maintenance into master 2025-03-08 03:05:47 +01:00
2 changed files with 71 additions and 35 deletions
Showing only changes of commit d53e3e56b5 - Show all commits

View File

@ -1,61 +1,96 @@
import { getGeoLine } from "../types/geom";
import * as api from "../api";
const filter_existing = function (tpe: "nominatim" | "travel", leg: leg, r: geoloc[]) {
const filter_existing = function (
tpe: "nominatim" | "travel",
leg: leg,
r: geoloc[]
) {
switch (tpe) {
case 'nominatim':
return r.filter(e => {
case "nominatim":
return r.filter((e) => {
if (leg.hotel && leg.hotel.osm_id == e.osm_id) return false;
if (leg.places.restaurants.find(i => i.osm_id == e.osm_id)) return false;
if (leg.places.activities.find(i => i.osm_id == e.osm_id)) return false;
return true
})
case 'travel':
console.log(r)
return r.filter(e => {
if (leg.travel.find(i => `${(e as any).from}->${(e as any).to}` == `${(i as any).from}->${(i as any).to}`)) return false;
return true
})
if (leg.places.restaurants.find((i) => i.osm_id == e.osm_id))
return false;
if (leg.places.activities.find((i) => i.osm_id == e.osm_id))
return false;
return true;
});
case "travel":
console.log(r);
return r.filter((e) => {
if (
leg.travel.find(
(i) =>
`${(e as any).from}->${(e as any).to}` ==
`${(i as any).from}->${(i as any).to}`
)
)
return false;
return true;
});
}
}
};
const process_results = function (tpe: "nominatim" | "travel", r: geoloc[]) {
switch (tpe) {
case 'nominatim':
case "nominatim":
return r.map((rr) => {
rr.latlon = [parseFloat((rr as any).lat), parseFloat((rr as any).lon)];
rr.latlon = [
parseFloat((rr as any).lat),
parseFloat((rr as any).lon),
];
rr.title = (rr as any).display_name.split(",")[0];
return rr;
});
case 'travel':
console.log(r)
return r.map(el => {
case "travel":
console.log(r);
return r.map((el) => {
(el as any).path = getGeoLine(
{ lat: (el as any).from_geo.lat, lng: (el as any).from_geo.lon },
{ lat: (el as any).to_geo.lat, lng: (el as any).to_geo.lon }, { dist: 2_500_000 }).map(v => [v.lat, v.lng]);
{
lat: (el as any).from_geo.lat,
lng: (el as any).from_geo.lon,
},
{
lat: (el as any).to_geo.lat,
lng: (el as any).to_geo.lon,
},
{ dist: 2_500_000 }
).map((v) => [v.lat, v.lng]);
(el as any).type = "flight";
return el;
});
}
}
};
var _search_set_results: (...arg: any[]) => any;
export const set_search_set_results = function (f: (...arg: any[]) => any) {
_search_set_results = f;
}
};
export const search_nominatim = api.throttle(
(f: string, q: string, bb: [[number, number], [number, number]], leg: leg) =>
api.query_nominatim(q, bb, api.get_filter(f)).catch((_err) => console.log(_err)).then((r) => {
r = process_results('nominatim', r)
r = filter_existing('nominatim', leg, r)
_search_set_results(r)
}), 1000);
(
f: string,
q: string,
bb: [[number, number], [number, number]],
leg: leg
) =>
api
.query_nominatim(q, bb, api.get_filter(f))
.catch((_err) => console.log(_err))
.then((r) => {
r = process_results("nominatim", r);
r = filter_existing("nominatim", leg, r);
_search_set_results(r);
}),
1000
);
export const search_flight = api.throttle(
(f: string, q: string, leg: leg) =>
api.query_flight(q).then((r) => {
r = process_results('travel', r)
r = filter_existing('travel', leg, r)
_search_set_results(r)
}), 2000)
r = process_results("travel", r);
r = filter_existing("travel", leg, r);
_search_set_results(r);
}),
3000
);

View File

@ -141,11 +141,12 @@ const app = new Vue({
},
drawer_click_item: function (item) {
const tpe = this.query.type
this.search_set_clear(item ? true : false);
this.drawer_hover_item();
if (item) {
item.step = -1;
journey_add_place(this.journey, this.query.type, item)
journey_add_place(this.journey, tpe, item)
}
},