Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public transport labels fixes #187

Merged
merged 6 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/components/FeaturePanel/PublicTransport/PublicTransport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ const useLoadingState = () => {
return { routes, error, loading, startRoutes, finishRoutes, failRoutes };
};

interface PublicTransportInnerProps {
name: string;
}

const PublicTransportInner: React.FC<PublicTransportInnerProps> = ({
name,
}) => {
const PublicTransportInner = () => {
const router = useRouter();

const { routes, error, loading, startRoutes, finishRoutes, failRoutes } =
Expand All @@ -52,7 +46,6 @@ const PublicTransportInner: React.FC<PublicTransportInnerProps> = ({
const lines = await requestLines(
router.query.all[0] as any,
Number(router.query.all[1]),
name,
).catch(failRoutes);
finishRoutes(lines);
};
Expand Down Expand Up @@ -94,5 +87,5 @@ export const PublicTransport: React.FC<PublicTransportProps> = ({ tags }) => {
return null;
}

return PublicTransportInner({ name: tags.name });
return PublicTransportInner();
};
11 changes: 3 additions & 8 deletions src/components/FeaturePanel/PublicTransport/requestRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ export interface LineInformation {
export async function requestLines(
featureType: 'node' | 'way' | 'relation',
id: number,
name: string,
radius = 150,
) {
// use the overpass api to request the lines in
const overpassQuery = `[out:csv(ref, colour; false; ';')];
${featureType}(${id})->.center;
(
node(around.center:${radius})["public_transport"="stop_position"]["name"="${name}"];
nw(around.center:${radius})["highway"="bus_stop"]["name"="${name}"];
nwr(around.center:${radius})["amenity"="ferry_terminal"]["name"="${name}"];
) -> .stops;
${featureType}(${id});
rel(bn)["public_transport"="stop_area"];
node(r: "stop") -> .stops;
rel(bn.stops)["route"~"bus|train|tram|subway|light_rail|ferry|monorail"];
Comment on lines +14 to 17
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is some advanced query! I will have to study how this works. It could be useful on my other PR #186 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see also here: #387

out;`;

Expand Down