Skip to content

Commit

Permalink
Improve the Overpass-Query to use stop_area relations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Sep 23, 2023
1 parent f0dd24a commit bf1d1eb
Show file tree
Hide file tree
Showing 3 changed files with 1,538 additions and 1,950 deletions.
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();
};
13 changes: 6 additions & 7 deletions src/components/FeaturePanel/PublicTransport/requestRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ 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"];
out;`;

Expand Down
Loading

0 comments on commit bf1d1eb

Please sign in to comment.