Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1412 from Qwant/extend-intention-places-params
Browse files Browse the repository at this point in the history
extend intention parameter with place information
  • Loading branch information
sdrll authored Oct 18, 2022
2 parents e7617c1 + 2f45850 commit 2f34a9c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
2 changes: 2 additions & 0 deletions @types/idunn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,8 @@ export interface operations {
source?: string;
/** Full text query */
q?: string;
place_name?: string;
place_code?: string;
size?: number;
lang?: string;
verbosity?: components['schemas']['Verbosity'];
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/intention.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ export default class Intention {
q: this.fullTextQuery,
type: this.category?.name,
bbox: this.bbox?.join(','),
place_name: this.place.properties.geocoding.name,
place_code: this.place.properties.geocoding.citycode,
});
}
32 changes: 24 additions & 8 deletions src/adapters/poi/idunn_poi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,34 @@ export default class IdunnPoi extends Poi {
size: APIGetPlacesPayload['size'],
category: APIGetPlacesPayload['category'],
q: APIGetPlacesPayload['q'],
place_name: APIGetPlacesPayload['place_name'],
place_code: APIGetPlacesPayload['place_code'],
extendBbox = false
) {
const url = `${serviceConfig.idunn.url}/v1/places`;

const requestParams = {
bbox,
size,
extend_bbox: extendBbox,
...(category ? { category } : {}),
...(q ? { q } : {}),
...(getIsOnlyOSM() ? { only_osm: true } : {}),
};
let requestParams = {};
if (extendBbox) {
requestParams = {
bbox,
size,
place_name,
place_code,
extend_bbox: extendBbox,
...(category ? { category } : {}),
...(q ? { q } : {}),
...(getIsOnlyOSM() ? { only_osm: true } : {}),
};
} else {
requestParams = {
bbox,
size,
extend_bbox: extendBbox,
...(category ? { category } : {}),
...(q ? { q } : {}),
...(getIsOnlyOSM() ? { only_osm: true } : {}),
};
}

try {
const response: APIGetPlacesResponse = await Ajax.getLang(url, requestParams);
Expand Down
11 changes: 10 additions & 1 deletion src/panel/PanelManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,22 @@ const PanelManager = ({ router }) => {
// Definition of url routes to panels
useEffect(() => {
router.addRoute('Category', '/places/(.*)', placesParams => {
const { type: category, q: query, ...otherOptions } = parseQueryString(placesParams);
const {
type: category,
q: query,
place_name: place_name,
place_code: place_code,
...otherOptions
} = parseQueryString(placesParams);

setPanelOptions({
ActivePanel: CategoryPanel,
options: {
poiFilters: {
category,
query,
place_name,
place_code,
},
...otherOptions,
},
Expand Down
4 changes: 3 additions & 1 deletion src/panel/category/CategoryPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const CategoryPanel = ({ poiFilters = {}, bbox }) => {
useEffect(() => {
const fetchData = debounce(
async () => {
const { category, query } = poiFilters;
const { category, query, place_name, place_code } = poiFilters;
const currentBounds = getVisibleBbox(window.map.mb);

const extendBbox = initialLoading;
Expand All @@ -88,6 +88,8 @@ const CategoryPanel = ({ poiFilters = {}, bbox }) => {
maxPlaces,
category,
query,
place_name,
place_code,
extendBbox
);

Expand Down

0 comments on commit 2f34a9c

Please sign in to comment.