Skip to content

Commit f569515

Browse files
committed
new back
1 parent f532d2c commit f569515

File tree

3 files changed

+22
-34
lines changed

3 files changed

+22
-34
lines changed

frontend/src/lib/services/PlacesRestApi.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,7 @@ export class PlacesRestApi implements Places {
2424
places_limit: placesLimit
2525
}
2626
});
27-
28-
const data = response.data;
29-
30-
// augment
31-
console.log(data.places);
32-
data.places = data.places.map((p) => {
33-
p.Lat += 56.3327 + Math.random() * 0.02 - 0.01;
34-
p.Lon += 44.0012 + Math.random() * 0.02 - 0.01;
35-
return p;
36-
});
37-
38-
return data;
27+
return response.data;
3928
}
4029

4130
async searchImage(areasId: number[], imageFile: File, placesLimit: number = 5) {
@@ -49,18 +38,7 @@ export class PlacesRestApi implements Places {
4938
areas_id: areasId
5039
}
5140
});
52-
53-
const data = response.data;
54-
55-
// augment
56-
console.log(data.places);
57-
data.places = data.places.map((p) => {
58-
p.Lat += 56.3327 + Math.random() * 0.02 - 0.01;
59-
p.Lon += 44.0012 + Math.random() * 0.02 - 0.01;
60-
return p;
61-
});
62-
63-
return data;
41+
return response.data;
6442
}
6543

6644
async getPlaceInfo(xid: string) {

frontend/src/lib/structs/Places.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ export interface CategoryPrediction {
88
probability: number;
99
}
1010

11+
export interface LatLon {
12+
Lat: number;
13+
Lon: number;
14+
}
15+
1116
export interface ImageQueryResponse {
17+
optimal_route: LatLon[] | null;
1218
places: PlacePrediction[];
1319
categories: CategoryPrediction[];
1420
}
1521

1622
export interface PlaceInfo {
1723
category: string;
18-
images: number[];
24+
images: string[];
1925
}
2026

2127
export interface PlacePrediction {
@@ -28,5 +34,6 @@ export interface PlacePrediction {
2834
}
2935

3036
export interface TextQueryResponse {
37+
optimal_route: LatLon[] | null;
3138
places: PlacePrediction[];
3239
}

frontend/src/routes/searchResults/+page.svelte

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@
2525
'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
2626
}).addTo(map);
2727
28-
const waypoints = searchResults.res.places.map((place) => L.latLng(place.Lat, place.Lon));
29-
L.Routing.control({
30-
waypoints: waypoints,
31-
routeWhileDragging: true,
32-
addWaypoints: false,
33-
createMarker: function () {
34-
return null;
35-
} // Prevent automatic marker creation
36-
}).addTo(map);
28+
let optimal_route = searchResults.res.optimal_route;
29+
if (optimal_route !== null) {
30+
const waypoints = optimal_route.map((ll) => L.latLng(ll.Lat, ll.Lon));
31+
L.Routing.control({
32+
waypoints: waypoints,
33+
routeWhileDragging: true,
34+
addWaypoints: false,
35+
createMarker: function () {
36+
return null;
37+
} // Prevent automatic marker creation
38+
}).addTo(map);
39+
}
3740
3841
// Add markers and tooltips for each place
3942
searchResults.res.places.forEach((place) => {

0 commit comments

Comments
 (0)