Skip to content

Commit

Permalink
osmApi: add member role to addMemberFeatures() (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz authored Feb 11, 2024
1 parent daee971 commit 59f0071
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/services/osmApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export const addMemberFeatures = async (feature: Feature) => {
const apiIds = feature.members.map(({ type, ref }) => ({ type, id: ref }));
const promises = apiIds.map((apiId) => fetchFeatureWithCenter(apiId)); // TODO optimize n+1 center-requests or fetch full
const memberFeatures = await Promise.all(promises);
memberFeatures.forEach((memberFeature, index) => {
memberFeature.osmMeta.role = feature.members[index].role; // eslint-disable-line no-param-reassign
});

const duration = Math.round(performance.now() - start);
console.log(`addMemberFeaturesToCrag took ${duration} ms`); // eslint-disable-line no-console
Expand Down
1 change: 1 addition & 0 deletions src/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface Feature {
uid?: string;
lat?: string;
lon?: string;
role?: string; // only for memberFeatures
};
tags: FeatureTags;
members?: RelationMember[];
Expand Down

0 comments on commit 59f0071

Please sign in to comment.