Compare commits
2 Commits
cef1cd01f4
...
7e881d1dea
Author | SHA1 | Date | |
---|---|---|---|
|
7e881d1dea | ||
|
d53e3e56b5
|
@@ -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
|
||||
);
|
||||
|
@@ -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)
|
||||
}
|
||||
},
|
||||
|
||||
|
16
yarn.lock
16
yarn.lock
@@ -1684,17 +1684,17 @@ thread-stream@^3.0.0:
|
||||
dependencies:
|
||||
real-require "^0.2.0"
|
||||
|
||||
tldts-core@^6.1.82:
|
||||
version "6.1.82"
|
||||
resolved "https://registry.yarnpkg.com/tldts-core/-/tldts-core-6.1.82.tgz#b93e0312378f67cfc15ea1da9bc1b699ec621ae9"
|
||||
integrity sha512-Jabl32m21tt/d/PbDO88R43F8aY98Piiz6BVH9ShUlOAiiAELhEqwrAmBocjAqnCfoUeIsRU+h3IEzZd318F3w==
|
||||
tldts-core@^6.1.83:
|
||||
version "6.1.83"
|
||||
resolved "https://registry.yarnpkg.com/tldts-core/-/tldts-core-6.1.83.tgz#8f31172cb5763cc1128d4e18ee5095aa2f990eb8"
|
||||
integrity sha512-I2wb9OJc6rXyh9d4aInhSNWChNI+ra6qDnFEGEwe9OoA68lE4Temw29bOkf1Uvwt8VZS079t1BFZdXVBmmB4dw==
|
||||
|
||||
tldts@^6.1.32:
|
||||
version "6.1.82"
|
||||
resolved "https://registry.yarnpkg.com/tldts/-/tldts-6.1.82.tgz#1c06e884bcdbcccbaf73bd552e2f188ad670a4a9"
|
||||
integrity sha512-KCTjNL9F7j8MzxgfTgjT+v21oYH38OidFty7dH00maWANAI2IsLw2AnThtTJi9HKALHZKQQWnNebYheadacD+g==
|
||||
version "6.1.83"
|
||||
resolved "https://registry.yarnpkg.com/tldts/-/tldts-6.1.83.tgz#2ba9aa8db0cbcc2d75291f148f8acf9ac469429a"
|
||||
integrity sha512-FHxxNJJ0WNsEBPHyC1oesQb3rRoxpuho/z2g3zIIAhw1WHJeQsUzK1jYK8TI1/iClaa4fS3Z2TCA9mtxXsENSg==
|
||||
dependencies:
|
||||
tldts-core "^6.1.82"
|
||||
tldts-core "^6.1.83"
|
||||
|
||||
to-regex-range@^5.0.1:
|
||||
version "5.0.1"
|
||||
|
Reference in New Issue
Block a user